This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How step over a ass call command?
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>, Peng Yu <pengyu dot ut at gmail dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Tue, 07 Oct 2014 17:24:15 +0100
- Subject: Re: How step over a ass call command?
- Authentication-results: sourceware.org; auth=none
- References: <CABrM6wkRbsZW97Bu6SA7hUP4GFgwiwrtPQEFVSWMA_AvACW=Lg at mail dot gmail dot com> <CAMo8BfJCdAsLDPD-Sxbp2xeG907difmfCC9Qs-Sc-Z2ObDe-Sg at mail dot gmail dot com> <CABrM6wnra-GjF0su9X1fZS7GqvuRJU9eHyt_9_AbQcU=kKgZAg at mail dot gmail dot com> <87r3ykt12e dot fsf at codesourcery dot com>
On 10/07/2014 03:19 PM, Yao Qi wrote:
> Peng Yu <pengyu.ut@gmail.com> writes:
>
>>>> Suppose that I use gdb with a binary file with source stripped.
>
> What do you mean by "a binary file with source stripped"? Did you
> compile without debug information? My gdb (built from current git repo
> for x86-linux target) works correctly for binary without debug info.
>
> (gdb) disassemble
> Dump of assembler code for function main:
> 0x08048406 <+0>: push %ebp
> 0x08048407 <+1>: mov %esp,%ebp
> => 0x08048409 <+3>: call 0x8048400 <foo>
> 0x0804840e <+8>: mov $0x0,%eax
> 0x08048413 <+13>: pop %ebp
> 0x08048414 <+14>: ret
> End of assembler dump.
> (gdb) ni
> 0x0804840e in main ()
>
>>> Try nexti, which is defined as
>>> Execute one machine instruction, but if it is a function call, proceed
>>> until the function returns
>>
>> I am sorry. I meant to say "nexti" in my original email. "nexti" seems
>> to the same as "stepi" when the source code is stripped. Is it
>> supposed to be so?
>
> No, it looks a bug to me. What is your gdb version? or you can report
> this bug here https://sourceware.org/bugzilla/
0x1ea7 <main+45>: mov %eax,(%esp)
0x1eaa <main+48>: call 0x1f14
0x1eaf <main+53>: mov 0x1180(%ebx),%ecx
Doesn't look like GDB which function is at 0x1f14.
"nexti" relies on being able to backtrace out of that "function",
and check that the previous caller is still found at frame #1, to
detect that a function call was done. So run to that "call" line,
and then do "bt". And then do "stepi" to step that instruction
instead of "nexti", and then do "bt" again. If the second
backtrace doesn't have one extra frame, or if the frame that was frame
#0 in the first backtrace is frame #1 in the second backtrace,
then "nexti" won't work either.
Thanks,
Pedro Alves