tags:

views:

109

answers:

1

I want to see which parameter and return value to a function. I use gdb breakpoint command list (gdb command script) as follow:

int foo(int)

(gdb) break foo
(gdb) print $r0
(gdb) finish
(gdb) print $r0
(gdb) continue
(gdb) end

But it print only the parameter.

I got the reason from here GDB Breakpoint command lists

Any other commands in the command list, after a command that resumes execution, are ignored.

Any help is appreciated.

A: 

You need a second breakpoint at the end of the function if you want to associate commands there.

Karl Bielefeldt
I don't have the source code of 'foo()'. How do I find the end of the function foo()'s body?
Gong Pengjun
When you are stopped at a breakpoint inside foo(), the disassemble command should disassemble the whole function, then set a breakpoint at the last address shown with `break *0xaddress`. Should be a `retq` or something similar depending on your architecture. There might be more than one return point shown. You should set a breakpoint at all of them.
Karl Bielefeldt
Thanks, I am working on arm.
Gong Pengjun