rizin/test/db/cmd/cmd_meta
Florian Märkl d9950f7479
Replace bp/sp-vars by generic stack-based ones (#3167)
Variables on the stack are not identified by bp/sp+<offset> anymore, but
by their address from the bottom of the stack frame (RzStackAddr),
independent of how they are accessed.
So now there are only two kinds of variables: stack and register.

This required some major refactoring and other changes:
* RzAnalysisVar.isarg was removed. Whether a variable is an argument is
  now specified implicitly by its storage location.
* Varsub of struct fields had to be rewritten so fields can be queried
  by arbitrary stack addresses using the recently introduced sp
  tracking, as the old approach to fill a list with all fields would not
  work anymore.
* analysis.vars.stackname was removed, new behavior is more similar to
  this being true before.
* Variables will not be created at stack+0 now, because the return
  address is there. Before, vars were only created sometimes in such
  cases.
* Variables created from bp offsets in x86 are not deleted anymore if
  the function's bp_frame is false (see removed
  rz_analysis_function_delete_vars_by_kind(fcn,
  RZ_ANALYSIS_VAR_KIND_BPV); calls). This may lead to some
  false-positive detected variables. Whether this really is a practical
  issue is yet to be seen. At least there are no meaningful tests that
  are broken by this.
* Applying variables from dwarf needed some fixes for determining the
  correct stack locations of variables in order to write meaningful
  tests. The handling is still not entirely correct for all
  possibilities of dwarf info, but at least the changed/added test cases
  are right and serve as a reference for future changes.
* Projects version 11 is introduced.
* afvb commands have been removed, afvs now handles all stack vars.
2023-01-02 11:36:21 +08:00

142 lines
2 KiB
Text

NAME=Cf. crash
FILE==
CMDS=<<EOF
Cf.
EOF
EXPECT=<<EOF
EOF
RUN
NAME=vars commenting
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
s 0x10
af
afvs 8 arg_8h int
afvs -8 var_8h uint32_t
afvr rax var_rax uint64_t
Cv arg_8h comment for arg_8h
Cv var_8h comment for var_8h
Cv var_rax comment for var_rax
pd 1 ~comment
?e --
Cvr
Cvr*
?e --
Cvs
Cvs*
?e --
Cv- arg_8h
pd 1 ~comment
?e --
Cv- var_8h
pd 1 ~comment
?e --
Cv- var_rax
pd 1 ~comment
?e --
EOF
EXPECT=<<EOF
| ; arg uint64_t var_rax @ rax ; comment for var_rax
| ; var uint32_t var_8h @ stack - 0x8 ; comment for var_8h
| ; arg int arg_8h @ stack + 0x8 ; comment for arg_8h
--
var_rax : comment for var_rax
"Cvr var_rax base64:Y29tbWVudCBmb3IgdmFyX3JheA== @ 0x00000010"
--
arg_8h : comment for arg_8h
var_8h : comment for var_8h
"Cvs arg_8h base64:Y29tbWVudCBmb3IgYXJnXzho @ 0x00000010"
"Cvs var_8h base64:Y29tbWVudCBmb3IgdmFyXzho @ 0x00000010"
--
| ; arg uint64_t var_rax @ rax ; comment for var_rax
| ; var uint32_t var_8h @ stack - 0x8 ; comment for var_8h
--
| ; arg uint64_t var_rax @ rax ; comment for var_rax
--
--
EOF
RUN
NAME=Cvb variable null pointer deref
FILE=bins/elf/analysis/x64-simple
CMDS=<<EOF
aaa
Cvb local_10
EOF
EXPECT=<<EOF
EOF
RUN
NAME=CC.
FILE==
CMDS=<<EOF
CC hello @ 10
CC.
CC. @ 10
CCl @ 10
EOF
EXPECT=<<EOF
hello
0x0000000a CCu "hello"
EOF
RUN
NAME=Cs
FILE==
CMDS=<<EOF
w "Friendly Conversation"
Cs
C
EOF
EXPECT=<<EOF
0x00000000 ascii[22] "Friendly Conversation"
EOF
RUN
NAME=Cs without bin
FILE==
CMDS=<<EOF
ob-*
w "Friendly Conversation"
Cs
# Right now, this does nothing. We just check that it doesn't crash.
# Later, it will be nice if it also actually detects the string.
C
EOF
EXPECT=
RUN
NAME=Cs8 without bin
FILE==
CMDS=<<EOF
ob-*
w "Friendly Conversation"
Cs8
C
EOF
EXPECT=<<EOF
0x00000000 utf8[22] "Friendly Conversation"
EOF
RUN
NAME=Csb without bin
FILE==
CMDS=<<EOF
ob-*
w "Friendly Conversation"
Csb
C
EOF
EXPECT=<<EOF
0x00000000 ascii[22] "Friendly Conversation"
EOF
RUN