[Lldb-commits] [PATCH] D12245: Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD.

Stephane Sezer via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 21 10:12:04 PDT 2015

sas created this revision.
sas added reviewers: clayborg, zturner.
sas added a subscriber: lldb-commits.

This commit implements basic DidAttach and DidLaunch for the windows
DynamicLoader plugin which allow us to load shared libraries from the

At the moment, I'm unsure how we're going to gather the load address of
the main module over gdb protocol so I always use an offset of 0, which
works well for processes we create ourselves (no randomization). I will
address this point later on.



Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -9,6 +9,7 @@
 #include "DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
@@ -72,11 +73,38 @@
+    Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+    if (log)
+        log->Printf ("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+    DidLaunch();
+    m_process->LoadModules();
+    Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+    if (log)
+        log->Printf ("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+    ModuleSP executable = GetTargetExecutable();
+    if (!executable.get())
+      return;
+    ModuleList module_list;
+    module_list.Append(executable);
+    // FIXME: We probably should not always use 0 as the load address
+    // here. Testing showed that when debugging a process that we start
+    // ourselves, there's no randomization of the load address of the
+    // main module, therefore an offset of 0 will be valid.
+    // If we attach to an already running process, this is probably
+    // going to be wrong and we'll have to get the load address somehow.
+    UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, 0);
+    m_process->GetTarget().ModulesDidLoad(module_list);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12245.32840.patch
Type: text/x-patch
Size: 1691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150821/047caf76/attachment.bin>

More information about the lldb-commits mailing list