简体   繁体   English

从C ++(Windows)转储堆栈跟踪-找不到符号

[英]Dumping a stack trace from C++ (Windows) - fails to find symbols

I'm a developer of Windows desktop software, and from time to time our app crashes. 我是Windows桌面软件的开发人员,因此我们的应用有时会崩溃。 In rare cases I'd like to get a customer to run a debug version of the app to send me a stack trace so I know where it crashed. 在极少数情况下,我想让客户运行该应用程序的调试版本以向我发送堆栈跟踪,以便我知道崩溃的地方。 I followed the instructions in here: 我按照这里的指示进行:

Windows C++ stack trace from a running app 来自正在运行的应用程序的Windows C ++堆栈跟踪

...but while it works on my development machine, it doesn't work on any client machine or those of my colleagues, who don't have Visual Studio installed. ...但是,尽管它在我的开发计算机上可以使用,但是在任何未安装Visual Studio的客户端计算机或我的同事的计算机上都无法使用。 So I presume that there's some .dll or something they need before it'll work. 因此,我认为有一些.dll或它们需要的东西才能起作用。 They're using the same .exe I'm using, ie the one I compiled in VC++ in debug mode. 他们使用的是同一个.exe,即我在VC ++中以调试模式编译的.exe。

After some painstaking "message window" debugging, I learnt it's failing in SymGetSymFromAddr64() - this returns FALSE. 经过一些艰苦的“消息窗口”调试,我了解到SymGetSymFromAddr64()失败-这将返回FALSE。 But when I walk the stack, this always returns FALSE or it returns garbage that doesn't make sense (random unrelated method names), as if it's the PC values which are invalid, not the mapping process. 但是,当我遍历堆栈时,它总是返回FALSE或返回没有意义的垃圾(随机无关的方法名),就像是PC值无效,而不是映射过程一样。 To reiterate, it's a debug mode .exe that produces a perfect symbolic stack trace on my development machine. 重申一下,它是一种调试模式.exe,可在我的开发机上生成完美的符号堆栈跟踪。

I did some research and found some mentions of "dbghelp.dll" and "imagehlp.dll" but I just ended up confused. 我做了一些研究,发现了“ dbghelp.dll”和“ imagehlp.dll”的提法,但最终我感到困惑。 "dbghelp.dll" ships with all versions of Windows, but with reduced functionality. “ dbghelp.dll”随Windows的所有版本一起提供,但功能有所减少。 There's some other things I could install, but it's a little scary to be installing some Windows "WDK" or "debug kits" which might overwrite important system .dll's or do god-knows-what to your computer. 我还可以安装其他东西,但是安装一些Windows“ WDK”或“调试工具包”可能会覆盖重要的系统.dll或对计算机有所帮助,这有点吓人。

So what I need to know is: "what's the simplest set of instructions I can give to these helper customers eg the minimum set of .dll's and where to stick them so that we can get proper symbolic information out of the stack traces when our program crashes?" 因此,我需要知道的是:“我可以给这些帮助客户的最简单的指令集是什么,例如最小的.dll文件集以及将其粘贴到哪里,以便我们在程序执行时可以从堆栈跟踪中获取正确的符号信息崩溃?”

The most likely reason for failing to find the symbols is that the .pdb file cannot be found. 找不到符号的最可能原因是找不到.pdb文件。 Even if you generate a .exe in debug mode, the symbols are not in the .exe, they are in the .pdb file. 即使在调试模式下生成.exe,这些符号也不位于.exe中,而是位于.pdb文件中。 Through a lot of empirical testing, it seems that the process has the pathname of the .pdb hardcoded in it, so if your clients don't have that file at that location, they won't necessarily find it. 通过大量的经验测试,似乎该进程中已硬编码了.pdb的路径名,因此,如果您的客户端在该位置没有该文件,则不一定会找到它。 However, you can supply a "search path" to the SymInitialize() function - a folder or set of folders to use to search for the .pdb file. 但是,您可以为SymInitialize()函数提供“搜索路径”-一个文件夹或一组文件夹,用于搜索.pdb文件。

In my configuration, I had an exe called "Edval.exe" and a .pdb called "DebugEdval.pdb". 在我的配置中,我有一个名为“ Edval.exe”的exe和一个名为“ DebugEdval.pdb”的.pdb。 The process searches for "DebugEdval.pdb" in the search folders. 该过程在搜索文件夹中搜索“ DebugEdval.pdb”。 This corresponds to what you've configured in "Properties > Linker > Debugging > Generate Program Database File". 这对应于您在“属性>链接器>调试>生成程序数据库文件”中配置的内容。

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

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