================
@@ -3426,6 +3427,89 @@ void
Target::SaveScriptedLaunchInfo(lldb_private::ProcessInfo &process_info) {
}
}
+Status
+Target::RegisterScriptedSymbolLocator(llvm::StringRef class_name,
+ StructuredData::DictionarySP args_sp) {
+ if (class_name.empty())
+ return Status::FromErrorString(
+ "class name must not be empty; use ClearScriptedSymbolLocator() to "
+ "unregister");
+
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
+ if (!interpreter)
+ return Status::FromErrorString("no script interpreter available");
+
+ auto interface_sp = interpreter->CreateScriptedSymbolLocatorInterface();
+ if (!interface_sp)
+ return Status::FromErrorString(
+ "failed to create scripted symbol locator interface");
+
+ ExecutionContext exe_ctx;
+ TargetSP target_sp(shared_from_this());
+ exe_ctx.SetTargetSP(target_sp);
+
+ auto obj_or_err =
+ interface_sp->CreatePluginObject(class_name, exe_ctx, args_sp);
+ if (!obj_or_err)
+ return Status::FromError(obj_or_err.takeError());
+
+ m_scripted_symbol_locator_metadata_sp =
+ std::make_shared<ScriptedMetadata>(class_name, args_sp);
+ m_scripted_symbol_locator_interface_sp = interface_sp;
+ m_scripted_source_file_cache.clear();
+
+ // Invalidate cached stack frames so the next backtrace re-resolves line
+ // entries through ApplyFileMappings, which will call our locator.
+ ProcessSP process_sp = GetProcessSP();
+ if (process_sp) {
+ ThreadList &thread_list = process_sp->GetThreadList();
+ for (uint32_t i = 0; i < thread_list.GetSize(false); i++) {
+ ThreadSP thread_sp = thread_list.GetThreadAtIndex(i, false);
+ if (thread_sp)
+ thread_sp->ClearStackFrames();
----------------
JDevlieghere wrote:
```suggestion
if (ThreadSP thread_sp = thread_list.GetThreadAtIndex(i, false))
thread_sp->ClearStackFrames();
```
https://github.com/llvm/llvm-project/pull/181334
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits