Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor RzTypes to use structs instead of SDB + New Tree-Sitter based C Parser #1047

Merged
merged 113 commits into from
Jul 19, 2021

Conversation

XVilka
Copy link
Member

@XVilka XVilka commented Apr 19, 2021

SQUASH ME PLEASE

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the documentation and the rizin book with the relevant information (if needed)

Detailed description

  • Removed oldshell version of t (types) commands
  • Removed tk command because types storage switched to the hashtable
  • Added tfc command to show the calling convention of the function or set it
  • Added tsl (RZ_OUTPUT_MODE_LONG) to show structure members' sizes and offsets
  • Added tul (RZ_OUTPUT_MODE_LONG) to show union members' sizes
  • Switched the types storage to the hashtable instead of SDB
  • Added load and export from/to SDB for standard type libraries and serialization for Projects
  • Changed all char *type occurences to the proper RzType
  • Added RzCallable type for the function/class method types
  • Changed all function types API to use the RzCallable API
  • Switched the function types (RzCallable) storage to the hashtable instead of SDB
  • Added a connection between RzAnalysisFunction and RzCallable - rz_analysis_function_derive_type() API function to derive new RzCallable type from the RzAnalysisFunction even if it doesn't exist in the RzTypeDB.
  • Moved type links to the RzAnalysis where they belong
  • Removed TCC and MPC-based parsers
  • Added Tree-Sitter-based parser for C grammar (see librz/type/parser/*)
  • Reworked type databases in librz/analysis/d/ to be consistent with C standard, libc, platform-specific definitions
  • Switched the type links from char * to RzType
  • Switched the type links from SDB to the hashtable
  • Added concept of the "type paths", e.g. a.b[20].c where b is a member of a (a is either structure or a union) and c is a member of b, and b is an array where we take 20-th element.
  • Added concept of the typeclasses (a bit similar to Haskell) for numerical types: None (the most generic one), Num (includes Integral and Floating), Integral (includes Signed Integral and Unsigned Integral), Floating.
  • Added concept of type equality (rz_types_equal(a, b) API function)
  • Added Doxygen documentation to every API function in the librz/type/*.
  • Updated the project format from V2 to V3, added migration.

Test plan

CI is green

Closing issues

Fixes #371
Fixes #370
Fixes #373
Fixes #275
Fixes #1249
Partially addresses #1169, #1064

@XVilka XVilka requested a review from kazarmy as a code owner April 19, 2021 08:03
@XVilka XVilka marked this pull request as draft April 19, 2021 08:03
@XVilka XVilka force-pushed the rztypes branch 6 times, most recently from ddee1d2 to 90c445b Compare April 19, 2021 10:33
@XVilka XVilka added this to the 0.3.0 milestone Apr 19, 2021
@XVilka XVilka mentioned this pull request Apr 20, 2021
4 tasks
@XVilka XVilka force-pushed the rztypes branch 3 times, most recently from 7c2b7ab to 919f0c4 Compare April 20, 2021 06:36
@XVilka XVilka force-pushed the rztypes branch 6 times, most recently from eb978b7 to 796c239 Compare April 20, 2021 08:33
@thestr4ng3r thestr4ng3r enabled auto-merge (squash) July 19, 2021 16:12
@thestr4ng3r thestr4ng3r merged commit 3c59df7 into dev Jul 19, 2021
@XVilka XVilka deleted the rztypes branch July 19, 2021 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment