File tree 3 files changed +30
-1
lines changed
source/Plugins/DynamicLoader/MacOSX-DYLD 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 10
10
#define LLDB_TARGET_DYNAMICLOADER_H
11
11
12
12
#include " lldb/Core/PluginInterface.h"
13
+ #include " lldb/Symbol/Symbol.h"
13
14
#include " lldb/Utility/FileSpec.h"
14
15
#include " lldb/Utility/Status.h"
15
16
#include " lldb/Utility/UUID.h"
@@ -24,7 +25,6 @@ namespace lldb_private {
24
25
class ModuleList ;
25
26
class Process ;
26
27
class SectionList ;
27
- class Symbol ;
28
28
class SymbolContext ;
29
29
class SymbolContextList ;
30
30
class Thread ;
@@ -329,6 +329,13 @@ class DynamicLoader : public PluginInterface {
329
329
// / safe to call certain APIs or SPIs.
330
330
virtual bool IsFullyInitialized () { return true ; }
331
331
332
+ // / Return the `start` function \b symbol in the dynamic loader module.
333
+ // / This is the symbol the process will begin executing with
334
+ // / `process launch --stop-at-entry`.
335
+ virtual std::optional<lldb_private::Symbol> GetStartSymbol () {
336
+ return std::nullopt;
337
+ }
338
+
332
339
protected:
333
340
// Utility methods for derived classes
334
341
Original file line number Diff line number Diff line change @@ -609,6 +609,26 @@ void DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
609
609
}
610
610
}
611
611
612
+ std::optional<lldb_private::Symbol> DynamicLoaderDarwin::GetStartSymbol () {
613
+ Log *log = GetLog (LLDBLog::DynamicLoader);
614
+
615
+ auto log_err = [log ](llvm::StringLiteral err_msg) -> std::nullopt_t {
616
+ LLDB_LOGV (log , " {}" , err_msg);
617
+ return std::nullopt;
618
+ };
619
+
620
+ ModuleSP dyld_sp = GetDYLDModule ();
621
+ if (!dyld_sp)
622
+ return log_err (" Couldn't retrieve DYLD module. Cannot get `start` symbol." );
623
+
624
+ const Symbol *symbol =
625
+ dyld_sp->FindFirstSymbolWithNameAndType (ConstString (" _dyld_start" ));
626
+ if (!symbol)
627
+ return log_err (" Cannot find `start` symbol in DYLD module." );
628
+
629
+ return *symbol;
630
+ }
631
+
612
632
void DynamicLoaderDarwin::SetDYLDModule (lldb::ModuleSP &dyld_module_sp) {
613
633
m_dyld_module_wp = dyld_module_sp;
614
634
}
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public lldb_private::DynamicLoader {
67
67
// Clear method for classes derived from this one
68
68
virtual void DoClear () = 0;
69
69
70
+ std::optional<lldb_private::Symbol> GetStartSymbol () override ;
71
+
70
72
void SetDYLDModule (lldb::ModuleSP &dyld_module_sp);
71
73
72
74
lldb::ModuleSP GetDYLDModule ();
You can’t perform that action at this time.
0 commit comments