[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread Pavel Labath via lldb-commits

https://github.com/labath edited 
https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

Looks good. Just a couple of tweaks.

https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread Pavel Labath via lldb-commits


@@ -57,3 +57,50 @@ def test_platform_process_connect(self):
 self.assertEqual(frame.GetFunction().GetName(), "main")
 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
 process.Continue()
+
+@skipIfRemote
+@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
+@skipIfDarwin  # lldb-server not found correctly
+@expectedFailureAll(oslist=["windows"])  # process modules not loaded
+# lldb-server platform times out waiting for the gdbserver port number to 
be
+# written to the pipe, yet it seems the gdbserver already has written it.
+@expectedFailureAll(
+archs=["aarch64"],
+oslist=["freebsd"],
+bugnumber="https://github.com/llvm/llvm-project/issues/84327";,
+)
+@add_test_categories(["lldb-server"])
+def test_platform_process_connect_with_unix_connect(self):
+self.build()
+import time
+
+timestamp = int(time.time())
+listen_url = "/tmp/listen_url_%s" % timestamp
+port_file = "/tmp/port_file_%s" % timestamp

labath wrote:

Putting files into /tmp like this is fairly rude. For the port file, you can 
just use the build directory (like the other test). Named pipes are somewhat 
tricky as they have a fairly short limit on the length. I might use 
`SBHostOS.GetLLDBPath(ePathTypeLLDBTempSystemDir)` for that as it's likely to 
be shorter than the build dir.

https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

I resolved all the comments that are done, I have a few left open that need 
addressing.

Then decide with @bulbazord what you do or don't do with the finer details. 
Everything else is looking good.

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The failure is unrelated, ignore it.

https://github.com/llvm/llvm-project/pull/142586
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb][llvm][AIX] Added support for getProcFile with TID (PR #142586)

2025-06-05 Thread Hemang Gadhavi via lldb-commits

HemangGadhavi wrote:

> The failure is unrelated, ignore it.

Thanks @DavidSpickett 

https://github.com/llvm/llvm-project/pull/142586
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/142932
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC]Add missing getKind/classof methods for ClientInfo (PR #142984)

2025-06-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/142984.diff


1 Files Affected:

- (modified) lldb/include/lldb/Core/Telemetry.h (+11) 


``diff
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 5be68de6fcd7f..1db69723b4706 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -102,6 +102,17 @@ struct ClientInfo : public LLDBBaseTelemetryInfo {
   std::string client_data;
   std::optional error_msg;
 
+  // For dyn_cast, isa, etc operations.
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::ClientInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LLDBEntryKind::ClientInfo) ==
+   LLDBEntryKind::ClientInfo;
+  }
+
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 

``




https://github.com/llvm/llvm-project/pull/142984
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

ashgti wrote:

I see some of this has been reverted.

Should I undo the revert and add that to my other PR or should I rebase my 
changes on HEAD and we can take another stab at updating the stepInTargets 
request?

https://github.com/llvm/llvm-project/pull/142831
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

I think the latter is better.

That way we don't have to revert both of them

https://github.com/llvm/llvm-project/pull/142831
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread David Peixotto via lldb-commits


@@ -46,12 +48,255 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  if (PluginManager::MatchPluginName(pattern, plugin_namespace,
+ plugin_info))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+
+static std::string ConvertJSONToPrettyString(const llvm::json::Value &json) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  os << llvm::formatv("{0:2}", json).str();
+  os.flush();
+  return str;
+}
+
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are used by the plugin list command.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'j':
+  m_json_format = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_json_format = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_json_format = false;
+};
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin list' requires zero or one arguments");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.S

