35

I am attempting to figure the canary value setting and checking mechanism.

#include 
int main(void)
{
        return printf("Hi!\n");
}

When disassemble the main, I get

(gdb) disas main
0x080483f4 :    lea    0x4(%esp),%ecx
0x080483f8 :    and    $0xfffffff0,%esp
0x080483fb :    pushl  -0x4(%ecx)
0x080483fe :   push   %ebp
0x080483ff :   mov    %esp,%ebp
0x08048401 :   push   %ecx
0x08048402 :   sub    $0x14,%esp
0x08048405 :   mov    %gs:0x14,%eax
0x0804840b :   mov    %eax,-0x8(%ebp)
0x0804840e :   xor    %eax,%eax
0x08048410 :   movl   $0x8048500,(%esp)
0x08048417 :   call   0x8048320 
0x0804841c :   mov    -0x8(%ebp),%edx
0x0804841f :   xor    %gs:0x14,%edx
0x08048426 :   je     0x804842d 
0x08048428 :   call   0x8048330 
0x0804842d :   add    $0x14,%esp
0x08048430 :   pop    %ecx
0x08048431 :   pop    %ebp
0x08048432 :   lea    -0x4(%ecx),%esp
0x08048435 :   ret

I set a breakpoint at 0x0804840e using

b *0x0804840e

After the program flow stops at this breakpoint I would like gdb to go to the next instruction instead of next line of c code. I don't think I can use next for this. So what other option do I have apart from setting a breakpoint at every instruction?

1
  • 2
    GDB does have fairly good online help - help will get you a list of topics, among which is running; help running lists "stepi -- Step one instruction exactly", and help stepi gives a more detailed description.
    – Cascabel
    Commented Oct 10, 2011 at 6:57

1 Answer 1

55

You want to use stepi, aka si. it steps by one machine instruction.
(Or ni to step over call instructions.)

Check the GDB manual's section on continuing and stepping, which has an entry for it.
Or inside GDB, help / help running will show you that si exists, and help stepi will show you more about it.

1
  • 12
    I tend to use shorter si or ni aliases. Commented Apr 20, 2017 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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