为什么调试器需要符号来重建堆栈? [英] Why does the debugger need symbols to reconstruct the stack?

查看:108
本文介绍了为什么调试器需要符号来重建堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中调试时,如果缺少调用堆栈的符号,例如:

When debugging in Visual Studio, if symbols for a call stack are missing, for example:

00 > HelloWorld.exe!my_function(int y=42)  Line 291
01   dynlib2.dll!10011435()  
  [Frames below may be incorrect and/or missing, no symbols loaded for dynlib2.dll] 
02   dynlib2.dll!10011497()  
03   HelloWorld.exe!wmain(int __formal=1, int __formal=1)  Line 297 + 0xd bytes
04   HelloWorld.exe!__tmainCRTStartup()  Line 594 + 0x19 bytes
05   HelloWorld.exe!wmainCRTStartup()  Line 414
06   kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes 

调试器将显示警告下面的框架可能不正确和/或缺少

(请注意,只有行01和02没有符号,行00,我设置断点,所有其他行都加载符号。)

(Note that only lines 01 and 02 have no symbols. Line 00, where I set a breakpoint and all other lines have symbols loaded.)

现在,我知道如何修复警告( - >获取pdb文件),我不太明白为什么它显示毕竟!我上面粘贴的堆栈是完全正常的,只是我没有一个用于dynlib2.dll模块的pdb文件。

Now, I know how to fix the warning (->get pdb file), what I do not quite get is why it is displayed after all! The stack I pasted above is fully OK, it's just that I do not have a pdb file for the dynlib2.dll module.

为什么调试器需要一个符号文件确保堆栈正确吗?

Why does the debugger need a symbols file to make sure the stack is correct?

推荐答案

我认为这是因为并非所有功能都遵循标准堆栈布局。通常每个功能都从以下开始:

I think this is because not all the functions follow the "standard" stack layout. Usually every function starts with:

push        ebp  
mov         ebp,esp 

结束于

pop         ebp  
ret

每个函数都创建它所谓的堆栈框架。 EBP 始终指向顶层堆栈框架的开头。在每个帧中,前两个值是指向前一个堆栈帧的指针和函数返回地址。

By this every function creates its so-called stack frame. EBP always points to the beginning of the top stack frame. In every frame the first two values are the pointer to the previous stack frame, and the function return address.

使用该信息可以轻松地重建堆栈。但是:

Using this information one can easily reconstruct the stack. However:


  1. 此堆栈信息不包括函数名称和参数信息。

  2. 不全部功能遵循这个堆栈帧布局。如果启用了一些优化(例如,Oy,省略堆栈帧指针) - 堆栈布局不同。

这篇关于为什么调试器需要符号来重建堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