Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Siva Chandra <sivachandra@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] - Exposing find_pc_line through Python API
Date: Mon, 07 May 2012 19:36:00 -0000	[thread overview]
Message-ID: <8362c73huz.fsf@gnu.org> (raw)
In-Reply-To: <CAGyQ6gzTihieQuLoQVyL1G1aJ1m2btqqnW+D=zqc4dasQovfRg@mail.gmail.com>

> Date: Mon, 7 May 2012 23:41:25 +0530
> From: Siva Chandra <sivachandra@google.com>
> 
> I wanted a way to get the actual line number given a PC value using
> the Python API.  The currently available Symtab_and_line.line gives
> the line number which the user thinks the current execution is, but
> not the actual.

That "user thinks the execution is at" notion is far from being
clear to me.  See below.

> Attached is a patch which adds gdb.find_pc_line corresponding to the
> C function find_pc_line.

Thanks.

> +@defun gdb.find_pc_line (pc [, actual])
> +Return the @code{gdb.Symtab_and_line} object corresponding to the
> +@var{pc} value.  If @var{actual} is @code{True}, it returns the
                                                    ^^^^^^^^^^
"return", for consistency with the first sentence.

> +@code{gdb.Symtab_and_line} object with the actual line corresponding
> +to the pc value.  Otherwise, it returns the @code{gdb.Symtab_and_line}
                                ^^^^^^^^^^
Likewise.

> +The difference between @var{actual} being @code{True} or @code{False}
> +can be illustrated with an example.  Let a call to a function @code{func}
> +be on line 20 in a C source file as
> +
> +@smallexample
> +18  ...
> +19
> +20  func ();
> +21
> +22  return 0;
> +23
> +24  ...
> +@end smallexample
> +
> +After executing @value{GDBN} commands @code{step} followed by @code{up}
> +at line 20, the actual value of the @code{PC} register should correspond
> +to the next code line at line 22.  However, since the function
> +@code{func} has not yet been executed, the user feels that the execution
> +is still at line 20 (the call site) in the caller.

If I were that user, I would "feel" that the execution is at the first
line (or maybe in the prologue) of 'func', since PC is (in my mind)
unaffected by commands that walk the call stack.  And if you are
talking about the value of PC saved in the frame of the caller of
'func', then saying that line 22 is the "actual" location is again
confusing, because execution did not yet reach that point.

So I have hard time understanding why we need the distinction.  And
since you say that the current Symtab_and_line.line gives the second
alternatives, I'm confused even more.

It's possible that I'm the only confused person here, but in that
case, at least the example should be fixed to show and explain the
distinction more clearly and unequivocally, and also in which
situations the "actual" value is useful.


  reply	other threads:[~2012-05-07 19:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07 18:11 Siva Chandra
2012-05-07 19:36 ` Eli Zaretskii [this message]
2012-05-08  2:35   ` Siva Chandra
2012-05-09  7:35   ` Siva Chandra
2012-05-09 20:05     ` Eli Zaretskii
2012-05-10 21:16     ` Doug Evans
2012-05-11 16:35       ` Siva Chandra
2012-05-11 18:14         ` Doug Evans
2012-05-13 11:37           ` Siva Chandra

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=8362c73huz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=sivachandra@google.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