Windows / C ++:是否可以找到引起异常的代码行有“异常偏移” [英] Windows/C++: Is it possible to find the line of code where exception was thrown having "Exception Offset"

查看:131
本文介绍了Windows / C ++:是否可以找到引起异常的代码行有“异常偏移”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的用户在我们的产品启动中有异常。
她向我们发送了以下Windows错误消息:

One of our users having an Exception on our product startup. She has sent us the following error message from Windows:

  Problem Event Name:                        APPCRASH
  Application Name:                          program.exe
  Application Version:                       1.0.0.1
  Application Timestamp:                     4ba62004
  Fault Module Name:                         agcutils.dll
  Fault Module Version:                      1.0.0.1
  Fault Module Timestamp:                    48dbd973
  Exception Code:                            c0000005
  Exception Offset:                          000038d7
  OS Version:                                6.0.6002.2.2.0.768.2
  Locale ID:                                 1033
  Additional Information 1:                  381d
  Additional Information 2:                  fdf78cd6110fd6ff90e9fff3d6ab377d
  Additional Information 3:                  b2df
  Additional Information 4:                  a3da65b92a4f9b2faa205d199b0aa9ef

是否可以找到源代码中具有此信息的异常发生的确切位置?

Is it possible to locate the exact place in the source code where the exception has occured having this information?

Windows上的C ++程序员常用的技术是找出用户计算机发生错误的地方?

What is the common technique for C++ programmers on Windows to locate the place of an error that has occured on user computer?

我们的项目使用版本配置编译,生成PDB文件。

Our project is compiled with Release configuration, PDB file is generated.

我希望我的问题不太天真。

I hope my question is not too naive.

推荐答案

是的,这是可能的。开始调试与用户执行的完全相同的二进制文件,确保DLL被加载,并且您已经有一个匹配的PDB文件。查看Debug + Windows + Modules中的DLL基地址。添加偏移量。调试+ Windows +反汇编,并在地址字段中输入计算的地址(前缀为0x)。这将显示导致异常的确切机器代码指令。右键单击+转到源代码以查看匹配的源代码行。

Yes, that's possible. Start debugging with the exact same binaries as ran by your user, make sure the DLL is loaded and you've got a matching PDB file for it. Look in Debug + Windows + Modules for the DLL base address. Add the offset. Debug + Windows + Disassembly and enter the calculated address in the Address field (prefix with 0x). That shows you the exact machine code instruction that caused the exception. Right-click + Go To Source code to see the matching source code line.

虽然这显示了该语句,但这通常不足以诊断原因。 0xc0000005异常是访问冲突,它有很多可能的原因。通常你甚至没有得到任何代码,由于堆栈损坏,程序可能已经被遗忘了。或者真正的问题是位于远处,一些指针操纵破坏了堆。您通常还需要一个堆栈跟踪,显示程序如何结束于被轰炸的语句。

While that shows you the statement, this isn't typically good enough to diagnose the cause. The 0xc0000005 exception is an access violation, it has many possible causes. Often you don't even get any code, the program may have jumped into oblivion due to a corrupted stack. Or the real problem is located far away, some pointer manipulation that corrupted the heap. You also typically really need a stack trace that shows you how the program ended up at the statement that bombed.

您需要的是一个minidump。如果运行Vista或Win7,您可以轻松地从用户那里获得一个。启动TaskMgr.exe进程选项卡,当它仍然显示崩溃对话框时选择被轰炸的程序。右键单击并创建转储文件。

What you need is a minidump. You can easily get one from your user if she runs Vista or Win7. Start TaskMgr.exe, Processes tab, select the bombed program while it is still displaying the crash dialog. Right-click it and Create Dump File.

为了使其顺利进行,您真的希望自动执行此过程。您可以在此主题中找到我的答案中的提示。

To make this smooth, you really want to automate this procedure. You'll find hints in my answer in this thread.

这篇关于Windows / C ++:是否可以找到引起异常的代码行有“异常偏移”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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