Search code examples
coperating-systemgdbbootloaderatt

GDB step over command


I have the following C code:

#include <inc/x86.h>
#include <inc/elf.h>

#define SECTSIZE 512
#define ELFHDR  ((struct Elf *)0x10000) // Scratch space

void readsect(void*, unit32_t);
void readsec(uint32_t, uint32_t, uint32_t);

void bootmain(void)
{
    struct Proghdr *ph, *eph;

    // Read the first page off disk
    readseg((uint32_t) ELFHDR, SECTSIZE*8, 0);
    .
    .  // The rest of the code
    .
}

I am using GDB to step in my code and see what is happening.

I found the address of bootmain 0x7d0a and I put a breakpoint there.

b *0x7d0a
c

The above two commands: b adds a breakpoint and c runs until the breakpoint is reached.

I can see that I stopped at 0x7d0a as expected.

Then after a few commands I can see the function parameters being pushed to the stack as arguments. And a call for readseg.

0x7d0f push $0x0      // 0
0x7d11 push $0x1000   // 512*8 = 4096 B
0x7d16 push $0x10000  // 64 KB
0x7d1b call 0x7cd1

How do I just step over this function? The next command using si just gets me inside the readseg function. I don't want to step into, but to step over. I tried putting a breakpoint next to the next command:

    b *0x7d21
    c

But it never returns...

Should I perhaps have set the breakpoint on a different address?

I am not sure. However this is a way around and I'd rather use the step over command which I couldn't find in the documentation here.


Solution

  • The "step over" analogue of si is called nexti (also abbreviated ni). This will step a single assembly instruction, but step over calls.