Skip to content

Commit cd938bf

Browse files
[lldb] Introduce Language::AreEquivalentFunctions (#112720)
This allows languages to provide an opinion on whether two symbol contexts are equivalent (i.e. belong to the same function). It is useful to drive the comparisons done by stepping plans that need to ensure symbol contexts obtained from different points in time are actually the same.
1 parent dde26e3 commit cd938bf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lldb/include/lldb/Target/Language.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,15 @@ class Language : public PluginInterface {
363363
return false;
364364
}
365365

366+
/// Returns a boolean indicating whether two symbol contexts are equal for the
367+
/// purposes of frame comparison. If the plugin has no opinion, it should
368+
/// return nullopt.
369+
virtual std::optional<bool>
370+
AreEqualForFrameComparison(const SymbolContext &sc1,
371+
const SymbolContext &sc2) const {
372+
return {};
373+
}
374+
366375
/// Returns true if this Language supports exception breakpoints on throw via
367376
/// a corresponding LanguageRuntime plugin.
368377
virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; }

lldb/source/Target/ThreadPlanStepOverRange.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "lldb/Symbol/CompileUnit.h"
1212
#include "lldb/Symbol/Function.h"
1313
#include "lldb/Symbol/LineTable.h"
14+
#include "lldb/Target/Language.h"
1415
#include "lldb/Target/Process.h"
1516
#include "lldb/Target/RegisterContext.h"
1617
#include "lldb/Target/Target.h"
@@ -103,6 +104,10 @@ void ThreadPlanStepOverRange::SetupAvoidNoDebug(
103104

104105
bool ThreadPlanStepOverRange::IsEquivalentContext(
105106
const SymbolContext &context) {
107+
if (Language *language = Language::FindPlugin(context.GetLanguage()))
108+
if (std::optional<bool> maybe_equivalent =
109+
language->AreEqualForFrameComparison(context, m_addr_context))
110+
return *maybe_equivalent;
106111
// Match as much as is specified in the m_addr_context: This is a fairly
107112
// loose sanity check. Note, sometimes the target doesn't get filled in so I
108113
// left out the target check. And sometimes the module comes in as the .o

0 commit comments

Comments
 (0)