[Lldb-commits] [lldb] r348526 - Implement WindowsDYLD::DidAttach for use with gdb-server attach
Nathan Lanza via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 6 13:13:04 PST 2018
Author: lanza
Date: Thu Dec 6 13:13:03 2018
New Revision: 348526
URL: http://llvm.org/viewvc/llvm-project?rev=348526&view=rev
Log:
Implement WindowsDYLD::DidAttach for use with gdb-server attach
Summary:
Windows lldb debugging currently uses a process plugin to handle
launching and attaching to a process. Launching a process via a debug
server (e.g. ds2) and attaching to it with `gdb-remote port` currently
doesn't communicate address information of the executable properly.
Implement DynamicLoaderWindowsDYLD::DidAttach which allow us to
obtain the proper executable load address.
Differential Revision: https://reviews.llvm.org/D55383
Modified:
lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
Modified: lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp?rev=348526&r1=348525&r2=348526&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp Thu Dec 6 13:13:03 2018
@@ -10,12 +10,14 @@
#include "DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/Triple.h"
@@ -60,7 +62,39 @@ DynamicLoader *DynamicLoaderWindowsDYLD:
return nullptr;
}
-void DynamicLoaderWindowsDYLD::DidAttach() {}
+void DynamicLoaderWindowsDYLD::DidAttach() {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+ if (log)
+ log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+
+ ModuleSP executable = GetTargetExecutable();
+
+ if (!executable.get())
+ return;
+
+ // Try to fetch the load address of the file from the process, since there
+ // could be randomization of the load address.
+
+ // It might happen that the remote has a different dir for the file, so we
+ // only send the basename of the executable in the query. I think this is safe
+ // because I doubt that two executables with the same basenames are loaded in
+ // memory...
+ FileSpec file_spec(
+ executable->GetPlatformFileSpec().GetFilename().GetCString());
+ bool is_loaded;
+ addr_t base_addr = 0;
+ lldb::addr_t load_addr;
+ Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
+ if (error.Success() && is_loaded) {
+ base_addr = load_addr;
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false);
+ }
+
+ ModuleList module_list;
+ module_list.Append(executable);
+ m_process->GetTarget().ModulesDidLoad(module_list);
+ m_process->LoadModules();
+}
void DynamicLoaderWindowsDYLD::DidLaunch() {}
More information about the lldb-commits
mailing list