This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
Re: showing function arguments
Kevin Buettner <kevinb@cygnus.com> writes:
On Nov 15, 7:41pm, Dan Nicolaescu wrote:
> Stan Shebs <shebs@cygnus.com> writes:
>
> From: Dan Nicolaescu <dann@ics.uci.edu>
> Lines: 19
>
> I would like to see all the arguments that each function is called
> with.
> gdb certainly has this information, as it displays it when you look at
> a backtrace.
>
> I would like to produce a trace that contains something like this:
> function_call1 (arg1=.., arg2=...)
> function_call2 (arg1=.., arg2=...)
> etc, etc
>
> Is this a trick question? GDB already does this normally. Are you
> using a GUI that doesn't show arguments perhaps?
>
> Stan
> No, no trick, sorry for being dense.
> I am not using any GUI.
>
> What I want is a trace of the execution of the whole program that
> contains all the function calls and their arguments, not just to see
> them when I do a "bt".
> Is it possible to instruct gdb so produce something like that? If not,
> do you have any suggestion how I might accomplish that?
I'm don't understand precisely what you want to do, but you should
know that it is possible to attach commands to breakpoints. It is
also possible to define your own commands. E.g, you could define
"btstep" which does an ordinary step followed by a backtrace as
follows:
define btstep
step
bt
end
document btstep
Provides a backtrace after an ordinary step.
end
Thanks for the tip, I found a way to do what I want: I get all the
function names from the executable with nm, the I create a gdb script
like this:
break function1
commands
silent
bt 1
continue
end
break function2
commands
silent
bt 1
continue
end
etc, etc.
The I load the program in gdb, source the script that I created ...
[good suggestions snipped]
Hope this helps...
It did, very much. Thanks a lot!
Now suggestions for gdb.
This would be a whole lot easier if `commands' would accept multiple
arguments (like `enable' and `disable' do)
Something like
commands 1 10 25
STUFF to execute for all these breakpoints
end
Is there any specific reason that this is not possible?
Analogous to this, it would be useful to be able to do:
rbreak REGEXP
commands
STUFF to execute for all the breakpoints that are set by
this rbreak command
end
If this was possible, in my case I could have just done:
rbreak .*
commands
silent
bt 1
continue
end
and be done with it...
--dan