gpt4 book ai didi

c - 调试器: How do I get "Mutex Owned" or "Mutex Free" info in a crash dump?

转载 作者:行者123 更新时间:2023-12-02 03:10:12 26 4
gpt4 key购买 nike

我不知道我没有做什么,但我根本无法让自己的调试器保存正在调试的应用程序的“Mutex Owned”或“Mutex Free”信息。

如果我按如下方式调用它,CDB 就可以正常工作:

  cdb -pn test.exe -c ".dump /f /ma /u test.dmp;.detach;q"

当我在 WinDbg 中打开故障转储文件并键入以下命令时,我看到 Mutex Free 或 Mutex Owned 状态:

 0:001> !handle 0 f Mutant
Handle 7f4
Type Mutant
Attributes 0
GrantedAccess 0x1f0001:
Delete,ReadControl,WriteDac,WriteOwner,Synch
QueryState
HandleCount 2
PointerCount 4
Name \BaseNamedObjects\PAUL_HANG_MUTEX
Object Specific Information
Mutex is Owned <--- THIS HERE IS WHAT I WANT TO SEE

下面是我的函数 - 我必须注释掉一些 MiniDumpWith 选项,因为除非我注释掉它们,否则它根本不会写入故障转储文件。

有人知道为什么当我使用/ma 时 CDB 可以保存信息,而我自己的代码却不能?

void WriteCrashDump( EXCEPTION_DEBUG_INFO *pExceptionInfo )
{
CONTEXT c;

memset( &c, 0, sizeof( c ) );

GetThreadContext( hThread, &c );

EXCEPTION_POINTERS ep;

memset( &ep, 0, sizeof( ep ) );

ep.ContextRecord = &c;
ep.ExceptionRecord = &pExceptionInfo->ExceptionRecord;

MINIDUMP_EXCEPTION_INFORMATION minidump_exception;

memset( &minidump_exception, 0, sizeof( minidump_exception ) );

minidump_exception .ThreadId = dwThreadId;
minidump_exception.ExceptionPointers = &ep;
minidump_exception.ClientPointers = true;

char txDumpPath[ MAX_PATH + 1 ];

sprintf( txDumpPath, "%s.dmp", txProcess );

HANDLE hFile = CreateFile( txDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

if( hFile )
{
BOOL fSuccess;


SetLastError( 0L );

int nDumpOptions =

MiniDumpNormal
| MiniDumpWithDataSegs
| MiniDumpWithFullMemory
| MiniDumpWithHandleData
| MiniDumpFilterMemory
| MiniDumpScanMemory
| MiniDumpWithUnloadedModules
| MiniDumpWithIndirectlyReferencedMemory
| MiniDumpFilterModulePaths
| MiniDumpWithProcessThreadData
| MiniDumpWithPrivateReadWriteMemory
| MiniDumpWithoutOptionalData
//| MiniDumpWithFullMemoryInfo
//| MiniDumpWithThreadInfo
//| MiniDumpWithCodeSegs
//| MiniDumpWithoutManagedState
;

fSuccess = MiniDumpWriteDump( hProcess,
dwProcessId,
hFile,
(MINIDUMP_TYPE) nDumpOptions,
&minidump_exception,
NULL,
NULL );

DWORD dwErr = GetLastError();

if( ! fSuccess )
printf( "MiniDumpWriteDump -FAILED (LastError:%u)\n", dwErr );

CloseHandle( hFile );
}
}

最佳答案

即使使用标志 MiniDumpWithHandleData,它也不包含互斥信息吗?它也可能失败,因为某些标志可能与您调用的 DebugHlp.dll 版本不兼容。请参阅MINIDUMP_TYPE enumeration

关于c - 调试器: How do I get "Mutex Owned" or "Mutex Free" info in a crash dump?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9832200/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com