mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 17:30:32 +00:00
[NTOS]
- Do not forget to initialize LoadDll->NamePointer in DbgkMapViewOfSection!! - Just copy the NamePointer (pointer to pointer to file name) in DbgUiConvertStateChangeStructure. See the description of the lpImageName member of the LOAD_DLL_DEBUG_INFO structure in https://msdn.microsoft.com/en-us/library/windows/desktop/ms680351(v=vs.85).aspx for more details. This fixes some debugging stuff with GDB (see the below-mentioned report). Adapted from a patch by andy-123 (whom I don't remember his name^^), CORE-7019 #resolve #comment Fixed in r68306 CORE-8622 #comment An updated fix was committed in r68306 svn path=/trunk/; revision=68306
This commit is contained in:
parent
143664a895
commit
0bc85fb9f3
2 changed files with 19 additions and 63 deletions
|
@ -62,13 +62,8 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
OUT PVOID Win32DebugEvent)
|
OUT PVOID Win32DebugEvent)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
THREAD_BASIC_INFORMATION ThreadBasicInfo;
|
THREAD_BASIC_INFORMATION ThreadBasicInfo;
|
||||||
LPDEBUG_EVENT DebugEvent = Win32DebugEvent;
|
LPDEBUG_EVENT DebugEvent = Win32DebugEvent;
|
||||||
HANDLE ThreadHandle;
|
|
||||||
HANDLE ProcessHandle;
|
|
||||||
PTEB Teb;
|
|
||||||
PVOID Pointer;
|
|
||||||
|
|
||||||
/* Write common data */
|
/* Write common data */
|
||||||
DebugEvent->dwProcessId = (DWORD)WaitStateChange->
|
DebugEvent->dwProcessId = (DWORD)WaitStateChange->
|
||||||
|
@ -80,7 +75,7 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
{
|
{
|
||||||
/* New thread */
|
/* New thread */
|
||||||
case DbgCreateThreadStateChange:
|
case DbgCreateThreadStateChange:
|
||||||
|
{
|
||||||
/* Setup Win32 code */
|
/* Setup Win32 code */
|
||||||
DebugEvent->dwDebugEventCode = CREATE_THREAD_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = CREATE_THREAD_DEBUG_EVENT;
|
||||||
|
|
||||||
|
@ -109,10 +104,11 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
ThreadBasicInfo.TebBaseAddress;
|
ThreadBasicInfo.TebBaseAddress;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* New process */
|
/* New process */
|
||||||
case DbgCreateProcessStateChange:
|
case DbgCreateProcessStateChange:
|
||||||
|
{
|
||||||
/* Write Win32 debug code */
|
/* Write Win32 debug code */
|
||||||
DebugEvent->dwDebugEventCode = CREATE_PROCESS_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = CREATE_PROCESS_DEBUG_EVENT;
|
||||||
|
|
||||||
|
@ -160,30 +156,33 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
DebugEvent->u.CreateProcessInfo.lpImageName = NULL;
|
DebugEvent->u.CreateProcessInfo.lpImageName = NULL;
|
||||||
DebugEvent->u.CreateProcessInfo.fUnicode = TRUE;
|
DebugEvent->u.CreateProcessInfo.fUnicode = TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Thread exited */
|
/* Thread exited */
|
||||||
case DbgExitThreadStateChange:
|
case DbgExitThreadStateChange:
|
||||||
|
{
|
||||||
/* Write the Win32 debug code and the exit status */
|
/* Write the Win32 debug code and the exit status */
|
||||||
DebugEvent->dwDebugEventCode = EXIT_THREAD_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = EXIT_THREAD_DEBUG_EVENT;
|
||||||
DebugEvent->u.ExitThread.dwExitCode =
|
DebugEvent->u.ExitThread.dwExitCode =
|
||||||
WaitStateChange->StateInfo.ExitThread.ExitStatus;
|
WaitStateChange->StateInfo.ExitThread.ExitStatus;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process exited */
|
/* Process exited */
|
||||||
case DbgExitProcessStateChange:
|
case DbgExitProcessStateChange:
|
||||||
|
{
|
||||||
/* Write the Win32 debug code and the exit status */
|
/* Write the Win32 debug code and the exit status */
|
||||||
DebugEvent->dwDebugEventCode = EXIT_PROCESS_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = EXIT_PROCESS_DEBUG_EVENT;
|
||||||
DebugEvent->u.ExitProcess.dwExitCode =
|
DebugEvent->u.ExitProcess.dwExitCode =
|
||||||
WaitStateChange->StateInfo.ExitProcess.ExitStatus;
|
WaitStateChange->StateInfo.ExitProcess.ExitStatus;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Any sort of exception */
|
/* Any sort of exception */
|
||||||
case DbgExceptionStateChange:
|
case DbgExceptionStateChange:
|
||||||
case DbgBreakpointStateChange:
|
case DbgBreakpointStateChange:
|
||||||
case DbgSingleStepStateChange:
|
case DbgSingleStepStateChange:
|
||||||
|
{
|
||||||
/* Check if this was a debug print */
|
/* Check if this was a debug print */
|
||||||
if (WaitStateChange->StateInfo.Exception.ExceptionRecord.
|
if (WaitStateChange->StateInfo.Exception.ExceptionRecord.
|
||||||
ExceptionCode == DBG_PRINTEXCEPTION_C)
|
ExceptionCode == DBG_PRINTEXCEPTION_C)
|
||||||
|
@ -225,84 +224,40 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
WaitStateChange->StateInfo.Exception.FirstChance;
|
WaitStateChange->StateInfo.Exception.FirstChance;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* DLL Load */
|
/* DLL Load */
|
||||||
case DbgLoadDllStateChange:
|
case DbgLoadDllStateChange:
|
||||||
|
{
|
||||||
/* Set the Win32 debug code */
|
/* Set the Win32 debug code */
|
||||||
DebugEvent->dwDebugEventCode = LOAD_DLL_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = LOAD_DLL_DEBUG_EVENT;
|
||||||
|
|
||||||
/* Copy the rest of the data */
|
/* Copy the rest of the data */
|
||||||
DebugEvent->u.LoadDll.lpBaseOfDll =
|
|
||||||
WaitStateChange->StateInfo.LoadDll.BaseOfDll;
|
|
||||||
DebugEvent->u.LoadDll.hFile =
|
DebugEvent->u.LoadDll.hFile =
|
||||||
WaitStateChange->StateInfo.LoadDll.FileHandle;
|
WaitStateChange->StateInfo.LoadDll.FileHandle;
|
||||||
|
DebugEvent->u.LoadDll.lpBaseOfDll =
|
||||||
|
WaitStateChange->StateInfo.LoadDll.BaseOfDll;
|
||||||
DebugEvent->u.LoadDll.dwDebugInfoFileOffset =
|
DebugEvent->u.LoadDll.dwDebugInfoFileOffset =
|
||||||
WaitStateChange->StateInfo.LoadDll.DebugInfoFileOffset;
|
WaitStateChange->StateInfo.LoadDll.DebugInfoFileOffset;
|
||||||
DebugEvent->u.LoadDll.nDebugInfoSize =
|
DebugEvent->u.LoadDll.nDebugInfoSize =
|
||||||
WaitStateChange->StateInfo.LoadDll.DebugInfoSize;
|
WaitStateChange->StateInfo.LoadDll.DebugInfoSize;
|
||||||
|
DebugEvent->u.LoadDll.lpImageName =
|
||||||
/* Open the thread */
|
WaitStateChange->StateInfo.LoadDll.NamePointer;
|
||||||
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
|
||||||
Status = NtOpenThread(&ThreadHandle,
|
|
||||||
THREAD_QUERY_INFORMATION,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&WaitStateChange->AppClientId);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Query thread information */
|
|
||||||
Status = NtQueryInformationThread(ThreadHandle,
|
|
||||||
ThreadBasicInformation,
|
|
||||||
&ThreadBasicInfo,
|
|
||||||
sizeof(ThreadBasicInfo),
|
|
||||||
NULL);
|
|
||||||
NtClose(ThreadHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we got thread information, open the process */
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
Status = NtOpenProcess(&ProcessHandle,
|
|
||||||
PROCESS_VM_READ,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&WaitStateChange->AppClientId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Read the image name from the TIB */
|
|
||||||
Teb = ThreadBasicInfo.TebBaseAddress;
|
|
||||||
Status = NtReadVirtualMemory(ProcessHandle,
|
|
||||||
&Teb->NtTib.ArbitraryUserPointer,
|
|
||||||
&Pointer,
|
|
||||||
sizeof(Pointer),
|
|
||||||
NULL);
|
|
||||||
NtClose(ProcessHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* If everything was successful, set the image name */
|
|
||||||
DebugEvent->u.LoadDll.lpImageName = Pointer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Otherwise, no name */
|
|
||||||
DebugEvent->u.LoadDll.lpImageName = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* It's Unicode */
|
/* It's Unicode */
|
||||||
DebugEvent->u.LoadDll.fUnicode = TRUE;
|
DebugEvent->u.LoadDll.fUnicode = TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* DLL Unload */
|
/* DLL Unload */
|
||||||
case DbgUnloadDllStateChange:
|
case DbgUnloadDllStateChange:
|
||||||
|
{
|
||||||
/* Set Win32 code and DLL Base */
|
/* Set Win32 code and DLL Base */
|
||||||
DebugEvent->dwDebugEventCode = UNLOAD_DLL_DEBUG_EVENT;
|
DebugEvent->dwDebugEventCode = UNLOAD_DLL_DEBUG_EVENT;
|
||||||
DebugEvent->u.UnloadDll.lpBaseOfDll =
|
DebugEvent->u.UnloadDll.lpBaseOfDll =
|
||||||
WaitStateChange->StateInfo.UnloadDll.BaseAddress;
|
WaitStateChange->StateInfo.UnloadDll.BaseAddress;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Anything else, fail */
|
/* Anything else, fail */
|
||||||
default: return STATUS_UNSUCCESSFUL;
|
default: return STATUS_UNSUCCESSFUL;
|
||||||
|
|
|
@ -405,6 +405,7 @@ DbgkMapViewOfSection(IN PVOID Section,
|
||||||
LoadDll->BaseOfDll = BaseAddress;
|
LoadDll->BaseOfDll = BaseAddress;
|
||||||
LoadDll->DebugInfoFileOffset = 0;
|
LoadDll->DebugInfoFileOffset = 0;
|
||||||
LoadDll->DebugInfoSize = 0;
|
LoadDll->DebugInfoSize = 0;
|
||||||
|
LoadDll->NamePointer = &NtCurrentTeb()->NtTib.ArbitraryUserPointer;
|
||||||
|
|
||||||
/* Get the NT Headers */
|
/* Get the NT Headers */
|
||||||
NtHeader = RtlImageNtHeader(BaseAddress);
|
NtHeader = RtlImageNtHeader(BaseAddress);
|
||||||
|
|
Loading…
Reference in a new issue