[Lldb-commits] [lldb] [LLDB] Add module hook implementation (PR #185465)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 7 16:33:29 PDT 2026
================
@@ -4243,6 +4307,407 @@ void Target::StopHookScripted::GetSubclassDescription(
as_dict->ForEach(print_one_element);
}
+// Hook
+
+Target::Hook::Hook(lldb::TargetSP target_sp, lldb::user_id_t uid)
+ : UserID(uid), m_target_sp(std::move(target_sp)) {}
+
+Target::Hook::Hook(const Hook &rhs)
+ : UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
+ m_enabled(rhs.m_enabled), m_trigger_mask(rhs.m_trigger_mask),
+ m_sc_specifier_sp(rhs.m_sc_specifier_sp),
+ m_at_initial_stop(rhs.m_at_initial_stop),
+ m_auto_continue(rhs.m_auto_continue),
+ m_suppress_output(rhs.m_suppress_output) {
+ if (rhs.m_thread_spec_up)
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
+}
+
+void Target::Hook::SetSCSpecifier(SymbolContextSpecifier *specifier) {
+ m_sc_specifier_sp.reset(specifier);
+}
+
+void Target::Hook::SetThreadSpecifier(ThreadSpec *specifier) {
+ m_thread_spec_up.reset(specifier);
+}
+
+bool Target::Hook::ExecutionContextPasses(const ExecutionContext &exc_ctx) {
+ SymbolContextSpecifier *specifier = GetSCSpecifier();
+ if (!specifier)
+ return true;
+
+ bool will_run = true;
+ if (exc_ctx.GetFramePtr())
+ will_run = specifier->SymbolContextMatches(
+ exc_ctx.GetFramePtr()->GetSymbolContext(eSymbolContextEverything));
+ if (will_run && GetThreadSpecifier() != nullptr)
+ will_run =
+ GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx.GetThreadRef());
+
+ return will_run;
+}
+
+void Target::Hook::GetDescription(Stream &s,
----------------
jimingham wrote:
I think you either need to compute the triggers for scripted hooks - so that the triggers are on the up and up everywhere - or make them a HookCommand only thing.
I think the former would be better. Then make the SetTrigger API's only available on HookCommand.
But for the sake of this PR you could also just move the to HookCommand for now.
https://github.com/llvm/llvm-project/pull/185465
More information about the lldb-commits
mailing list