2

In the function below, let's say EIP is 0x400688. Now, I want to step over the call instead of stepping inside the subroutine.

    0x40067a <main+4>       sub    $0x20,%rsp                                                                                                         │
   │0x40067e <main+8>       mov    $0x3c00,%edi                                                                                                       │
   │0x400683 <main+13>      mov    $0x0,%eax                                                                                                          │
  >│0x400688 <main+18>      callq  0x400560 <alarm@plt>                                                                                               │
   │0x40068d <main+23>      mov    0x2009ac(%rip),%rax        # 0x601040 <stdout@@GLIBC_2.2.5>                                                        │
   │0x400694 <main+30>      mov    $0x0,%ecx                                                                                                          │
   │0x400699 <main+35>      mov    $0x2,%edx                                                                                                          │
   │0x40069e <main+40>      mov    $0x0,%esi                       

I used the next command however it starts executing the main() function itself instead of just executing call and breaking at instruction: 0x40068d as shown below:

(gdb) next 
Single stepping until exit from function main,
which has no line number information.
2

As said, next won't work if the source has not its symbol table. You can obtain such debug symbols with -g option from gcc.

But otherwise, I think you're looking for the command nexti that can be shortened to ni.

1

next will not work as intended unless there is source line information in the symbol table.

From Next: Skipping Over Functions and Files:

Continue to the next source line in the current (innermost) stack frame. This is similar to step, but function calls that appear within the line of code are executed without stopping. Execution stops when control reaches a different line of code at the original stack level that was executing when you gave the next command. This command is abbreviated n.

An argument count is a repeat count, as for step.

The next command only stops at the first instruction of a source line. This prevents multiple stops that could otherwise occur in switch statements, for loops, etc.

  • Then what is the alternative? How do I step over the function call? – Neon Flash Dec 16 '18 at 19:45
  • @NeonFlash I typically set a breakpoint at the memory address of the instruction immediately following the function call. Then when I get to the function call I continue to skip the function code. – julian Dec 16 '18 at 19:51
  • Yes, that is one way but I was expecting a more convenient way instead of setting a breakpoint each time there is a call instruction. – Neon Flash Dec 17 '18 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.