summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/DebuggerThread.cpp')
-rw-r--r--lldb/source/Plugins/Process/Windows/DebuggerThread.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
index f67438c3127..ac191c40e06 100644
--- a/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
+++ b/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
@@ -13,6 +13,8 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/ThisThread.h"
#include "lldb/Host/ThreadLauncher.h"
@@ -21,6 +23,7 @@
#include "lldb/Host/windows/ProcessLauncherWindows.h"
#include "lldb/Target/ProcessLaunchInfo.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"
using namespace lldb;
@@ -185,7 +188,8 @@ DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
((HostThreadWindows &)m_main_thread.GetNativeThread()).SetOwnsHandle(false);
m_image_file = info.hFile;
- m_debug_delegate->OnDebuggerConnected();
+ lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfImage);
+ m_debug_delegate->OnDebuggerConnected(load_addr);
return DBG_CONTINUE;
}
@@ -211,7 +215,33 @@ DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWOR
DWORD
DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
{
- // Windows does not automatically close info.hFile when the DLL is unloaded.
+ if (info.hFile == nullptr)
+ {
+ // Not sure what this is, so just ignore it.
+ return DBG_CONTINUE;
+ }
+
+ std::vector<char> buffer(1);
+ DWORD required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);
+ if (required_size > 0)
+ {
+ buffer.resize(required_size + 1);
+ required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], required_size + 1, VOLUME_NAME_DOS);
+ llvm::StringRef path_str(&buffer[0]);
+ const char *path = path_str.data();
+ if (path_str.startswith("\\\\?\\"))
+ path += 4;
+
+ FileSpec file_spec(path, false);
+ ModuleSpec module_spec(file_spec);
+ lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll);
+ m_debug_delegate->OnLoadDll(module_spec, load_addr);
+ }
+ else
+ {
+ // An unknown error occurred getting the path name.
+ }
+ // Windows does not automatically close info.hFile, so we need to do it.
::CloseHandle(info.hFile);
return DBG_CONTINUE;
}
@@ -219,6 +249,7 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread
DWORD
DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
{
+ m_debug_delegate->OnUnloadDll(reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll));
return DBG_CONTINUE;
}
OpenPOWER on IntegriCloud