This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: how to print a function's return value
On Wed, Jul 11, 2012 at 8:10 AM, Tom Frank <gdbhelper@gmail.com> wrote:
> hi,
>
> in source code , there is a fuction call like this : int a = func(param);
>
> then I debug it with gdb , whein it stop at this line,I want to print
> the func's retvalue, which results in a gdb sigtrap,and
>
> cause gdb to go into a trap, then I can not find where am I .
>
> I konw there is a command to prevent gdb going to trap like this,
> what is that command?
Hi.
Your question is a bit confusing.
If I were to set the sigtrap aside, there are two ways to print func's
return value.
#1
(gdb) print func(param)
IOW call func from gdb. Depending on what func does this may or may
not be reasonable.
The second way is to either set a breakpoint on func or step into into
and then step out of it like this:
#2
(gdb) step # step into func
(gdb) finish # run until func returns, gdb will print its return value
Now, as for sigtrap, I think in order to provide an accurate answer I
need more details. An example session log for example.