“如何解读GDB”;“信息框架”;输出?

“如何解读GDB”;“信息框架”;输出?,gdb,Gdb,请一些人帮助我理解这一点:- (gdb) info frame Stack level 0, frame at 0xb75f7390: eip = 0x804877f in base::func() (testing.cpp:16); saved eip 0x804869a called by frame at 0xb75f73b0 source language c++. Arglist at 0xb75f7388, args: this=0x0 Locals at 0xb75f73

请一些人帮助我理解这一点:-

(gdb) info frame
Stack level 0, frame at 0xb75f7390:
 eip = 0x804877f in base::func() (testing.cpp:16); saved eip 0x804869a
 called by frame at 0xb75f73b0
 source language c++.
 Arglist at 0xb75f7388, args: this=0x0
 Locals at 0xb75f7388, Previous frame's sp is 0xb75f7390
 Saved registers:
  ebp at 0xb75f7388, eip at 0xb75f738c
“ebp、eip本地值和前一帧的sp”是什么意思?请解释

要理解“ebp、eip本地值和前一帧的sp”的含义,您需要理解

一旦你了解了如何做,所有其他的事情都会变得显而易见。

(gdb)信息框

堆栈级别0

  • 回溯中的frame num,0是当前正在执行的帧,它向下生长,与堆栈一致
0xb75f7390处的帧

  • 此堆栈帧的起始内存地址
base::func()中的eip=0x804877f(testing.cpp:16);已保存的eip 0x804869a

  • eip是下一条要执行的指令(也称为程序计数器)的寄存器。 因此,此时,下一个要执行的是“0x804877f”,即testing.cpp的第16行

  • 保存的eip“0x804869a”称为“返回地址”,即从该被调用方堆栈返回后在调用方堆栈帧中恢复的指令。在执行“CALL”指令时将其推入堆栈(保存以供返回)

由0xb75f73b0处的帧调用

  • 调用方堆栈帧的地址
源语言c++

  • 使用哪种语言
Arglist位于0xb75f7388,args:this=0x0

  • 参数的起始地址
本地人在0xb75f7388

局部变量的地址

上一帧的sp为0xb75f7390

这是前一帧的堆栈指针指向(调用方帧)的地方,在调用时,它也是被调用堆栈帧的起始内存地址

保存的寄存器: 这是被调用方堆栈上的两个地址,用于两个保存的寄存器

  • 0xb75f7388处的ebp 这是调用方堆栈帧的“ebp”寄存器保存的地址(请注意,这是寄存器,而不是调用方的堆栈地址)。 i、 e.,对应于“推送%ebp”。“ebp”是寄存器,通常被视为该堆栈帧的局部数的起始地址,它使用“偏移量”来寻址。 换句话说,局部变量的操作都使用这个“ebp”,因此您将看到类似于
    mov-0x4(%ebp),%eax
    ,等等的内容

  • 0xb75f738c处的eip 如前所述,但这里是堆栈的地址(其中包含值“0x804877f”)


    • 我知道这个问题来自。。。8年前。但对于未来的用户,我发现了一个非常清晰的信息轮廓

      这是从上述链接中提取的:

      info frame
      info f
      
      This command prints a verbose description of the selected stack frame, including:
      
          the address of the frame
          the address of the next frame down (called by this frame)
          the address of the next frame up (caller of this frame)
          the language in which the source code corresponding to this frame is written
          the address of the frame’s arguments
          the address of the frame’s local variables
          the program counter saved in it (the address of execution in the caller frame)
          which registers were saved in the frame 
      

      答案很好,不过我想为最后一点指出一个不同的答案。“保存的eip 0x804869a”显示保存的指令指针的值,即返回程序中的确切位置。但是,该值保存在堆栈的特定地址。要找出eip保存在堆栈上的地址,请查看“保存的寄存器”下的最后两行,其中显示“0xb75f738c处的eip”。换句话说,“保存的eip”的地址是0xb75f738c,包含值0x804869a,而不是值0x804877f。值0x804877f存储在寄存器eip中。类似地,前一个ebp也保存在堆栈地址0xb75f7388处的堆栈上。据我所知,寄存器ebp的值指向前一个ebp保存的堆栈地址。然后,它作为各种计算的参考点,例如ebp+4、ebp+8。我听说您可以使用“信息帧”信息来确定它是否为内联函数。我们如何推断这些信息来确定函数是否是内联的?