vaivaswatha / debugir

DebugIR: Debugging LLVM-IR Files
Apache License 2.0
125 stars 18 forks source link

Support function parameters #16

Closed Shamazo closed 4 months ago

Shamazo commented 4 months ago

This means we can inspect and print function parameters in GDB.

Before:

user@server:/tmp/tmp.gPOktVHa0q/test-files$ gdb --args  /scratch/user/llvm-17/opt/bin/lli -jit-kind=mcjit hello.dbg.ll
Reading symbols from /scratch/user/llvm-17/opt/bin/lli...
(No debugging symbols found in /scratch/user/llvm-17/opt/bin/lli)
(gdb) set breakpoint pending on
(gdb) break hello.ll:25
No symbol table is loaded.  Use the "file" command.
Breakpoint 1 (hello.ll:25) pending.
(gdb) r
Starting program: /scratch/user/llvm-17/opt/bin/lli -jit-kind=mcjit hello.dbg.ll
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, foo () at hello.ll:25
25    %add = add nsw i32 %0, 1
(gdb)

after:

user@server:/tmp/tmp.gPOktVHa0q/test-files$ gdb --args  /scratch/user/llvm-17/opt/bin/lli -jit-kind=mcjit hello.dbg.ll
Reading symbols from /scratch/user/llvm-17/opt/bin/lli...
(No debugging symbols found in /scratch/user/llvm-17/opt/bin/lli)
(gdb) set breakpoint pending on
(gdb) break hello.ll:25
No symbol table is loaded.  Use the "file" command.
Breakpoint 1 (hello.ll:25) pending.
(gdb) r
Starting program: /scratch/user/llvm-17/opt/bin/lli -jit-kind=mcjit hello.dbg.ll
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, foo (a=100, s.coerce=421973825946) at hello.ll:25
25    %add = add nsw i32 %0, 1
(gdb) p a
$1 = 100
vaivaswatha commented 4 months ago

Thank you @Shamazo