3
我不知道我沒做什麼,但我根本無法讓我自己的調試器保存正在調試的應用程序的「Mutex Owned」或「Mutex Free」信息。調試器:如何在崩潰轉儲中獲取「互斥鎖擁有」或「無互斥鎖」信息?
CDB工作正常,如果我把它叫做如下:
cdb -pn test.exe -c ".dump /f /ma /u test.dmp;.detach;q"
當我WinDbg打開崩潰轉儲文件,並鍵入以下命令,我看到了互斥免費或互斥擁有狀態:
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選項,因爲它根本不會寫入崩潰轉儲文件,除非我將它們評論出來。
有人知道爲什麼CDB可以在使用/ ma時保存信息,但我自己的代碼卻不能?
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);
}
}