rizin/test/db/cmd/cmd_to
Anton Kochkov 3c59df7e98
Refactor RzTypes to use structs instead of SDB + New Tree-Sitter based C Parser (#1047)
- 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.
2021-07-20 01:46:45 +08:00

98 lines
1.1 KiB
Text

NAME=to
FILE==
CMDS=to bins/headers/s1.h;t S1
EXPECT=<<EOF
pf ddd x y z
EOF
RUN
NAME=to
FILE==
CMDS=to bins/headers/s2.h; t S1
EXPECT=<<EOF
pf ddd x test z
EOF
RUN
NAME=to same struct redefinition
FILE==
CMDS=<<EOF
to bins/headers/s1.h
to bins/headers/s2.h
t S1
t- S1
to bins/headers/s2.h
t S1
t- S1
EOF
EXPECT=<<EOF
pf ddd x y z
pf ddd x test z
EOF
RUN
NAME=to perturbated
FILE==
CMDS=<<EOF
to bins/headers/s1.h
to bins/headers/s4.h
t S1
t Perturbator
t- S1
to bins/headers/s4.h
t S1
t Perturbator
EOF
EXPECT=<<EOF
pf ddd x y z
pf d a
pf ddd x test z
pf d a
EOF
RUN
NAME=to arrays
FILE==
CMDS=<<EOF
to bins/headers/s3.h
t S1
tsc S1
EOF
EXPECT=<<EOF
pf [3]d[4]dd x y z
struct S1 {
int x[3];
int y[4];
int z;
};
EOF
RUN
NAME=to typedefs
FILE==
CMDS=<<EOF
to bins/headers/t1.h
tt easy_prey
ttc easy_prey
tt humans
ttc humans
tt days
ttc days
tt tokyo
ttc tokyo
tsc dangerous
EOF
EXPECT=<<EOF
easy_prey = uint32_t
typedef uint32_t easy_prey;
humans = easy_prey
typedef easy_prey humans;
days = struct dangerous
typedef struct dangerous days;
tokyo = struct dangerous
typedef struct dangerous tokyo;
struct dangerous {
uint64_t neo;
};
EOF
RUN