简体   繁体   English

GDB 跳过命令

[英]GDB step over command

I have the following C code:我有以下 C 代码:

#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.我正在使用 GDB 来介入我的代码,看看发生了什么。

I found the address of bootmain 0x7d0a and I put a breakpoint there.我找到了 bootmain 0x7d0a的地址,并在那里放置了一个断点。

b *0x7d0a
c

The above two commands: b adds a breakpoint and c runs until the breakpoint is reached.上面两条命令: b添加断点, c运行直到到达断点。

I can see that I stopped at 0x7d0a as expected.我可以看到我按预期停在0x7d0a

Then after a few commands I can see the function parameters being pushed to the stack as arguments.然后在几个命令之后,我可以看到函数参数作为参数被推送到堆栈。 And a call for readseg .并呼吁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.使用si的下一个命令只是让我进入readseg函数。 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 .但是,这是一种解决方法,我宁愿使用我在此处的文档中找不到的 step over 命令。

The "step over" analogue of si is called nexti (also abbreviated ni ). si的“跨越”类似物称为nexti (也缩写为ni )。 This will step a single assembly instruction, but step over calls.这将单步执行单个汇编指令,但会跳过调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM