public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How step over a ass call command?
@ 2014-10-05 22:12 Peng Yu
  2014-10-05 22:31 ` Max Filippov
  0 siblings, 1 reply; 6+ messages in thread
From: Peng Yu @ 2014-10-05 22:12 UTC (permalink / raw)
  To: gdb

Hi,

Suppose that I use gdb with a binary file with source stripped.

   0x1ea7 <main+45>:    mov    %eax,(%esp)
   0x1eaa <main+48>:    call   0x1f14
   0x1eaf <main+53>:    mov    0x1180(%ebx),%ecx

Suppose that pc is at 0x1ea7 and I want to step 2 instructions to
0x1eaf and without stopping inside call 0x1f14. "stepi" does not seem
to work in this case (my guess is that it only works with source code
for skipping function calls, but not at the assembly level.)

Does anybody know what is the best way to get to the line 0x1eaf? (I
could set a breakpoint at 0x1eaf, but I found this is too cumbersome.)
Thanks.

-- 
Regards,
Peng

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How step over a ass call command?
  2014-10-05 22:12 How step over a ass call command? Peng Yu
@ 2014-10-05 22:31 ` Max Filippov
  2014-10-05 22:59   ` Peng Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Max Filippov @ 2014-10-05 22:31 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

On Mon, Oct 6, 2014 at 2:12 AM, Peng Yu <pengyu.ut@gmail.com> wrote:
> Suppose that I use gdb with a binary file with source stripped.
>
>    0x1ea7 <main+45>:    mov    %eax,(%esp)
>    0x1eaa <main+48>:    call   0x1f14
>    0x1eaf <main+53>:    mov    0x1180(%ebx),%ecx
>
> Suppose that pc is at 0x1ea7 and I want to step 2 instructions to
> 0x1eaf and without stopping inside call 0x1f14. "stepi" does not seem
> to work in this case (my guess is that it only works with source code
> for skipping function calls, but not at the assembly level.)
>
> Does anybody know what is the best way to get to the line 0x1eaf? (I
> could set a breakpoint at 0x1eaf, but I found this is too cumbersome.)

Try nexti, which is defined as
    Execute one machine instruction, but if it is a function call, proceed
    until the function returns

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How step over a ass call command?
  2014-10-05 22:31 ` Max Filippov
@ 2014-10-05 22:59   ` Peng Yu
  2014-10-07 14:23     ` Yao Qi
  0 siblings, 1 reply; 6+ messages in thread
From: Peng Yu @ 2014-10-05 22:59 UTC (permalink / raw)
  To: gdb

On Sun, Oct 5, 2014 at 5:31 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Mon, Oct 6, 2014 at 2:12 AM, Peng Yu <pengyu.ut@gmail.com> wrote:
>> Suppose that I use gdb with a binary file with source stripped.
>>
>>    0x1ea7 <main+45>:    mov    %eax,(%esp)
>>    0x1eaa <main+48>:    call   0x1f14
>>    0x1eaf <main+53>:    mov    0x1180(%ebx),%ecx
>>
>> Suppose that pc is at 0x1ea7 and I want to step 2 instructions to
>> 0x1eaf and without stopping inside call 0x1f14. "stepi" does not seem
>> to work in this case (my guess is that it only works with source code
>> for skipping function calls, but not at the assembly level.)
>>
>> Does anybody know what is the best way to get to the line 0x1eaf? (I
>> could set a breakpoint at 0x1eaf, but I found this is too cumbersome.)
>
> 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?

-- 
Regards,
Peng

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How step over a ass call command?
  2014-10-05 22:59   ` Peng Yu
@ 2014-10-07 14:23     ` Yao Qi
  2014-10-07 16:24       ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Yao Qi @ 2014-10-07 14:23 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

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/

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How step over a ass call command?
  2014-10-07 14:23     ` Yao Qi
@ 2014-10-07 16:24       ` Pedro Alves
  2014-10-07 16:26         ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2014-10-07 16:24 UTC (permalink / raw)
  To: Yao Qi, Peng Yu; +Cc: gdb

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How step over a ass call command?
  2014-10-07 16:24       ` Pedro Alves
@ 2014-10-07 16:26         ` Pedro Alves
  0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2014-10-07 16:26 UTC (permalink / raw)
  To: Pedro Alves, Yao Qi, Peng Yu; +Cc: gdb

On 10/07/2014 05:24 PM, Pedro Alves wrote:
> "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,
                               ^NOT^

> then "nexti" won't work either.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-07 16:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-05 22:12 How step over a ass call command? Peng Yu
2014-10-05 22:31 ` Max Filippov
2014-10-05 22:59   ` Peng Yu
2014-10-07 14:23     ` Yao Qi
2014-10-07 16:24       ` Pedro Alves
2014-10-07 16:26         ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).