This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] - Exposing find_pc_line through Python API


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

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

Not just the PC saved in the frame of the caller of 'func', even $pc
will have the same value.  If after a 'step' and 'up' you do 'print /d
$pc', it will print the same value as

(gdb) python print gdb.selected_frame().pc()

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

I do not understand myself why the second alternative was selected to
reflect in Symtab_and_line.line.

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

I am working on something for which I need to know the last function
call on a particular source line.  The heuristic I am trying to use is
that, when we 'step' in and out (via 'up') of the last function call,
the PC should correspond to the next source line and not the call site
of the last function call.

Thanks,
Siva Chandra


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]