DBG: misc. changes and fixes in SymbolSourceDIA:
- Rename SetThreadDescription to SetWin10ThreadDescription, to clarify that this function isn't actually useful to anyone. (ha ha, OK... but seriously, the same name is also used by the Windows SDK which apparently takes precedence and gets added as a static import, making it impossible to start the debugger on OSes other than Windows 10) - Thread names are a good idea and they even kind of work on older Windows versions with NtQueryInformationThread(ThreadQuerySetWin32StartAddress), which is what e.g. Process Explorer and Process Hacker use. What *doesn't* work so well is lambdas. Added static functions SymbolsThread() and SourceLinesThread() to replace these. (before: x64dbg.dll!<lambda_fc00d3fb731b14a9b4857ac068d657c4>::<lambda_invoker_cdecl>. after: x64dbg.dll!SymbolSourceDIA::SymbolsThread). These should probably be file statics instead of class members, but they need access to private class functions - GetModuleHandleA -> GetModuleHandleW. The former just calls the latter but with an extra string allocation and pointless unicode conversion - Fix pedantic Clang warnings about member initialization order in ctor - Qualify type name in call to virtual function in destructor, as this will be statically resolved and won't call any potential future implementations in derived classes (this can be further 'fixed' by making either the function or the class final so you'll get a compile time error if you try to do this later)
This commit is contained in:
parent
9b0f9b5c59
commit
a4638d2ea9
|
@ -4,27 +4,40 @@
|
|||
#include <algorithm>
|
||||
|
||||
SymbolSourceDIA::SymbolSourceDIA()
|
||||
: _requiresShutdown(false),
|
||||
_imageBase(0),
|
||||
: _isOpen(false),
|
||||
_requiresShutdown(false),
|
||||
_loadCounter(0),
|
||||
_isOpen(false)
|
||||
_imageBase(0),
|
||||
_imageSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
SymbolSourceDIA::~SymbolSourceDIA()
|
||||
{
|
||||
cancelLoading();
|
||||
SymbolSourceDIA::cancelLoading();
|
||||
}
|
||||
|
||||
static void SetThreadDescription(HANDLE hThread, WString name)
|
||||
static void SetWin10ThreadDescription(HANDLE threadHandle, const WString & name)
|
||||
{
|
||||
typedef HRESULT(WINAPI * fnSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription);
|
||||
|
||||
fnSetThreadDescription fp = (fnSetThreadDescription)GetProcAddress(GetModuleHandleA("kernel32.dll"), "SetThreadDescription");
|
||||
fnSetThreadDescription fp = (fnSetThreadDescription)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetThreadDescription");
|
||||
if(!fp)
|
||||
return; // Only available on windows 10.
|
||||
|
||||
fp(hThread, name.c_str());
|
||||
fp(threadHandle, name.c_str());
|
||||
}
|
||||
|
||||
DWORD WINAPI SymbolSourceDIA::SymbolsThread(void* parameter)
|
||||
{
|
||||
((SymbolSourceDIA*)parameter)->loadSymbolsAsync();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI SymbolSourceDIA::SourceLinesThread(void* parameter)
|
||||
{
|
||||
((SymbolSourceDIA*)parameter)->loadSourceLinesAsync();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SymbolSourceDIA::loadPDB(const std::string & path, duint imageBase, duint imageSize, DiaValidationData_t* validationData)
|
||||
|
@ -39,18 +52,10 @@ bool SymbolSourceDIA::loadPDB(const std::string & path, duint imageBase, duint i
|
|||
_imageBase = imageBase;
|
||||
_requiresShutdown = false;
|
||||
_loadCounter.store(2);
|
||||
_symbolsThread = CreateThread(nullptr, 0, [](LPVOID thisPtr) -> DWORD
|
||||
{
|
||||
((SymbolSourceDIA*)thisPtr)->loadSymbolsAsync();
|
||||
return 0;
|
||||
}, this, CREATE_SUSPENDED, nullptr);
|
||||
SetThreadDescription(_symbolsThread, L"SymbolsThread");
|
||||
_sourceLinesThread = CreateThread(nullptr, 0, [](LPVOID thisPtr) -> DWORD
|
||||
{
|
||||
((SymbolSourceDIA*)thisPtr)->loadSourceLinesAsync();
|
||||
return 0;
|
||||
}, this, CREATE_SUSPENDED, nullptr);
|
||||
SetThreadDescription(_sourceLinesThread, L"SourceLinesThread");
|
||||
_symbolsThread = CreateThread(nullptr, 0, SymbolsThread, this, CREATE_SUSPENDED, nullptr);
|
||||
SetWin10ThreadDescription(_symbolsThread, L"SymbolsThread");
|
||||
_sourceLinesThread = CreateThread(nullptr, 0, SourceLinesThread, this, CREATE_SUSPENDED, nullptr);
|
||||
SetWin10ThreadDescription(_sourceLinesThread, L"SourceLinesThread");
|
||||
ResumeThread(_symbolsThread);
|
||||
ResumeThread(_sourceLinesThread);
|
||||
}
|
||||
|
|
|
@ -154,6 +154,9 @@ private:
|
|||
void loadPDBAsync();
|
||||
bool loadSymbolsAsync();
|
||||
bool loadSourceLinesAsync();
|
||||
|
||||
static DWORD WINAPI SymbolsThread(void* parameter);
|
||||
static DWORD WINAPI SourceLinesThread(void* parameter);
|
||||
};
|
||||
|
||||
#endif // _SYMBOLSOURCEPDB_H_
|
||||
|
|
Loading…
Reference in New Issue