================
@@ -0,0 +1,271 @@
+//===-- SymbolLocatorScripted.cpp
+//------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SymbolLocatorScripted.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include <unordered_map>
+
+using namespace lldb;
+using namespace lldb_private;
+
+LLDB_PLUGIN_DEFINE(SymbolLocatorScripted)
+
+namespace {
+
+#define LLDB_PROPERTIES_symbollocatorscripted
+#include "SymbolLocatorScriptedProperties.inc"
+
+enum {
+#define LLDB_PROPERTIES_symbollocatorscripted
+#include "SymbolLocatorScriptedPropertiesEnum.inc"
+};
+
+class PluginProperties : public Properties {
+public:
+ static llvm::StringRef GetSettingName() {
+ return SymbolLocatorScripted::GetPluginNameStatic();
+ }
+
+ PluginProperties() {
+ m_collection_sp =
std::make_shared<OptionValueProperties>(GetSettingName());
+ m_collection_sp->Initialize(g_symbollocatorscripted_properties_def);
+
+ m_collection_sp->SetValueChangedCallback(
+ ePropertyScriptClass, [this] { ScriptClassChangedCallback(); });
+ }
+
+ llvm::StringRef GetScriptClassName() const {
+ const OptionValueString *s =
+ m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ ePropertyScriptClass);
+ if (s)
+ return s->GetCurrentValueAsRef();
+ return {};
+ }
----------------
rchamala wrote:
Done. Replaced the global setting with per-target registration:
- `target symbols scripted register -C <class> [-k key -v
value ...]`
- `target symbols scripted clear`
- `target symbols scripted info`
- `SBTarget::RegisterScriptedSymbolLocator()` /
`SBTarget::ClearScriptedSymbolLocator()`
For the static callbacks (which have no target context), the plugin iterates
all debuggers/targets to find registered locators. For `LocateSourceFile`, it
uses the `ModuleSP` to identify the owning target via
`target->GetImages().FindModule()`. For the other callbacks, it tries all
targets that have a locator registered.
@jimingham's point about keeping a list of targets per module is a good one —
that would make the dispatch more precise. Happy to tackle that as a follow-up.
https://github.com/llvm/llvm-project/pull/181334
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits