[Target] Generalize language-specific behavior in ThreadPlanStepThrough

Summary:
When creating a ThreadPlan to step through a trampoline, we ask the
ObjC language runtime and the CPP language runtime to come up with such a thread
plan if the dynamic loader fails to give us one. I don't see why this behavior
can't be language agnostic.

Differential Revision: https://reviews.llvm.org/D61921

llvm-svn: 362164
This commit is contained in:
Alex Langford 2019-05-30 22:00:18 +00:00
parent 365e592480
commit e5a7a858f5
4 changed files with 14 additions and 20 deletions

View File

@ -61,7 +61,7 @@ public:
/// \return /// \return
/// A ThreadPlan Shared pointer /// A ThreadPlan Shared pointer
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others); bool stop_others) override;
bool IsRuntimeSupportValue(ValueObject &valobj) override; bool IsRuntimeSupportValue(ValueObject &valobj) override;
protected: protected:

View File

@ -143,6 +143,9 @@ public:
return false; return false;
} }
virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others) = 0;
/// Identify whether a value is a language implementation detaul /// Identify whether a value is a language implementation detaul
/// that should be hidden from the user interface by default. /// that should be hidden from the user interface by default.
virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; } virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; }

View File

@ -216,9 +216,6 @@ public:
virtual bool HasReadObjCLibrary() = 0; virtual bool HasReadObjCLibrary() = 0;
virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others) = 0;
lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel); lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel);
void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel,

View File

@ -8,9 +8,8 @@
#include "lldb/Target/ThreadPlanStepThrough.h" #include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/DynamicLoader.h" #include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h" #include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h" #include "lldb/Target/Target.h"
@ -85,22 +84,17 @@ void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
m_sub_plan_sp = m_sub_plan_sp =
loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others); loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
// If that didn't come up with anything, try the ObjC runtime plugin: // If the DynamicLoader was unable to provide us with a ThreadPlan, then we
if (!m_sub_plan_sp.get()) { // try the LanguageRuntimes.
ObjCLanguageRuntime *objc_runtime = if (!m_sub_plan_sp) {
m_thread.GetProcess()->GetObjCLanguageRuntime(); for (LanguageRuntime *runtime :
if (objc_runtime) m_thread.GetProcess()->GetLanguageRuntimes()) {
m_sub_plan_sp = m_sub_plan_sp =
objc_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others); runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
CPPLanguageRuntime *cpp_runtime = if (m_sub_plan_sp)
m_thread.GetProcess()->GetCPPLanguageRuntime(); break;
}
// If the ObjC runtime did not provide us with a step though plan then if we
// have it check the C++ runtime for a step though plan.
if (!m_sub_plan_sp.get() && cpp_runtime)
m_sub_plan_sp =
cpp_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
} }
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));