From: Andrew Burgess <andrew.burgess@embecosm.com>
To: dwk <dwks42@gmail.com>
Cc: David Griffiths <dgriffiths@undo.io>, GDB <gdb@sourceware.org>
Subject: Re: Is nexti confused by pushq?
Date: Tue, 26 Feb 2019 07:32:00 -0000 [thread overview]
Message-ID: <20190226073236.GD10887@embecosm.com> (raw)
In-Reply-To: <CAPkwjGtoLAPg6dnPOp5fe9-dqFDerhmATESu_wZaUtOOQOp4hA@mail.gmail.com>
* dwk <dwks42@gmail.com> [2019-02-25 10:54:19 -0500]:
> I encounter this frequently, although I don't have a minimal case yet
> either. I think it may have something to do with symbol information, as
> I've only encountered the case when symbol information is not present (as
> in the example you gave). stepi always works but nexti sometimes turns into
> a continue, I assumed because it was unable to figure out where the "next"
> instruction was somehow in the absence of symbols.
The problem here is that pushq changes the stack pointer, this is
obviously interacting badly with the unwinder in some cases.
If we consider the difference between 'stepi' and 'nexti' we will see
what is going wrong.
A 'stepi' simply single steps the machine. There's very little extra
logic, it's just a single step.
A 'nexti' however, steps the next instruction in the current function,
stepping over function calls. The way this works is that when the
'nexti' is issued GDB caches the current frame-id, that is (roughly)
function entry $pc, and the frame base pointer (related to $sp at
entry to the function). Once this is cached GDB single steps, and
after each step it checks the current frame-id. If the frame-id has
changed then GDB believes we have entered a new (nested) function,
places a breakpoint at the return address, and then continues. Once
we hit the breakpoint we should be back in the original frame and we
have completed the 'nexti'.
Now the problem comes if when we single step over the 'pushq' the
frame-id changes, if this happens GDB gets confused and then
continues.
To check this you should try walking over your problem code using
'stepi', and at each step run the 'bt' command. What you'll see is
that as you step over the 'pushq' the backtrace will change in
someway, this indicates the change in frame-id that is causing
problems for you.
Of course, this doesn't solve the problem for you, but at least you
know what's going wrong now :)
Thanks,
Andrew
>
> dwk
>
> On Mon, Feb 25, 2019, 10:41 AM David Griffiths <dgriffiths@undo.io> wrote:
>
> > Hi, when I get to the following instructions:
> >
> > 0x00007fffe192413e: rex.W pushq 0x28(%rsp)
> > 0x00007fffe1924143: rex.W popq (%rsp)
> > 0x00007fffe1924147: callq 0x00007fffe1045de0
> >
> > and do "nexti" at the first, it doesn't stop at the second but instead acts
> > as though I'd done "continue". For some reason I can't reproduce with a
> > little test though.
> >
> > (gdb 8.1 on Ubuntu 16.04)
> >
> > BTW I'm doing nexti programmatically and trying to avoid looking at the
> > next instruction to decide whether to do stepi or nexti.
> >
> > Cheers,
> >
> > David
> >
> > --
> >
> > David Griffiths, Senior Software Engineer
> >
> > Undo <https://undo.io> | Resolve even the most challenging software
> > defects
> > with software flight recorder technology
> >
> > Software reliability report: optimizing the software supplier and customer
> > relationship
> > <
> > https://info.undo.io/software-reliability-report-optimizing-supplier-and-customer-relationship
> > >
> >
next prev parent reply other threads:[~2019-02-26 7:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA++j6c4bKPiWgYsSp2ajPLrJmv4wQ6Fb_Z=nXfs7TTOjzAqKRg@mail.gmail.com>
2019-02-25 15:54 ` dwk
2019-02-26 7:32 ` Andrew Burgess [this message]
2019-02-26 10:12 ` Jan Kratochvil
2019-02-26 11:50 ` David Griffiths
2019-02-26 11:58 ` Jan Kratochvil
2019-02-26 14:19 ` Dmitry Samersoff
2019-02-26 14:42 ` David Griffiths
2019-02-26 19:05 ` Tom Tromey
2019-02-27 7:59 ` Dmitry Samersoff
2019-02-27 14:53 ` Tom Tromey
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=20190226073236.GD10887@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=dgriffiths@undo.io \
--cc=dwks42@gmail.com \
--cc=gdb@sourceware.org \
/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