GDB step over command

2019-09-12 03:30发布

问题:

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 1st page off disk
    readseg((uint32_t) ELFHDR, SECTSIZE*8, 0);
    .
    .  // REST OF 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 2 commands: b puts break-point and c runs until break-point is reached.

I can see that I stoped at 0x7d0a as expected. Then after few commands I can see the function parameters being pushed to 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 

My question is: How do I just step over this function ? 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 break-point next next command:

b *0x7d21
c

But it never returns...

Perhaps I should have set the break-point on a different address ? not sure. However this is a way around and I'd rather use step over command which I couldn't find in the documentation here.

回答1:

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