[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142831

>From 0824e3c626ad5e8c2ce37f2fdfcf0c2fa47b7b1d Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Jun 2025 11:03:37 -0700
Subject: [PATCH 1/5] [lldb-dap] Creating a 'capabilities' event helper.

This adds a new 'CapabilitiesEventBody' type for having a well structured type 
for the event and updates the 'stepInTargets' and 'restart' request to 
dynamically set their capabilities.

This also fixes the 'stepInTargets' test on non-x86 platforms.
---
 .../test/tools/lldb-dap/dap_server.py | 25 +++---
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  2 +-
 .../stepInTargets/TestDAP_stepInTargets.py|  2 +
 lldb/tools/lldb-dap/CMakeLists.txt|  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   | 18 
 lldb/tools/lldb-dap/EventHelper.h |  3 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  3 --
 .../Handler/RestartRequestHandler.cpp | 17 ---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  4 +-
 .../lldb-dap/Protocol/ProtocolEvents.cpp  | 21 +
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 46 +++
 11 files changed, 112 insertions(+), 30 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..c3c8dbb12e9d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,10 @@ def as_dict(self):
 return source_dict
 
 
+class NotSupportedError(Exception):
+"""Raised if a feature is not supported due to its capabilities."""
+
+
 class DebugCommunication(object):
 def __init__(
 self,
@@ -153,7 +157,7 @@ def __init__(
 self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
 self.exit_status: Optional[int] = None
-self.initialize_body = None
+self.capabilities: dict[str, Any] = {}
 self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
@@ -300,6 +304,9 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 elif event == "breakpoint":
 # Breakpoint events are sent when a breakpoint is resolved
 self._update_verified_breakpoints([body["breakpoint"]])
+elif event == "capabilities":
+# Update the capabilities with new ones from the event.
+self.capabilities.update(body["capabilities"])
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
@@ -488,13 +495,11 @@ def wait_for_terminated(self, timeout: Optional[float] = 
None):
 raise ValueError("didn't get terminated event")
 return event_dict
 
-def get_initialize_value(self, key):
+def get_capability(self, key, default=None):
 """Get a value for the given key if it there is a key/value pair in
-the "initialize" request response body.
+the capabilities reported by the adapter.
 """
-if self.initialize_body and key in self.initialize_body:
-return self.initialize_body[key]
-return None
+return self.capabilities.get(key, default)
 
 def get_threads(self):
 if self.threads is None:
@@ -760,6 +765,10 @@ def request_continue(self, threadId=None, 
singleThread=False):
 return response
 
 def request_restart(self, restartArguments=None):
+if self.exit_status is not None:
+raise ValueError("request_restart called after process exited")
+if not self.get_capability("supportsRestartRequest", False):
+raise NotSupportedError("supportsRestartRequest is not set")
 command_dict = {
 "command": "restart",
 "type": "request",
@@ -867,7 +876,7 @@ def request_initialize(self, sourceInitFile=False):
 response = self.send_recv(command_dict)
 if response:
 if "body" in response:
-self.initialize_body = response["body"]
+self.capabilities = response["body"]
 return response
 
 def request_launch(
@@ -972,6 +981,8 @@ def request_stepIn(self, threadId, targetId, 
granularity="statement"):
 def request_stepInTargets(self, frameId):
 if self.exit_status is not None:
 raise ValueError("request_stepInTargets called after process 
exited")
+if not self.get_capability("supportsStepInTargetsRequest", False):
+raise NotSupportedError("supportsStepInTargetsRequest is not set")
 args_dict = {"frameId": frameId}
 command_dict = {
 "com

[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142831

>From 0824e3c626ad5e8c2ce37f2fdfcf0c2fa47b7b1d Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Jun 2025 11:03:37 -0700
Subject: [PATCH 1/6] [lldb-dap] Creating a 'capabilities' event helper.

This adds a new 'CapabilitiesEventBody' type for having a well structured type 
for the event and updates the 'stepInTargets' and 'restart' request to 
dynamically set their capabilities.

This also fixes the 'stepInTargets' test on non-x86 platforms.
---
 .../test/tools/lldb-dap/dap_server.py | 25 +++---
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  2 +-
 .../stepInTargets/TestDAP_stepInTargets.py|  2 +
 lldb/tools/lldb-dap/CMakeLists.txt|  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   | 18 
 lldb/tools/lldb-dap/EventHelper.h |  3 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  3 --
 .../Handler/RestartRequestHandler.cpp | 17 ---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  4 +-
 .../lldb-dap/Protocol/ProtocolEvents.cpp  | 21 +
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 46 +++
 11 files changed, 112 insertions(+), 30 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..c3c8dbb12e9d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,10 @@ def as_dict(self):
 return source_dict
 
 
+class NotSupportedError(Exception):
+"""Raised if a feature is not supported due to its capabilities."""
+
+
 class DebugCommunication(object):
 def __init__(
 self,
@@ -153,7 +157,7 @@ def __init__(
 self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
 self.exit_status: Optional[int] = None
-self.initialize_body = None
+self.capabilities: dict[str, Any] = {}
 self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
@@ -300,6 +304,9 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 elif event == "breakpoint":
 # Breakpoint events are sent when a breakpoint is resolved
 self._update_verified_breakpoints([body["breakpoint"]])
+elif event == "capabilities":
+# Update the capabilities with new ones from the event.
+self.capabilities.update(body["capabilities"])
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
@@ -488,13 +495,11 @@ def wait_for_terminated(self, timeout: Optional[float] = 
None):
 raise ValueError("didn't get terminated event")
 return event_dict
 
-def get_initialize_value(self, key):
+def get_capability(self, key, default=None):
 """Get a value for the given key if it there is a key/value pair in
-the "initialize" request response body.
+the capabilities reported by the adapter.
 """
-if self.initialize_body and key in self.initialize_body:
-return self.initialize_body[key]
-return None
+return self.capabilities.get(key, default)
 
 def get_threads(self):
 if self.threads is None:
@@ -760,6 +765,10 @@ def request_continue(self, threadId=None, 
singleThread=False):
 return response
 
 def request_restart(self, restartArguments=None):
+if self.exit_status is not None:
+raise ValueError("request_restart called after process exited")
+if not self.get_capability("supportsRestartRequest", False):
+raise NotSupportedError("supportsRestartRequest is not set")
 command_dict = {
 "command": "restart",
 "type": "request",
@@ -867,7 +876,7 @@ def request_initialize(self, sourceInitFile=False):
 response = self.send_recv(command_dict)
 if response:
 if "body" in response:
-self.initialize_body = response["body"]
+self.capabilities = response["body"]
 return response
 
 def request_launch(
@@ -972,6 +981,8 @@ def request_stepIn(self, threadId, targetId, 
granularity="statement"):
 def request_stepInTargets(self, frameId):
 if self.exit_status is not None:
 raise ValueError("request_stepInTargets called after process 
exited")
+if not self.get_capability("supportsStepInTargetsRequest", False):
+raise NotSupportedError("supportsStepInTargetsRequest is not set")
 args_dict = {"frameId": frameId}
 command_dict = {
 "com

[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

ashgti wrote:

Done, rebased on main.

https://github.com/llvm/llvm-project/pull/142831
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Show more children of top level values (PR #140938)

2025-06-05 Thread Dave Lee via lldb-commits

kastiglione wrote:

@jimingham is the updated description for `max-children-count` sufficient?

https://github.com/llvm/llvm-project/pull/140938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142831

>From 0824e3c626ad5e8c2ce37f2fdfcf0c2fa47b7b1d Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Jun 2025 11:03:37 -0700
Subject: [PATCH 1/4] [lldb-dap] Creating a 'capabilities' event helper.

This adds a new 'CapabilitiesEventBody' type for having a well structured type 
for the event and updates the 'stepInTargets' and 'restart' request to 
dynamically set their capabilities.

This also fixes the 'stepInTargets' test on non-x86 platforms.
---
 .../test/tools/lldb-dap/dap_server.py | 25 +++---
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  2 +-
 .../stepInTargets/TestDAP_stepInTargets.py|  2 +
 lldb/tools/lldb-dap/CMakeLists.txt|  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   | 18 
 lldb/tools/lldb-dap/EventHelper.h |  3 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  3 --
 .../Handler/RestartRequestHandler.cpp | 17 ---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  4 +-
 .../lldb-dap/Protocol/ProtocolEvents.cpp  | 21 +
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 46 +++
 11 files changed, 112 insertions(+), 30 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..c3c8dbb12e9d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,10 @@ def as_dict(self):
 return source_dict
 
 
+class NotSupportedError(Exception):
+"""Raised if a feature is not supported due to its capabilities."""
+
+
 class DebugCommunication(object):
 def __init__(
 self,
@@ -153,7 +157,7 @@ def __init__(
 self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
 self.exit_status: Optional[int] = None
-self.initialize_body = None
+self.capabilities: dict[str, Any] = {}
 self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
@@ -300,6 +304,9 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 elif event == "breakpoint":
 # Breakpoint events are sent when a breakpoint is resolved
 self._update_verified_breakpoints([body["breakpoint"]])
+elif event == "capabilities":
+# Update the capabilities with new ones from the event.
+self.capabilities.update(body["capabilities"])
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
@@ -488,13 +495,11 @@ def wait_for_terminated(self, timeout: Optional[float] = 
None):
 raise ValueError("didn't get terminated event")
 return event_dict
 
-def get_initialize_value(self, key):
+def get_capability(self, key, default=None):
 """Get a value for the given key if it there is a key/value pair in
-the "initialize" request response body.
+the capabilities reported by the adapter.
 """
-if self.initialize_body and key in self.initialize_body:
-return self.initialize_body[key]
-return None
+return self.capabilities.get(key, default)
 
 def get_threads(self):
 if self.threads is None:
@@ -760,6 +765,10 @@ def request_continue(self, threadId=None, 
singleThread=False):
 return response
 
 def request_restart(self, restartArguments=None):
+if self.exit_status is not None:
+raise ValueError("request_restart called after process exited")
+if not self.get_capability("supportsRestartRequest", False):
+raise NotSupportedError("supportsRestartRequest is not set")
 command_dict = {
 "command": "restart",
 "type": "request",
@@ -867,7 +876,7 @@ def request_initialize(self, sourceInitFile=False):
 response = self.send_recv(command_dict)
 if response:
 if "body" in response:
-self.initialize_body = response["body"]
+self.capabilities = response["body"]
 return response
 
 def request_launch(
@@ -972,6 +981,8 @@ def request_stepIn(self, threadId, targetId, 
granularity="statement"):
 def request_stepInTargets(self, frameId):
 if self.exit_status is not None:
 raise ValueError("request_stepInTargets called after process 
exited")
+if not self.get_capability("supportsStepInTargetsRequest", False):
+raise NotSupportedError("supportsStepInTargetsRequest is not set")
 args_dict = {"frameId": frameId}
 command_dict = {
 "com

[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142510

>From 3a16210ba7643608dd0bd6a1ff4a76b4e72c74e3 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Jun 2025 18:07:52 -0700
Subject: [PATCH 1/6] [lldb-dap] Migrating 'threads' request to structured
 types.

Moving `threads` request to structured types. Adding helper types for this and 
moving helpers from JSONUtils to ProtocolUtils.
---
 .../test/tools/lldb-dap/dap_server.py |   4 +-
 .../tools/lldb-dap/threads/TestDAP_threads.py |   2 +-
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/EventHelper.cpp   | 128 +-
 lldb/tools/lldb-dap/EventHelper.h |   2 +-
 .../ConfigurationDoneRequestHandler.cpp   |   3 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../Handler/RestartRequestHandler.cpp |   2 +-
 .../Handler/ThreadsRequestHandler.cpp |  75 --
 lldb/tools/lldb-dap/JSONUtils.cpp |  64 -
 lldb/tools/lldb-dap/JSONUtils.h   |  24 
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 119 +++-
 .../lldb-dap/Protocol/ProtocolRequests.h  |  10 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |   9 ++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  10 ++
 lldb/tools/lldb-dap/ProtocolUtils.cpp |  50 +++
 lldb/tools/lldb-dap/ProtocolUtils.h   |  26 
 17 files changed, 257 insertions(+), 282 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index f1e3cab06ccde..1ae1ec09ae3b6 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -311,7 +311,6 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 return keepGoing
 
 def _process_continued(self, all_threads_continued: bool):
-self.threads = None
 self.frame_scopes = {}
 if all_threads_continued:
 self.thread_stop_reasons = {}
@@ -1183,6 +1182,9 @@ def request_threads(self):
 with information about all threads"""
 command_dict = {"command": "threads", "type": "request", "arguments": 
{}}
 response = self.send_recv(command_dict)
+if not response["success"]:
+self.threads = None
+return response
 body = response["body"]
 # Fill in "self.threads" correctly so that clients that call
 # self.get_threads() or self.get_thread_id(...) can get information
diff --git a/lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py 
b/lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
index acd6108853787..15bae3cc83daf 100644
--- a/lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
+++ b/lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
@@ -33,7 +33,7 @@ def test_correct_thread(self):
 self.dap_server.request_continue()
 stopped_event = self.dap_server.wait_for_stopped()
 # Verify that the description is the relevant breakpoint,
-# preserveFocusHint is False and threadCausedFocus is True
+# preserveFocusHint is False.
 self.assertTrue(
 stopped_event[0]["body"]["description"].startswith(
 "breakpoint %s." % breakpoint_ids[0]
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 1bd94fab402ca..0bde0ba0c9830 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -152,7 +152,7 @@ struct DAP {
   llvm::DenseSet clientFeatures;
 
   /// The initial thread list upon attaching.
-  std::optional initial_thread_list;
+  std::optional> initial_thread_list;
 
   /// Keep track of all the modules our client knows about: either through the
   /// modules request or the module events.
diff --git a/lldb/tools/lldb-dap/EventHelper.cpp 
b/lldb/tools/lldb-dap/EventHelper.cpp
index 33bc7c2cbef11..cffe15bd2e4eb 100644
--- a/lldb/tools/lldb-dap/EventHelper.cpp
+++ b/lldb/tools/lldb-dap/EventHelper.cpp
@@ -134,77 +134,79 @@ void SendProcessEvent(DAP &dap, LaunchMethod 
launch_method) {
 
 // Send a thread stopped event for all threads as long as the process
 // is stopped.
-void SendThreadStoppedEvent(DAP &dap) {
+void SendThreadStoppedEvent(DAP &dap, bool on_entry) {
   lldb::SBProcess process = dap.target.GetProcess();
-  if (process.IsValid()) {
-auto state = process.GetState();
-if (state == lldb::eStateStopped) {
-  llvm::DenseSet old_thread_ids;
-  old_thread_ids.swap(dap.thread_ids);
-  uint32_t stop_id = process.GetStopID();
-  const uint32_t num_threads = process.GetNumThreads();
+  if (!process.IsValid()) {
+DAP_LOG(dap.log, "error: SendThreadStoppedEvent() invalid process");
+return;
+  }
 
-  // First make a pass through the threads to see if the focused thread
-  // has a stop reason. In case the focus 

[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett approved this pull request.

LGTM with the UNSUPPORTED changed to apply to any system.

https://github.com/llvm/llvm-project/pull/138032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,15 @@
+# Disabling until the lldb-rpc-gen tool lands.
+UNSUPPORTED: system-windows, system-linux, system-darwin

DavidSpickett wrote:

Do that for the rest of the tests as well.

https://github.com/llvm/llvm-project/pull/138032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,15 @@
+# Disabling until the lldb-rpc-gen tool lands.
+UNSUPPORTED: system-windows, system-linux, system-darwin

DavidSpickett wrote:

`UNSUPPORTED: *` should disable it everywhere.

Saves someone on FreeBSD getting an unpleasant surprise.

https://github.com/llvm/llvm-project/pull/138032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/138032
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,504 @@
+//===-- RPCCommon.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 "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication", // This class is pretty much unused by consumers, so we
+   // skip it.
+"SBInputReader",   // This class is pretty much unused by consumers, so we
+   // skip it.
+"SBCommandPluginInterface", // This class uses virtual functions, and the 
SB
+// API should not have those, so we skip this
+// class.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// NOTE: In lldb-rpc-gen, we use mangled names when we need to work with
+// functions. We do this because we support many functions that have overloads,
+// and mangled names have no ambiguity which makes it easier to keep track of.
+// This is also possible since the LLDB SB API is stable.
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// NOTE: These methods are marked as deprecated using LLDB_DEPRECATED.
+// Normally this macro defines to the deprecated annotation, but this
+// functionality is removed in SBDefines.h when generating SWIG bindings which
+// we use for testing. Because of this, there is no annotation for the tool to
+// pick up on so this list will be used while we have this restriction in
+// SBDefines.h.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
+"_ZN4lldb6SBData11ReadRawDataERNS_7SBErrorEyPvm",
+"_ZN4lldb6SBData7SetDataERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData20SetDataWithOwnershipERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData25CreateDataFromUInt64ArrayENS_9ByteOrderEjPym",
+"_ZN4lldb6SBData25CreateDataFromUInt32ArrayENS_9ByteOrderEjPjm",
+"_ZN4lldb6SBData25CreateDataFromSInt64ArrayENS_9ByteOrderEjPxm",
+"_ZN4lldb6SBData25CreateDataFromSInt32ArrayENS_9ByteOrderEjPim",
+"_ZN4lldb6SBData25CreateDataFromDoubleArrayENS_9ByteOrderEjPdm",
+"_ZN4lldb6SBData22SetDataFromUInt64ArrayEPym",
+"_ZN4lldb6SBData22SetDataFromUInt32ArrayEPjm",
+"_ZN4lldb6SBData22SetDataFromSInt64ArrayEPxm",
+"_ZN4lldb6SBData22SetDataFromSInt32ArrayEPim",
+"_ZN4lldb6SBData22SetDataFromDoubleArrayEPdm",
+"_ZN4lldb10SBDebugger22GetDefaultArchitectureEPcm",
+"_ZN4lldb10SBDebugger13DispatchInputEPvPKvm",
+"_ZN4lldb10SBDebugger13DispatchInputEPKvm",
+"_ZN4lldb6SBFile4ReadEPhmPm",
+"_ZN4lldb6SBFile5WriteEPKhmPm",
+"_ZNK4lldb10SBFileSpec7GetPathEPcm",
+"_ZN4lldb10SBFileSpec11ResolvePathEPKcPcm",
+"_ZN4lldb8SBModule10GetVersionEPjj",
+"_ZN4lldb12SBModuleSpec12SetUUIDBytesEPKhm",
+"_ZNK4lldb9SBProcess9Get

[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,504 @@
+//===-- RPCCommon.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 "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication", // This class is pretty much unused by consumers, so we
+   // skip it.
+"SBInputReader",   // This class is pretty much unused by consumers, so we
+   // skip it.
+"SBCommandPluginInterface", // This class uses virtual functions, and the 
SB
+// API should not have those, so we skip this
+// class.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// NOTE: In lldb-rpc-gen, we use mangled names when we need to work with
+// functions. We do this because we support many functions that have overloads,
+// and mangled names have no ambiguity which makes it easier to keep track of.
+// This is also possible since the LLDB SB API is stable.
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// NOTE: These methods are marked as deprecated using LLDB_DEPRECATED.
+// Normally this macro defines to the deprecated annotation, but this
+// functionality is removed in SBDefines.h when generating SWIG bindings which
+// we use for testing. Because of this, there is no annotation for the tool to
+// pick up on so this list will be used while we have this restriction in
+// SBDefines.h.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
+"_ZN4lldb6SBData11ReadRawDataERNS_7SBErrorEyPvm",
+"_ZN4lldb6SBData7SetDataERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData20SetDataWithOwnershipERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData25CreateDataFromUInt64ArrayENS_9ByteOrderEjPym",
+"_ZN4lldb6SBData25CreateDataFromUInt32ArrayENS_9ByteOrderEjPjm",
+"_ZN4lldb6SBData25CreateDataFromSInt64ArrayENS_9ByteOrderEjPxm",
+"_ZN4lldb6SBData25CreateDataFromSInt32ArrayENS_9ByteOrderEjPim",
+"_ZN4lldb6SBData25CreateDataFromDoubleArrayENS_9ByteOrderEjPdm",
+"_ZN4lldb6SBData22SetDataFromUInt64ArrayEPym",
+"_ZN4lldb6SBData22SetDataFromUInt32ArrayEPjm",
+"_ZN4lldb6SBData22SetDataFromSInt64ArrayEPxm",
+"_ZN4lldb6SBData22SetDataFromSInt32ArrayEPim",
+"_ZN4lldb6SBData22SetDataFromDoubleArrayEPdm",
+"_ZN4lldb10SBDebugger22GetDefaultArchitectureEPcm",
+"_ZN4lldb10SBDebugger13DispatchInputEPvPKvm",
+"_ZN4lldb10SBDebugger13DispatchInputEPKvm",
+"_ZN4lldb6SBFile4ReadEPhmPm",
+"_ZN4lldb6SBFile5WriteEPKhmPm",
+"_ZNK4lldb10SBFileSpec7GetPathEPcm",
+"_ZN4lldb10SBFileSpec11ResolvePathEPKcPcm",
+"_ZN4lldb8SBModule10GetVersionEPjj",
+"_ZN4lldb12SBModuleSpec12SetUUIDBytesEPKhm",
+"_ZNK4lldb9SBProcess9Get

[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,502 @@
+//===-- RPCCommon.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 "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// NOTE: These methods are marked as deprecated using LLDB_DEPRECATED.
+// Normally this macro defines to the deprecated annotation, but this
+// functionality is removed in SBDefines.h when generating SWIG bindings which
+// we use for testing. Because of this, there is no annotation for the tool to
+// pick up on so this list will be used while we have this restriction in
+// SBDefines.h.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
+"_ZN4lldb6SBData11ReadRawDataERNS_7SBErrorEyPvm",
+"_ZN4lldb6SBData7SetDataERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData20SetDataWithOwnershipERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData25CreateDataFromUInt64ArrayENS_9ByteOrderEjPym",
+"_ZN4lldb6SBData25CreateDataFromUInt32ArrayENS_9ByteOrderEjPjm",
+"_ZN4lldb6SBData25CreateDataFromSInt64ArrayENS_9ByteOrderEjPxm",
+"_ZN4lldb6SBData25CreateDataFromSInt32ArrayENS_9ByteOrderEjPim",
+"_ZN4lldb6SBData25CreateDataFromDoubleArrayENS_9ByteOrderEjPdm",
+"_ZN4lldb6SBData22SetDataFromUInt64ArrayEPym",
+"_ZN4lldb6SBData22SetDataFromUInt32ArrayEPjm",
+"_ZN4lldb6SBData22SetDataFromSInt64ArrayEPxm",
+"_ZN4lldb6SBData22SetDataFromSInt32ArrayEPim",
+"_ZN4lldb6SBData22SetDataFromDoubleArrayEPdm",
+"_ZN4lldb10SBDebugger22GetDefaultArchitectureEPcm",
+"_ZN4lldb10SBDebugger13DispatchInputEPvPKvm",
+"_ZN4lldb10SBDebugger13DispatchInputEPKvm",
+"_ZN4lldb6SBFile4ReadEPhmPm",
+"_ZN4lldb6SBFile5WriteEPKhmPm",
+"_ZNK4lldb10SBFileSpec7GetPathEPcm",
+"_ZN4lldb10SBFileSpec11ResolvePathEPKcPcm",
+"_ZN4lldb8SBModule10GetVersionEPjj",
+"_ZN4lldb12SBModuleSpec12SetUUIDBytesEPKhm",
+"_ZNK4lldb9SBProcess9GetSTDOUTEPcm",
+"_ZNK4lldb9SBProcess9GetSTDERREPcm",
+"_ZNK4lldb9SBProcess19GetAsyncProfileDataEPcm",
+"_ZN4lldb9SBProcess10ReadMemoryEyPvmRNS_7SBErrorE",
+"_ZN4lldb9SBProcess11WriteMemoryEyPKvmRNS_7SBErrorE",
+"_ZN4lldb9SBProcess21ReadCStringFromMemoryEyPvmRNS_7SBErrorE",
+"_ZNK4lldb16SBStructuredData14GetStringValueEPcm",
+"_ZN4lldb8SBTarget23BreakpointCreateByNamesEPPKcjjRKNS_"
+"14SBFileSpecListES6_",
+"_ZN4lldb8SBTarget10ReadMemoryENS_9S

[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-05 Thread David Spickett via lldb-commits


@@ -0,0 +1,107 @@
+//===-- RPCCommon.h 
---===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_RPC_GEN_RPCCOMMON_H
+#define LLDB_RPC_GEN_RPCCOMMON_H
+
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include 
+
+using namespace clang;
+
+namespace lldb_rpc_gen {
+QualType GetUnderlyingType(QualType T);
+QualType GetUnqualifiedUnderlyingType(QualType T);
+std::string GetMangledName(ASTContext &Context, CXXMethodDecl *MDecl);
+
+bool TypeIsFromLLDBPrivate(QualType T);
+bool TypeIsSBClass(QualType T);
+bool TypeIsConstCharPtr(QualType T);
+bool TypeIsConstCharPtrPtr(QualType T);
+bool TypeIsDisallowedClass(QualType T);
+bool TypeIsCallbackFunctionPointer(QualType T);
+
+bool MethodIsDisallowed(ASTContext &Context, CXXMethodDecl *MDecl);
+bool HasCallbackParameter(CXXMethodDecl *MDecl);
+
+std::string ReplaceLLDBNamespaceWithRPCNamespace(std::string Name);
+std::string StripLLDBNamespace(std::string Name);
+bool SBClassRequiresDefaultCtor(const std::string &ClassName);
+bool SBClassRequiresCopyCtorAssign(const std::string &ClassName);
+bool SBClassInheritsFromObjectRef(const std::string &ClassName);
+std::string GetSBClassNameFromType(QualType T);
+struct Param {
+  std::string Name;
+  QualType Type;
+  std::string DefaultValueText;
+  bool IsFollowedByLen;
+};
+
+enum GenerationKind : bool { eServer, eLibrary };
+
+struct Method {
+  enum Type { eOther, eConstructor, eDestructor };
+
+  Method(CXXMethodDecl *MDecl, const PrintingPolicy &Policy,
+ ASTContext &Context);
+
+  // Adding a '<' allows us to use Methods in ordered containers.
+  bool operator<(const lldb_rpc_gen::Method &rhs) const;
+  const PrintingPolicy &Policy;
+  const ASTContext &Context;
+  std::string QualifiedName;
+  std::string BaseName;
+  std::string MangledName;
+  QualType ReturnType;
+  QualType ThisType;
+  std::vector Params;
+  bool IsConst = false;
+  bool IsInstance = false;
+  bool IsCtor = false;
+  bool IsCopyCtor = false;
+  bool IsCopyAssign = false;
+  bool IsMoveCtor = false;
+  bool IsMoveAssign = false;
+  bool IsDtor = false;
+  bool IsConversionMethod = false;
+  bool IsExplicitCtorOrConversionMethod = false;
+  bool ContainsFunctionPointerParameter = false;
+
+  std::string CreateParamListAsString(GenerationKind Generation,
+  bool IncludeDefaultValue = false) const;
+
+  bool RequiresConnectionParameter() const;
+};
+
+std::string
+GetDefaultArgumentsForConstructor(std::string ClassName,
+  const lldb_rpc_gen::Method &method);
+
+class FileEmitter {
+protected:
+  FileEmitter(std::unique_ptr &&OutputFile)

DavidSpickett wrote:

Understood

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ayush Sahay (ayushsahay1837)


Changes

The standard RISC-V ISA sets aside a 12-bit encoding space for up to 4,096 
CSRs. However, many of these may remain unutilized and needn't be saved in core 
dump images. To address this, we've come up with a new note, _NT_CSREGMAP_, 
that saves subsets of CSRs as key-value pairs. This change provisions support 
for handling the subsets of CSRs saved in 32-bit RISC-V core dump images by 
building the register information for GPRs, FPRs, and CSRs dynamically.

Kindly refer to the corresponding topic ([Add RISC-V CSRs to core 
dumps](https://discourse.llvm.org/t/add-risc-v-csrs-to-core-dumps/84348)) for 
additional details.

---

Patch is 411.90 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/142932.diff


12 Files Affected:

- (modified) lldb/include/lldb/Target/DynamicRegisterInfo.h (+8) 
- (modified) lldb/source/Plugins/Process/Utility/CMakeLists.txt (+1) 
- (added) 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIXDynamic_riscv32.cpp (+87) 
- (added) 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIXDynamic_riscv32.h (+50) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv32.cpp 
(+3) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfos_riscv32.h 
(+4230-20) 
- (modified) lldb/source/Plugins/Process/Utility/lldb-riscv-register-enums.h 
(+4473) 
- (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+7-3) 
- (modified) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv32.cpp 
(+328-31) 
- (modified) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv32.h 
(+28-11) 
- (modified) lldb/source/Plugins/Process/elf-core/RegisterUtilities.h (+12) 
- (modified) lldb/source/Utility/RISCV_DWARF_Registers.h (+4489-13) 


``diff
diff --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index 43bba5038e537..558adefe2e151 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -95,6 +95,8 @@ class DynamicRegisterInfo {
 
   template  T registers() = delete;
 
+  template  T registers() const = delete;
+
   void ConfigureOffsets();
 
 protected:
@@ -145,6 +147,12 @@ DynamicRegisterInfo::registers() {
   return reg_collection_range(m_regs);
 }
 
+template <>
+inline DynamicRegisterInfo::reg_collection_const_range
+DynamicRegisterInfo::registers() const {
+  return reg_collection_const_range(m_regs);
+}
+
 void addSupplementaryRegister(std::vector ®s,
   DynamicRegisterInfo::Register new_reg_info);
 
diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt 
b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index fd3019613892a..53313e139c4e7 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -60,6 +60,7 @@ add_lldb_library(lldbPluginProcessUtility
   RegisterInfoPOSIX_ppc64le.cpp
   RegisterInfoPOSIX_riscv32.cpp
   RegisterInfoPOSIX_riscv64.cpp
+  RegisterInfoPOSIXDynamic_riscv32.cpp
   StopInfoMachException.cpp
   ThreadMemory.cpp
 
diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIXDynamic_riscv32.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIXDynamic_riscv32.cpp
new file mode 100644
index 0..950c0c3d3cae8
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIXDynamic_riscv32.cpp
@@ -0,0 +1,87 @@
+//===-- RegisterInfoPOSIXDynamic_riscv32.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 
+#include 
+
+#include "lldb/lldb-defines.h"
+#include "llvm/Support/Compiler.h"
+
+#include "RegisterInfoPOSIXDynamic_riscv32.h"
+
+RegisterInfoPOSIXDynamic_riscv32::RegisterInfoPOSIXDynamic_riscv32(
+const lldb_private::ArchSpec &target_arch)
+: lldb_private::RegisterInfoAndSetInterface(target_arch),
+  m_target_arch(target_arch) {}
+
+uint32_t RegisterInfoPOSIXDynamic_riscv32::GetRegisterCount() const {
+  return m_dyn_reg_infos.GetNumRegisters();
+}
+
+size_t RegisterInfoPOSIXDynamic_riscv32::GetGPRSize() const {
+  for (uint32_t set_idx = 0; set_idx < GetRegisterSetCount(); ++set_idx) {
+const lldb_private::RegisterSet *set =
+m_dyn_reg_infos.GetRegisterSet(set_idx);
+if (lldb_private::ConstString(set->name) == "GPR")
+  return set->num_registers;
+  }
+  return 0;
+}
+
+size_t RegisterInfoPOSIXDynamic_riscv32::GetFPRSize() const {
+  for (uint32_t set_idx = 0; set_idx < GetRegisterSetCount(); ++set_idx) {
+const lldb_private::RegisterSet *set =
+m_dyn_reg_infos.GetRegisterSet(set_idx);
+

[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread David Spickett via lldb-commits


@@ -999,9 +999,13 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   case llvm::Triple::OpenBSD:
 return parseOpenBSDNotes(*notes_or_error);
   default:
-return llvm::make_error(
-"Don't know how to parse core file. Unsupported OS.",
-llvm::inconvertibleErrorCode());
+// Treat bare-metal 32-bit RISC-V like Linux.

DavidSpickett wrote:

I have been wondering if Linux cores work or not. If they do, I would 
appreciate one being added as a test case, in a separate PR. If they don't 
work, you don't have to make them work.

https://github.com/llvm/llvm-project/pull/142932
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

I'll leave the proper review to the RISC-V interested parties, just some high 
level points:
* The csrs that have names, are all the ones here from the RISC-V standard? Do 
they include any names allocated for custom extensions or do you plan to do 
anything like that? (I assume custom extensions can also make use of some csr 
space, but you could just make people type the generic name for these).
* LLDB's design is unfortunately forcing you to enumerate everything up front, 
I doubt there's much we can do about that without refactoring the others. In 
some places you might be able to consteveal something, but it probably works 
out the same if not more in compile time.
* You have this riscv-32-dynamic now, is the existing riscv-32 just the dynamic 
one with no extra registers, can we share the two implementations?
* You're treating bare metal core files as if they are Linux, I would like to 
know if Linux cores themselves work and how far we are from supporting those. 
This will become a popular use case. You can raise an issue with what you find, 
I'm not expecting you to do the work.

https://github.com/llvm/llvm-project/pull/142932
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

@AlexeyMerzlyakov worked on RV64 core file support in the past, might have some 
comments.

https://github.com/llvm/llvm-project/pull/142932
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/142952
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/142952
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make stop-hooks fire when lldb first gains control of a process. (PR #137410)

2025-06-05 Thread via lldb-commits

jimingham wrote:

Two things.  First off, adding the -I 0 option did indeed fix a failure.

In the first run you cited, three tests failed:

FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_auto_continue 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_auto_continue)
FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_right_func 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_func)
FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_wrong_func 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_func)

But then in the second log after you patch only the last two tests failed.  So 
the addition did in fact make the first test pass.  

That makes sense because those other two failing tests don't use the same 
command string as the first one.  They use the command string on line 148 in 
the test. So you also need to add the -I 0 to the command line  in 
`stop_hooks_scripted` in the test file.

But still, those failures are odd.  The only difference between these two 
failing tests and two that pass:

PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_right_lines 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_lines)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_wrong_lines 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_lines)

are that the failing tests pass in a function name filter to determine when the 
stop-hook should fire, and the passing tests pass in a line-range filter.  In 
both failures the stop hook failure symptom is that the stop-hook got to fire 
one more time than expected.  The only change in this patch was adding one more 
place where the stop-hook might fire - "at the entry point", but in the case of 
these tests, that "entry point" firing shouldn't matter because the "entry 
point" stop won't pass the filter.  Somehow, in your case, that's not true.

Given that it did make the first test pass, I'm guessing adding the `-I 0` to 
the other `target stop-hook add` command in the test file will make those tests 
pass as well.

But where was that "entry point" stop happening on your system such that both 
file and line number filters correctly reject it, but it passes BOTH the filter 
on function name `main` AND the filter on function name `step_out_of_me`?




https://github.com/llvm/llvm-project/pull/137410
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

ashgti wrote:

Working on an update rebased on HEAD.

https://github.com/llvm/llvm-project/pull/142831
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/142952

>From 7d2a6406b8069b6c23611860d937db1275fb33ef Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 5 Jun 2025 12:02:17 +0100
Subject: [PATCH] [lldb][Format] Add [inlined] marker to names of inlined
 frames

This was removed in https://github.com/llvm/llvm-project/pull/135343 in
favour of making it a format variable, which we do here. This follows
the precedent of the `[opt]` and `[artificial]` markers.

rdar://152642178
---
 lldb/docs/use/formatting.rst  |  2 ++
 lldb/include/lldb/Core/FormatEntity.h |  1 +
 lldb/source/Core/CoreProperties.td|  4 +--
 lldb/source/Core/FormatEntity.cpp |  6 
 .../Settings/TestFrameFunctionInlined.test| 35 +++
 lldb/unittests/Core/FormatEntityTest.cpp  |  1 +
 6 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 lldb/test/Shell/Settings/TestFrameFunctionInlined.test

diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e71b08780eb3d..21b3ca1912b02 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -122,6 +122,8 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``function.initial-function`` | Will evaluate to true if 
this is the start of the first function, as opposed to a change of functions 
(may be used in ``disassembly-format`` to print the function name for the first 
function being disassembled)
  |
 
+---+-+
+| ``function.is-inlined``   | Will evaluate to true if 
this function was inlined   


   |
++---+-+
 | ``line.file.basename``| The line table entry 
basename to the file for the current line entry in the current frame.   


   |
 
+---+-+
 | ``line.file.fullpath``| The line table entry 
fullpath to the file for the current line entry in the current frame.   


   |
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 18257161eec7b..17fee068230b2 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -104,6 +104,7 @@ struct Entry {
 FunctionInitial,
 FunctionChanged,
 FunctionIsOptimized,
+FunctionIsInlined,
 LineEntryFile,
 LineEntryLineNumber,
 LineEntryColumn,
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 78988ce5b732f..4d1ea5dfec2eb 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.cyan}${frame.pc}${ansi.normal}{ 
${module.file.basena

[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This was removed in https://github.com/llvm/llvm-project/pull/135343 in favour 
of making it a format variable, which we do here. This follows the precedent of 
the `[opt]` and `[artificial]` markers.

rdar://152642178

---
Full diff: https://github.com/llvm/llvm-project/pull/142952.diff


6 Files Affected:

- (modified) lldb/docs/use/formatting.rst (+2) 
- (modified) lldb/include/lldb/Core/FormatEntity.h (+1) 
- (modified) lldb/source/Core/CoreProperties.td (+2-2) 
- (modified) lldb/source/Core/FormatEntity.cpp (+6) 
- (added) lldb/test/Shell/Settings/TestFrameFunctionInlined.test (+35) 
- (modified) lldb/unittests/Core/FormatEntityTest.cpp (+1) 


``diff
diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e71b08780eb3d..21b3ca1912b02 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -122,6 +122,8 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``function.initial-function`` | Will evaluate to true if 
this is the start of the first function, as opposed to a change of functions 
(may be used in ``disassembly-format`` to print the function name for the first 
function being disassembled)
  |
 
+---+-+
+| ``function.is-inlined``   | Will evaluate to true if 
this function was inlined   


   |
++---+-+
 | ``line.file.basename``| The line table entry 
basename to the file for the current line entry in the current frame.   


   |
 
+---+-+
 | ``line.file.fullpath``| The line table entry 
fullpath to the file for the current line entry in the current frame.   


   |
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 18257161eec7b..17fee068230b2 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -104,6 +104,7 @@ struct Entry {
 FunctionInitial,
 FunctionChanged,
 FunctionIsOptimized,
+FunctionIsInlined,
 LineEntryFile,
 LineEntryLineNumber,
 LineEntryColumn,
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 78988ce5b732f..4d1ea5dfec2eb 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.cyan}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${func

[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/142952

This was removed in https://github.com/llvm/llvm-project/pull/135343 in favour 
of making it a format variable, which we do here. This follows the precedent of 
the `[opt]` and `[artificial]` markers.

rdar://152642178

>From 3de64abff2cc702d43a5436990e804111f513414 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 5 Jun 2025 12:02:17 +0100
Subject: [PATCH] [lldb][Format] Add [inlined] marker to names of inlined
 frames

This was removed in https://github.com/llvm/llvm-project/pull/135343 in
favour of making it a format variable, which we do here. This follows
the precedent of the `[opt]` and `[artificial]` markers.

rdar://152642178
---
 lldb/docs/use/formatting.rst | 2 ++
 lldb/include/lldb/Core/FormatEntity.h| 1 +
 lldb/source/Core/CoreProperties.td   | 4 ++--
 lldb/source/Core/FormatEntity.cpp| 6 ++
 lldb/unittests/Core/FormatEntityTest.cpp | 1 +
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e71b08780eb3d..21b3ca1912b02 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -122,6 +122,8 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``function.initial-function`` | Will evaluate to true if 
this is the start of the first function, as opposed to a change of functions 
(may be used in ``disassembly-format`` to print the function name for the first 
function being disassembled)
  |
 
+---+-+
+| ``function.is-inlined``   | Will evaluate to true if 
this function was inlined   


   |
++---+-+
 | ``line.file.basename``| The line table entry 
basename to the file for the current line entry in the current frame.   


   |
 
+---+-+
 | ``line.file.fullpath``| The line table entry 
fullpath to the file for the current line entry in the current frame.   


   |
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 18257161eec7b..17fee068230b2 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -104,6 +104,7 @@ struct Entry {
 FunctionInitial,
 FunctionChanged,
 FunctionIsOptimized,
+FunctionIsInlined,
 LineEntryFile,
 LineEntryLineNumber,
 LineEntryColumn,
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 78988ce5b732f..95259abfe8bd4 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.cyan}${

[Lldb-commits] [lldb] [lldb][RISCV] Handle subsets of CSRs in RV32 core dump images (PR #142932)

2025-06-05 Thread via lldb-commits

tedwoodward wrote:

> I'll leave the proper review to the RISC-V interested parties, just some high 
> level points:
> 
> * The csrs that have names, are all the ones here from the RISC-V 
> standard? Do they include any names allocated for custom extensions or do you 
> plan to do anything like that? (I assume custom extensions can also make use 
> of some csr space, but you could just make people type the generic name for 
> these).
> 
> * LLDB's design is unfortunately forcing you to enumerate everything up 
> front, I doubt there's much we can do about that without refactoring the 
> others. In some places you might be able to consteveal something, but it 
> probably works out the same if not more in compile time.
> 
> * You have this riscv-32-dynamic now, is the existing riscv-32 just the 
> dynamic one with no extra registers, can we share the two implementations?
> 
> * You're treating bare metal core files as if they are Linux, I would 
> like to know if Linux cores themselves work and how far we are from 
> supporting those. This will become a popular use case. You can raise an issue 
> with what you find, I'm not expecting you to do the work.

Our intention is to provide support in this PR for all the standard CSRs, and 
in a later PR for the CSRs in the Xqci extension, and use that as an example 
for others to implement their own extensions. These should be gated by some 
discovery mechanism, like ELF attributes, since we don't want to collide if 2 
extensions use, say, CSR 50.

The existing riscv-32 is static. I think we'll need to replace that (and the 64 
bit static implementation, to add CSR support) with dynamic. Downstream we have 
only dynamic in our 20.0 release.

We don't have a running Linux, so I can't comment on "real" Linux core files. 
In theory, they're the same, but you know about theory vs practice...

> Also, test cases?
> 
> I already let one RISC-V core file patch go in without test cases, I'm not 
> happy about another.
> 
> If you want to know how to make them, some way that documents the format of 
> the note at the same time would be great. If you were able to yaml2obj 
> perhaps.
> 
> (because otherwise the C++ code is the only documentation)
> 
> Maybe Python could be used to generate YAML of various sparse or not sparse 
> notes and substitute those into a template for testing.

I'm currently negotiating with our users on this. Like @JDevlieghere , I can't 
publish a core dump with internal code in it. But if I can learn how to dump 
core with an arbitrary testcase, then I can make a core file to load and test. 
We'll see.

> Also we need a comment somewhere, I suggest in this PR's description for now, 
> that describes the note's format in detail. It will also help review.
> 
> (as there's no natural place for it, if the Linux kernel was generating them, 
> it'd go there, but bare metal, could be anyone generating them)

I agree - we should publish a comment with the note's format. I think a comment 
in the sources would be a more natural place to look than the commit message.

https://github.com/llvm/llvm-project/pull/142932
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/142952

>From 7d2a6406b8069b6c23611860d937db1275fb33ef Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 5 Jun 2025 12:02:17 +0100
Subject: [PATCH 1/2] [lldb][Format] Add [inlined] marker to names of inlined
 frames

This was removed in https://github.com/llvm/llvm-project/pull/135343 in
favour of making it a format variable, which we do here. This follows
the precedent of the `[opt]` and `[artificial]` markers.

rdar://152642178
---
 lldb/docs/use/formatting.rst  |  2 ++
 lldb/include/lldb/Core/FormatEntity.h |  1 +
 lldb/source/Core/CoreProperties.td|  4 +--
 lldb/source/Core/FormatEntity.cpp |  6 
 .../Settings/TestFrameFunctionInlined.test| 35 +++
 lldb/unittests/Core/FormatEntityTest.cpp  |  1 +
 6 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 lldb/test/Shell/Settings/TestFrameFunctionInlined.test

diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e71b08780eb3d..21b3ca1912b02 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -122,6 +122,8 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``function.initial-function`` | Will evaluate to true if 
this is the start of the first function, as opposed to a change of functions 
(may be used in ``disassembly-format`` to print the function name for the first 
function being disassembled)
  |
 
+---+-+
+| ``function.is-inlined``   | Will evaluate to true if 
this function was inlined   


   |
++---+-+
 | ``line.file.basename``| The line table entry 
basename to the file for the current line entry in the current frame.   


   |
 
+---+-+
 | ``line.file.fullpath``| The line table entry 
fullpath to the file for the current line entry in the current frame.   


   |
diff --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 18257161eec7b..17fee068230b2 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -104,6 +104,7 @@ struct Entry {
 FunctionInitial,
 FunctionChanged,
 FunctionIsOptimized,
+FunctionIsInlined,
 LineEntryFile,
 LineEntryLineNumber,
 LineEntryColumn,
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 78988ce5b732f..4d1ea5dfec2eb 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.cyan}${frame.pc}${ansi.normal}{ 
${module.file.ba

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread David Peixotto via lldb-commits


@@ -54,12 +57,67 @@ struct RegisteredPluginInfo {
   bool enabled = false;
 };
 
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugins. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "macosx" plugin in the "system-runtime" namespace then we will
+// match a plugin name pattern against the "system-runtime.macosx" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
 class PluginManager {
 public:
   static void Initialize();
 
   static void Terminate();
 
+  // Support for enabling and disabling plugins.
+
+  // Return the plugins that can be enabled or disabled by the user.
+  static llvm::ArrayRef GetPluginNamespaces();
+
+  // Generate a json object that describes the plugins that are available.
+  // This is a json representation of the plugin info returned by
+  // GetPluginNamespaces().
+  //
+  //{
+  //   : [
+  //   {
+  //   "enabled": ,
+  //   "name": ,
+  //   },
+  //   ...
+  //   ],
+  //   ...
+  //}
+  //
+  // If pattern is given it will be used to filter the plugins that are
+  // are returned. The pattern filters the plugin names using the
+  // PluginManager::MatchPluginName() function.
+  static llvm::json::Object GetJSON(llvm::StringRef pattern = "");
+
+  // Return true if the pattern matches the plugin name.
+  //
+  // The pattern matches the name if it is exactly equal to the namespace name
+  // or if it is equal to the qualified name, which is the namespace name
+  // followed by a dot and the plugin name (e.g. "system-runtime.foo").
+  //
+  // An empty pattern matches all plugins.
+  static bool MatchPluginName(llvm::StringRef pattern,
+  const PluginNamespace &plugin_ns,
+  const RegisteredPluginInfo &plugin);
+

dmpots wrote:

It is used in 
[ActOnMatchingPlugins](https://github.com/llvm/llvm-project/pull/134418/files#diff-630b9ff8bd3f2f236eeb85da70c2a3de3284e9aef31882f75e14830088e4ae12R68)
 so that we do not duplicate the matching logic in multiple places.

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread David Peixotto via lldb-commits


@@ -46,12 +48,255 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  if (PluginManager::MatchPluginName(pattern, plugin_namespace,
+ plugin_info))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+
+static std::string ConvertJSONToPrettyString(const llvm::json::Value &json) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  os << llvm::formatv("{0:2}", json).str();
+  os.flush();
+  return str;
+}
+
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are used by the plugin list command.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'j':
+  m_json_format = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_json_format = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_json_format = false;
+};
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin list' requires zero or one arguments");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.S

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread David Peixotto via lldb-commits


@@ -0,0 +1,52 @@
+# This test validates the plugin list command.
+# Currently it works only for system-runtime plugins and we only have one
+# system runtime plugin so testing is a bit limited.
+#
+# Note that commands that return errors will stop running a script, so we
+# have new RUN lines for any command that is expected to return an error.
+
+# RUN: %lldb -s %s -o exit 2>&1 | FileCheck %s
+
+# Test plugin list without an argument will list all plugins.
+plugin list
+# CHECK-LABEL: plugin list
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test plugin list works with fully qualified name.
+plugin list system-runtime.systemruntime-macosx
+# CHECK-LABEL: plugin list system-runtime.systemruntime-macosx
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test plugin list on plugin namespace works.
+plugin list system-runtime
+# CHECK-LABEL: plugin list system-runtime
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test json output for plugin list.
+plugin list --json
+# CHECK-LABEL plugin list --json
+# CHECK: {
+# CHECK:  "system-runtime": [
+# CHECK:{
+# CHECK:  "enabled": true,
+# CHECK:  "name": "systemruntime-macosx"

dmpots wrote:

I think they should always be in that order because the keys will be sorted. I 
can add the -DAG suffix to allow them to be reordered.

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5a91892 - [lldb][Format] Add [inlined] marker to names of inlined frames (#142952)

2025-06-05 Thread via lldb-commits

Author: Michael Buch
Date: 2025-06-05T17:41:37+01:00
New Revision: 5a918923f37e49b426f117c691c83d29df8c955d

URL: 
https://github.com/llvm/llvm-project/commit/5a918923f37e49b426f117c691c83d29df8c955d
DIFF: 
https://github.com/llvm/llvm-project/commit/5a918923f37e49b426f117c691c83d29df8c955d.diff

LOG: [lldb][Format] Add [inlined] marker to names of inlined frames (#142952)

This was removed in https://github.com/llvm/llvm-project/pull/135343 in
favour of making it a format variable, which we do here. This follows
the precedent of the `[opt]` and `[artificial]` markers.

Before:
```
 thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
 * frame #0: 0x0001037c a.out`inlined1() at inline.cpp:4:3
   frame #1: 0x0001037c a.out`regular() at inline.cpp:6:17
   frame #2: 0x000103b8 a.out`inlined2() at inline.cpp:7:43
   frame #3: 0x000103b4 a.out`main at inline.cpp:10:3
   frame #4: 0x000186345be4 dyld`start + 7040
```

After (note the `[inlined]` markers):
```
thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
* frame #0: 0x0001037c a.out`inlined1() at inline.cpp:4:3 [inlined]
  frame #1: 0x0001037c a.out`regular() at inline.cpp:6:17
  frame #2: 0x000103b8 a.out`inlined2() at inline.cpp:7:43 [inlined]
  frame #3: 0x000103b4 a.out`main at inline.cpp:10:3
  frame #4: 0x000186345be4 dyld`start + 7040
```

rdar://152642178

Added: 
lldb/test/Shell/Settings/TestFrameFunctionInlined.test

Modified: 
lldb/docs/use/formatting.rst
lldb/include/lldb/Core/FormatEntity.h
lldb/source/Core/CoreProperties.td
lldb/source/Core/FormatEntity.cpp
lldb/unittests/Core/FormatEntityTest.cpp

Removed: 




diff  --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e71b08780eb3d..21b3ca1912b02 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -122,6 +122,8 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``function.initial-function`` | Will evaluate to true if 
this is the start of the first function, as opposed to a change of functions 
(may be used in ``disassembly-format`` to print the function name for the first 
function being disassembled)
  |
 
+---+-+
+| ``function.is-inlined``   | Will evaluate to true if 
this function was inlined   


   |
++---+-+
 | ``line.file.basename``| The line table entry 
basename to the file for the current line entry in the current frame.   


   |
 
+---+-+
 | ``line.file.fullpath``| The line table entry 
fullpath to the file for the current line entry in the current frame.   


   |

diff  --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index 18257161eec7b..17fee068230b2 100644
--- 

[Lldb-commits] [lldb] Revert "[lldb-dap] Use structured types for stepInTargets request (#142439)" (PR #142891)

2025-06-05 Thread John Harrison via lldb-commits

ashgti wrote:

#142831 should fix the failing test on macOS. Should I revert this revert and 
add that to my other PR or should I rebase my changes on HEAD and we can take 
another stab at updating the stepInTargets request?

https://github.com/llvm/llvm-project/pull/142891
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Format] Add [inlined] marker to names of inlined frames (PR #142952)

2025-06-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 closed 
https://github.com/llvm/llvm-project/pull/142952
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

nb this PR is causing a failure on the x86_64 macOS CI bot 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/ in 
TestUniversal.py where `image list -t -b` returns a triple name of 
`x86_64-apple-macosx10.9.0-macho` instead of `x86_64-apple-macosx10.9.0` and 
the API test isn't expecting that.  I don't have an opinion on where this 
should be fixed yet -- if there's an issue with this PR, the way the test is 
written, or the way image list is printing the ArchSpec for the modules.  I'm 
looking into it now.

https://github.com/llvm/llvm-project/pull/142704
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142831

>From 0824e3c626ad5e8c2ce37f2fdfcf0c2fa47b7b1d Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Jun 2025 11:03:37 -0700
Subject: [PATCH 1/6] [lldb-dap] Creating a 'capabilities' event helper.

This adds a new 'CapabilitiesEventBody' type for having a well structured type 
for the event and updates the 'stepInTargets' and 'restart' request to 
dynamically set their capabilities.

This also fixes the 'stepInTargets' test on non-x86 platforms.
---
 .../test/tools/lldb-dap/dap_server.py | 25 +++---
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  2 +-
 .../stepInTargets/TestDAP_stepInTargets.py|  2 +
 lldb/tools/lldb-dap/CMakeLists.txt|  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   | 18 
 lldb/tools/lldb-dap/EventHelper.h |  3 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  3 --
 .../Handler/RestartRequestHandler.cpp | 17 ---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  4 +-
 .../lldb-dap/Protocol/ProtocolEvents.cpp  | 21 +
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 46 +++
 11 files changed, 112 insertions(+), 30 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..c3c8dbb12e9d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,10 @@ def as_dict(self):
 return source_dict
 
 
+class NotSupportedError(Exception):
+"""Raised if a feature is not supported due to its capabilities."""
+
+
 class DebugCommunication(object):
 def __init__(
 self,
@@ -153,7 +157,7 @@ def __init__(
 self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
 self.exit_status: Optional[int] = None
-self.initialize_body = None
+self.capabilities: dict[str, Any] = {}
 self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
@@ -300,6 +304,9 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 elif event == "breakpoint":
 # Breakpoint events are sent when a breakpoint is resolved
 self._update_verified_breakpoints([body["breakpoint"]])
+elif event == "capabilities":
+# Update the capabilities with new ones from the event.
+self.capabilities.update(body["capabilities"])
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
@@ -488,13 +495,11 @@ def wait_for_terminated(self, timeout: Optional[float] = 
None):
 raise ValueError("didn't get terminated event")
 return event_dict
 
-def get_initialize_value(self, key):
+def get_capability(self, key, default=None):
 """Get a value for the given key if it there is a key/value pair in
-the "initialize" request response body.
+the capabilities reported by the adapter.
 """
-if self.initialize_body and key in self.initialize_body:
-return self.initialize_body[key]
-return None
+return self.capabilities.get(key, default)
 
 def get_threads(self):
 if self.threads is None:
@@ -760,6 +765,10 @@ def request_continue(self, threadId=None, 
singleThread=False):
 return response
 
 def request_restart(self, restartArguments=None):
+if self.exit_status is not None:
+raise ValueError("request_restart called after process exited")
+if not self.get_capability("supportsRestartRequest", False):
+raise NotSupportedError("supportsRestartRequest is not set")
 command_dict = {
 "command": "restart",
 "type": "request",
@@ -867,7 +876,7 @@ def request_initialize(self, sourceInitFile=False):
 response = self.send_recv(command_dict)
 if response:
 if "body" in response:
-self.initialize_body = response["body"]
+self.capabilities = response["body"]
 return response
 
 def request_launch(
@@ -972,6 +981,8 @@ def request_stepIn(self, threadId, targetId, 
granularity="statement"):
 def request_stepInTargets(self, frameId):
 if self.exit_status is not None:
 raise ValueError("request_stepInTargets called after process 
exited")
+if not self.get_capability("supportsStepInTargetsRequest", False):
+raise NotSupportedError("supportsStepInTargetsRequest is not set")
 args_dict = {"frameId": frameId}
 command_dict = {
 "com

[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Aha, I see.  Any call to llvm's `setObjectFormat` is going to add this to the 
triple string if there is no environ set:

```
   1608 void Triple::setObjectFormat(ObjectFormatType Kind) {
   1609   if (Environment == UnknownEnvironment)
-> 1610 return setEnvironmentName(getObjectFormatTypeName(Kind));
   1611 
   1612   setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
   1613   getObjectFormatTypeName(Kind)).str());
   1614 }
```

Well that's not great.  I really don't want `-macho` in our triples, it looks 
terrible.

https://github.com/llvm/llvm-project/pull/142704
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

In `ArchSpec::SetArchitecture` if we passed in the vendor in addition to the 
architecture, that would set the ObjectFile to MachO correctly *without* 
calling `Triple::setObjectFormat` which adds the object file name to the triple 
as an environment, if there is no environment.  something like 

```
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 70b9800f4da..aead2f7f364 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -887,6 +887,9 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, 
uint32_t cpu,
 // Always use the architecture name because it might be more
 // descriptive than the architecture enum ("armv7" ->
 // llvm::Triple::arm).
+std::string initial_triple = core_def->name;
+if (arch_type == eArchTypeMachO)
+  initial_triple += "-apple-";
 m_triple.setArchName(llvm::StringRef(core_def->name));
 if (arch_type == eArchTypeMachO) {
   m_triple.setVendor(llvm::Triple::Apple);
```

although that's not very prettily done.

https://github.com/llvm/llvm-project/pull/142704
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f961d6a - Revert "[lldb] Set default object format to `MachO` in `ObjectFileMachO` (#142704)"

2025-06-05 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2025-06-05T16:24:31-07:00
New Revision: f961d6a89abe5a6fb70afc043f33b2efcec77536

URL: 
https://github.com/llvm/llvm-project/commit/f961d6a89abe5a6fb70afc043f33b2efcec77536
DIFF: 
https://github.com/llvm/llvm-project/commit/f961d6a89abe5a6fb70afc043f33b2efcec77536.diff

LOG: Revert "[lldb] Set default object format to `MachO` in `ObjectFileMachO` 
(#142704)"

This reverts commit d4d2f069dec4fb8b13447f52752d4ecd08d976d6.

Temporarily reverting until we can find a way to get the correct
ObjectFile set in Module's Triples without adding "-macho" to the
triple string for each Module.  This is breaking TestUniversal.py
on the x86_64 macOS CI bots.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 0079672c5cbd0..3950454b7c90e 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5148,7 +5148,6 @@ void ObjectFileMachO::GetAllArchSpecs(const 
llvm::MachO::mach_header &header,
   llvm::Triple base_triple = base_arch.GetTriple();
   base_triple.setOS(llvm::Triple::UnknownOS);
   base_triple.setOSName(llvm::StringRef());
-  base_triple.setObjectFormat(llvm::Triple::MachO);
 
   if (header.filetype == MH_PRELOAD) {
 if (header.cputype == CPU_TYPE_ARM) {

diff  --git a/lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp 
b/lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp
index 71ff866abb352..0ef2d0b85fd36 100644
--- a/lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp
+++ b/lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp
@@ -94,59 +94,4 @@ TEST_F(ObjectFileMachOTest, IndirectSymbolsInTheSharedCache) 
{
   for (size_t i = 0; i < 10; i++)
 OF->ParseSymtab(symtab);
 }
-
-TEST_F(ObjectFileMachOTest, ObjectFormatWithoutVersionLoadCommand) {
-  // A Mach-O file without the load command LC_BUILD_VERSION.
-  const char *yamldata = R"(
 !mach-o
-FileHeader:
-  magic:   0xFEEDFACF
-  cputype: 0x010C
-  cpusubtype:  0x
-  filetype:0x0001
-  ncmds:   1
-  sizeofcmds:  152
-  flags:   0x2000
-  reserved:0x
-LoadCommands:
-  - cmd: LC_SEGMENT_64
-cmdsize: 152
-segname: __TEXT
-vmaddr:  0
-vmsize:  4
-fileoff: 184
-filesize:4
-maxprot: 7
-initprot:7
-nsects:  1
-flags:   0
-Sections:
-  - sectname:__text
-segname: __TEXT
-addr:0x
-content: 'AABBCCDD'
-size:4
-offset:  184
-align:   0
-reloff:  0x
-nreloc:  0
-flags:   0x8400
-reserved1:   0x
-reserved2:   0x
-reserved3:   0x
-...
-)";
-
-  // Perform setup.
-  llvm::Expected file = TestFile::fromYaml(yamldata);
-  EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
-  auto module_sp = std::make_shared(file->moduleSpec());
-  ASSERT_NE(module_sp, nullptr);
-  auto object_file = module_sp->GetObjectFile();
-  ASSERT_NE(object_file, nullptr);
-
-  // Verify that the object file is recognized as Mach-O.
-  ASSERT_EQ(object_file->GetArchitecture().GetTriple().getObjectFormat(),
-llvm::Triple::MachO);
-}
 #endif



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I've reverted this commit on main for now,

```
commit f961d6a89abe5a6fb70afc043f33b2efcec77536
Author: Jason Molenda 
Date:   Thu Jun 5 16:23:27 2025 -0700

Revert "[lldb] Set default object format to `MachO` in `ObjectFileMachO` 
(#142704)"
```

Until we can find a way to set the ObjectFile correctly without adding "-macho" 
to each Module's triple string.  TestUniversal.py failing is the specific 
failure caused by this change, but it's also an undesirable change to have 
"-macho" added to triple strings from a UI point of view. 

https://github.com/llvm/llvm-project/pull/142704
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga updated 
https://github.com/llvm/llvm-project/pull/142875

>From 196837389c032a59f47dd0acf98bfd18bbaa0ae3 Mon Sep 17 00:00:00 2001
From: satya janga 
Date: Wed, 4 Jun 2025 09:40:51 -0700
Subject: [PATCH] Minor fix to connect-url to support unix-connect sockets on
 localhost Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
---
 .../gdb-server/PlatformRemoteGDBServer.cpp|  5 ++-
 .../platform/connect/TestPlatformConnect.py   | 45 +++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 26ca6ed128972..4a77423bac526 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -800,7 +800,10 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char 
*scheme,
  const char *hostname,
  uint16_t port, const char *path) {
   StreamString result;
-  result.Printf("%s://[%s]", scheme, hostname);
+  result.Printf("%s://", scheme);
+  if (strlen(hostname) > 0)
+result.Printf("[%s]", hostname);
+
   if (port != 0)
 result.Printf(":%u", port);
   if (path)
diff --git a/lldb/test/API/commands/platform/connect/TestPlatformConnect.py 
b/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
index fc6c2ee98df44..5df0c16fbd1f7 100644
--- a/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
+++ b/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
@@ -57,3 +57,48 @@ def test_platform_process_connect(self):
 self.assertEqual(frame.GetFunction().GetName(), "main")
 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
 process.Continue()
+
+@skipIfRemote
+@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
+@skipIfDarwin  # lldb-server not found correctly
+@expectedFailureAll(oslist=["windows"])  # process modules not loaded
+# lldb-server platform times out waiting for the gdbserver port number to 
be
+# written to the pipe, yet it seems the gdbserver already has written it.
+@expectedFailureAll(
+archs=["aarch64"],
+oslist=["freebsd"],
+bugnumber="https://github.com/llvm/llvm-project/issues/84327";,
+)
+@add_test_categories(["lldb-server"])
+def test_platform_process_connect_with_unix_connect(self):
+self.build()
+lldb_temp_dir = 
lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBTempSystemDir)
+named_pipe = "%s/platform_server.sock" % lldb_temp_dir
+port_file = self.getBuildArtifact("port")
+commandline_args = [
+"platform",
+"--listen",
+named_pipe,
+"--socket-file",
+port_file,
+"--",
+self.getBuildArtifact("a.out"),
+"foo",
+]
+self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), 
commandline_args)
+
+socket_file = lldbutil.wait_for_file_on_target(self, port_file)
+new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
+self.dbg.SetSelectedPlatform(new_platform)
+connect_url = "unix-connect://%s" % socket_file
+self.runCmd("platform connect %s" % connect_url)
+
+lldbutil.run_break_set_by_symbol(self, "main")
+process = self.process()
+
+process.Continue()
+
+frame = self.frame()
+self.assertEqual(frame.GetFunction().GetName(), "main")
+self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
+process.Continue()

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits


@@ -800,7 +800,11 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char 
*scheme,
  const char *hostname,
  uint16_t port, const char *path) {
   StreamString result;
-  result.Printf("%s://[%s]", scheme, hostname);
+  if (strlen(hostname) > 0)
+result.Printf("%s://[%s]", scheme, hostname);
+  else
+result.Printf("%s://", scheme);
+

satyajanga wrote:

updated this.

https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/142831

>From 0824e3c626ad5e8c2ce37f2fdfcf0c2fa47b7b1d Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Jun 2025 11:03:37 -0700
Subject: [PATCH 1/7] [lldb-dap] Creating a 'capabilities' event helper.

This adds a new 'CapabilitiesEventBody' type for having a well structured type 
for the event and updates the 'stepInTargets' and 'restart' request to 
dynamically set their capabilities.

This also fixes the 'stepInTargets' test on non-x86 platforms.
---
 .../test/tools/lldb-dap/dap_server.py | 25 +++---
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  2 +-
 .../stepInTargets/TestDAP_stepInTargets.py|  2 +
 lldb/tools/lldb-dap/CMakeLists.txt|  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   | 18 
 lldb/tools/lldb-dap/EventHelper.h |  3 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  3 --
 .../Handler/RestartRequestHandler.cpp | 17 ---
 lldb/tools/lldb-dap/Protocol/ProtocolBase.h   |  4 +-
 .../lldb-dap/Protocol/ProtocolEvents.cpp  | 21 +
 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 46 +++
 11 files changed, 112 insertions(+), 30 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
 create mode 100644 lldb/tools/lldb-dap/Protocol/ProtocolEvents.h

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..c3c8dbb12e9d0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,10 @@ def as_dict(self):
 return source_dict
 
 
+class NotSupportedError(Exception):
+"""Raised if a feature is not supported due to its capabilities."""
+
+
 class DebugCommunication(object):
 def __init__(
 self,
@@ -153,7 +157,7 @@ def __init__(
 self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
 self.exit_status: Optional[int] = None
-self.initialize_body = None
+self.capabilities: dict[str, Any] = {}
 self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
@@ -300,6 +304,9 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 elif event == "breakpoint":
 # Breakpoint events are sent when a breakpoint is resolved
 self._update_verified_breakpoints([body["breakpoint"]])
+elif event == "capabilities":
+# Update the capabilities with new ones from the event.
+self.capabilities.update(body["capabilities"])
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
@@ -488,13 +495,11 @@ def wait_for_terminated(self, timeout: Optional[float] = 
None):
 raise ValueError("didn't get terminated event")
 return event_dict
 
-def get_initialize_value(self, key):
+def get_capability(self, key, default=None):
 """Get a value for the given key if it there is a key/value pair in
-the "initialize" request response body.
+the capabilities reported by the adapter.
 """
-if self.initialize_body and key in self.initialize_body:
-return self.initialize_body[key]
-return None
+return self.capabilities.get(key, default)
 
 def get_threads(self):
 if self.threads is None:
@@ -760,6 +765,10 @@ def request_continue(self, threadId=None, 
singleThread=False):
 return response
 
 def request_restart(self, restartArguments=None):
+if self.exit_status is not None:
+raise ValueError("request_restart called after process exited")
+if not self.get_capability("supportsRestartRequest", False):
+raise NotSupportedError("supportsRestartRequest is not set")
 command_dict = {
 "command": "restart",
 "type": "request",
@@ -867,7 +876,7 @@ def request_initialize(self, sourceInitFile=False):
 response = self.send_recv(command_dict)
 if response:
 if "body" in response:
-self.initialize_body = response["body"]
+self.capabilities = response["body"]
 return response
 
 def request_launch(
@@ -972,6 +981,8 @@ def request_stepIn(self, threadId, targetId, 
granularity="statement"):
 def request_stepInTargets(self, frameId):
 if self.exit_status is not None:
 raise ValueError("request_stepInTargets called after process 
exited")
+if not self.get_capability("supportsStepInTargetsRequest", False):
+raise NotSupportedError("supportsStepInTargetsRequest is not set")
 args_dict = {"frameId": frameId}
 command_dict = {
 "com

[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga edited 
https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits


@@ -57,3 +57,50 @@ def test_platform_process_connect(self):
 self.assertEqual(frame.GetFunction().GetName(), "main")
 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
 process.Continue()
+
+@skipIfRemote
+@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
+@skipIfDarwin  # lldb-server not found correctly
+@expectedFailureAll(oslist=["windows"])  # process modules not loaded
+# lldb-server platform times out waiting for the gdbserver port number to 
be
+# written to the pipe, yet it seems the gdbserver already has written it.
+@expectedFailureAll(
+archs=["aarch64"],
+oslist=["freebsd"],
+bugnumber="https://github.com/llvm/llvm-project/issues/84327";,
+)
+@add_test_categories(["lldb-server"])
+def test_platform_process_connect_with_unix_connect(self):
+self.build()
+import time
+
+timestamp = int(time.time())
+listen_url = "/tmp/listen_url_%s" % timestamp
+port_file = "/tmp/port_file_%s" % timestamp

satyajanga wrote:

named pipes max length is 108 chars, so i selected to use /tmp dir. thank for 
the pointer to do it correctly.
```
struct sockaddr_un
  {
__SOCKADDR_COMMON (sun_);
char sun_path[108]; /* Path name.  */
  };
  ```

https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)

2025-06-05 Thread John Harrison via lldb-commits

ashgti wrote:

I also added some unit tests for the new 'CapabilitiesEventBody' serialization 
logic. But I have a style question.

The existing `Capabilities` type doesn't initialize its fields, so if I use the 
aggregate I have to include all the fields. However, we could initialize the 
values and then the aggregate initializer is short, but that leads to my style 
questions.

```c++
// style 1, no initializers:
struct Capabilities {
  llvm::DenseSet supportedFeatures;
  std::optional> 
exceptionBreakpointFilters;
  std::optional> completionTriggerCharacters;

};
// all fields must be set or we get a warning on `-Wmissing-field-initializers`
Capabilities cap{
  /*supportedFeatures=*/{...},
  /*exceptionBreakpointFilters=*/std::nullopt,
  /*completionTriggerCharacters=*/std::nullopt
...
};


// style 2, = initial value:
struct Capabilities {
  llvm::DenseSet supportedFeatures = {};
  std::optional> 
exceptionBreakpointFilters = std::nullopt;
  std::optional> completionTriggerCharacters = 
std::nullopt;

};
Capabilities cap{/*supportedFeatures=*/{...}}; // no need to specify the 
nullopts.


// style 3, brace initializers:
struct Capabilities {
  llvm::DenseSet supportedFeatures{};
  std::optional> 
exceptionBreakpointFilters{};
  std::optional> completionTriggerCharacters{};

};
Capabilities cap{/*supportedFeatures=*/{...}}; // no need to specify the 
nullopts.
```


https://github.com/llvm/llvm-project/pull/142831
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread Prabhu Rajasekaran via lldb-commits

https://github.com/Prabhuk created 
https://github.com/llvm/llvm-project/pull/143048

`TestStopHookScripted.py` Was failing for cases where -I 0 was not passed to 
stop-hook add calls. 

>From caba21d891cf799aecd98a038dc74458e6078867 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Thu, 5 Jun 2025 22:52:24 +
Subject: [PATCH] Fix tests

---
 .../target/stop-hooks/TestStopHookScripted.py| 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index b71f3421f9834..71f805e7f296b 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -58,19 +58,19 @@ def test_stop_hooks_scripted_no_entry(self):
 
 def test_stop_hooks_scripted_right_func(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-n step_out_of_me")
+self.stop_hooks_scripted(5, "-I 0 -n step_out_of_me")
 
 def test_stop_hooks_scripted_wrong_func(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-n main")
+self.stop_hooks_scripted(0, "-I 0 -n main")
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(5, "-I 0 -f main.c -l 1 -e %d" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(0, "-I 0 -f main.c -l %d -e 100" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""
@@ -89,9 +89,9 @@ def do_test_auto_continue(self, return_true):
 result = lldb.SBCommandReturnObject()
 
 if return_true:
-command = "target stop-hook add -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
+command = "target stop-hook add -I 0 -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
 else:
-command = "target stop-hook add -G 1 -P stop_hook.stop_handler -k 
increment -v 5 -n step_out_of_me"
+command = "target stop-hook add -I 0 -G 1 -P 
stop_hook.stop_handler -k increment -v 5 -n step_out_of_me"
 
 self.interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "Set the target stop hook")

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Prabhu Rajasekaran (Prabhuk)


Changes

`TestStopHookScripted.py` Was failing for cases where -I 0 was not passed to 
stop-hook add calls. 

---
Full diff: https://github.com/llvm/llvm-project/pull/143048.diff


1 Files Affected:

- (modified) lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
(+6-6) 


``diff
diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index b71f3421f9834..71f805e7f296b 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -58,19 +58,19 @@ def test_stop_hooks_scripted_no_entry(self):
 
 def test_stop_hooks_scripted_right_func(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-n step_out_of_me")
+self.stop_hooks_scripted(5, "-I 0 -n step_out_of_me")
 
 def test_stop_hooks_scripted_wrong_func(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-n main")
+self.stop_hooks_scripted(0, "-I 0 -n main")
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(5, "-I 0 -f main.c -l 1 -e %d" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(0, "-I 0 -f main.c -l %d -e 100" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""
@@ -89,9 +89,9 @@ def do_test_auto_continue(self, return_true):
 result = lldb.SBCommandReturnObject()
 
 if return_true:
-command = "target stop-hook add -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
+command = "target stop-hook add -I 0 -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
 else:
-command = "target stop-hook add -G 1 -P stop_hook.stop_handler -k 
increment -v 5 -n step_out_of_me"
+command = "target stop-hook add -I 0 -G 1 -P 
stop_hook.stop_handler -k increment -v 5 -n step_out_of_me"
 
 self.interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "Set the target stop hook")

``




https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Make stop-hooks fire when lldb first gains control of a process. (PR #137410)

2025-06-05 Thread Prabhu Rajasekaran via lldb-commits

Prabhuk wrote:

> Two things. First off, adding the -I 0 option did indeed fix a failure.
> 
> In the first run you cited, three tests failed:
> 
> FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_auto_continue 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_auto_continue) 
> FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_right_func 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_func) 
> FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_wrong_func 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_func)
> 
> But then in the second log from after you applied the patch I suggested, only 
> the last two tests failed. So the addition did in fact make the first test 
> pass.
> 
> That makes sense because those other two failing tests don't use the same 
> command string as the first one. They use the command string on line 148 in 
> the test. So you also need to add the -I 0 to the command line in 
> `stop_hooks_scripted` in the test file.
> 
> But still, those failures are odd. The only difference between these two 
> failing tests and two that pass:
> 
> PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_right_lines 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_lines) 
> PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_wrong_lines 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_lines)
> 
> are that the failing tests pass in a function name filter to determine when 
> the stop-hook should fire, and the passing tests pass in a line-range filter. 
> In both failures the symptom is that the stop-hook got to fire one more time 
> than expected. The only change in this patch was adding one more place where 
> the stop-hook might fire - "at the entry point", but in the case of these 
> tests, that "entry point" firing shouldn't matter because the "entry point" 
> stop won't pass the filter. Somehow, in your case, that's not true.
> 
> Given that it did make the first test pass, I'm guessing adding the `-I 0` to 
> the other `target stop-hook add` command in the test file will make those 
> tests pass as well.
> 
> But where was that "entry point" stop happening on your system such that both 
> file and line number filters correctly reject it, but it passes BOTH the 
> filter on function name `main` AND the filter on function name 
> `step_out_of_me`?

Thank you. I added a PR with suggested changes that address the test failure 
https://github.com/llvm/llvm-project/pull/143048

I do not have the larger context to understand the test failures. I can bring 
this up with my team and get back to you with what we find out. Thank you for 
helping out here.

https://github.com/llvm/llvm-project/pull/137410
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
``





View the diff from darker here.


``diff
--- TestStopHookScripted.py 2025-06-05 23:42:55.00 +
+++ TestStopHookScripted.py 2025-06-05 23:55:15.784789 +
@@ -64,15 +64,19 @@
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
 self.stop_hooks_scripted(0, "-I 0 -n main")
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-I 0 -f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+5, "-I 0 -f main.c -l 1 -e %d" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-I 0 -f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+0, "-I 0 -f main.c -l %d -e 100" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""
 self.do_test_auto_continue(False)
 

``




https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga converted_to_draft 
https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga updated 
https://github.com/llvm/llvm-project/pull/142875

>From 41aa3b5c467a7ff07894060b11613c450e7804c5 Mon Sep 17 00:00:00 2001
From: satya janga 
Date: Thu, 5 Jun 2025 17:07:08 -0700
Subject: [PATCH] update the  "Usage: error message" for socket-file

---
 lldb/tools/lldb-server/lldb-platform.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 37ec8455c63a7..67b0fcf4449a7 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -97,9 +97,10 @@ static void signal_handler(int signo) {
 #endif
 
 static void display_usage(const char *progname, const char *subcommand) {
-  fprintf(stderr, "Usage:\n  %s %s [--log-file log-file-name] [--log-channels "
-  "log-channel-list] [--port-file port-file-path] --server "
-  "--listen port\n",
+  fprintf(stderr,
+  "Usage:\n  %s %s [--log-file log-file-name] [--log-channels "
+  "log-channel-list] [--socket-file socket-file-path] --server "
+  "--listen port\n",
   progname, subcommand);
   exit(0);
 }

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga updated 
https://github.com/llvm/llvm-project/pull/142875

>From 196837389c032a59f47dd0acf98bfd18bbaa0ae3 Mon Sep 17 00:00:00 2001
From: satya janga 
Date: Wed, 4 Jun 2025 09:40:51 -0700
Subject: [PATCH] Minor fix to connect-url to support unix-connect sockets on
 localhost Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
---
 .../gdb-server/PlatformRemoteGDBServer.cpp|  5 ++-
 .../platform/connect/TestPlatformConnect.py   | 45 +++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 26ca6ed128972..4a77423bac526 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -800,7 +800,10 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char 
*scheme,
  const char *hostname,
  uint16_t port, const char *path) {
   StreamString result;
-  result.Printf("%s://[%s]", scheme, hostname);
+  result.Printf("%s://", scheme);
+  if (strlen(hostname) > 0)
+result.Printf("[%s]", hostname);
+
   if (port != 0)
 result.Printf(":%u", port);
   if (path)
diff --git a/lldb/test/API/commands/platform/connect/TestPlatformConnect.py 
b/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
index fc6c2ee98df44..5df0c16fbd1f7 100644
--- a/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
+++ b/lldb/test/API/commands/platform/connect/TestPlatformConnect.py
@@ -57,3 +57,48 @@ def test_platform_process_connect(self):
 self.assertEqual(frame.GetFunction().GetName(), "main")
 self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
 process.Continue()
+
+@skipIfRemote
+@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
+@skipIfDarwin  # lldb-server not found correctly
+@expectedFailureAll(oslist=["windows"])  # process modules not loaded
+# lldb-server platform times out waiting for the gdbserver port number to 
be
+# written to the pipe, yet it seems the gdbserver already has written it.
+@expectedFailureAll(
+archs=["aarch64"],
+oslist=["freebsd"],
+bugnumber="https://github.com/llvm/llvm-project/issues/84327";,
+)
+@add_test_categories(["lldb-server"])
+def test_platform_process_connect_with_unix_connect(self):
+self.build()
+lldb_temp_dir = 
lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBTempSystemDir)
+named_pipe = "%s/platform_server.sock" % lldb_temp_dir
+port_file = self.getBuildArtifact("port")
+commandline_args = [
+"platform",
+"--listen",
+named_pipe,
+"--socket-file",
+port_file,
+"--",
+self.getBuildArtifact("a.out"),
+"foo",
+]
+self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), 
commandline_args)
+
+socket_file = lldbutil.wait_for_file_on_target(self, port_file)
+new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
+self.dbg.SetSelectedPlatform(new_platform)
+connect_url = "unix-connect://%s" % socket_file
+self.runCmd("platform connect %s" % connect_url)
+
+lldbutil.run_break_set_by_symbol(self, "main")
+process = self.process()
+
+process.Continue()
+
+frame = self.frame()
+self.assertEqual(frame.GetFunction().GetName(), "main")
+self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
+process.Continue()

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Minor fix to connect-url to support unix-connect sockets on localhost (PR #142875)

2025-06-05 Thread via lldb-commits

https://github.com/satyajanga ready_for_review 
https://github.com/llvm/llvm-project/pull/142875
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 7730093 - Revert "[lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (#139170)"

2025-06-05 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2025-06-05T17:47:04-07:00
New Revision: 7730093596b898fa2773003f396da4b3ad1f3c0a

URL: 
https://github.com/llvm/llvm-project/commit/7730093596b898fa2773003f396da4b3ad1f3c0a
DIFF: 
https://github.com/llvm/llvm-project/commit/7730093596b898fa2773003f396da4b3ad1f3c0a.diff

LOG: Revert "[lldb] Don't create instance of `SymbolFileDWARFDebugMap` for 
non-Mach-O files (#139170)"

This reverts commit 3096f8768676bd64123270cc59b7cc904a72d875.

Reverting this commit because it depends on another PR
that was reverted, https://github.com/llvm/llvm-project/pull/142704

Both can be reapplied once we find a correct fix for that.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt

Removed: 
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 83437c2db8778..f3a940b2ee396 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -246,10 +246,6 @@ llvm::StringRef 
SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() {
 }
 
 SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFileSP objfile_sp) {
-  assert(objfile_sp);
-  // Don't create a debug map if the object file isn't a Mach-O.
-  if (!objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
-return nullptr;
   return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
 }
 

diff  --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index 7408f88c5ab89..cf8702209a7c3 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -4,7 +4,6 @@ add_lldb_unittest(SymbolFileDWARFTests
   DWARFDIETest.cpp
   DWARFIndexCachingTest.cpp
   DWARFUnitTest.cpp
-  SymbolFileDWARFDebugMapTests.cpp
   SymbolFileDWARFTests.cpp
   XcodeSDKModuleTests.cpp
 

diff  --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
deleted file mode 100644
index 445304ad63110..0
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-//===-- SymbolFileDWARFDebugMapTests.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 "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "TestingSupport/SubsystemRAII.h"
-#include "TestingSupport/TestUtilities.h"
-
-#include "lldb/Core/Module.h"
-#include "llvm/Testing/Support/Error.h"
-
-#include "gtest/gtest.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::plugin::dwarf;
-
-class SymbolFileDWARFDebugMapTests : public testing::Test {
-  SubsystemRAII subsystems;
-};
-
-TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
-  // A Mach-O file built for arm64 CPU type and macOS platform.
-  const char *yamldata = R"(
 !mach-o
-FileHeader:
-  magic:   0xFEEDFACF
-  cputype: 0x010C
-  cpusubtype:  0x
-  filetype:0x0001
-  ncmds:   1
-  sizeofcmds:  176
-  flags:   0x2000
-  reserved:0x
-LoadCommands:
-  - cmd: LC_BUILD_VERSION
-cmdsize: 24
-platform:1
-minos:   658944
-sdk: 658944
-ntools:  0
-  - cmd: LC_SEGMENT_64
-cmdsize: 152
-segname: __TEXT
-vmaddr:  0
-vmsize:  4
-fileoff: 208
-filesize:4
-maxprot: 7
-initprot:7
-nsects:  1
-flags:   0
-Sections:
-  - sectname:__text
-segname: __TEXT
-addr:0x
-content: 'AABBCCDD'
-size:4
-offset:  208
-align:   0
-reloff:  0x
-nreloc:  0
-flags:   0x8400
-reserved1:   0x
-reserved2:   0x
-reserved3:   0x
-...
-)";
-
-  // Perform setup.
-  llvm::Expected file = TestFile::fromYaml(yamldata);
-  EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
-  auto module_sp = std::make_shared(file->moduleSpec()

[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

NB I reverted this on main because it depends on
https://github.com/llvm/llvm-project/pull/142704
which I also reverted as it adds "-macho" to every Module's Triple string, and 
we need to find a way to mark the object file as MachO without doing that.

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Show more children of top level values (PR #140938)

2025-06-05 Thread via lldb-commits

jimingham wrote:

One other thing, if I set a custom value and want to get the default behavior 
back, how do I do that?  I think that `defaults clear max-children-count` 
should do it, but it would be worth checking.  If it does, it might be worth 
giving that hint in the help, since that's not obvious.

https://github.com/llvm/llvm-project/pull/140938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,52 @@
+# This test validates the plugin list command.
+# Currently it works only for system-runtime plugins and we only have one
+# system runtime plugin so testing is a bit limited.
+#
+# Note that commands that return errors will stop running a script, so we
+# have new RUN lines for any command that is expected to return an error.
+
+# RUN: %lldb -s %s -o exit 2>&1 | FileCheck %s
+
+# Test plugin list without an argument will list all plugins.
+plugin list
+# CHECK-LABEL: plugin list
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test plugin list works with fully qualified name.
+plugin list system-runtime.systemruntime-macosx
+# CHECK-LABEL: plugin list system-runtime.systemruntime-macosx
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test plugin list on plugin namespace works.
+plugin list system-runtime
+# CHECK-LABEL: plugin list system-runtime
+# CHECK: system-runtime
+# CHECK:  [+] systemruntime-macosx   System runtime plugin for Mac OS 
X native libraries
+
+# Test json output for plugin list.
+plugin list --json
+# CHECK-LABEL plugin list --json
+# CHECK: {
+# CHECK:  "system-runtime": [
+# CHECK:{
+# CHECK:  "enabled": true,
+# CHECK:  "name": "systemruntime-macosx"

clayborg wrote:

Do these alway come out in this order? I would append a "-DAG" to these lines 
to ensure this test always passes no matter what changes are made to our JSON 
classes:

```
# CHECK-DAG:  "enabled": true,
# CHECK-DAG:  "name": "systemruntime-macosx"
```
This will allow these two lines to be out of order.


https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits


@@ -46,12 +48,255 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  if (PluginManager::MatchPluginName(pattern, plugin_namespace,
+ plugin_info))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+
+static std::string ConvertJSONToPrettyString(const llvm::json::Value &json) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  os << llvm::formatv("{0:2}", json).str();
+  os.flush();
+  return str;
+}
+
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are used by the plugin list command.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'j':
+  m_json_format = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_json_format = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_json_format = false;
+};
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin list' requires zero or one arguments");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.S

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits


@@ -46,12 +48,255 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  if (PluginManager::MatchPluginName(pattern, plugin_namespace,
+ plugin_info))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+
+static std::string ConvertJSONToPrettyString(const llvm::json::Value &json) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  os << llvm::formatv("{0:2}", json).str();
+  os.flush();
+  return str;
+}
+
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are used by the plugin list command.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'j':
+  m_json_format = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_json_format = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_json_format = false;
+};
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin list' requires zero or one arguments");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.S

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits


@@ -54,12 +57,67 @@ struct RegisteredPluginInfo {
   bool enabled = false;
 };
 
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugins. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "macosx" plugin in the "system-runtime" namespace then we will
+// match a plugin name pattern against the "system-runtime.macosx" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
 class PluginManager {
 public:
   static void Initialize();
 
   static void Terminate();
 
+  // Support for enabling and disabling plugins.
+
+  // Return the plugins that can be enabled or disabled by the user.
+  static llvm::ArrayRef GetPluginNamespaces();
+
+  // Generate a json object that describes the plugins that are available.
+  // This is a json representation of the plugin info returned by
+  // GetPluginNamespaces().
+  //
+  //{
+  //   : [
+  //   {
+  //   "enabled": ,
+  //   "name": ,
+  //   },
+  //   ...
+  //   ],
+  //   ...
+  //}
+  //
+  // If pattern is given it will be used to filter the plugins that are
+  // are returned. The pattern filters the plugin names using the
+  // PluginManager::MatchPluginName() function.
+  static llvm::json::Object GetJSON(llvm::StringRef pattern = "");
+
+  // Return true if the pattern matches the plugin name.
+  //
+  // The pattern matches the name if it is exactly equal to the namespace name
+  // or if it is equal to the qualified name, which is the namespace name
+  // followed by a dot and the plugin name (e.g. "system-runtime.foo").
+  //
+  // An empty pattern matches all plugins.
+  static bool MatchPluginName(llvm::StringRef pattern,
+  const PluginNamespace &plugin_ns,
+  const RegisteredPluginInfo &plugin);
+

clayborg wrote:

Is this used outside of PluginManager.cpp? If not, move to PluginManager.cpp as 
a static function or function in anonymous namespace.

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread Greg Clayton via lldb-commits


@@ -46,12 +48,255 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  if (PluginManager::MatchPluginName(pattern, plugin_namespace,
+ plugin_info))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+
+static std::string ConvertJSONToPrettyString(const llvm::json::Value &json) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+  os << llvm::formatv("{0:2}", json).str();
+  os.flush();
+  return str;
+}
+
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are used by the plugin list command.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'j':
+  m_json_format = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_json_format = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_json_format = false;
+};
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+  Options *GetOptions() override { return &m_options; }
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin list' requires zero or one arguments");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.S

[Lldb-commits] [lldb] 52075f0 - [lldb-dap] Migrating 'threads' request to structured types. (#142510)

2025-06-05 Thread via lldb-commits

Author: John Harrison
Date: 2025-06-05T15:58:30-07:00
New Revision: 52075f01a70990ce5e4b89f825d417a903a8dbe6

URL: 
https://github.com/llvm/llvm-project/commit/52075f01a70990ce5e4b89f825d417a903a8dbe6
DIFF: 
https://github.com/llvm/llvm-project/commit/52075f01a70990ce5e4b89f825d417a903a8dbe6.diff

LOG: [lldb-dap] Migrating 'threads' request to structured types. (#142510)

Moving `threads` request to structured types. Adding helper types for
this and moving helpers from JSONUtils to ProtocolUtils.

-

Co-authored-by: Ebuka Ezike 
Co-authored-by: Jonas Devlieghere 

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/EventHelper.cpp
lldb/tools/lldb-dap/EventHelper.h
lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
lldb/tools/lldb-dap/Handler/RequestHandler.h
lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
lldb/tools/lldb-dap/Handler/ThreadsRequestHandler.cpp
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/JSONUtils.h
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
lldb/tools/lldb-dap/ProtocolUtils.cpp
lldb/tools/lldb-dap/ProtocolUtils.h
lldb/unittests/DAP/ProtocolTypesTest.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6b41aef2bb5b8..71bae5c4ea035 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -308,7 +308,6 @@ def _handle_recv_packet(self, packet: 
Optional[ProtocolMessage]) -> bool:
 return keepGoing
 
 def _process_continued(self, all_threads_continued: bool):
-self.threads = None
 self.frame_scopes = {}
 if all_threads_continued:
 self.thread_stop_reasons = {}
@@ -1180,6 +1179,9 @@ def request_threads(self):
 with information about all threads"""
 command_dict = {"command": "threads", "type": "request", "arguments": 
{}}
 response = self.send_recv(command_dict)
+if not response["success"]:
+self.threads = None
+return response
 body = response["body"]
 # Fill in "self.threads" correctly so that clients that call
 # self.get_threads() or self.get_thread_id(...) can get information

diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 2537e007d691b..b034c967594ba 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1240,7 +1240,10 @@ void DAP::EventThread() {
 // automatically restarted.
 if (!lldb::SBProcess::GetRestartedFromEvent(event)) {
   SendStdOutStdErr(*this, process);
-  SendThreadStoppedEvent(*this);
+  if (llvm::Error err = SendThreadStoppedEvent(*this))
+DAP_LOG_ERROR(log, std::move(err),
+  "({1}) reporting thread stopped: {0}",
+  transport.GetClientName());
 }
 break;
   case lldb::eStateRunning:

diff  --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 1bd94fab402ca..89bc827c1141f 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -152,7 +152,7 @@ struct DAP {
   llvm::DenseSet clientFeatures;
 
   /// The initial thread list upon attaching.
-  std::optional initial_thread_list;
+  std::vector initial_thread_list;
 
   /// Keep track of all the modules our client knows about: either through the
   /// modules request or the module events.

diff  --git a/lldb/tools/lldb-dap/EventHelper.cpp 
b/lldb/tools/lldb-dap/EventHelper.cpp
index c698084836e2f..ae6fc6ec73ae3 100644
--- a/lldb/tools/lldb-dap/EventHelper.cpp
+++ b/lldb/tools/lldb-dap/EventHelper.cpp
@@ -8,10 +8,11 @@
 
 #include "EventHelper.h"
 #include "DAP.h"
-#include "DAPLog.h"
+#include "DAPError.h"
 #include "JSONUtils.h"
 #include "LLDBUtils.h"
 #include "lldb/API/SBFileSpec.h"
+#include "llvm/Support/Error.h"
 
 #if defined(_WIN32)
 #define NOMINMAX
@@ -22,6 +23,8 @@
 #endif
 #endif
 
+using namespace llvm;
+
 namespace lldb_dap {
 
 static void SendThreadExitedEvent(DAP &dap, lldb::tid_t tid) {
@@ -116,78 +119,78 @@ void SendProcessEvent(DAP &dap, LaunchMethod 
launch_method) {
 
 // Send a thread stopped event for all threads as long as the process
 // is stopped.
-void SendThreadStoppedEvent(DAP &dap) {
+llvm::Error SendThreadStoppedEvent(DAP &dap, bool on_entry) {
+  lldb::SBMutex lock = dap.GetAPIMutex();
+  std::lock_guard guard(lock);
+
   lldb::SBProcess process = dap.target.GetProces

[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)

2025-06-05 Thread John Harrison via lldb-commits

https://github.com/ashgti closed 
https://github.com/llvm/llvm-project/pull/142510
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Set default object format to `MachO` in `ObjectFileMachO` (PR #142704)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

In `ObjectFileMachO::GetAllArchSpecs()`, we call `ArchSpec::SetArchitecture()`,
```
base_arch.SetArchitecture(eArchTypeMachO, header.cputype, header.cpusubtype);
```

given a `mach_header`.  This does 
```
   890  m_triple.setArchName(llvm::StringRef(core_def->name));
```

Then in llvm's `Triple::Triple()`, 

```
   1068   ObjectFormat = getDefaultFormat(*this);
```

And that's where the object file format is being set to ELF,

```
   923  static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
-> 924switch (T.getArch()) {
   925case Triple::UnknownArch:
   926case Triple::aarch64:

   936  default:
   937return T.isOSDarwin() ? Triple::MachO : Triple::ELF;
```

The triple being passed in here is just "arm64" at this point, so the 
T.isOSDarwin() fails, ObjectFile is set to ELF and it is never reset.

But I don't see why the ModuleArchSpec being set to ObjectFileELF (which I'd 
never noticed before, ever) was not showing up in the triples, but -macho is, 
when it's set in ObjectFileMachO.  Maybe it's an ordering thing, where now that 
the object file is being set in `ObjectFileMachO::GetAllArchSpecs` it is 
constructing a triple string based on that, and it enters the picture.

It seems like it would be better to set the ObjectFile format in 
`ArchSpec::SetArchitecture` when we know we're building a triple for a mach-o 
file, to fix the erroneous ObjectFileELF setting from llvm when we only gave it 
a cpu name.  but let me look a little more.

https://github.com/llvm/llvm-project/pull/142704
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

I still don't understand the failures that triggered this patch - stopping at 
the entry point somehow is at a place where both the function name filter for 
`main` and `step_into_me` pass - even though that should be the same stop-point 
for both checks.  That seems quite odd.  

But this test was not intending to test entry point behavior, so it's fine to 
exclude this for the purposes of this test.

You still have to fix the Python formatting but then this should be fine.

https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-06-05 Thread Alexander Ziaee via lldb-commits

concussious wrote:

*nudges*

https://github.com/llvm/llvm-project/pull/133148
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC]Add missing getKind/classof methods for ClientInfo (PR #142984)

2025-06-05 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/142984

None

>From 9ae263cc0ffc6dc95d4a5b44d58462c1a22f1294 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 5 Jun 2025 10:55:38 -0400
Subject: [PATCH] [LLDB][NFC]Add missing getKind/classof methods for ClientInfo

---
 lldb/include/lldb/Core/Telemetry.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 5be68de6fcd7f..1db69723b4706 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -102,6 +102,17 @@ struct ClientInfo : public LLDBBaseTelemetryInfo {
   std::string client_data;
   std::optional error_msg;
 
+  // For dyn_cast, isa, etc operations.
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::ClientInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LLDBEntryKind::ClientInfo) ==
+   LLDBEntryKind::ClientInfo;
+  }
+
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC]Add missing getKind/classof methods for ClientInfo (PR #142984)

2025-06-05 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo closed 
https://github.com/llvm/llvm-project/pull/142984
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] eb6577d - [LLDB][NFC]Add missing getKind/classof methods for ClientInfo (#142984)

2025-06-05 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-06-05T11:00:39-04:00
New Revision: eb6577d54f53715e8917cf8a91eb68c8b47d489f

URL: 
https://github.com/llvm/llvm-project/commit/eb6577d54f53715e8917cf8a91eb68c8b47d489f
DIFF: 
https://github.com/llvm/llvm-project/commit/eb6577d54f53715e8917cf8a91eb68c8b47d489f.diff

LOG: [LLDB][NFC]Add missing getKind/classof methods for ClientInfo (#142984)

Added: 


Modified: 
lldb/include/lldb/Core/Telemetry.h

Removed: 




diff  --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 5be68de6fcd7f..1db69723b4706 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -102,6 +102,17 @@ struct ClientInfo : public LLDBBaseTelemetryInfo {
   std::string client_data;
   std::optional error_msg;
 
+  // For dyn_cast, isa, etc operations.
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::ClientInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LLDBEntryKind::ClientInfo) ==
+   LLDBEntryKind::ClientInfo;
+  }
+
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-06-05 Thread David Peixotto via lldb-commits

https://github.com/dmpots updated 
https://github.com/llvm/llvm-project/pull/134418

>From e240bda8fcea9db4d9c456929ba811feb8d4152b Mon Sep 17 00:00:00 2001
From: David Peixotto 
Date: Tue, 11 Mar 2025 13:02:14 -0700
Subject: [PATCH 01/23] Add commands to list/enable/disable plugins

This commit adds three new commands for managing plugins. The `list`
command will show which plugins are currently registered and their
enabled state. The `enable` and `disable` commands can be used to
enable or disable plugins.

A disabled plugin will not show up to the PluginManager when it iterates
over available plugins of a particular type.

The purpose of these commands is to provide more visibility into registered
plugins and allow users to disable plugins for experimental perf reasons.

There are a few limitations to the current implementation

  1. Only SystemRuntime plugins are currently supported. We can easily
 extend the existing implementation to support more types.
  2. Only "statically" know plugin types are supported (i.e. those
 managed by the PluginManager and not from `plugin load`). It is
 possibly we could support dynamic plugins as well, but I have
 not looked into it yet.
---
 lldb/source/Commands/CommandObjectPlugin.cpp  | 335 ++
 .../source/Commands/CommandObjectSettings.cpp |   1 +
 lldb/source/Commands/Options.td   |   5 +
 .../command-plugin-enable+disable.test|  53 +++
 .../Shell/Commands/command-plugin-list.test   |  51 +++
 5 files changed, 445 insertions(+)
 create mode 100644 lldb/test/Shell/Commands/command-plugin-enable+disable.test
 create mode 100644 lldb/test/Shell/Commands/command-plugin-list.test

diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp 
b/lldb/source/Commands/CommandObjectPlugin.cpp
index f3108b8a768d2..68261d24ffe1f 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -7,8 +7,11 @@
 
//===--===//
 
 #include "CommandObjectPlugin.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
+#include "llvm/Support/GlobPattern.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -46,12 +49,344 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vecto

[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread Prabhu Rajasekaran via lldb-commits

https://github.com/Prabhuk closed 
https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread Prabhu Rajasekaran via lldb-commits

Prabhuk wrote:

> I still don't understand the failures that triggered this patch - stopping at 
> the entry point somehow is at a place where both the function name filter for 
> `main` and `step_into_me` pass - even though that should be the same 
> stop-point for both checks. That seems quite odd.
> 
> But this test was not intending to test entry point behavior, so it's fine to 
> exclude this for the purposes of this test.
> 
> You still have to fix the Python formatting but then this should be fine.

Can we file a bug for this? If there are patches that you'd like me to try in 
our environment to address the bug I'll be happy to do so.

https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread via lldb-commits

royitaqi wrote:

> the correct fix for #142704

How about:
1. In `Triple`'s `getDefaultFormat`, first check if vendor is 
`llvm::Triple::Apple` and return `MachO` if so. The vendor is set to `Apple` by 
`ObjectFileMachO::GetAllArchSpecs` calling `base_arch.SetArchitecture`, which 
calls `m_triple.setVendor(llvm::Triple::Apple)`.

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread via lldb-commits

royitaqi wrote:

> NB I reverted this on main because it depends on #142704 which I also 
> reverted as it adds "-macho" to every Module's Triple string, and we need to 
> find a way to mark the object file as MachO without doing that.

Hi @jasonmolenda,

I appreciate you actively trying to make the code base better, and I can see 
why the other revert may make sense, BUT:

> it depends on #142704

I respectfully disagree. **This patch doesn't depend on #142704.**
* In a normal production environment (e.g. on a regular macOS machine) and in 
tests, without #142704, the object format of mach-o files are already `MachO`.
* The only caveat of this patch may be if there are mach-o files out there 
which don't have the `LC_BUILD_VERSION` or `LC_VERSION_MIN_*` load commands. 
However, their triple is already wrong (object format being `ELF`), so their 
behavior is already undefined at best. So I don't think we need to worry about 
them.

Please kindly LMK if I missed something in the above.

Thanks,
Roy

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread Prabhu Rajasekaran via lldb-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/143048

>From d1371371fbcfd6f8113e2d04707f80a7c439d287 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Thu, 5 Jun 2025 22:52:24 +
Subject: [PATCH 1/2] [lldb] Fix linux x64 test

Test was failing for cases where -I 0 was not passed to stop-hook add calls.
---
 .../target/stop-hooks/TestStopHookScripted.py| 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index b71f3421f9834..71f805e7f296b 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -58,19 +58,19 @@ def test_stop_hooks_scripted_no_entry(self):
 
 def test_stop_hooks_scripted_right_func(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-n step_out_of_me")
+self.stop_hooks_scripted(5, "-I 0 -n step_out_of_me")
 
 def test_stop_hooks_scripted_wrong_func(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-n main")
+self.stop_hooks_scripted(0, "-I 0 -n main")
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(5, "-I 0 -f main.c -l 1 -e %d" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(0, "-I 0 -f main.c -l %d -e 100" % 
(self.main_start_line))
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""
@@ -89,9 +89,9 @@ def do_test_auto_continue(self, return_true):
 result = lldb.SBCommandReturnObject()
 
 if return_true:
-command = "target stop-hook add -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
+command = "target stop-hook add -I 0 -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
 else:
-command = "target stop-hook add -G 1 -P stop_hook.stop_handler -k 
increment -v 5 -n step_out_of_me"
+command = "target stop-hook add -I 0 -G 1 -P 
stop_hook.stop_handler -k increment -v 5 -n step_out_of_me"
 
 self.interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "Set the target stop hook")

>From 9b257aa18e05d0d305c0b5b983827872268f9a03 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Fri, 6 Jun 2025 01:59:11 +
Subject: [PATCH 2/2] Format python file.

---
 .../commands/target/stop-hooks/TestStopHookScripted.py| 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index 71f805e7f296b..954cac1592435 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -66,11 +66,15 @@ def test_stop_hooks_scripted_wrong_func(self):
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-I 0 -f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+5, "-I 0 -f main.c -l 1 -e %d" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-I 0 -f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+0, "-I 0 -f main.c -l %d -e 100" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix linux x64 test (PR #143048)

2025-06-05 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/162/builds/23971


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/command_script_import.test 
(2982 of 2994)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Python/Crashlog/json.test (2983 of 
2994)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Lua/breakpoint_function_callback.test (2984 of 2994)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test (2985 of 
2994)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/convenience_variables.test 
(2986 of 2994)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/persistent_state.test (2987 of 
2994)
UNSUPPORTED: lldb-shell :: 
ScriptInterpreter/Python/Crashlog/no_threadState.test (2988 of 2994)
UNSUPPORTED: lldb-shell :: ScriptInterpreter/Python/Crashlog/parser_text.test 
(2989 of 2994)
PASS: lldb-api :: terminal/TestEditlineCompletions.py (2990 of 2994)
UNRESOLVED: lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py (2991 of 2994)
 TEST 'lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py' 
FAILED 
Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make 
/usr/bin/gmake --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/launch
 -p TestDAP_launch.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
0a1fdbe4df326a237e775c81de37aa9ddbb714e0)
  clang revision 0a1fdbe4df326a237e775c81de37aa9ddbb714e0
  llvm revision 0a1fdbe4df326a237e775c81de37aa9ddbb714e0
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/launch
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

runCmd: settings set target.auto-apply-fixits false

```



https://github.com/llvm/llvm-project/pull/143048
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread via lldb-commits

royitaqi wrote:

@jasonmolenda I appreciate the details. IIRC I ran `ninja check-lldb` both 
before and after rebasing the patch onto #142704, but from what you said I must 
have not done that. Let me double check on my side.

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread via lldb-commits

royitaqi wrote:

You are right, `lldb/test/Shell/Breakpoint/case-sensitive.test` failed on my 
arm64 macOS, too. So what I did must be that I tested before switching to using 
`isAppleMachO()`, then never tested it again until rebased on top of #142704.

Thank you for catching this and the revert. My bad (mistakenly thought the 
patch is independent).

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I'll admit I didn't debug it very far, but when I reverted the 
ObjectFileMachO.cpp change, `lldb/test/Shell/Breakpoint/case-sensitive.test` 
started failing on the bots.  When I built main myself and ran it, it failed on 
my desktop.  When I used the built lldb on the `case-sensitive.test.tmp` binary 
this test built, lldb could not set a source & line breakpoint -- it had no 
debug info.  When I also reverted this PR, the failure went away.

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Ultimately I expect
```
  // Don't create a debug map if the object file isn't a Mach-O.
  if (!objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
```

was not succeeding for this binary.  I didn't debug what was special about this 
binary; the compile command in the shell test is doing `%build 
%p/Inputs/case-sensitive.c --nodefaultlib -o %t` and looking at the built 
binary in my checkout, it links against no libraries and has no LC_BUILD load 
command.  

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

e.g. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/27150/ 
but it reproduced on my arm64 macOS desktop no problem when I did `ninja 
check-lldb-shell`

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 0a1fdbe - [lldb] Fix linux x64 test (#143048)

2025-06-05 Thread via lldb-commits

Author: Prabhu Rajasekaran
Date: 2025-06-05T19:26:17-07:00
New Revision: 0a1fdbe4df326a237e775c81de37aa9ddbb714e0

URL: 
https://github.com/llvm/llvm-project/commit/0a1fdbe4df326a237e775c81de37aa9ddbb714e0
DIFF: 
https://github.com/llvm/llvm-project/commit/0a1fdbe4df326a237e775c81de37aa9ddbb714e0.diff

LOG: [lldb] Fix linux x64 test (#143048)

`TestStopHookScripted.py` Was failing for cases where -I 0 was not
passed to stop-hook add calls.

Added: 


Modified: 
lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py

Removed: 




diff  --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index b71f3421f9834..954cac1592435 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -58,19 +58,23 @@ def test_stop_hooks_scripted_no_entry(self):
 
 def test_stop_hooks_scripted_right_func(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-n step_out_of_me")
+self.stop_hooks_scripted(5, "-I 0 -n step_out_of_me")
 
 def test_stop_hooks_scripted_wrong_func(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-n main")
+self.stop_hooks_scripted(0, "-I 0 -n main")
 
 def test_stop_hooks_scripted_right_lines(self):
 """Test that a scripted stop hook fires when there is a function 
match"""
-self.stop_hooks_scripted(5, "-f main.c -l 1 -e %d" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+5, "-I 0 -f main.c -l 1 -e %d" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_wrong_lines(self):
 """Test that a scripted stop hook doesn't fire when the function does 
not match"""
-self.stop_hooks_scripted(0, "-f main.c -l %d -e 100" % 
(self.main_start_line))
+self.stop_hooks_scripted(
+0, "-I 0 -f main.c -l %d -e 100" % (self.main_start_line)
+)
 
 def test_stop_hooks_scripted_auto_continue(self):
 """Test that the --auto-continue flag works"""
@@ -89,9 +93,9 @@ def do_test_auto_continue(self, return_true):
 result = lldb.SBCommandReturnObject()
 
 if return_true:
-command = "target stop-hook add -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
+command = "target stop-hook add -I 0 -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
 else:
-command = "target stop-hook add -G 1 -P stop_hook.stop_handler -k 
increment -v 5 -n step_out_of_me"
+command = "target stop-hook add -I 0 -G 1 -P 
stop_hook.stop_handler -k increment -v 5 -n step_out_of_me"
 
 self.interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "Set the target stop hook")



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-06-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

FTR I suspect the correct fix for 
https://github.com/llvm/llvm-project/pull/142704 is

1. This Triple object file setting should be done in ArchSpec::SetArchitecture, 
so it doesn't depending on hitting an LC_BUILD load command, if anything is 
going to depend on it.
2. There needs to be a way of setting the Triple's object file to MachO 
(because it is defaulting to ELF when we start with just "arm64") without 
adding "-macho" to the triple string.  I don't see a way to do that with the 
llvm Triple methods today.



https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits