进程终止 C++
我有以下问题:我有一个用 C++ 编写的应用程序(永远不会结束的服务器)作为服务运行,主线程内还包含 3 个线程(主要执行 IO)。
在主循环中,我捕获所有可能的异常。
进程终止,主循环或线程本身没有打印任何内容。我在事件日志中看到该进程以代码 1000 停止。Windows
- 是否像 unix 中那样创建 Core 文件?
- 如果我从事件日志中获得内存地址,有什么方法可以知道它发生在应用程序的哪个部分?
- 也许这是一个线索:在它发生的同时,我启动了另一个应用程序(不是同一类型)。
I have the following problem: I have an application (server that never ends) written in C++ running as a service containing inside the main thread also 3 threads (mainly doing IO).
In the main loop I CATCH all possible exceptions.
The process terminated and nothing was printed either by the main loop or by the threads themselves. I saw in the event log that the process stopped with code 1000.
- Does Windows creates Core files like in unix ?
- If from the event log I get a memory address, is there any way of knowing in which part in the application it occurred?
- Maybe this is a clue: at the same time that it happened I started another application (not the same type).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试将 Windbg 设置为事后调试器。
windbg -I”
将激活windbg。
从windbg中使用
“kb”或“!uniqstack”
查看堆栈跟踪。在此处查找更多命令。
并查看这里 了解如何分析。
并尝试使用SEH:
try to set windbg as the postmortem debugger.
windbg -I
"the windbg will be activated .
from windbg use
"kb" or "!uniqstack"
to see the stacktrace.look here for more commands.
and look here for how to analysis.
and try use SEH:
请记住,
catch(...)
不会拦截代码中可能出错的所有内容,除非您使用结构化异常处理。例如Bear in mind that
catch(...)
does not intercept everything that can go wrong in your code, unless you are using Structured Exception Handling. Eg在构建应用程序时,您需要使用 /EHa 编译器开关,以便使用 C++ try/catch 结构捕获 Windows 结构化异常(例如访问冲突)。
在 Visual Studio 中,这是在项目属性“配置属性”->“项目属性”中。 C/C++->代码生成->启用 C++ 异常。您想要“是,但有 SEH 例外 (/EHa)”。我记得读到的设置有一些明显的缺点,尽管我不记得它们到底是什么。
链接:MSDN on C++ 异常处理模型
编辑:As whunmr 建议,直接使用结构化异常可能比 /EHa 更好
You need to use the /EHa compiler switch when building your application in order to catch windows structured exceptions (such as access violation) with the C++ try/catch constructs.
In Visual Studio this is in project properties Configuration Properties -> C/C++ -> Code Generation -> Enable C++ Exceptions. You want "Yes With SEH Exceptions (/EHa)". I remember reading setting this has some significant drawbacks, although I cannot recall what they were exactly.
Link: MSDN on C++ exception handling model
Edit: As whunmr suggests, directly using structured exceptions is probably better idea than /EHa
它不会自动地。但是您可以通过以下方式启用此类文件
在您的代码中实现它或使用外部应用程序
作为 Windbg,或 Dr.沃森
一般来说,如果你不保留调试信息文件(pdb),就没有办法
这不是有用的信息,除非两个应用程序彼此交互
it does not, automatically. however you can enable such a files by
either implementing it in your code or by using external application
as windbg, or Dr. Watson
There is no way if in general, if you don't keep debug information files (pdb)
this is not helpful information, unless both of the applications are interacted each other
Windows 将根据以下设置将您使用的任何程序用作调试器:
您可以将
My_Debugger
更改为您用于调试的任何程序/IDE 的完整路径。这通常设置为 Dr Watson,它将创建崩溃的日志条目,这不是您想要的。
Windows will whatever program you are using as a debugger depending on the setting in:
You can change
My_Debugger
to the full path of whatever program/IDE you are using for debugging.This is often set to Dr Watson which will create a log entry of the crash which is not what you want.