[Lldb-commits] [lldb] [lldb] Add `scripting extension instances` command (PR #226043)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 25 11:59:18 PDT 2026


================
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "lldb/Interpreter/ScriptedInstanceRegistry.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/Stream.h"
+
+#include "llvm/ADT/StringMap.h"
+
+#include <tuple>
+
+using namespace lldb;
+using namespace lldb_private;
+
+static bool HasArgs(const ScriptedInstanceInfo &info) {
+  return info.args_sp && info.args_sp->GetSize();
+}
+
+std::vector<ScriptedInstanceGroup> ScriptedInstanceRegistry::GetInstanceGroups(
+    llvm::ArrayRef<ScriptedExtension> extensions) const {
+  // Unknown names map to eScriptedExtensionInvalid, the zero value.
+  llvm::StringMap<ScriptedExtension> extension_by_plugin;
+  for (uint32_t i = 0; i < PluginManager::GetNumScriptedInterfaces(); i++)
+    extension_by_plugin[PluginManager::GetScriptedInterfaceNameAtIndex(i)] =
+        PluginManager::GetScriptedInterfaceExtensionAtIndex(i);
+
+  std::vector<ScriptedInstanceGroup> groups;
+  for (ScriptedInstanceInfo &info : GetInstances()) {
----------------
JDevlieghere wrote:

`GetInstances` is already doing an iteration, copy, sort and now this function is pretty much doing all that again. Seems like you either need a raw accessor to share getting a copy that defers the sorting and then have both implementation call that, or simply not reimplement one in terms of the other.

https://github.com/llvm/llvm-project/pull/226043


More information about the lldb-commits mailing list