rizin/test/db/cmd/cmd_att
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

130 lines
3.2 KiB
Text

NAME=att subrel
FILE=bins/mach0/mac-ls
CMDS=<<EOF
e asm.syntax=att
e asm.lines.bb=0
e asm.bytes=0
e asm.comments=false
pd 20
EOF
EXPECT=<<EOF
;-- main:
;-- entry0:
;-- func.100001058:
0x100001058 pushq %rbp
0x100001059 movq %rsp, %rbp
0x10000105c pushq %r15
0x10000105e pushq %r14
0x100001060 pushq %r13
0x100001062 pushq %r12
0x100001064 pushq %rbx
0x100001065 subq $0x648, %rsp
0x10000106c movq %rsi, %rbx
0x10000106f movl %edi, %r14d
0x100001072 leaq -0x640(%rbp), %rax
0x100001079 movq %rax, -0x648(%rbp)
0x100001080 testl %r14d, %r14d
0x100001083 jg 0x10000108a
0x100001085 callq sym.func.100004401
0x10000108a leaq section.4.__TEXT.__cstring, %rsi
0x100001091 xorl %edi, %edi
0x100001093 callq sym.imp.setlocale
0x100001098 movl $1, %r13d
0x10000109e movl $1, %edi
EOF
RUN
NAME=att varsub
FILE=bins/mach0/mac-ls
CMDS=<<EOF
af
e asm.syntax=att
e asm.var=0
e asm.lines.bb=0
e asm.bytes=0
e asm.comments=false
pd 20
EOF
EXPECT=<<EOF
;-- entry0:
;-- func.100001058:
/ int main (int argc, char **argv, char **envp);
| 0x100001058 pushq %rbp
| 0x100001059 movq %rsp, %rbp
| 0x10000105c pushq %r15
| 0x10000105e pushq %r14
| 0x100001060 pushq %r13
| 0x100001062 pushq %r12
| 0x100001064 pushq %rbx
| 0x100001065 subq $0x648, %rsp
| 0x10000106c movq %rsi, %rbx
| 0x10000106f movl %edi, %r14d
| 0x100001072 leaq var_640h, %rax
| 0x100001079 movq %rax, var_648h
| 0x100001080 testl %r14d, %r14d
| 0x100001083 jg 0x10000108a
| 0x100001085 callq sym.func.100004401
| 0x10000108a leaq section.4.__TEXT.__cstring, %rsi
| 0x100001091 xorl %edi, %edi
| 0x100001093 callq sym.imp.setlocale
| 0x100001098 movl $1, %r13d
| 0x10000109e movl $1, %edi
EOF
RUN
NAME=att varsub 2
FILE=bins/elf/varsub
CMDS=<<EOF
aa; s main
e asm.syntax=att
e asm.var=0
e asm.lines.bb=0
e asm.bytes=0
e asm.comments=false
pdf
EOF
EXPECT=<<EOF
/ int main (int argc, char **argv, char **envp);
| 0x004004a6 pushq %rbp
| 0x004004a7 movq %rsp, %rbp
| 0x004004aa movq arg_8h, %rax
| 0x004004af movq -8(%rsp), %rax
| 0x004004b4 movq arg_8h, %rax
| 0x004004b8 movq var_8h, %rax
| 0x004004bc movq arg_18h, %rax
| 0x004004c1 movq -0x18(%rsp), %rax
| 0x004004c6 movq arg_18h, %rax
| 0x004004ca movq var_18h, %rax
| 0x004004ce leave
\ 0x004004cf retq
EOF
RUN
NAME=att varsub 2 with asm.sub.varonly disabled
FILE=bins/elf/varsub
CMDS=<<EOF
aa; s main
e asm.syntax=att
e asm.var=0
e asm.lines.bb=0
e asm.bytes=0
e asm.comments=false
e asm.sub.varonly=false
pdf
EOF
EXPECT=<<EOF
/ int main (int argc, char **argv, char **envp);
| 0x004004a6 pushq %rbp
| 0x004004a7 movq %rsp, %rbp
| 0x004004aa movq arg_8h(%rsp), %rax
| 0x004004af movq -8(%rsp), %rax
| 0x004004b4 movq arg_8h(%rbp), %rax
| 0x004004b8 movq var_8h(%rbp), %rax
| 0x004004bc movq arg_18h(%rsp), %rax
| 0x004004c1 movq -0x18(%rsp), %rax
| 0x004004c6 movq arg_18h(%rbp), %rax
| 0x004004ca movq var_18h(%rbp), %rax
| 0x004004ce leave
\ 0x004004cf retq
EOF
RUN