public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Tom Frank <gdbhelper@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: how to print a function's return value
Date: Wed, 11 Jul 2012 21:49:00 -0000	[thread overview]
Message-ID: <CADPb22S07DmRuR_JYbhLghun3s42kvwm3x9ZZ=s-x66_PqFL_A@mail.gmail.com> (raw)
In-Reply-To: <CAMHBcgqhCiyvU_XeCTH0Vx_8xdimzWhD1kU5_CnpX5+Hw=4+tw@mail.gmail.com>

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.

      reply	other threads:[~2012-07-11 21:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 15:10 Tom Frank
2012-07-11 21:49 ` Doug Evans [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADPb22S07DmRuR_JYbhLghun3s42kvwm3x9ZZ=s-x66_PqFL_A@mail.gmail.com' \
    --to=dje@google.com \
    --cc=gdb@sourceware.org \
    --cc=gdbhelper@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).