简体   繁体   English

如何在未知代码中调试异常?

[英]How do I debug exceptions in unknown code?

I have a program that uses external libraries. 我有一个使用外部库的程序。 One of the libraries (responsible for a camera hardware) starts a thread and crashes unpredictably. 其中一个库(负责相机硬件)启动一个线程并且无法预测崩溃。 Sometimes every 2 minutes, sometimes not for an hour. 有时每2分钟,有时不会持续一个小时。 There's no obvious trigger. 没有明显的触发因素。 The exception is not caught be the thread, which leads to a termination of the application. 线程没有捕获异常,导致应用程序终止。 :( :(

Luckily I can stop the application in the moment the exception is raised by the RaiseException() function from the kernel32.dll . 幸运的是,我可以在kernel32.dllRaiseException()函数引发异常时停止应用程序。 There are no other functions on the call stack of which I know what they are for. 调用堆栈上没有其他函数,我知道它们的用途。

The debugger told me, that it's a std::bad_alloc exception. 调试器告诉我,这是一个std :: bad_alloc异常。 How does the debugger know that? 调试器如何知道? Can I get more information about the exception somehow? 我可以以某种方式获得有关异常的更多信息吗? If necessary, I would look into the Disassembly, but I don't know where to look to get the information. 如果有必要,我会查看反汇编,但我不知道从哪里获取信息。

I'm using Visual Studio C++ 2010, am well acquainted with assembler and have some understanding of the WINAPI. 我正在使用Visual Studio C ++ 2010,熟悉汇编程序并对WINAPI有所了解。 We want to release this software soon and this bug MUST dissappear. 我们想尽快发布这个软件,这个bug必须消失。

Use Windbg instead, that is a hard-core debugger that hides nothing and exposes things 'as they are'. 使用Windbg代替,这是一个硬核调试器,它不会隐藏任何东西,并且“按原样”暴露事物。 Using sxe syntax enable the desired exception (Windgb will enable to break at any SEH type, not only C++). 使用sxe语法启用所需的异常(Windgb将允许在任何SEH类型中断,而不仅仅是C ++)。 Windbg also has a clear distinction between first chance exception and second chance exception. Windbg还明确区分了第一次机会异常和第二次机会异常。 You should figure out then whether this is a C++ exception being raise or a more fundamental SEH type like perhaps an AV. 你应该弄清楚这是一个C ++异常被提升还是更基本的SEH类型,比如AV。

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

相关问题 如何在C ++非托管代码中调试较低级别的文件访问异常/崩溃? - How do I debug lower level File access exceptions/crashes in C++ unmanaged code? 程序崩溃与0xC000000D没有例外 - 我该如何调试它? - Program crashes with 0xC000000D and no exceptions - how do I debug it? 如何在自己的代码中使用_DEBUG_ERROR? - How do I use _DEBUG_ERROR in my own code? 如何在Eclipse中调试Android上的OpenCV示例的本机代码? - How do I debug native code of OpenCV samples on Android in Eclipse? 如何检测我的代码是否正在使用-fno-exceptions编译? - How do I detect if my code is being compiled with -fno-exceptions? 如何从托管代码项目中调试本机代码项目? C++/C# - How do I debug a native code project from inside a managed code project? C++/C# 如何在 WSL 上获取 VS 代码来调试我的 C++ 代码? - How do I get VS Code on WSL to debug my C++ code? 如何调用主要处于调试模式的程序或代码? - How do I call a program or code which has main in debug mode? 如何在Visual Studio 2015中调试现有的C ++源代码? - How do I debug existing C++ source code in Visual Studio 2015? 如何使用 pdb 调试现有的 C++ 可执行文件但没有源代码 - How do I debug an existing C++ executable with pdb but without source code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM