[Lldb-commits] [lldb] r235118 - Add new virtual method for language runtime plug-ins:
Greg Clayton
gclayton at apple.com
Thu Apr 16 10:13:35 PDT 2015
Author: gclayton
Date: Thu Apr 16 12:13:34 2015
New Revision: 235118
URL: http://llvm.org/viewvc/llvm-project?rev=235118&view=rev
Log:
Add new virtual method for language runtime plug-ins:
virtual void
LanguageRuntime::ModulesDidLoad (const ModuleList &module_list);
Then reorganized how the objective C plug-in is notified so it will work for all LanguageRuntime subclasses.
Modified:
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Thu Apr 16 12:13:34 2015
@@ -119,6 +119,12 @@ public:
return false;
}
+ virtual void
+ ModulesDidLoad (const ModuleList &module_list)
+ {
+ return;
+ }
+
protected:
//------------------------------------------------------------------
// Classes that inherit from LanguageRuntime can see and modify these
Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Thu Apr 16 12:13:34 2015
@@ -313,8 +313,8 @@ public:
virtual
~ObjCLanguageRuntime();
- virtual lldb::LanguageType
- GetLanguageType () const
+ lldb::LanguageType
+ GetLanguageType () const override
{
return lldb::eLanguageTypeObjC;
}
@@ -515,10 +515,10 @@ public:
m_negative_complete_class_cache.clear();
}
- virtual bool
+ bool
GetTypeBitSize (const ClangASTType& clang_type,
- uint64_t &size);
-
+ uint64_t &size) override;
+
protected:
//------------------------------------------------------------------
// Classes that inherit from ObjCLanguageRuntime can see and modify these
@@ -645,6 +645,9 @@ protected:
ISAToDescriptorIterator
GetDescriptorIterator (const ConstString &name);
+ void
+ ReadObjCLibraryIfNeeded (const ModuleList &module_list);
+
DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime);
};
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Thu Apr 16 12:13:34 2015
@@ -39,6 +39,15 @@ using namespace lldb_private;
#define PO_FUNCTION_TIMEOUT_USEC 15*1000*1000
+AppleObjCRuntime::AppleObjCRuntime(Process *process) :
+ ObjCLanguageRuntime (process),
+ m_read_objc_library (false),
+ m_objc_trampoline_handler_ap (),
+ m_Foundation_major()
+{
+ ReadObjCLibraryIfNeeded (process->GetTarget().GetImages());
+}
+
bool
AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &valobj)
{
@@ -443,3 +452,29 @@ AppleObjCRuntime::CreateExceptionSearchF
}
}
+void
+AppleObjCRuntime::ReadObjCLibraryIfNeeded (const ModuleList &module_list)
+{
+ if (!HasReadObjCLibrary ())
+ {
+ Mutex::Locker locker (module_list.GetMutex ());
+
+ size_t num_modules = module_list.GetSize();
+ for (size_t i = 0; i < num_modules; i++)
+ {
+ auto mod = module_list.GetModuleAtIndex (i);
+ if (IsModuleObjCLibrary (mod))
+ {
+ ReadObjCLibrary (mod);
+ break;
+ }
+ }
+ }
+}
+
+void
+AppleObjCRuntime::ModulesDidLoad (const ModuleList &module_list)
+{
+ ReadObjCLibraryIfNeeded (module_list);
+}
+
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h Thu Apr 16 12:13:34 2015
@@ -34,37 +34,37 @@ public:
virtual ~AppleObjCRuntime() { }
// These are generic runtime functions:
- virtual bool
- GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
+ bool
+ GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) override;
- virtual bool
- GetObjectDescription (Stream &str, ValueObject &object);
+ bool
+ GetObjectDescription (Stream &str, ValueObject &object) override;
- virtual bool
- CouldHaveDynamicValue (ValueObject &in_value);
+ bool
+ CouldHaveDynamicValue (ValueObject &in_value) override;
- virtual bool
+ bool
GetDynamicTypeAndAddress (ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
- Address &address);
+ Address &address) override;
// These are the ObjC specific functions.
- virtual bool
- IsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
+ bool
+ IsModuleObjCLibrary (const lldb::ModuleSP &module_sp) override;
- virtual bool
- ReadObjCLibrary (const lldb::ModuleSP &module_sp);
+ bool
+ ReadObjCLibrary (const lldb::ModuleSP &module_sp) override;
- virtual bool
- HasReadObjCLibrary ()
+ bool
+ HasReadObjCLibrary () override
{
return m_read_objc_library;
}
- virtual lldb::ThreadPlanSP
- GetStepThroughTrampolinePlan (Thread &thread, bool stop_others);
+ lldb::ThreadPlanSP
+ GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) override;
// Get the "libobjc.A.dylib" module from the current target if we can find
// it, also cache it once it is found to ensure quick lookups.
@@ -76,10 +76,16 @@ public:
//------------------------------------------------------------------
// Note there is no CreateInstance, Initialize & Terminate functions here, because
// you can't make an instance of this generic runtime.
-
+
+
+ // Sync up with the target
+
+ void
+ ModulesDidLoad (const ModuleList &module_list) override;
+
protected:
- virtual bool
- CalculateHasNewLiteralsAndIndexing();
+ bool
+ CalculateHasNewLiteralsAndIndexing() override;
static bool
AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
@@ -87,24 +93,27 @@ protected:
static enum ObjCRuntimeVersions
GetObjCVersion (Process *process, lldb::ModuleSP &objc_module_sp);
+ void
+ ReadObjCLibraryIfNeeded (const ModuleList &module_list);
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
public:
- virtual void
- SetExceptionBreakpoints();
+ void
+ SetExceptionBreakpoints() override;
- virtual void
- ClearExceptionBreakpoints ();
+ void
+ ClearExceptionBreakpoints () override;
- virtual bool
- ExceptionBreakpointsAreSet ();
+ bool
+ ExceptionBreakpointsAreSet () override;
- virtual bool
- ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason);
+ bool
+ ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason) override;
- virtual lldb::SearchFilterSP
- CreateExceptionSearchFilter ();
+ lldb::SearchFilterSP
+ CreateExceptionSearchFilter () override;
uint32_t
GetFoundationVersion ();
@@ -121,14 +130,8 @@ protected:
llvm::Optional<uint32_t> m_Foundation_major;
- AppleObjCRuntime(Process *process) :
- lldb_private::ObjCLanguageRuntime(process),
- m_read_objc_library (false),
- m_objc_trampoline_handler_ap (),
- m_Foundation_major()
- {
- // Call CreateInstance instead.
- }
+ // Call CreateInstance instead.
+ AppleObjCRuntime(Process *process);
};
} // namespace lldb_private
Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Thu Apr 16 12:13:34 2015
@@ -44,7 +44,6 @@ ObjCLanguageRuntime::ObjCLanguageRuntime
m_complete_class_cache(),
m_negative_complete_class_cache()
{
-
}
bool
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Apr 16 12:13:34 2015
@@ -6469,13 +6469,29 @@ Process::ModulesDidLoad (ModuleList &mod
runtime->ModulesDidLoad(module_list);
}
+ // Let any language runtimes we have already created know
+ // about the modules that loaded.
+
+ // Iterate over a copy of this language runtime list in case
+ // the language runtime ModulesDidLoad somehow causes the language
+ // riuntime to be unloaded.
+ LanguageRuntimeCollection language_runtimes(m_language_runtimes);
+ for (const auto &pair: language_runtimes)
+ {
+ // We must check language_runtime_sp to make sure it is not
+ // NULL as we might cache the fact that we didn't have a
+ // language runtime for a language.
+ LanguageRuntimeSP language_runtime_sp = pair.second;
+ if (language_runtime_sp)
+ language_runtime_sp->ModulesDidLoad(module_list);
+ }
}
ThreadCollectionSP
Process::GetHistoryThreads(lldb::addr_t addr)
{
ThreadCollectionSP threads;
-
+
const MemoryHistorySP &memory_history = MemoryHistory::FindPlugin(shared_from_this());
if (! memory_history.get()) {
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=235118&r1=235117&r2=235118&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Apr 16 12:13:34 2015
@@ -1259,24 +1259,6 @@ Target::ModulesDidLoad (ModuleList &modu
if (m_process_sp)
{
m_process_sp->ModulesDidLoad (module_list);
-
- // This assumes there can only be one libobjc loaded.
- ObjCLanguageRuntime *objc_runtime = m_process_sp->GetObjCLanguageRuntime ();
- if (objc_runtime && !objc_runtime->HasReadObjCLibrary ())
- {
- Mutex::Locker locker (module_list.GetMutex ());
-
- size_t num_modules = module_list.GetSize();
- for (size_t i = 0; i < num_modules; i++)
- {
- auto mod = module_list.GetModuleAtIndex (i);
- if (objc_runtime->IsModuleObjCLibrary (mod))
- {
- objc_runtime->ReadObjCLibrary (mod);
- break;
- }
- }
- }
}
BroadcastEvent (eBroadcastBitModulesLoaded, new TargetEventData (this->shared_from_this(), module_list));
}
More information about the lldb-commits
mailing list