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][Python] New command 'fstep' using the GDB Python API


>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> Attached is a patch which implements a new command 'fstep' using the
Siva> GDB Python API.  The functionality is similar to the 'step' command,
Siva> but 'fstep' will bypass all intermediary functions and step into the
Siva> last function called on the source line.

It is cool that you can do this in Python.

I read the patch a while ago and I have been trying to come up with
trouble cases for it ever since.  In particular I am a bit concerned
that it is not integrated with the core infrun code.

I think due to how it is written it should work ok for most normal
cases.  But it seems like it would not handle non-stop very well -- if
you "fstep" one thread, and then there is an event in another thread,
won't the fstep'd thread just stop somewhere in the middle of the
operation?  And, there doesn't seem to be a way to "fstep &".

Siva> The implementation looks up for the last 'call' instruction on the
Siva> current source line, and hence is not perfect.

It seems to me that there is no real guarantee that the last such call
will really correspond to what the user expects.  The compiler might do
all kinds of wacky things under the hood.

I think this won't handle inlined functions in a way that is consistent
with the rest of gdb.  That is, they should be treated like function
calls, but "fstep" will not see the call instruction for the outermost
call, so it will stop at the wrong place.

I wonder about cases where the functions are split across lines, like:

    outer_call (
        inner_call(),
        inner_call());

But maybe the line table is always ok here.

I think a DWARF extension would be more reliable and portable.

Siva> The implementation at this point might also not yet be working as
Siva> desired for a few cases. For example, if we have a source line as
Siva> follows:
Siva> func1(); func2();
Siva> 'fstep' will step into func2, but that might not be what is desired.

I would not worry about this case.

Siva> 2013-03-19  Siva Chandra Reddy  <sivachandra@google.com>
Siva>         Implementation of a new command 'fstep' using the GDB Python
Siva>         API
Siva>         * data-directory/Makefile.in: Add entry for the new file.
Siva>         * python/lib/gdb/command/fstep.py: Implementation of the new
Siva>         command.

There is an open PR about this, so the ChangeLog should mention it.

Siva> +CALL_MNEMONIC_MAP = {
Siva> +    'i386:x86-64' : 'callq',
Siva> +    'i386' : 'call'
Siva> +}

This also seems like trouble.  I thought some architectures didn't even
have call-like instructions, or that compilers did not always use them
for whatever reason.

Tom


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