Repository navigation
Add call depth indicator to Vp visual mode - #6815
ThanSin02426 wants to merge 7 commits into
Conversation
|
Forgot to mention it in the issue. Please add a video which shows how it works. |
|
Demo video demo.mov |
|
@Rot127 please see if I am missing something. |
Rot127
left a comment
There was a problem hiding this comment.
Looks like a good start!
One issue though.
It only works if the cursor is exactly at a function address:
[0xc09ee2ac [xAdvc]0 0% 285 vfile://0/modem.b08]> pd $r @ fcn.c09ee2ac depth from fcn.c09ee36c: 1
; CALL XREF from fcn.c09ee304 @ 0xc09ee30c
; CALL XREF from fcn.c09ee36c @ 0xc09ee374
┌ fcn.c09ee2ac();
│ 0xc09ee2ac ┌ immext(##0xc09afd00)
│ 0xc09ee2b0 │ R16 = ##-0x3f6502c8
│ 0xc09ee2b4 └ memd(R29+#-0x10) = R17:16 ; allocframe(#0x8)
Seeking only one instruction down shows ???
[0xc09ee2b0 [xAdvc]0 0% 285 vfile://0/modem.b08]> pd $r @ fcn.c09ee2ac+4 depth from fcn.c09ee36c: ???
│ 0xc09ee2b0 │ R16 = ##-0x3f6502c8
│ 0xc09ee2b4 └ memd(R29+#-0x10) = R17:16 ; allocframe(#0x8)
But it should still be 1.
|
Segfaults for me now on a basic test: |
@Rot127 I am not able to reproduce the segfault locally on macOS (may be because malloc keeps freed blocks intact longer) however I pushed a fix which likely caused it. Can you please check it and help me upon this :) |
|
Can't reproduce the crash now. I seek to main, stepped a few instructions down and then jumped to different call targets and went back with |
Not able to get an infinite loop but yes when in Vp I pressed j multiple times and jumped to different call target then got a CPU spike on pressing u. This exists even with the feature off likely due to disasm renderer. |
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Detailed description
This PR implements the "simple version" of the call-depth indicator requested in #6788.
The
Vpvisual disassembly view now shows adepth from <ref>: Nindicator in the title bar, where N is the shortest number of calls between a user-configurable reference function and the function containing the cursor. When no path is known (e.g., due to indirect calls), it shows???.New config options:
graph.depth.enabled(bool, defaultfalse)graph.depth.ref(string: flag name, hex address, or math expression)graph.depth.max(int, default20)Design decisions:
rz_num_math, so bothmainand0x100000490work.CALLxrefs counted. Indirect calls (br x16) produceUNKNOWNxrefs and correctly fall through to???.to == 0orto == UT64_MAX.Note on AI assistance: Claude is used only for test logic and to navigate through Rizin codebase.
...
Test plan
Manual verification
Built a small ARM64 test binary with chain
main → sym.call. Ran:```
./build/binrz/rizin/rizin test/bins/elf/analysis/armcall
```
Inside Rizin:
```
aaa
e graph.depth.enabled=true
e graph.depth.ref=main
s main
Vp
```
The title bar shows
depth from main: 0. Seeking tosym.callshowsdepth from main: 1. Seeking to an address not inside any function showsdepth from main: ???.Indirect-call behaviour verified:
```
$ s sym.imp.puts
$ axt
(nofunc) 0x100000120 [UNKNOWN] udf sym.imp.puts
dbg._a 0x100000470 [CALL] bl sym.imp.puts
```
Confirms only direct
CALLxrefs are traversed; indirect branches produceUNKNOWNxrefs and correctly result in???.Automated test
Added
NAME=depth indicator simple chainintest/db/cmd/cmd_visualusing the interactive mode pattern:```
cd test
../build/binrz/rz-test/rz-test db/cmd/cmd_visual
```
Result: all 11 tests pass on darwin-arm64.
...
Closing issues
Closes #6788
...