当使用MiniDumpWriteDump进程外时如何获取异常信息? [英] How do I get at the exception information when using MiniDumpWriteDump out-of-process?

查看:1511
本文介绍了当使用MiniDumpWriteDump进程外时如何获取异常信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用MiniDumpWriteDump函数在Windows上创建进程的核心转储时,建议(例如此处此处), MiniDumpWriteDump 是从另一个看门狗进程运行的,因为它在同一进程中调用时可能无法正常工作。

When using the MiniDumpWriteDump function to create a core dump of a process on Windows, it is recommended (e.g. here, and here) that the MiniDumpWriteDump is run from another "watchdog" process because it may well not work when called from within the same process.

应用程序是在未处理的异常(我们通过看门狗线程)中调用它。因为我们有时候有问题,它不工作,我们想移动到一个单独的过程。

At the moment, our application is calling it in-process on an unhandled exception (we do it from a watchdog thread). Since we sometimes have problems with it not working, we'd like to move it to a separate process.

现在,信号通知其他进程开始写转储是微不足道的(只是使用一个事件,信号量,你命名它)但如何传递 LPEXCEPTION_POINTERS 信息我获得的回调函数我注册 SetUnhandledExceptionFilter 到其他进程,以便它可以传递到 MiniDumpWriteDump s ExceptionParam / p>

Now, signalling the other process to start writing the dump is trivial (just use an event, semaphore, you name it) but how do I pass the LPEXCEPTION_POINTERS info I get for the callback function I register with SetUnhandledExceptionFilter to the other process so that it can be passed to MiniDumpWriteDumps ExceptionParam argument??

推荐答案

您还需要MINIDUMP_EXCEPTION_INFORMATION.ThreadId值。最简单的方法,以及我使它工作的方式是使用内存映射文件传输ThreadId和ExceptionPointers。和一个命名的事件来唤醒看门狗。

You also need the MINIDUMP_EXCEPTION_INFORMATION.ThreadId value. The simplest way, and the way I made it work, is to use a memory-mapped file to transfer both the ThreadId and the ExceptionPointers. And a named event to wake up the watchdog. It doesn't matter that the pointer is not valid in the context of the watchdog process.

在观察进程中使用CreateFileMapping + MapViewOfFile作为其初始化的一部分,OpenFileMapping + MapViewOfFile在看门狗。您的SetUnhandledExceptionFilter应该只调用GetCurrentThreadId()并将tid和pExcept复制到内存映射文件视图,调用SetEvent()来唤醒看门狗并永久阻止,直到看门狗终止它。

Use CreateFileMapping + MapViewOfFile in the watched process as part of its initialization, OpenFileMapping + MapViewOfFile in the watchdog. Your SetUnhandledExceptionFilter should then only call GetCurrentThreadId() and copy the tid and the pExcept to the memory mapped file view, call SetEvent() to wake up the watchdog and block forever until the watchdog terminates it.

这篇关于当使用MiniDumpWriteDump进程外时如何获取异常信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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