diff options
author | Zachary Turner <zturner@google.com> | 2014-11-12 19:31:56 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-11-12 19:31:56 +0000 |
commit | a32d2cecba6eacf42e8eb86fb40e75e3078ab353 (patch) | |
tree | 2270af112d02dddbc7ef209f4e4ddb105098a146 /lldb/source/Plugins/Process/Windows/DebuggerThread.cpp | |
parent | d6a7b63f26ece27e78b05609b2ad56aba43aef8f (diff) | |
download | bcm5719-llvm-a32d2cecba6eacf42e8eb86fb40e75e3078ab353.tar.gz bcm5719-llvm-a32d2cecba6eacf42e8eb86fb40e75e3078ab353.zip |
[ProcessWindows] Improve support for launching processes.
This sends notifications for module load / unload to the process
plugin, and also manages the state more accurately during the
loading sequence.
Similar work by Virgile Bello was referenced during the
implementation of this patch.
Differential Revision: http://reviews.llvm.org/D6224
llvm-svn: 221807
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/DebuggerThread.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/Windows/DebuggerThread.cpp | 35 |
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; } |