[Lldb-commits] [lldb] [lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (PR #127505)

2025-04-04 Thread Alex Bradbury via lldb-commits

asb wrote:

My apologies for missing this before. It is indeed completely valid to have a 
compressed branch immediately after the lr.w or sc.w and remain compliant with 
the forward progress guarantee. I feel I'm lacking a bit of higher level 
understanding of what this code is trying to do it, because:
* It matches only one of many possible lr.[wd]/sc.[wd] sequences. For instance 
we'll have sequences of other integer instructions between the lr and sc for 
e.g. narrower than 32-bit cmpxchg (see 
llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll)
* Why isn't there a a call to m_emu.WriteMem in the implementation?

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


[Lldb-commits] [lldb] [LLDB] Fix tests on Windows (PR #131600)

2025-04-04 Thread Aleksandr Korepanov via lldb-commits


@@ -201,8 +201,15 @@ def test_watch_address_with_invalid_watch_size(self):
 value.GetValueAsUnsigned(), 365, wp_opts, error
 )
 self.assertFalse(watchpoint)
-self.expect(
-error.GetCString(),
-exe=False,
-substrs=["Setting one of the watchpoint resources failed"],
-)
+if self.getPlatform() == "windows":

AlexK0 wrote:

Fixed

https://github.com/llvm/llvm-project/pull/131600
___
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-04-04 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 1/2] 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::vector 

[Lldb-commits] [lldb] control Darwin parallel image loading with target.parallel-module-load (PR #134437)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Tom Yang (zhyty)


Changes

A requested follow-up from https://github.com/llvm/llvm-project/pull/130912 by 
@JDevlieghere to control Darwin parallel image loading with the same 
`target.parallel-module-load` that controls the POSIX dyld parallel image 
loading.

This small change:
* removes 
`plugin.dynamic-loader.darwin.experimental.enable-parallel-image-load` and 
associated code.
* changes setting call site in 
`DynamicLoaderDarwin::PreloadModulesFromImageInfos` to use the new setting.

Tested by running `ninja check-lldb` and loading some targets.

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


8 Files Affected:

- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt (-13) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+1-14) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h (-2) 
- (removed) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp 
(-53) 
- (removed) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.h 
(-34) 
- (removed) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.td 
(-8) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
(+1-7) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (-2) 


``diff
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
index 77a560541fcb1..7308374c8bfba 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
@@ -1,16 +1,7 @@
-lldb_tablegen(DynamicLoaderDarwinProperties.inc -gen-lldb-property-defs
-  SOURCE DynamicLoaderDarwinProperties.td
-  TARGET LLDBPluginDynamicLoaderDarwinPropertiesGen)
-
-lldb_tablegen(DynamicLoaderDarwinPropertiesEnum.inc 
-gen-lldb-property-enum-defs
-  SOURCE DynamicLoaderDarwinProperties.td
-  TARGET LLDBPluginDynamicLoaderDarwinPropertiesEnumGen)
-
 add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN
   DynamicLoaderMacOSXDYLD.cpp
   DynamicLoaderMacOS.cpp
   DynamicLoaderDarwin.cpp
-  DynamicLoaderDarwinProperties.cpp
 
   LINK_LIBS
 lldbBreakpoint
@@ -25,7 +16,3 @@ add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN
 Support
 TargetParser
   )
-
-add_dependencies(lldbPluginDynamicLoaderMacOSXDYLD
-  LLDBPluginDynamicLoaderDarwinPropertiesGen
-  LLDBPluginDynamicLoaderDarwinPropertiesEnumGen)
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index f9b49c50355d5..e25c4ff55e408 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -8,7 +8,6 @@
 
 #include "DynamicLoaderDarwin.h"
 
-#include "DynamicLoaderDarwinProperties.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
@@ -79,17 +78,6 @@ void DynamicLoaderDarwin::DidLaunch() {
   SetNotificationBreakpoint();
 }
 
-void DynamicLoaderDarwin::CreateSettings(lldb_private::Debugger &debugger) {
-  if (!PluginManager::GetSettingForDynamicLoaderPlugin(
-  debugger, DynamicLoaderDarwinProperties::GetSettingName())) {
-const bool is_global_setting = true;
-PluginManager::CreateSettingForDynamicLoaderPlugin(
-debugger,
-DynamicLoaderDarwinProperties::GetGlobal().GetValueProperties(),
-"Properties for the DynamicLoaderDarwin plug-in.", is_global_setting);
-  }
-}
-
 // Clear out the state of this class.
 void DynamicLoaderDarwin::Clear(bool clear_process) {
   std::lock_guard guard(m_mutex);
@@ -670,8 +658,7 @@ DynamicLoaderDarwin::PreloadModulesFromImageInfos(
 image_info, FindTargetModuleForImageInfo(image_info, true, nullptr));
   };
   auto it = image_infos.begin();
-  bool is_parallel_load =
-  DynamicLoaderDarwinProperties::GetGlobal().GetEnableParallelImageLoad();
+  bool is_parallel_load = m_process->GetTarget().GetParallelModuleLoad();
   if (is_parallel_load) {
 llvm::ThreadPoolTaskGroup taskGroup(Debugger::GetThreadPool());
 for (size_t i = 0; i < size; ++i, ++it) {
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index bc5464d76b950..37528b88b615e 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -58,8 +58,6 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
 
   std::optional GetStartAddress() override;
 
-  static void CreateSettings(lldb_private::Debugger &debugger);
-
 protected:
   void 

[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-04-04 Thread Matheus Izvekov via lldb-commits

mizvekov wrote:

@nico thanks, that's landed. Let me know if it's all green now, otherwise we 
proceed with the revert.

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


[Lldb-commits] [lldb] 52de49e - [lldb][debugserver][MacOSX] Work around sanitizer misaligned address errors when reading exception data (#132193)

2025-04-04 Thread via lldb-commits

Author: Michael Buch
Date: 2025-03-21T11:21:29Z
New Revision: 52de49e4b9cd69957b7dc50a5fed061ecd0b0d77

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

LOG: [lldb][debugserver][MacOSX] Work around sanitizer misaligned address 
errors when reading exception data (#132193)

We've been dealing with UBSAN issues around this code for some time now
(see `9c36859b33b386fbfa9599646de1e2ae01158180` and
`1a2122e9e9d1d495fdf337a4a9445b61ca56df6f`). On recent macOS versions, a
UBSAN-enabled debugserver will crash when performing a `memcpy` of the
input `mach_exception_data_t`. The pointer to the beginning of the
exception data may not be aligned on a doubleword boundary, leading to
UBSAN failures such as:
```
$ ./bin/debugserver 0.0.0.0: 
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/build-sanitized-release/tools/lldb/test/Shell/Recognizer/Output/verbose_trap.test.tmp.out
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12:
 runtime error: store to misaligned address 0x00016ddfa634 for type 
'mach_exception_data_type_t *' (aka 'long long *'), which requires 8 byte 
alignment
0x00016ddfa634: note: pointer points here
  02 00 00 00 03 00 01 00  00 00 00 00 11 00 00 00  00 00 00 00 00 00 00 00  08 
00 00 00 00 00 00 00
  ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12
```

Work around these failures by pretending the input data is a `char*`
buffer.

Drive-by changes:
* I factored out some duplicated code into a static
`AppendExceptionData` and made the types consistent

-

Co-authored-by: Jonas Devlieghere 

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachException.cpp
lldb/tools/debugserver/source/MacOSX/MachException.h

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index 659fb2ff8186d..40450c2c9d1ff 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -18,9 +18,25 @@
 #include "PThreadMutex.h"
 #include "SysSignal.h"
 #include 
+#include 
 #include 
 #include 
 
+static void AppendExceptionData(std::vector &out,
+mach_exception_data_t data,
+mach_msg_type_number_t count) {
+  mach_exception_data_type_t buf;
+  for (mach_msg_type_number_t i = 0; i < count; ++i) {
+// The input Data we receive need not be aligned correctly.
+// Perform an unaligned copy by pretending we're dealing with
+// a char* buffer. This is required to work around UBSAN/ASAN
+// "misaligned address" errors.
+auto *src = reinterpret_cast(data + i);
+memcpy(&buf, src, sizeof(mach_exception_data_type_t));
+out.push_back(buf);
+  }
+}
+
 // Routine mach_exception_raise
 extern "C" kern_return_t
 catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread,
@@ -95,20 +111,16 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
-std::vector exc_datas;
-uint64_t tmp;
-for (unsigned i = 0; i < exc_data_count; ++i) {
-  // Perform an unaligned copy.
-  memcpy(&tmp, &exc_data[i], sizeof(uint64_t));
-  exc_datas.push_back(tmp);
-}
+std::vector exc_datas;
+AppendExceptionData(exc_datas, exc_data, exc_data_count);
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
-   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
-   "0x%llx })",
+   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%" PRIx64
+   ", "
+   "0x%" PRIx64 " })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
+   (exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();
@@ -117,7 +129,7 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
 g_message->task_port = task_port;
 g_message->thread_port = thread_port;
 g_message->exc_type = exc_type;
-g_message->AppendExceptionData(exc_data,

[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132234)

2025-04-04 Thread Matheus Izvekov via lldb-commits

mizvekov wrote:

Will need to revert a dependent commit, this needs to revert as well so it goes 
cleanly.

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


[Lldb-commits] [lldb] Reapply LLDB-Telemetry TargetInfo branch (pr/127834) (PR #132043)

2025-04-04 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/132043

>From 9f0a47af2b7fdb90e4fa4cc7f8f97c840af1d2bc Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 19 Mar 2025 10:44:12 -0400
Subject: [PATCH 1/5] Reapply "[LLDB][Telemetry]Define TargetInfo for
 collecting data about a target (#127834)"

This reverts commit 7dbcdd578cd4d37b1f4094dbd17556be6382f1cc.
---
 lldb/include/lldb/Core/Telemetry.h| 74 +--
 lldb/source/Core/Telemetry.cpp| 25 ++-
 .../source/Interpreter/CommandInterpreter.cpp |  2 +-
 lldb/source/Target/Process.cpp| 21 ++
 lldb/source/Target/Target.cpp | 21 ++
 5 files changed, 134 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 29ec36b2d64d1..28897f283dc55 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -23,9 +23,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 namespace lldb_private {
 namespace telemetry {
@@ -46,12 +49,18 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
 // Specifically:
 //  - Length: 8 bits
 //  - First two bits (MSB) must be 11 - the common prefix
+//  - Last two bits (LSB) are reserved for grand-children of LLDBTelemetryInfo
 // If any of the subclass has descendents, those descendents
-// must have their LLDBEntryKind in the similar form (ie., share common prefix)
+// must have their LLDBEntryKind in the similar form (ie., share common prefix
+// and differ by the last two bits)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
-  static const llvm::telemetry::KindType BaseInfo = 0b1100;
-  static const llvm::telemetry::KindType CommandInfo = 0b1101;
-  static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
+  // clang-format off
+  static const llvm::telemetry::KindType BaseInfo= 0b1100;
+  static const llvm::telemetry::KindType CommandInfo = 0b1101;
+  static const llvm::telemetry::KindType DebuggerInfo= 0b11001000;
+  static const llvm::telemetry::KindType ExecModuleInfo  = 0b11000100;
+  static const llvm::telemetry::KindType ProcessExitInfo = 0b11001100;
+  // clang-format on
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -89,7 +98,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
   /// session. Necessary because we'd send off an entry right before a 
command's
   /// execution and another right after. This is to avoid losing telemetry if
   /// the command does not execute successfully.
-  uint64_t command_id;
+  uint64_t command_id = 0;
   /// The command name(eg., "breakpoint set")
   std::string command_name;
   /// These two fields are not collected by default due to PII risks.
@@ -116,7 +125,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
 
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 
-  static uint64_t GetNextId();
+  static uint64_t GetNextID();
 
 private:
   // We assign each command (in the same session) a unique id so that their
@@ -146,6 +155,59 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ExecutableModuleInfo : public LLDBBaseTelemetryInfo {
+  lldb::ModuleSP exec_mod;
+  /// The same as the executable-module's UUID.
+  UUID uuid;
+  /// PID of the process owned by this target.
+  lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+  /// The triple of this executable module.
+  std::string triple;
+
+  /// If true, this entry was emitted at the beginning of an event (eg., before
+  /// the executable is set). Otherwise, it was emitted at the end of an
+  /// event (eg., after the module and any dependency were loaded.)
+  bool is_start_entry = false;
+
+  ExecutableModuleInfo() = default;
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::ExecModuleInfo;
+  }
+
+  static bool classof(const TelemetryInfo *T) {
+// Subclasses of this is also acceptable
+return (T->getKind() & LLDBEntryKind::ExecModuleInfo) ==
+   LLDBEntryKind::ExecModuleInfo;
+  }
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
+/// Describes an exit status.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct ProcessExitInfo : public LLDBBaseTelemetryInfo {
+  // The executable-module's UUID.
+  UUID module_uuid;
+  lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+  bool is_start_entry = false;
+  std::optional exit_desc;
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::ProcessExitInfo;
+  }
+
+  static bool classof(const TelemetryInfo *T) {
+// Subclasses of this is also acceptable
+return (T->getKind() & LLDBEntryKind::ProcessExitInfo) ==
+   LLDBEntryKind::ProcessExitInfo;
+  }
+  void serialize(llvm::t

[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

2025-04-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Adding support for cancelling a request. (PR #130169)

2025-04-04 Thread John Harrison via lldb-commits


@@ -671,11 +693,25 @@ void DAP::SetTarget(const lldb::SBTarget target) {
   }
 }
 
-bool DAP::HandleObject(const protocol::Message &M) {
-  if (const auto *req = std::get_if(&M)) {
+bool DAP::HandleObject(const Message &M) {
+  if (const auto *req = std::get_if(&M)) {
+{
+  std::lock_guard lock(m_active_request_mutex);
+  m_active_request = req;
+
+  // Clear interrupt marker prior to handling the next request.
+  if (debugger.InterruptRequested())
+debugger.CancelInterruptRequest();

ashgti wrote:

Done, we still have this check, but it should be cleared sooner in `Send` as 
well.

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


[Lldb-commits] [lldb] [lldb] Make ELF files able to load section headers from memory. (PR #129166)

2025-04-04 Thread Greg Clayton via lldb-commits


@@ -1477,32 +1506,32 @@ size_t 
ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers,
   }
   if (idx < section_headers.size())
 section_headers.resize(idx);
+  // Sometimes we are able to read the section header memory from an in memory

clayborg wrote:

Normal ELF files, when mapped into a process, will have sometimes or maybe 
always, have the data for the section headers in readable memory, but they are 
all set to zero. So it doesn't make sense to show a ton of `SHT_NULL` sections. 
So we keep one `SHT_NULL` section for the first section and remove the rest. I 
can check to make sure they are all SHT_NULL sections and only remove them if 
they are all SHT_NULL if that would make everyone feel better

https://github.com/llvm/llvm-project/pull/129166
___
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-04-04 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 1/3] 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::vector 

[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Alex Langford via lldb-commits

bulbazord wrote:

> That said, I don't think this code should be here (and I think Alex would 
> agree).

I do agree with this.

> > I was referring more to the other items on the list. I assumed, it seems 
> > incorrectly, that Alex's patch would fix the dependency in the mangler. It 
> > seems like that part still needs to be pluginized, somehow.
> 
> Note Module.cpp still uses `CPlusPlusLanguage::MethodName` in 
> `Module::LookupInfo::Prune()` besides Alex's patch.

These should also be abstracted into plugins then.

We *should* do things "a proper way", otherwise you will see more regressions 
in size because of innocent changes. It's not the responsibility of 
contributors to consider the change in size of lldb-server if they cannot 
reason that their change will impact the size of lldb-server. Until we address 
the circular dependencies between lldb's "core" libraries (lldbCore, 
lldbTarget, lldbSymbol, etc.) and lldb's Plugin libraries, I think you will 
continue playing whack-a-mole to reduce lldb-server's size forever.

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


[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 Thread Julian Lettner via lldb-commits

https://github.com/yln updated https://github.com/llvm/llvm-project/pull/134323

>From 8aa5e0e7f97df7627187bbd8ad4b3df51c798f4f Mon Sep 17 00:00:00 2001
From: Julian Lettner 
Date: Thu, 3 Apr 2025 14:47:53 -0700
Subject: [PATCH 1/5] [LLDB] Update reason for why tests are disabled

---
 lldb/test/API/functionalities/asan/TestMemoryHistory.py | 6 ++
 lldb/test/API/functionalities/asan/TestReportData.py| 6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index b04182a543719..c3f15aefb1d49 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -19,7 +19,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
-@skipIf(bugnumber="rdar://144997976")
+@skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])
@@ -39,9 +39,7 @@ def setUp(self):
 def libsanitizer_tests(self):
 target = self.createTestTarget()
 
-self.runCmd(
-"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
-)
+self.runCmd("env SanitizersAddress=1 MallocSanitizerZone=1")
 
 self.runCmd("run")
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index fabc985d0ed44..52ae199378f3b 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -20,7 +20,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
-@skipIf(bugnumber="rdar://144997976")
+@skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])
@@ -42,9 +42,7 @@ def asan_tests(self, libsanitizers=False):
 target = self.createTestTarget()
 
 if libsanitizers:
-self.runCmd(
-"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
-)
+self.runCmd("env SanitizersAddress=1 MallocSanitizerZone=1")
 else:
 self.registerSanitizerLibrariesWithTarget(target)
 

>From 803214e7ccb5c45a58c90951481af3570bb4be9d Mon Sep 17 00:00:00 2001
From: Julian Lettner 
Date: Thu, 3 Apr 2025 16:07:04 -0700
Subject: [PATCH 2/5] [LLDB] Add integration test for libsanitizers trace
 collection

Add integration test for libsanitizers trace
collection (`SanitizersAllocationTraces=all`).

rdar://144244084
---
 lldb/test/API/functionalities/asan/Makefile   | 11 ++-
 .../functionalities/asan/TestMemoryHistory.py | 88 ---
 .../functionalities/asan/TestReportData.py|  6 +-
 3 files changed, 67 insertions(+), 38 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index d66696fed7078..eae5ca3e4626c 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,8 +1,11 @@
 C_SOURCES := main.c
-asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
-asan: all
+compiler_rt-asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+compiler_rt-asan: all
 
-libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
-libsanitizers: all
+libsanitizers-asan: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi 
-g -gcolumn-info
+libsanitizers-asan: all
+
+libsanitizers-traces: CFLAGS_EXTRAS := -g -gcolumn-info
+libsanitizers-traces: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index c3f15aefb1d49..894235481c440 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -15,17 +15,23 @@ class AsanTestCase(TestBase):
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build(make_targets=["asan"])
+self.build(make_targets=["compiler_rt-asan"])
 self.asan_tests()
 
-@skipIf(oslist=no_match(["macosx"]))
+@skipUnlessDarwin
 @skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
-self.build(make_targets=["libsanitizers"])
+self.build(make_targets=["libsanitizers-asan"])
 except BuildError as e:
 self.skipTest("failed to build with libsanitizers")
-self.libsanitizer_tests()
+self.libsanitizers_asan_tests()
+
+@skipUnlessDarwin
+@skipIf(macos_version=["<", "15.5"])
+def test_libsanitizers_traces(self):
+self.build(make_targets=["libsanitizers-traces"])
+self.libsanitize

[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [RFC][lldb-dap] Always stop on enrty for attaching (PR #134339)

2025-04-04 Thread via lldb-commits

jimingham wrote:

Note, the current stop locker is a `pthread_rwlock_t`.  These locks according 
to the docs I could find are recursive for reading, but not recursive for 
writing.  We need them to be recursive for reading because you want to do:

locker = process.GetStopLocker()
process.GetThreadAtIndex()

and the latter will also acquire need to acquire the stop locker's reader end.

That should be okay since we would only expose the reader side, and we would 
always set the state in the locker on some lldb private thread before running 
any code.  But we might want to make sure that you can't Continue the process 
while still holding the stop locker to keep from having the reader still in 
force when the writer needs to change the value.

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


[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

2025-04-04 Thread Pavel Labath via lldb-commits

labath wrote:

I think it's a good start (thanks for helping out, David), but I don't get the 
removal part. What you actually want to test that it *succeeds* in launching 
the llgs persona, is it not? Wouldn't it be better to *not* remove the 
lldb-server and check that the "run" command actually succeeds? (you can check 
that the debugged binary returns the correct exit code, stops at some 
breakpoint or whatever is easiest)

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


[Lldb-commits] [lldb] [lldb] Add a {ObjectFile, SymbolFile}::GetObjectName method (PR #133370)

2025-04-04 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 Thread Mariusz Borsa via lldb-commits


@@ -36,34 +42,61 @@ def setUp(self):
 self.line_breakpoint = line_number("main.c", "// break line")
 
 # Test line numbers: rdar://126237493
-def libsanitizer_tests(self):
-target = self.createTestTarget()
+# for libsanitizers and remove `skip_line_numbers` parameter
+def check_traces(self, skip_line_numbers):

wrotki wrote:

I think you need to say skip_line_numbers=False here, or you'll get TypeError 
from a call to self.check_traces(), no?

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


[Lldb-commits] [lldb] [lldb] Expose the Target API mutex through the SB API (PR #133295)

2025-04-04 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,57 @@
+//===-- SBMutexTest.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
+//
+//===--===//
+
+// Use the umbrella header for -Wdocumentation.
+#include "lldb/API/LLDB.h"
+
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBTarget.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+class SBMutexTest : public testing::Test {
+protected:
+  void SetUp() override { debugger = SBDebugger::Create(); }
+  void TearDown() override { SBDebugger::Destroy(debugger); }
+
+  SubsystemRAII subsystems;
+  SBDebugger debugger;
+};
+
+TEST_F(SBMutexTest, LockTest) {
+  lldb::SBTarget target = debugger.GetDummyTarget();
+
+  std::future f;
+  {
+std::atomic locked = false;
+lldb::SBMutex lock = target.GetAPIMutex();
+std::lock_guard lock_guard(lock);
+ASSERT_FALSE(locked.exchange(true));
+
+f = std::async(std::launch::async, [&]() {
+  ASSERT_TRUE(locked);
+  target.BreakpointCreateByName("foo", "bar");
+  ASSERT_FALSE(locked);
+});
+ASSERT_TRUE(f.valid());
+
+// Wait 500ms to confirm the thread is blocked.
+auto status = f.wait_for(std::chrono::milliseconds(500));
+ASSERT_EQ(status, std::future_status::timeout);
+
+ASSERT_TRUE(locked.exchange(false));
+  }

JDevlieghere wrote:

I'm building with ASan, but based on your description this should fix it? 

```
diff --git a/lldb/unittests/API/SBMutexTest.cpp 
b/lldb/unittests/API/SBMutexTest.cpp
index 0b888c2725aa..aafad59d58c1 100644
--- a/lldb/unittests/API/SBMutexTest.cpp
+++ b/lldb/unittests/API/SBMutexTest.cpp
@@ -32,10 +32,9 @@ protected:
 
 TEST_F(SBMutexTest, LockTest) {
   lldb::SBTarget target = debugger.GetDummyTarget();
-
+  std::atomic locked = false;
   std::future f;
   {
-std::atomic locked = false;
 lldb::SBMutex lock = target.GetAPIMutex();
 std::lock_guard lock_guard(lock);
 ASSERT_FALSE(locked.exchange(true));
```

If you have a local build to confirm let me know, otherwise I'll put up a PR 
once my build finishes. 

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Disabling asserts locally solved the problem with LLVM_DUMP_METHOD. This patch 
works again. 
I have refactored CPlusPlusLanguage::MethodName and RichManglingContext.
I got the lldb-server size 6MB. Please review. Thanks

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/132274

>From a4d62ca1dfaca8eb29ce7d2809c28137d22416b9 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 20 Mar 2025 21:50:51 +0400
Subject: [PATCH 1/2] [LLDB] Refactor Module::LookupInfo constructor and move
 out CPlusPlusLanguage::MethodName to break lldb-server dependencies

This patch addresses the issue #129543.
After this patch the size of lldb-server is reduced by 9MB.

Based on https://github.com/swiftlang/llvm-project/pull/3240 by @bulbazord Alex 
Langford
---
 lldb/include/lldb/Target/Language.h   |   5 +
 lldb/source/Core/CMakeLists.txt   |   1 -
 lldb/source/Core/Module.cpp   | 130 
 lldb/source/Core/RichManglingContext.cpp  |   2 +-
 .../Clang/ClangExpressionDeclMap.cpp  |  11 +-
 lldb/source/Plugins/Language/CMakeLists.txt   |   2 +
 .../Plugins/Language/CPlusPlus/CMakeLists.txt |   1 +
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 294 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  91 +-
 .../CPlusPlus/CPlusPlusLanguageMethod.cpp | 279 +
 .../CPlusPlus/CPlusPlusLanguageMethod.h   | 106 +++
 .../Plugins/Language/ObjC/ObjCLanguage.cpp|  15 +
 .../Plugins/Language/ObjC/ObjCLanguage.h  |   3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   6 +-
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  |   4 +-
 .../CPlusPlus/CPlusPlusLanguageTest.cpp   |  27 +-
 16 files changed, 524 insertions(+), 453 deletions(-)
 create mode 100644 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguageMethod.cpp
 create mode 100644 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguageMethod.h

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index b699a90aff8e4..d095499bd596e 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -214,6 +214,11 @@ class Language : public PluginInterface {
 return std::vector();
   };
 
+  virtual std::pair
+  GetFunctionNameInfo(ConstString name) const {
+return std::pair{lldb::eFunctionNameTypeNone, llvm::StringRef()};
+  };
+
   /// Returns true iff the given symbol name is compatible with the mangling
   /// scheme of this language.
   ///
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 0a08da0fec230..62390104cd588 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -72,7 +72,6 @@ add_lldb_library(lldbCore
 lldbValueObject
 lldbVersion
 lldbPluginCPlusPlusLanguage
-lldbPluginObjCLanguage
 ${LLDB_CURSES_LIBS}
 
   CLANG_LIBS
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 53dc6fcde0381..43635b7e31ca4 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -52,8 +52,7 @@
 #include "lldb/Host/windows/PosixApi.h"
 #endif
 
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguageMethod.h"
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Compiler.h"
@@ -641,98 +640,75 @@ void Module::FindCompileUnits(const FileSpec &path,
 Module::LookupInfo::LookupInfo(ConstString name,
FunctionNameType name_type_mask,
LanguageType language)
-: m_name(name), m_lookup_name(), m_language(language) {
-  const char *name_cstr = name.GetCString();
+: m_name(name), m_lookup_name(name), m_language(language) {
   llvm::StringRef basename;
-  llvm::StringRef context;
+
+  std::vector languages;
+  auto collect_language_plugins = [&languages](Language *lang) {
+languages.push_back(lang);
+return true;
+  };
 
   if (name_type_mask & eFunctionNameTypeAuto) {
-if (CPlusPlusLanguage::IsCPPMangledName(name_cstr))
-  m_name_type_mask = eFunctionNameTypeFull;
-else if ((language == eLanguageTypeUnknown ||
-  Language::LanguageIsObjC(language)) &&
- ObjCLanguage::IsPossibleObjCMethodName(name_cstr))
-  m_name_type_mask = eFunctionNameTypeFull;
-else if (Language::LanguageIsC(language)) {
-  m_name_type_mask = eFunctionNameTypeFull;
+if (language == eLanguageTypeUnknown) {
+  Language::ForEach(collect_language_plugins);
+  for (Language *lang : languages) {
+auto info = lang->GetFunctionNameInfo(name);
+if (info.first != eFunctionNameTypeNone) {
+  m_name_type_mask |= info.first;
+  basename = info.second;
+  break;
+}
+  }
 } else {
-  if ((language == eLanguageTypeUnknown ||
-   Language::LanguageIsObjC(language)) &&
-  ObjCLanguage::IsPossibleObjCSelector(name_cstr))
-m_name_type_mask |= eFunctionNameTypeSelector;
-
-  CPlusPlusLanguage::MethodName cpp_method(name);
-  basename = cpp_method.GetBasename();
-  if (basename.empty()) 

[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 Thread Julian Lettner via lldb-commits

https://github.com/yln updated https://github.com/llvm/llvm-project/pull/134323

>From 8aa5e0e7f97df7627187bbd8ad4b3df51c798f4f Mon Sep 17 00:00:00 2001
From: Julian Lettner 
Date: Thu, 3 Apr 2025 14:47:53 -0700
Subject: [PATCH 1/4] [LLDB] Update reason for why tests are disabled

---
 lldb/test/API/functionalities/asan/TestMemoryHistory.py | 6 ++
 lldb/test/API/functionalities/asan/TestReportData.py| 6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index b04182a543719..c3f15aefb1d49 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -19,7 +19,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
-@skipIf(bugnumber="rdar://144997976")
+@skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])
@@ -39,9 +39,7 @@ def setUp(self):
 def libsanitizer_tests(self):
 target = self.createTestTarget()
 
-self.runCmd(
-"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
-)
+self.runCmd("env SanitizersAddress=1 MallocSanitizerZone=1")
 
 self.runCmd("run")
 
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index fabc985d0ed44..52ae199378f3b 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -20,7 +20,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
-@skipIf(bugnumber="rdar://144997976")
+@skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])
@@ -42,9 +42,7 @@ def asan_tests(self, libsanitizers=False):
 target = self.createTestTarget()
 
 if libsanitizers:
-self.runCmd(
-"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
-)
+self.runCmd("env SanitizersAddress=1 MallocSanitizerZone=1")
 else:
 self.registerSanitizerLibrariesWithTarget(target)
 

>From 803214e7ccb5c45a58c90951481af3570bb4be9d Mon Sep 17 00:00:00 2001
From: Julian Lettner 
Date: Thu, 3 Apr 2025 16:07:04 -0700
Subject: [PATCH 2/4] [LLDB] Add integration test for libsanitizers trace
 collection

Add integration test for libsanitizers trace
collection (`SanitizersAllocationTraces=all`).

rdar://144244084
---
 lldb/test/API/functionalities/asan/Makefile   | 11 ++-
 .../functionalities/asan/TestMemoryHistory.py | 88 ---
 .../functionalities/asan/TestReportData.py|  6 +-
 3 files changed, 67 insertions(+), 38 deletions(-)

diff --git a/lldb/test/API/functionalities/asan/Makefile 
b/lldb/test/API/functionalities/asan/Makefile
index d66696fed7078..eae5ca3e4626c 100644
--- a/lldb/test/API/functionalities/asan/Makefile
+++ b/lldb/test/API/functionalities/asan/Makefile
@@ -1,8 +1,11 @@
 C_SOURCES := main.c
-asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
-asan: all
+compiler_rt-asan: CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
+compiler_rt-asan: all
 
-libsanitizers: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi -g 
-gcolumn-info
-libsanitizers: all
+libsanitizers-asan: CFLAGS_EXTRAS := -fsanitize=address -fsanitize-stable-abi 
-g -gcolumn-info
+libsanitizers-asan: all
+
+libsanitizers-traces: CFLAGS_EXTRAS := -g -gcolumn-info
+libsanitizers-traces: all
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index c3f15aefb1d49..894235481c440 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -15,17 +15,23 @@ class AsanTestCase(TestBase):
 @expectedFailureNetBSD
 @skipUnlessAddressSanitizer
 def test(self):
-self.build(make_targets=["asan"])
+self.build(make_targets=["compiler_rt-asan"])
 self.asan_tests()
 
-@skipIf(oslist=no_match(["macosx"]))
+@skipUnlessDarwin
 @skipIf(bugnumber="rdar://109913184&143590169")
 def test_libsanitizers_asan(self):
 try:
-self.build(make_targets=["libsanitizers"])
+self.build(make_targets=["libsanitizers-asan"])
 except BuildError as e:
 self.skipTest("failed to build with libsanitizers")
-self.libsanitizer_tests()
+self.libsanitizers_asan_tests()
+
+@skipUnlessDarwin
+@skipIf(macos_version=["<", "15.5"])
+def test_libsanitizers_traces(self):
+self.build(make_targets=["libsanitizers-traces"])
+self.libsanitize

[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 Thread Julian Lettner via lldb-commits


@@ -36,35 +42,59 @@ def setUp(self):
 self.line_breakpoint = line_number("main.c", "// break line")
 
 # Test line numbers: rdar://126237493
-def libsanitizer_tests(self):
-target = self.createTestTarget()
-
-self.runCmd(
-"env SanitizersAddress=1 MallocSanitizerZone=1 
MallocSecureAllocator=0"
-)
-
-self.runCmd("run")
-
-# In libsanitizers, memory history is not supported until a report has 
been generated
-self.expect(
-"thread list",
-"Process should be stopped due to ASan report",
-substrs=["stopped", "stop reason = Use of deallocated memory"],
-)
-
-# test the 'memory history' command
+# for libsanitizers and remove `skip_line_numbers` parameter
+def check_traces(self, skip_line_numbers=False):
 self.expect(
 "memory history 'pointer'",
 substrs=[
 "Memory deallocated by Thread",
 "a.out`f2",
-"main.c",
+"main.c" if skip_line_numbers else f"main.c:{self.line_free}",
 "Memory allocated by Thread",
 "a.out`f1",
-"main.c",
+"main.c" if skip_line_numbers else 
f"main.c:{self.line_malloc}",
 ],
 )
 
+# Set breakpoint after free, but before bug
+def set_breakpoint(self):
+self.runCmd(f"breakpoint set -f main.c -l {self.line_breakpoint}")

yln wrote:

Addressed by: 7d65214

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


[Lldb-commits] [lldb] [lldb] Add a {ObjectFile, SymbolFile}::GetObjectName method (PR #133370)

2025-04-04 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/133370

>From 8af1b715a2d2dd19f8ff374c1fcc4c513a2e6fed Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 4 Apr 2025 13:02:57 -0700
Subject: [PATCH 1/2] [lldb] Add a {ObjectFile,SymbolFile}::GetObjectName
 method

Add ObjectFile::GetObjectName and SymbolFile::GetObjectName to retrieve
the name of the object file, including the `.a` for static libraries.

We currently do something similar in CommandObjectTarget, but the code
for dumping this is a lot more involved than what's being offered by the
new method. We have options to print he full path, the base name, and
the directoy of the path and trim it to a specific width.
---
 lldb/include/lldb/Symbol/ObjectFile.h| 1 +
 lldb/include/lldb/Symbol/SymbolFile.h| 2 ++
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 7 +--
 lldb/source/Symbol/ObjectFile.cpp| 9 +
 lldb/source/Symbol/SymbolFile.cpp| 8 
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 874926da2ceb7..cfcca04a76de8 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -748,6 +748,7 @@ class ObjectFile : public 
std::enable_shared_from_this,
 
   static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size,
 uint64_t Offset);
+  std::string GetObjectName() const;
 
 protected:
   // Member variables.
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index dd056035d546e..f35d3ee9f22ae 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -491,6 +491,8 @@ class SymbolFile : public PluginInterface {
 return args;
   }
 
+  std::string GetObjectName() const;
+
 protected:
   void AssertModuleLock();
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index ce351274b4576..961c212e2e6dc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -727,12 +727,7 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
 Progress::kDefaultHighFrequencyReportTime);
   for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
-  progress.Increment(oso_idx, oso_dwarf->GetObjectFile()
-  ? oso_dwarf->GetObjectFile()
-->GetFileSpec()
-.GetFilename()
-.GetString()
-  : "");
+  progress.Increment(oso_idx, oso_dwarf->GetObjectName());
   if (closure(*oso_dwarf) == IterationAction::Stop)
 return;
 }
diff --git a/lldb/source/Symbol/ObjectFile.cpp 
b/lldb/source/Symbol/ObjectFile.cpp
index 264acad050e35..2f2c59d6af620 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -775,6 +775,15 @@ uint32_t ObjectFile::GetCacheHash() {
   return *m_cache_hash;
 }
 
+std::string ObjectFile::GetObjectName() const {
+  if (ModuleSP module_sp = GetModule())
+if (ConstString object_name = module_sp->GetObjectName())
+  return llvm::formatv("{0}({1})", GetFileSpec().GetFilename().GetString(),
+   object_name.GetString())
+  .str();
+  return GetFileSpec().GetFilename().GetString();
+}
+
 namespace llvm {
 namespace json {
 
diff --git a/lldb/source/Symbol/SymbolFile.cpp 
b/lldb/source/Symbol/SymbolFile.cpp
index 16ed98d7840f7..9353d651b4b13 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -12,7 +12,9 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolFileOnDemand.h"
+#include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/TypeMap.h"
 #include "lldb/Symbol/TypeSystem.h"
 #include "lldb/Symbol/VariableList.h"
@@ -259,3 +261,9 @@ void SymbolFileCommon::Dump(Stream &s) {
   if (Symtab *symtab = GetSymtab())
 symtab->Dump(&s, nullptr, eSortOrderNone);
 }
+
+std::string SymbolFile::GetObjectName() const {
+  if (const ObjectFile *object_file = GetObjectFile())
+return object_file->GetObjectName();
+  return "";
+}

>From 2c2d35a8ea718dc66fc6d7ef40314a4950f25323 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 4 Apr 2025 15:51:55 -0700
Subject: [PATCH 2/2] Remove includes clangd added

---
 lldb/source/Symbol/SymbolFile.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lldb/source/Symbol/

[Lldb-commits] [lldb] [lldb-dap] Replace GetBreakpointLabel with kDAPBreakpointLabel constant (NFC) (PR #133746)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Replace GetBreakpointLabel with kDAPBreakpointLabel constant to avoid an 
unnecessary function call.

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


5 Files Affected:

- (modified) lldb/tools/lldb-dap/Breakpoint.cpp (+1-3) 
- (modified) lldb/tools/lldb-dap/BreakpointBase.cpp (-16) 
- (modified) lldb/tools/lldb-dap/BreakpointBase.h (+15-1) 
- (modified) lldb/tools/lldb-dap/ExceptionBreakpoint.cpp (+1-3) 
- (modified) lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp (+4-4) 


``diff
diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
index b3bfa61595a82..eba534dcc51c7 100644
--- a/lldb/tools/lldb-dap/Breakpoint.cpp
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -72,9 +72,7 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) 
{
 bool Breakpoint::MatchesName(const char *name) { return bp.MatchesName(name); }
 
 void Breakpoint::SetBreakpoint() {
-  // See comments in BreakpointBase::GetBreakpointLabel() for details of why
-  // we add a label to our breakpoints.
-  bp.AddName(GetBreakpointLabel());
+  bp.AddName(kDAPBreakpointLabel);
   if (!condition.empty())
 SetCondition();
   if (!hitCondition.empty())
diff --git a/lldb/tools/lldb-dap/BreakpointBase.cpp 
b/lldb/tools/lldb-dap/BreakpointBase.cpp
index 7979bac098766..15fecaf691199 100644
--- a/lldb/tools/lldb-dap/BreakpointBase.cpp
+++ b/lldb/tools/lldb-dap/BreakpointBase.cpp
@@ -26,19 +26,3 @@ void BreakpointBase::UpdateBreakpoint(const BreakpointBase 
&request_bp) {
 SetHitCondition();
   }
 }
-
-const char *BreakpointBase::GetBreakpointLabel() {
-  // Breakpoints in LLDB can have names added to them which are kind of like
-  // labels or categories. All breakpoints that are set through the IDE UI get
-  // sent through the various DAP set*Breakpoint packets, and these
-  // breakpoints will be labeled with this name so if breakpoint update events
-  // come in for breakpoints that the IDE doesn't know about, like if a
-  // breakpoint is set manually using the debugger console, we won't report any
-  // updates on them and confused the IDE. This function gets called by all of
-  // the breakpoint classes after they set breakpoints to mark a breakpoint as
-  // a UI breakpoint. We can later check a lldb::SBBreakpoint object that comes
-  // in via LLDB breakpoint changed events and check the breakpoint by calling
-  // "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a
-  // breakpoint in one of the UI breakpoints that we should report changes for.
-  return "dap";
-}
diff --git a/lldb/tools/lldb-dap/BreakpointBase.h 
b/lldb/tools/lldb-dap/BreakpointBase.h
index 3c248dd1736d0..0b036dd1985b3 100644
--- a/lldb/tools/lldb-dap/BreakpointBase.h
+++ b/lldb/tools/lldb-dap/BreakpointBase.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
 
 #include "DAPForward.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 
 namespace lldb_dap {
@@ -34,7 +35,20 @@ struct BreakpointBase {
 
   void UpdateBreakpoint(const BreakpointBase &request_bp);
 
-  static const char *GetBreakpointLabel();
+  /// Breakpoints in LLDB can have names added to them which are kind of like
+  /// labels or categories. All breakpoints that are set through DAP get sent
+  /// through the various DAP set*Breakpoint packets, and these breakpoints 
will
+  /// be labeled with this name so if breakpoint update events come in for
+  /// breakpoints that the client doesn't know about, like if a breakpoint is
+  /// set manually using the debugger console, we won't report any updates on
+  /// them and confused the client. This label gets added by all of the
+  /// breakpoint classes after they set breakpoints to mark a breakpoint as a
+  /// DAP breakpoint. We can later check a lldb::SBBreakpoint object that comes
+  /// in via LLDB breakpoint changed events and check the breakpoint by calling
+  /// "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a
+  /// breakpoint in one of the DAP breakpoints that we should report changes
+  /// for.
+  static constexpr const char *kDAPBreakpointLabel = "dap";
 };
 
 } // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp 
b/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp
index 0fb865c19e574..15aee55ad923e 100644
--- a/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp
+++ b/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp
@@ -20,9 +20,7 @@ void ExceptionBreakpoint::SetBreakpoint() {
   bool throw_value = filter.find("_throw") != std::string::npos;
   bp = dap.target.BreakpointCreateForException(language, catch_value,
throw_value);
-  // See comments in BreakpointBase::GetBreakpointLabel() for details of why
-  // we add a label to our breakpoints.
-  bp.AddName(BreakpointBase::GetBreakpointLabel());
+  bp.AddName(BreakpointBase::kDAPBreakpointLabel);
 }
 
 void ExceptionBreakp

[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

2025-04-04 Thread Yuval Deutscher via lldb-commits

yuvald-sweet-security wrote:

Yea, these tests only test the `lldb` binary, as evident from lit: 
https://github.com/yuvald-sweet-security/llvm-project/blob/main/lldb/test/API/lit.cfg.py#L247-L248

Do you know if there are any tests that run lldb-server? I couldn't find 
anything by grepping the repo

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


[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)

2025-04-04 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/functionalities/asan/TestMemoryHistory.py 
lldb/test/API/functionalities/asan/TestReportData.py
``





View the diff from darker here.


``diff
--- TestMemoryHistory.py2025-04-04 23:10:05.00 +
+++ TestMemoryHistory.py2025-04-04 23:13:34.229548 +
@@ -57,13 +57,11 @@
 )
 
 # Set breakpoint: after free, but before bug
 def set_breakpoint(self, target):
 bkpt = target.BreakpointCreateByLocation("main.c", 
self.line_breakpoint)
-self.assertGreater(
-bkpt.GetNumLocations(), 0, "Set the breakpoint successfully"
-)
+self.assertGreater(bkpt.GetNumLocations(), 0, "Set the breakpoint 
successfully")
 
 def run_to_breakpoint(self, target):
 self.set_breakpoint(target)
 self.runCmd("run")
 self.expect(

``




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


[Lldb-commits] [lldb] [lldb] Add a {ObjectFile, SymbolFile}::GetObjectName method (PR #133370)

2025-04-04 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] 5271dea - [lldb] Add a {ObjectFile, SymbolFile}::GetObjectName method (#133370)

2025-04-04 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-04T16:33:40-07:00
New Revision: 5271dead61dca30f4a6db0f0df8da00f8987449e

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

LOG: [lldb] Add a {ObjectFile,SymbolFile}::GetObjectName method (#133370)

Add ObjectFile::GetObjectName and SymbolFile::GetObjectName to retrieve
the name of the object file, including the `.a` for static libraries.

We currently do something similar in CommandObjectTarget, but the code
for dumping this is a lot more involved than what's being offered by the
new method. We have options to print he full path, the base name, and
the directoy of the path and trim it to a specific width. 

This is motivated by #133211, where Greg pointed out that the old code
would print the static archive (the .a file) rather than the actual
object file inside of it.

Added: 


Modified: 
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/SymbolFile.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 874926da2ceb7..cfcca04a76de8 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -748,6 +748,7 @@ class ObjectFile : public 
std::enable_shared_from_this,
 
   static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size,
 uint64_t Offset);
+  std::string GetObjectName() const;
 
 protected:
   // Member variables.

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index dd056035d546e..f35d3ee9f22ae 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -491,6 +491,8 @@ class SymbolFile : public PluginInterface {
 return args;
   }
 
+  std::string GetObjectName() const;
+
 protected:
   void AssertModuleLock();
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index ce351274b4576..961c212e2e6dc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -727,12 +727,7 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
 Progress::kDefaultHighFrequencyReportTime);
   for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
-  progress.Increment(oso_idx, oso_dwarf->GetObjectFile()
-  ? oso_dwarf->GetObjectFile()
-->GetFileSpec()
-.GetFilename()
-.GetString()
-  : "");
+  progress.Increment(oso_idx, oso_dwarf->GetObjectName());
   if (closure(*oso_dwarf) == IterationAction::Stop)
 return;
 }

diff  --git a/lldb/source/Symbol/ObjectFile.cpp 
b/lldb/source/Symbol/ObjectFile.cpp
index 264acad050e35..2f2c59d6af620 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -775,6 +775,15 @@ uint32_t ObjectFile::GetCacheHash() {
   return *m_cache_hash;
 }
 
+std::string ObjectFile::GetObjectName() const {
+  if (ModuleSP module_sp = GetModule())
+if (ConstString object_name = module_sp->GetObjectName())
+  return llvm::formatv("{0}({1})", GetFileSpec().GetFilename().GetString(),
+   object_name.GetString())
+  .str();
+  return GetFileSpec().GetFilename().GetString();
+}
+
 namespace llvm {
 namespace json {
 

diff  --git a/lldb/source/Symbol/SymbolFile.cpp 
b/lldb/source/Symbol/SymbolFile.cpp
index 16ed98d7840f7..94e32b55572dd 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -259,3 +259,9 @@ void SymbolFileCommon::Dump(Stream &s) {
   if (Symtab *symtab = GetSymtab())
 symtab->Dump(&s, nullptr, eSortOrderNone);
 }
+
+std::string SymbolFile::GetObjectName() const {
+  if (const ObjectFile *object_file = GetObjectFile())
+return object_file->GetObjectName();
+  return "";
+}



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


[Lldb-commits] [lldb] [lldb] Make `RegisterContextThreadMemory` thread safe (PR #134469)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

The UpdateRegisterContext method can be called from multiple threads.

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


2 Files Affected:

- (modified) 
lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp (+2) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h 
(+2) 


``diff
diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 75438550ce914..29927e3b5e4ed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -25,6 +25,8 @@ RegisterContextThreadMemory::RegisterContextThreadMemory(
 RegisterContextThreadMemory::~RegisterContextThreadMemory() = default;
 
 void RegisterContextThreadMemory::UpdateRegisterContext() {
+  std::lock_guard lock(m_update_register_ctx_lock);
+
   ThreadSP thread_sp(m_thread_wp.lock());
   if (thread_sp) {
 ProcessSP process_sp(thread_sp->GetProcess());
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 23f675508cf38..1df32bbc1f057 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -99,6 +99,8 @@ class RegisterContextThreadMemory : public 
lldb_private::RegisterContext {
   RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete;
   const RegisterContextThreadMemory &
   operator=(const RegisterContextThreadMemory &) = delete;
+
+  std::mutex m_update_register_ctx_lock;
 };
 
 } // namespace lldb_private

``




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


[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Peixotto (dmpots)


Changes

This is an attempt to fix a test failure from #133794 when running on 
windows builds. I suspect we are running into a case where the 
[ICF](https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170)
 optimization kicks in and combines the CreateSystemRuntimePlugin* functions 
into a single address. This means that we cannot uniquely unregister the plugin 
based on its create function address.

The fix is have each create function return a different (bogus) value.

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


1 Files Affected:

- (modified) lldb/unittests/Core/PluginManagerTest.cpp (+17-3) 


``diff
diff --git a/lldb/unittests/Core/PluginManagerTest.cpp 
b/lldb/unittests/Core/PluginManagerTest.cpp
index ca1003ca9a85a..9b0ce2286d273 100644
--- a/lldb/unittests/Core/PluginManagerTest.cpp
+++ b/lldb/unittests/Core/PluginManagerTest.cpp
@@ -7,11 +7,21 @@ using namespace lldb;
 using namespace lldb_private;
 
 // Mock system runtime plugin create functions.
-SystemRuntime *CreateSystemRuntimePluginA(Process *process) { return nullptr; }
+// Make them all return different values to avoid the ICF optimization
+// from combining them into the same function. The values returned
+// are not valid SystemRuntime pointers, but they are unique and
+// sufficient for testing.
+SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
+  return (SystemRuntime *)0x1;
+}
 
-SystemRuntime *CreateSystemRuntimePluginB(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
+  return (SystemRuntime *)0x2;
+}
 
-SystemRuntime *CreateSystemRuntimePluginC(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
+  return (SystemRuntime *)0x3;
+}
 
 // Test class for testing the PluginManager.
 // The PluginManager modifies global state when registering new plugins. This
@@ -24,6 +34,10 @@ class PluginManagerTest : public testing::Test {
 
   // Add mock system runtime plugins for testing.
   void RegisterMockSystemRuntimePlugins() {
+// Make sure the create functions all have different addresses.
+ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
+ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);
+
 ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
   CreateSystemRuntimePluginA));
 ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",

``




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


[Lldb-commits] [lldb] [lldb] Make `RegisterContextThreadMemory` thread safe (PR #134469)

2025-04-04 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] 6272e1f - [lldb] Make `RegisterContextThreadMemory` thread safe (#134469)

2025-04-04 Thread via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2025-04-04T18:43:31-07:00
New Revision: 6272e1f37e0710b51d38cb98b905a3f2ffea7966

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

LOG: [lldb] Make `RegisterContextThreadMemory` thread safe (#134469)

The UpdateRegisterContext method can be called from multiple threads.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 75438550ce914..29927e3b5e4ed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -25,6 +25,8 @@ RegisterContextThreadMemory::RegisterContextThreadMemory(
 RegisterContextThreadMemory::~RegisterContextThreadMemory() = default;
 
 void RegisterContextThreadMemory::UpdateRegisterContext() {
+  std::lock_guard lock(m_update_register_ctx_lock);
+
   ThreadSP thread_sp(m_thread_wp.lock());
   if (thread_sp) {
 ProcessSP process_sp(thread_sp->GetProcess());

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 23f675508cf38..1df32bbc1f057 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -99,6 +99,8 @@ class RegisterContextThreadMemory : public 
lldb_private::RegisterContext {
   RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete;
   const RegisterContextThreadMemory &
   operator=(const RegisterContextThreadMemory &) = delete;
+
+  std::mutex m_update_register_ctx_lock;
 };
 
 } // namespace lldb_private



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


[Lldb-commits] [lldb] [lldb] Make `RegisterContextThreadMemory` thread safe (PR #134469)

2025-04-04 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

2025-04-04 Thread Yuval Deutscher via lldb-commits

https://github.com/yuvald-sweet-security updated 
https://github.com/llvm/llvm-project/pull/131609

>From 6f2d070facaced221295a5b0c48ccb3a41a5048d Mon Sep 17 00:00:00 2001
From: Yuval Deutscher 
Date: Mon, 17 Mar 2025 14:37:26 +0200
Subject: [PATCH 1/2] [lldb] Use correct path for debugserver

---
 lldb/tools/lldb-server/SystemInitializerLLGS.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-server/SystemInitializerLLGS.h 
b/lldb/tools/lldb-server/SystemInitializerLLGS.h
index 4469a8ba5f60a..c6020b0dd37da 100644
--- a/lldb/tools/lldb-server/SystemInitializerLLGS.h
+++ b/lldb/tools/lldb-server/SystemInitializerLLGS.h
@@ -11,10 +11,17 @@
 
 #include "lldb/Initialization/SystemInitializer.h"
 #include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Utility/FileSpec.h"
 
 class SystemInitializerLLGS : public lldb_private::SystemInitializerCommon {
 public:
-  SystemInitializerLLGS() : SystemInitializerCommon(nullptr) {}
+  SystemInitializerLLGS()
+  : SystemInitializerCommon(
+// Finding the shared libraries directory on lldb-server is broken
+// since lldb-server isn't dynamically linked with liblldb.so.
+// Clearing the filespec here causes GetShlibDir to fail and
+// GetSupportExeDir to fall-back to using the binary path instead.
+[](lldb_private::FileSpec &file) { file.Clear(); }) {}
 
   llvm::Error Initialize() override;
   void Terminate() override;

>From fcc85b8e28052a49edb1c933c22d9d7ddc95485a Mon Sep 17 00:00:00 2001
From: Yuval Deutscher 
Date: Thu, 3 Apr 2025 14:52:43 +0300
Subject: [PATCH 2/2] [lldb] Test running lldb-server through symlink

---
 .../TestPlatformLaunchGDBServer.py| 43 +++
 1 file changed, 43 insertions(+)

diff --git 
a/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
 
b/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
index c365bc993e338..e2f20a658e6e2 100644
--- 
a/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
+++ 
b/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
@@ -4,6 +4,7 @@
 """
 
 import os
+import signal
 import socket
 import shutil
 import lldbgdbserverutils
@@ -58,3 +59,45 @@ def test_platform_process_launch_gdb_server(self):
 
 self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
 self.expect("run", substrs=["unable to launch a GDB server on"], 
error=True)
+
+@skipIfRemote
+@skipUnlessPlatform(["linux"])
+@add_test_categories(["lldb-server"])
+def test_lldb_server_weird_symlinks(self):
+self.build()
+
+hostname = socket.getaddrinfo("localhost", 0, 
proto=socket.IPPROTO_TCP)[0][4][0]
+listen_url = "[%s]:0" % hostname
+
+port_file = self.getBuildArtifact("port")
+commandline_args = [
+"platform",
+"--listen",
+listen_url,
+"--socket-file",
+port_file,
+]
+
+# Run lldb-server from a symlink without any binary called 
"lldb-server" in the directory.
+llgs_hiding_directory = self.getBuildArtifact("hiding-directory")
+new_lldb_server_link = self.getBuildArtifact(
+"lldb-server-with-an-unconventional-name"
+)
+new_lldb_server = os.path.join(llgs_hiding_directory, "lldb-server")
+os.makedirs(llgs_hiding_directory)
+shutil.copy(lldbgdbserverutils.get_lldb_server_exe(), new_lldb_server)
+os.symlink(new_lldb_server, new_lldb_server_link)
+
+proc = self.spawnSubprocess(new_lldb_server_link, commandline_args)
+socket_id = lldbutil.wait_for_file_on_target(self, port_file)
+
+new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
+self.dbg.SetSelectedPlatform(new_platform)
+
+connect_url = "connect://[%s]:%s" % (hostname, socket_id)
+self.runCmd("platform connect %s" % connect_url)
+self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
+self.runCmd("run")
+
+# So that lldb-server doesn't crash over SIGHUP
+os.kill(proc.pid, signal.SIGTERM)

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


[Lldb-commits] [lldb] [lldb] Make `RegisterContextThreadMemory` thread safe (PR #134469)

2025-04-04 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/134469

The UpdateRegisterContext method can be called from multiple threads.

>From ef59ad0f6522e5ca35cfeed562fc528b4732fb22 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Fri, 4 Apr 2025 18:28:00 -0700
Subject: [PATCH] [lldb] Make `RegisterContextThreadMemory` thread safe

The UpdateRegisterContext method can be called from multiple threads.
---
 .../Plugins/Process/Utility/RegisterContextThreadMemory.cpp | 2 ++
 .../Plugins/Process/Utility/RegisterContextThreadMemory.h   | 2 ++
 2 files changed, 4 insertions(+)

diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 75438550ce914..29927e3b5e4ed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -25,6 +25,8 @@ RegisterContextThreadMemory::RegisterContextThreadMemory(
 RegisterContextThreadMemory::~RegisterContextThreadMemory() = default;
 
 void RegisterContextThreadMemory::UpdateRegisterContext() {
+  std::lock_guard lock(m_update_register_ctx_lock);
+
   ThreadSP thread_sp(m_thread_wp.lock());
   if (thread_sp) {
 ProcessSP process_sp(thread_sp->GetProcess());
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 23f675508cf38..1df32bbc1f057 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -99,6 +99,8 @@ class RegisterContextThreadMemory : public 
lldb_private::RegisterContext {
   RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete;
   const RegisterContextThreadMemory &
   operator=(const RegisterContextThreadMemory &) = delete;
+
+  std::mutex m_update_register_ctx_lock;
 };
 
 } // namespace lldb_private

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


[Lldb-commits] [lldb] 554f4d1 - [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (#134097)

2025-04-04 Thread via lldb-commits

Author: Michael Buch
Date: 2025-04-03T11:10:16+01:00
New Revision: 554f4d1a5769357ee8438c23f572d595c720ff3c

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

LOG: [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame 
if one exists (#134097)

When using `SBFrame::EvaluateExpression` on a frame that's not the
currently selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

During expression parsing, we call `RunStaticInitializers`. On our
internal fork this happens quite frequently because any usage of, e.g.,
function pointers, will inject ptrauth fixup code into the expression.
The static initializers are run using `RunThreadPlan`. The
`ExecutionContext::m_frame_sp` going into the `RunThreadPlan` is the
`SBFrame` that we called `EvaluateExpression` on. LLDB then tries to
save this frame to restore it after the thread-plan ran (the restore
occurs by unconditionally overwriting whatever is in
`ExecutionContext::m_frame_sp`). However, if the `selected_frame_sp` is
not the same as the `SBFrame`, then `RunThreadPlan` would set the
`ExecutionContext`'s frame to a different frame than what we started
with. When we `PrepareToExecuteJITExpression`, LLDB checks whether the
`ExecutionContext` frame changed from when we initially
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the
fix because our ptrauth static initializers code isn't upstream yet. But
the plan is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the
incoming `ExecutionContext`, if such frame exists. Otherwise, fall back
to using the selected frame.

rdar://147456589

Added: 
lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile

lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
lldb/test/API/commands/expression/expr-from-non-zero-frame/main.c

Modified: 
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 7936cf28467b2..2adda309dea9c 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5080,7 +5080,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
 return eExpressionSetupError;
   }
 
-  StackID ctx_frame_id = selected_frame_sp->GetStackID();
+  // If the ExecutionContext has a frame, we want to make sure to save/restore
+  // that frame into exe_ctx. This can happen when we run expressions from a
+  // non-selected SBFrame, in which case we don't want some thread-plan
+  // to overwrite the ExecutionContext frame.
+  StackID ctx_frame_id = exe_ctx.HasFrameScope()
+ ? exe_ctx.GetFrameRef().GetStackID()
+ : selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
   // We don't want to do that either, so we should arrange to reset them as

diff  --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
new file mode 100644
index 0..9b1bcfb177765
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
@@ -0,0 +1,30 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprFromNonZeroFrame(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test(self):
+"""
+Tests that we can use SBFrame::EvaluateExpression on a frame
+that we're not stopped in, even if thread-plans run as part of
+parsing the expression (e.g., when running static initializers).
+"""
+self.build()
+
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+self, "Break here", lldb.SBFileSpec("main.c")
+)
+frame = thread.GetFrameAtIndex(1)
+
+# Using a function pointer inside the expression ensures we
+# emit a ptrauth static initializer on arm64e into the JITted
+# expression. The thread-plan that runs for this static
+# i

[Lldb-commits] [lldb] [LLDB] Fix tests on Windows (PR #131600)

2025-04-04 Thread Pavel Labath via lldb-commits


@@ -63,7 +63,7 @@ def execute(self, test, litConfig):
 try:
 out, err, exitCode = lit.util.executeCommand(
 cmd,
-env=test.config.environment,
+env={**os.environ, **test.config.environment},

labath wrote:

Instead of this, you probably want to find the variable which controls this 
behavior, and add it to the list in test/API/lit.cfg.py

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


[Lldb-commits] [lldb] [lldb][debugserver] remove g/G packet handling from debugserver (PR #132127)

2025-04-04 Thread Felipe de Azevedo Piovezan via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [LLDB][NFC] Added the interface DWARFExpression::Delegate to break dependencies and reduce lldb-server size (PR #131645)

2025-04-04 Thread Pavel Labath via lldb-commits


@@ -40,6 +35,31 @@ class DWARFUnit;
 /// location expression or a location list and interprets it.
 class DWARFExpression {
 public:
+  class Delegate {
+  public:
+Delegate() = default;
+virtual ~Delegate() = default;
+
+virtual uint16_t GetVersion() const = 0;
+virtual dw_addr_t GetBaseAddress() const = 0;
+virtual uint8_t GetAddressByteSize() const = 0;
+virtual llvm::Error GetDIEBitSizeAndSign(uint64_t die_offset,
+ uint64_t &bit_size,
+ bool &sign) = 0;

labath wrote:

```suggestion
virtual llvm::Expected> 
GetDIEBitSizeAndSign(uint64_t relative_die_offset) const = 0;
```

(I'm prioritizing the interface over implementation, so I'm making the method 
const. You can put the const_cast into the implementation (I think it's only 
needed for `GetDIE`. I am also emphasizing the relativeness of the die offset 
as lldb default is to use absolute section offsets)

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


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-04-04 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/131304

>From 106e137fea7d4b420ce3d97a8df16c3a91400997 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Fri, 14 Mar 2025 02:51:21 -0500
Subject: [PATCH 1/3] Support for XCOFF Sections

---
 .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp  | 153 +-
 1 file changed, 114 insertions(+), 39 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index b54d43c5dd737..0dd9126468923 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -190,50 +190,125 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
-void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {}
-
-void ObjectFileXCOFF::Dump(Stream *s) {}
-
-ArchSpec ObjectFileXCOFF::GetArchitecture() {
-  ArchSpec arch_spec =
-  ArchSpec(eArchTypeXCOFF, XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE);
-  return arch_spec;
+void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+
+  if (m_sections_up)
+return;
+  m_sections_up = std::make_unique();
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+
+ModuleSP module_sp(GetModule());
+for (auto sIdx = m_binary->section_begin(); sIdx != 
m_binary->section_end();
+ ++sIdx) {
+  llvm::Expected name =
+  m_binary->getSectionName(sIdx->getRawDataRefImpl());
+  if (!name) {
+llvm::Error err = name.takeError();
+  }
+  llvm::StringRef sect_name = *name;
+  ConstString const_sect_name(sect_name);
+  int sect_index = sIdx->getIndex(), idx = 1;
+  llvm::Expected section =
+  m_binary->getSectionByNum(sect_index);
+  if (!section) {
+llvm::Error err = section.takeError();
+  }
+  llvm::object::DataRefImpl dataref = section.get();
+  const llvm::object::XCOFFSectionHeader64 *sectionPtr =
+  reinterpret_cast(
+  dataref.p);
+
+  SectionType section_type = lldb::eSectionTypeOther;
+  if (sectionPtr->Flags & XCOFF::STYP_TEXT)
+section_type = eSectionTypeCode;
+  if (sectionPtr->Flags & XCOFF::STYP_DATA)
+section_type = eSectionTypeData;
+  if (sectionPtr->Flags & XCOFF::STYP_BSS)
+section_type = eSectionTypeZeroFill;
+  if (sectionPtr->Flags & XCOFF::STYP_DWARF) {
+SectionType section_type =
+llvm::StringSwitch(sect_name)
+.Case(".dwinfo", eSectionTypeDWARFDebugInfo)
+.Case(".dwline", eSectionTypeDWARFDebugLine)
+.Case(".dwabrev", eSectionTypeDWARFDebugAbbrev)
+.Default(eSectionTypeInvalid);
+
+if (section_type == eSectionTypeInvalid)
+  section_type = lldb::eSectionTypeOther;
+  }
+  SectionSP section_sp(new Section(
+  module_sp,   // Module to which this section belongs
+  this,// Object file to which this section belongs
+  idx++,   // Section ID is the 1 based section index.
+  const_sect_name, // Name of this section
+  section_type,
+  sectionPtr->VirtualAddress,  // File VM address == addresses as
+   // they are found in the object file
+  sectionPtr->SectionSize, // VM size in bytes of this section
+  sectionPtr->FileOffsetToRawData, // Offset to the data for this
+   // section in the file
+  sectionPtr->SectionSize, // Size in bytes of this section as found in
+   // the file
+  0,   // FIXME: alignment
+  sectionPtr->Flags)); // Flags for this section
+
+  uint32_t permissions = 0;
+  permissions |= ePermissionsReadable;
+  if (sectionPtr->Flags & (XCOFF::STYP_DATA | XCOFF::STYP_BSS))
+permissions |= ePermissionsWritable;
+  if (sectionPtr->Flags & XCOFF::STYP_TEXT)
+permissions |= ePermissionsExecutable;
+  section_sp->SetPermissions(permissions);
+
+  m_sections_up->AddSection(section_sp);
+  unified_section_list.AddSection(section_sp);
+}
+  }
 }
+  void ObjectFileXCOFF::Dump(Stream * s) {}
 
-UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
+  ArchSpec ObjectFileXCOFF::GetArchitecture() {
+ArchSpec arch_spec =
+ArchSpec(eArchTypeXCOFF, XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE);
+return arch_spec;
+  }
 
-uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; 
}
+  UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
 
-ObjectFile::Type ObjectFileXCOFF::CalculateType() {
-  if (m_binary->fileHeader64()->Flags & XCOFF::F_EXEC)
-return eTypeExecutable;
-  else if (m_binary->fileHeader

[Lldb-commits] [lldb] [lldb-dap] Stop the process for the threads request (PR #134456)

2025-04-04 Thread via lldb-commits

kusmour wrote:

Thanks a lot for the comments and draft. I will go a head with the option 3!

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Dhruv Srivastava via lldb-commits


@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp

DhruvSrivastavaX wrote:

In the original draft PR, we have a copy file from linux for aix as well. 
Shall we use the linux version to avoid redundant code, or create a new one for 
aix? 
For the NativeProcessAIX, we are using the linux/Support.cpp as of now.

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Dhruv Srivastava via lldb-commits


@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+

DhruvSrivastavaX wrote:

You can remove this blank line and run clang format once to keep all the 
includes together in order.

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


[Lldb-commits] [lldb] [RFC][lldb-dap] Always stop on enrty for attaching (PR #134339)

2025-04-04 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Pavel Labath via lldb-commits

labath wrote:

I'm not sure what has changed. This code has been here since 2022, so I suspect 
it's one of those "perfectly reasonable" changes I mentioned earlier.

That said, I don't think this code should be here (and I think Alex would 
agree). It should probably go into some kind of a plugin. We have the ability 
to add new commands from (some) plugins. Their names tend to be rather long, 
but that's okay since this appears to be a internal/debugging command. 
@kastiglione, WDYT?

Another way to attack this would be to remove the 
SystemLifetimeManager->Debugger dependency. I'm not quite sure what it does, 
but it shouldn't be here because lldb-server does not need the Debugger. It 
might be possible to move this into `SystemInitializerFull`. I'm also not sure 
if this will help you, as I expect something else will pull in the Debugger 
object anyway.

(and of course, there's always the refactoring I mentioned previously)

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Pavel Labath via lldb-commits

labath wrote:

> are used in the following files except Module.cpp:
> 
> ```
> source/Core/RichManglingContext.cpp
> source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
> source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
> ```

The question here is who is using those files and why. These are all plugins, 
so they shouldn't be pulled in unless they are `Initialized`.

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> I was referring more to the other items on the list. I assumed, it seems 
> incorrectly, that Alex's patch would fix the dependency in the mangler. It 
> seems like that part still needs to be pluginized, somehow.

Note Module.cpp still uses `CPlusPlusLanguage::MethodName` in 
`Module::LookupInfo::Prune()` besides Alex's patch.

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


[Lldb-commits] [lldb] Add DAP tests for initialized event to be sure stats are present (PR #134266)

2025-04-04 Thread via lldb-commits

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


[Lldb-commits] [lldb] e4f76e3 - Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " (#134246)

2025-04-04 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-04-04T09:49:27+02:00
New Revision: e4f76e3a3335dda608c661d76efacc70e607a5e4

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

LOG: Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " 
(#134246)

This reverts commit 094904303d50e0ab14bc5f2586a602f79af95953, reapplying
d7afafdbc464e65c56a0a1d77bad426aa7538306 (#133247).

The failure ought to be fixed by
0509932bb6a291ba11253f30c465ab3ad164ae08.

Added: 


Modified: 
lldb/include/lldb/Symbol/FuncUnwinders.h
lldb/include/lldb/Symbol/UnwindPlan.h
lldb/include/lldb/Target/RegisterContextUnwind.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Symbol/FuncUnwinders.cpp
lldb/source/Symbol/UnwindPlan.cpp
lldb/source/Target/RegisterContextUnwind.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/FuncUnwinders.h 
b/lldb/include/lldb/Symbol/FuncUnwinders.h
index 1d4c28324e90f..479ccf87b6e2c 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -36,18 +36,19 @@ class FuncUnwinders {
 
   ~FuncUnwinders();
 
-  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread);
+  std::shared_ptr GetUnwindPlanAtCallSite(Target &target,
+Thread &thread);
 
-  lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
-lldb_private::Thread &thread);
+  std::shared_ptr
+  GetUnwindPlanAtNonCallSite(Target &target, lldb_private::Thread &thread);
 
-  lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
- lldb_private::Thread &thread);
+  std::shared_ptr
+  GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread);
 
-  lldb::UnwindPlanSP
+  std::shared_ptr
   GetUnwindPlanArchitectureDefault(lldb_private::Thread &thread);
 
-  lldb::UnwindPlanSP
+  std::shared_ptr
   GetUnwindPlanArchitectureDefaultAtFunctionEntry(lldb_private::Thread 
&thread);
 
   Address &GetFirstNonPrologueInsn(Target &target);
@@ -77,32 +78,34 @@ class FuncUnwinders {
   // used. Instead, clients should ask for the *behavior* they are looking for,
   // using one of the above UnwindPlan retrieval methods.
 
-  lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread);
+  std::shared_ptr GetAssemblyUnwindPlan(Target &target,
+  Thread &thread);
 
-  lldb::UnwindPlanSP GetObjectFileUnwindPlan(Target &target);
+  std::shared_ptr GetObjectFileUnwindPlan(Target &target);
 
-  lldb::UnwindPlanSP GetObjectFileAugmentedUnwindPlan(Target &target,
-  Thread &thread);
+  std::shared_ptr
+  GetObjectFileAugmentedUnwindPlan(Target &target, Thread &thread);
 
-  lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target);
+  std::shared_ptr GetEHFrameUnwindPlan(Target &target);
 
-  lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
-   Thread &thread);
+  std::shared_ptr
+  GetEHFrameAugmentedUnwindPlan(Target &target, Thread &thread);
 
-  lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target);
+  std::shared_ptr GetDebugFrameUnwindPlan(Target &target);
 
-  lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target,
-  Thread &thread);
+  std::shared_ptr
+  GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread);
 
-  lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target);
+  std::shared_ptr GetCompactUnwindUnwindPlan(Target &target);
 
-  lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target);
+  std::shared_ptr GetArmUnwindUnwindPlan(Target &target);
 
-  lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread);
+  std::shared_ptr GetSymbolFileUnwindPlan(Thread &thread);
 
-  lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread);
+  std::shared_ptr GetArchDefaultUnwindPlan(Thread &thread);
 
-  lldb::UnwindPlanSP GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
+  std::shared_ptr
+  GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
 
 private:
   lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target);
@@ -113,7 +116,8 @@ class FuncUnwinders {
   // unwind rule for the pc, and LazyBoolCalculate if it was unable to
   // determine this for some reason.
   lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation(
-  Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP 
&b);
+  Thread &thread, const std::shared_ptr &a,
+  const std::shared_ptr &b);
 
   UnwindTable &m_unwind_table;
 
@@ -129,22 +133,22 @@ class FuncUnwinders {
 
   std::recursi

[Lldb-commits] [lldb] Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " (PR #134246)

2025-04-04 Thread Pavel Labath via lldb-commits

labath wrote:

> I wasn't able to reproduce the problem locally either, but I've got the same 
> failing tests with the same stack traces by setting
> 
> ```
> const UnwindPlan::Row *active_row = (const UnwindPlan::Row *) 0x1;
> ```


Good idea. Thanks for trying it out.

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Hemang Gadhavi via lldb-commits

https://github.com/HemangGadhavi created 
https://github.com/llvm/llvm-project/pull/134354

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added changes to get the host information for AIX. (GetProcessInfo()) 
(Information like : executable path, arch, process status etc.)
[@DavidSpickett](https://github.com/DavidSpickett) 
[@labath](https://github.com/labath) 
[@DhruvSrivastavaX](https://github.com/DhruvSrivastavaX)

>From e7b3d8d95477f96b4c1b1a2bbec5cce49f4c15cd Mon Sep 17 00:00:00 2001
From: HemangGadhavi 
Date: Fri, 4 Apr 2025 00:59:17 -0500
Subject: [PATCH] [lldb][AIX] get host info for AIX

---
 lldb/source/Host/CMakeLists.txt |   1 +
 lldb/source/Host/aix/Host.cpp   | 156 +++-
 2 files changed, 156 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index a2ae6f1430c38..a02b1c104396e 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index 751c4fbcc9368..6ba3e05348df1 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd")

[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Hemang Gadhavi (HemangGadhavi)


Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added changes to get the host information for AIX. (GetProcessInfo()) 
(Information like : executable path, arch, process status etc.)
[@DavidSpickett](https://github.com/DavidSpickett) [@labath](https://github.com/labath) [@DhruvSrivastavaX](https://github.com/DhruvSrivastavaX)

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


2 Files Affected:

- (modified) lldb/source/Host/CMakeLists.txt (+1) 
- (modified) lldb/source/Host/aix/Host.cpp (+155-1) 


``diff
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index a2ae6f1430c38..a02b1c104396e 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index 751c4fbcc9368..6ba3e05348df1 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd").toVector(ProcExe);
+
+  ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
+  if (len > 0) {
+ExePath.resize(len);
+
+  

[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

Hi Team, 

@HemangGadhavi from my ibm aix team will be helping me out in some of the 
merging process, as per our decided guidelines. Please provide your review.

Thanks!
Dhruv Srivastava

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Pavel Labath via lldb-commits

labath wrote:

> > The question here is who is using those files and why. These are all 
> > plugins, so they shouldn't be pulled in unless they are `Initialized`.
> 
> RichManglingContext.cpp is not a plugin and it uses `m_cxx_method_parser = 
> new CPlusPlusLanguage::MethodName(demangled);`, including casting 
> `get(m_cxx_method_parser)`. We can move 
> `CPlusPlusLanguage::MethodName` from CPlusPlusLanguage plugin to core, but it 
> still depends on CPlusPlusNameParser.cpp

I was referring more to the other items on the list. I assumed, it seems 
incorrectly, that Alex's patch would fix the dependency in the mangler. It 
seems like that part still needs to be pluginized, somehow.

> 
> > Another way to attack this would be to remove the 
> > SystemLifetimeManager->Debugger dependency.
> 
> I tried it. `SystemLifetimeManager` calls `Debugger::Initialize(nullptr);` 
> and `Debugger::Terminate();`. `Debugger::Initialize()` creates a mutex and an 
> empty list of debuggers. But it seems the Debugger instance is created while 
> a remote process is running. I'm not sure lldb-server can work w/o Debugger. 
> It also contains a lot of I/O handling code and thread pools. Anyway the 
> class Debugger is used directly in many places. We can start making the class 
> Debugger an interface and move the implementation to the new class 
> DebuggerImpl or such.


I'm actually very much opposed to that. lldb-server not need/use a Debugger, 
nor a thread pool nor any IO handling present in that file. I wouldn't want to 
create a Debugger "plugin" for the sake of lldb-server. It should be cut off 
above that.

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Pavel Labath via lldb-commits


@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp

labath wrote:

I'd move those functions into the `posix` folder given that other systems have 
similar functionality (besides AIX, freebsd also seems to have something 
similar, albeit deprecated). The functions don't do anything unless they are 
called, and they're quite simple, so it shouldn't hurt having them even if not 
all OSes have that functionality.

We might want to keep the three-arg overload (with pid+tid) linux specific -- I 
don't know if any other system has that.

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


[Lldb-commits] [clang] [libcxxabi] [lldb] [llvm] [WIP][lldb] Alternative implementation of more reliable function call infrastructure (PR #115245)

2025-04-04 Thread Michael Buch via lldb-commits

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

>From 63ca211312cd9dcbf28d30866a429262b504bdb3 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 5 Nov 2024 00:22:07 +
Subject: [PATCH] Init

---
 clang/include/clang/Basic/Attr.td |   7 +
 clang/include/clang/Basic/AttrDocs.td |   5 +
 clang/lib/AST/Mangle.cpp  |  16 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  11 ++
 libcxxabi/src/demangle/ItaniumDemangle.h  |   2 +
 lldb/source/Expression/IRExecutionUnit.cpp| 186 ++
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  29 ++-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  12 +-
 llvm/include/llvm/Demangle/Demangle.h |   1 +
 llvm/include/llvm/Demangle/ItaniumDemangle.h  |   2 +
 llvm/lib/Demangle/ItaniumDemangle.cpp |  17 +-
 11 files changed, 275 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fd9e686485552..d72ae1fd80e81 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -812,6 +812,13 @@ def AbiTag : Attr {
   let Documentation = [AbiTagsDocs];
 }
 
+def StructorName : Attr {
+let Spellings = [Clang<"structor_name">];
+let Args = [StringArgument<"Name">];
+let Subjects = SubjectList<[Function], ErrorDiag>;
+let Documentation = [StructorNameDocs];
+}
+
 def AddressSpace : TypeAttr {
   let Spellings = [Clang<"address_space">];
   let Args = [IntArgument<"AddressSpace">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index c8b371280e35d..32eec4d2f8b79 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4067,6 +4067,11 @@ manipulating bits of the enumerator when issuing 
warnings.
   }];
 }
 
+def StructorNameDocs : Documentation {
+let Category = DocCatDecl;
+let Content = [{ TODO }];
+}
+
 def AsmLabelDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index b44ab23f1d0e1..124b06a430e69 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -125,7 +125,7 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl 
*D) {
 
   // Any decl can be declared with __asm("foo") on it, and this takes 
precedence
   // over all other naming in the .o file.
-  if (D->hasAttr())
+  if (D->hasAttr() || D->hasAttr())
 return true;
 
   // Declarations that don't have identifier names always need to be mangled.
@@ -139,6 +139,20 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream 
&Out) {
   const ASTContext &ASTContext = getASTContext();
   const NamedDecl *D = cast(GD.getDecl());
 
+  if (const auto *SNA = D->getAttr()) {
+Out << SNA->getName() << ':';
+
+if (isa(D)) {
+  Out << 'C';
+  Out << GD.getCtorType();
+} else {
+  Out << 'D';
+  Out << GD.getDtorType();
+}
+
+return;
+  }
+
   // Any decl can be declared with __asm("foo") on it, and this takes 
precedence
   // over all other naming in the .o file.
   if (const AsmLabelAttr *ALA = D->getAttr()) {
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 0b844b44930b9..9906131c684bc 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1730,6 +1730,14 @@ static void handleIFuncAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
 }
 
+static void handleStructorNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
+return;
+
+  D->addAttr(::new (S.Context) StructorNameAttr(S.Context, AL, Str));
+}
+
 static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   StringRef Str;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
@@ -7532,6 +7540,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
 S.HLSL().handleParamModifierAttr(D, AL);
 break;
 
+  case ParsedAttr::AT_StructorName:
+handleStructorNameAttr(S, D, AL);
+break;
   case ParsedAttr::AT_AbiTag:
 handleAbiTagAttr(S, D, AL);
 break;
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..9ae7c1160d2e9 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -1750,6 +1750,8 @@ class CtorDtorName final : public Node {
 
   template void match(Fn F) const { F(Basename, IsDtor, Variant); 
}
 
+  int getVariant() const { return Variant; }
+
   void printLeft(OutputBuffer &OB) const override {
 if (IsDtor)
   OB += "~";
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 06b0cb7769f64..1056195b108fb 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/

[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Dhruv Srivastava via lldb-commits


@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd").toVector(ProcExe);
+
+  ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
+  if (len > 0) {
+ExePath.resize(len);
+
+struct stat statData;
+

DhruvSrivastavaX wrote:

Delete the extra blank lines.

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


[Lldb-commits] [lldb] a2e888f - [LLDB][NFC]Fix stack-use-after free bug. (#134296)

2025-04-04 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-04-04T08:00:46-04:00
New Revision: a2e888f5b49113c66b055290cb7069ae88c9d2e1

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

LOG: [LLDB][NFC]Fix stack-use-after free bug. (#134296)

Details: detailed_command_telemetry (bool) and command_id (int) could
already be freed when the dispatcher's dtor runs. So we should just copy
them into the lambda since they are cheap.

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 949b1191c28f0..112d2f20fda41 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1918,7 +1918,9 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
 // Those will be collected by the on-exit-callback.
   });
 
-  helper.DispatchOnExit([&](lldb_private::telemetry::CommandInfo *info) {
+  helper.DispatchOnExit([&cmd_obj, &parsed_command_args, &result,
+ detailed_command_telemetry, command_id](
+lldb_private::telemetry::CommandInfo *info) {
 // TODO: this is logging the time the command-handler finishes.
 // But we may want a finer-grain durations too?
 // (ie., the execute_time recorded below?)



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


[Lldb-commits] [lldb] [LLDB][NFC]Fix stack-use-after free bug. (PR #134296)

2025-04-04 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

I think this is a trivial enough fix - i'm going to just merge it.

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


[Lldb-commits] [lldb] Reapply "[lldb] Return *const* UnwindPlan pointers from FuncUnwinders " (PR #134246)

2025-04-04 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

We have a tests for this function in `unittests/Host/linux/HostTest.cpp` and it 
looks like at least some of it should apply to other systems as well. We could 
move it to the "posix" folder so that it applies to your code as well. 
Depending on the size of linux-specific parts, we could either keep them in the 
"linux" folder, or `#ifdef` them out

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Pavel Labath via lldb-commits


@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd").toVector(ProcExe);
+
+  ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
+  if (len > 0) {
+ExePath.resize(len);
+
+struct stat statData;
+
+std::ostringstream oss;
+
+oss << "/proc/" << std::dec << pid << "/psinfo";
+assert(stat(oss.str().c_str(), &statData) == 0);
+
+const int fd = open(oss.str().c_str(), O_RDONLY);
+assert(fd >= 0);
+
+ssize_t readNum = read(fd, &psinfoData, sizeof(psinfoData));
+assert(readNum >= 0);
+
+close(fd);

labath wrote:

This could be done with `getProcFile`, right?

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Pavel Labath via lldb-commits


@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd").toVector(ProcExe);

labath wrote:

cwd??

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


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-04 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] Parallelize module loading in POSIX dyld code (PR #130912)

2025-04-04 Thread Tom Yang via lldb-commits

https://github.com/zhyty updated 
https://github.com/llvm/llvm-project/pull/130912

>From fbf25b1cd4f6d527944fb85fc4d2d03498755a05 Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Mon, 10 Mar 2025 17:58:17 -0700
Subject: [PATCH 1/5] Add option for enabling/disabling parallel load

Add a setting to gate the new parallel dynamic library loading feature in the 
next diff. I followed the example of 
`lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp` and 
`lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp` to 
create a scoped setting for the new feature.

NOTE: this setting defaults to FALSE.

Users should be able to enable the new feature as easily as adding a line to 
their .lldbinit file, or manually setting it in their session.

```
(lldb) apropos "POSIX dynamic"
No commands found pertaining to 'POSIX dynamic'. Try 'help' to see a complete 
list of debugger commands.

The following settings variables may relate to 'POSIX dynamic':
  plugin.dynamic-loader.posix-dyld.parallel-module-load -- Enable experimental 
loading of modules in parallel for the POSIX dynamic loader.
(lldb) settings show plugin.dynamic-loader.posix-dyld.parallel-module-load
plugin.dynamic-loader.posix-dyld.parallel-module-load (boolean) = false
(lldb) settings set plugin.dynamic-loader.posix-dyld.parallel-module-load true
(lldb) settings show plugin.dynamic-loader.posix-dyld.parallel-module-load
plugin.dynamic-loader.posix-dyld.parallel-module-load (boolean) = true
```
---
 .../DynamicLoader/POSIX-DYLD/CMakeLists.txt   | 12 +
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 49 ++-
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.h   |  2 +
 .../DynamicLoaderPOSIXDYLDProperties.td   |  8 +++
 4 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLDProperties.td

diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
index c1e00b2dd444f..532bfb20ea0f1 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
@@ -1,3 +1,11 @@
+lldb_tablegen(DynamicLoaderPOSIXDYLDProperties.inc -gen-lldb-property-defs
+  SOURCE DynamicLoaderPOSIXDYLDProperties.td
+  TARGET LLDBPluginDynamicLoaderPOSIXDYLDPropertiesGen)
+
+lldb_tablegen(DynamicLoaderPOSIXDYLDPropertiesEnum.inc 
-gen-lldb-property-enum-defs
+  SOURCE DynamicLoaderPOSIXDYLDProperties.td
+  TARGET LLDBPluginDynamicLoaderPOSIXDYLDPropertiesEnumGen)
+
 add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
   DYLDRendezvous.cpp
   DynamicLoaderPOSIXDYLD.cpp
@@ -13,3 +21,7 @@ add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
   LINK_COMPONENTS
 Support
   )
+
+add_dependencies(lldbPluginDynamicLoaderPosixDYLD
+  LLDBPluginDynamicLoaderPOSIXDYLDPropertiesGen
+  LLDBPluginDynamicLoaderPOSIXDYLDPropertiesEnumGen)
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 53ba11ac21bd3..c89d16649922d 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -34,9 +34,56 @@ using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE_ADV(DynamicLoaderPOSIXDYLD, DynamicLoaderPosixDYLD)
 
+namespace {
+
+#define LLDB_PROPERTIES_dynamicloaderposixdyld
+#include "DynamicLoaderPOSIXDYLDProperties.inc"
+
+enum {
+#define LLDB_PROPERTIES_dynamicloaderposixdyld
+#include "DynamicLoaderPOSIXDYLDPropertiesEnum.inc"
+};
+
+class PluginProperties : public Properties {
+public:
+  static llvm::StringRef GetSettingName() {
+return DynamicLoaderPOSIXDYLD::GetPluginNameStatic();
+  }
+
+  PluginProperties() : Properties() {
+m_collection_sp = 
std::make_shared(GetSettingName());
+m_collection_sp->Initialize(g_dynamicloaderposixdyld_properties);
+  }
+
+  ~PluginProperties() override = default;
+
+  bool GetParallelModuleLoad() const {
+const uint32_t idx = ePropertyParallelModuleLoad;
+return GetPropertyAtIndexAs(idx, true);
+  }
+};
+
+} // namespace
+
+static PluginProperties &GetGlobalPluginProperties() {
+  static PluginProperties g_settings;
+  return g_settings;
+}
+
 void DynamicLoaderPOSIXDYLD::Initialize() {
   PluginManager::RegisterPlugin(GetPluginNameStatic(),
-GetPluginDescriptionStatic(), CreateInstance);
+GetPluginDescriptionStatic(), CreateInstance,
+&DebuggerInitialize);
+}
+
+void DynamicLoaderPOSIXDYLD::DebuggerInitialize(Debugger &debugger) {
+  if (!PluginManager::GetSettingForDynamicLoaderPlugin(
+  debugger, PluginProperties::GetSettingName())) {
+const bool is_global_setting = true;
+PluginManager::CreateSettingForDynamicLoaderPlugin(
+debugger, GetGlobal

[Lldb-commits] [lldb] d4002b4 - [lldb] Skip Expression NonZeroFrame test on Windows

2025-04-04 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-04-04T14:32:48Z
New Revision: d4002b43f517fea0292bf71dccaa3d0f6dd798b9

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

LOG: [lldb] Skip Expression NonZeroFrame test on Windows

It is failing on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/7605

Will investigate later.

Added: 


Modified: 

lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
index 623c5b87f14c7..bc3f0459bd649 100644
--- 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
+++ 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
@@ -7,6 +7,8 @@
 class ExprFromNonZeroFrame(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+# Expression fails to evaluate on Windows, for unknown reasons.
+@skipIfWindows
 def test(self):
 """
 Tests that we can use SBFrame::EvaluateExpression on a frame



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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Note currently I see the following Debugger dependencies in lldb-server:
```
std::__1::__throw_bad_weak_ptr[abi:nn21](): referenced by Section.cpp 
lldb_private::Section::GetLoadBaseAddress(lldb_private::Target*) const
lldb_private::Debugger::GetCurrentProgressReport() const: referenced by 
FormatEntity.cpp 
lldb_private::FormatEntity::Format(lldb_private::FormatEntity::Entry const&, 
lldb_private::Stream&, lldb_private::SymbolContext const*, 
lldb_private::ExecutionContext const*, lldb_private::Address const*, 
lldb_private::ValueObject*, bool, bool)
lldb_private::Debugger::GetDisassemblyFormat() const: referenced by 
ThreadPlanTracer.cpp lldb_private::ThreadPlanAssemblyTracer::Log()
lldb_private::Debugger::GetSelectedExecutionContext(): referenced by 
CommandInterpreter.cpp lldb_private::CommandInterpreter::GetExecutionContext() 
const
lldb_private::Debugger::ReportWarning(std::__1::basic_string, std::__1::allocator>, 
std::__1::optional, std::__1::once_flag*): referenced by 
Module.cpp 
lldb_private::Module::ReportWarningUnsupportedLanguage(lldb::LanguageType, 
std::__1::optional)
```

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> The question here is who is using those files and why. These are all plugins, 
> so they shouldn't be pulled in unless they are `Initialized`.

RichManglingContext.cpp is not a plugin and it uses `m_cxx_method_parser = new 
CPlusPlusLanguage::MethodName(demangled);`, including casting 
`get(m_cxx_method_parser)`. We can move 
`CPlusPlusLanguage::MethodName` from CPlusPlusLanguage plugin to core, but it 
still depends on CPlusPlusNameParser.cpp

> Another way to attack this would be to remove the 
> SystemLifetimeManager->Debugger dependency.

I tried it. `SystemLifetimeManager` calls `Debugger::Initialize(nullptr);` and 
`Debugger::Terminate();`. `Debugger::Initialize()` creates a mutex and an empty 
list of debuggers. But it seems the Debugger instance is created while a remote 
process is running. I'm not sure lldb-server can work w/o Debugger. It also 
contains a lot of I/O handling code and thread pools. Anyway the class Debugger 
is used directly in many places. We can start making the class Debugger an 
interface and move the implementation to the new class DebuggerImpl or such.

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


[Lldb-commits] [lldb] [LLDB][NFC]Fix stack-use-after free bug. (PR #134296)

2025-04-04 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] 87bebd3 - [LLDB][NFC]Move fields that might be referenced in scope-exit to beginning (#133785)

2025-04-04 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-04-02T10:19:12-04:00
New Revision: 87bebd37ffe08c4911d9636ab09cb1406d7ac677

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

LOG: [LLDB][NFC]Move fields that might be referenced in scope-exit to beginning 
(#133785)

Details: The ScopedDiscpatcher's dtor may reference these fields so we
need the fields' dtor to be be invoked *after* the dispatcher's.

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index e0bf5520e16ef..949b1191c28f0 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1886,6 +1886,13 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
LazyBool lazy_add_to_history,
CommandReturnObject &result,
bool force_repeat_command) {
+  // These are assigned later in the function but they must be declared before
+  // the ScopedDispatcher object because we need their destructions to occur
+  // after the dispatcher's dtor call, which may reference them.
+  // TODO: This function could be refactored?
+  std::string parsed_command_args;
+  CommandObject *cmd_obj = nullptr;
+
   telemetry::ScopedDispatcher helper(&m_debugger);
   const bool detailed_command_telemetry =
   telemetry::TelemetryManager::GetInstance()
@@ -1896,8 +1903,6 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
   std::string command_string(command_line);
   std::string original_command_string(command_string);
   std::string real_original_command_string(command_string);
-  std::string parsed_command_args;
-  CommandObject *cmd_obj = nullptr;
 
   helper.DispatchNow([&](lldb_private::telemetry::CommandInfo *info) {
 info->command_id = command_id;



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


[Lldb-commits] [lldb] [SBProgress] Add swig support for `with` statement in Python (PR #133527)

2025-04-04 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

> > @JDevlieghere @bulbazord Is there a Discourse on the recent changes to the 
> > terminal colors? On Linux I'm getting this white bar that crosses the whole 
> > terminal. I think this is part of your reverse video change Jonas? 
> > ![image](https://private-user-images.githubusercontent.com/25160653/428218316-95783b29-99a2-4423-bdc6-b2243790c328.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDMyMDE0OTgsIm5iZiI6MTc0MzIwMTE5OCwicGF0aCI6Ii8yNTE2MDY1My80MjgyMTgzMTYtOTU3ODNiMjktOTlhMi00NDIzLWJkYzYtYjIyNDM3OTBjMzI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAzMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMzI4VDIyMzMxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU5NDA5MjEyOGMwYTkwNDI3NTJlYTc2YmY0NDIwMjRhMzIzMGEzOGU0OWJkM2UxMGMwZTcwMjljZmExNjM0OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PmF7xP1gbFA2IYclCxw3MuDyjjQTdoEOS2ReWIQcbDc)
> 
> Yes, what you're seeing is the new 
> [Statusline](https://discourse.llvm.org/t/rfc-lldb-statusline/83948/14). The 
> reverse video change (#133315) just changes the default color. Based on your 
> screenshot, that looks expected.

Neat! While I don't love the reverse video, is there an easier way to update 
the status line color other than setting the entire format like so?

```
settings set statusline-format "${ansi.bg.blue}{${target.file.basename}}{ | 
${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ 
| {${progress.count} }${progress.message}}"
```

If not, I'd love to contribute to make this a bit easier to update the color. 
Otherwise it's really neat!

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


[Lldb-commits] [lldb] [lldb] Convert Breakpoint & Watchpoints structs to classes (NFC) (PR #133780)

2025-04-04 Thread John Harrison via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Use correct path for lldb-server executable (PR #131519)

2025-04-04 Thread Yuval Deutscher via lldb-commits

yuvald-sweet-security wrote:

@JDevlieghere @labath how do I get this PR merged? I don't think I have access 
to merge on my own; will one of you merge it, or am I missing something here? 

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


[Lldb-commits] [lldb] [lldb] Remove raw access to PluginInstances vector (PR #132884)

2025-04-04 Thread David Peixotto via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/134383

It reduces the memory usage in lldb-server.
Later I will try to remove the rest Debugger dependencies to reduce lldb-server 
size.

>From 629601c6c1e974e7981d2e61583c69540bf1cd5c Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 4 Apr 2025 17:49:07 +0400
Subject: [PATCH] [LLDB][NFC] Remove Debugger dependency in
 SystemLifetimeManager

It reduces the memory usage in lldb-server.
Later I will try to remove the rest Debugger dependencies to reduce lldb-server 
size.
---
 .../Initialization/SystemLifetimeManager.h|  5 ++-
 .../Initialization/SystemLifetimeManagerDbg.h | 36 +++
 lldb/source/API/SBDebugger.cpp|  4 +--
 .../Initialization/SystemLifetimeManager.cpp  |  5 ++-
 lldb/tools/lldb-test/lldb-test.cpp|  4 +--
 5 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h

diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
index 06328e60133fe..55138b33be712 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
@@ -21,7 +21,7 @@ namespace lldb_private {
 class SystemLifetimeManager {
 public:
   SystemLifetimeManager();
-  ~SystemLifetimeManager();
+  virtual ~SystemLifetimeManager();
 
   llvm::Error Initialize(std::unique_ptr initializer,
  LoadPluginCallbackType plugin_callback);
@@ -32,6 +32,9 @@ class SystemLifetimeManager {
   std::unique_ptr m_initializer;
   bool m_initialized = false;
 
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) {};
+  virtual void TerminateDebugger() {};
+
   // Noncopyable.
   SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
   SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = 
delete;
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
new file mode 100644
index 0..81e0b9a382b70
--- /dev/null
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
@@ -0,0 +1,36 @@
+//===-- SystemLifetimeManagerDbg.h --*- C++ 
-*-===//
+//
+// 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_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+
+#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Core/Debugger.h"
+
+namespace lldb_private {
+
+class SystemLifetimeManagerDbg : SystemLifetimeManager {
+public:
+  SystemLifetimeManagerDbg() : SystemLifetimeManager() {};
+
+private:
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) 
override {
+Debugger::Initialize(plugin_callback);
+  };
+
+  virtual void TerminateDebugger() override {
+Debugger::Terminate();
+  };
+
+  // Noncopyable.
+  SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
+  SystemLifetimeManagerDbg &operator=(const SystemLifetimeManagerDbg &other) = 
delete;
+};
+}
+
+#endif
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index e646b09e05852..55ccfd415ca47 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -44,7 +44,7 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Host/XML.h"
-#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -66,7 +66,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static llvm::ManagedStatic g_debugger_lifetime;
+static llvm::ManagedStatic g_debugger_lifetime;
 
 SBError SBInputReader::Initialize(
 lldb::SBDebugger &sb_debugger,
diff --git a/lldb/source/Initialization/SystemLifetimeManager.cpp 
b/lldb/source/Initialization/SystemLifetimeManager.cpp
index f9de41a675356..b07fe71affec7 100644
--- a/lldb/source/Initialization/SystemLifetimeManager.cpp
+++ b/lldb/source/Initialization/SystemLifetimeManager.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Initialization/SystemLifetimeManager.h"
 
-#include "lldb/Core/Debugger.h"
 #include "lldb/Initialization/SystemInitializer.h"
 
 #include 
@@ -36,7 +35,7 @@ llvm::Error SystemLifetimeManager::Initialize(
 if (auto e = m_initializer->Initialize())
   return e;
 
-Debugger::Initialize(plugin_callback);
+InitializeDebugger(plugin_callback);
   }
 
   return llvm::Error::success();

[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

It reduces the memory usage in lldb-server.
Later I will try to remove the rest Debugger dependencies to reduce lldb-server 
size.

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


5 Files Affected:

- (modified) lldb/include/lldb/Initialization/SystemLifetimeManager.h (+4-1) 
- (added) lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h (+36) 
- (modified) lldb/source/API/SBDebugger.cpp (+2-2) 
- (modified) lldb/source/Initialization/SystemLifetimeManager.cpp (+2-3) 
- (modified) lldb/tools/lldb-test/lldb-test.cpp (+2-2) 


``diff
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
index 06328e60133fe..55138b33be712 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
@@ -21,7 +21,7 @@ namespace lldb_private {
 class SystemLifetimeManager {
 public:
   SystemLifetimeManager();
-  ~SystemLifetimeManager();
+  virtual ~SystemLifetimeManager();
 
   llvm::Error Initialize(std::unique_ptr initializer,
  LoadPluginCallbackType plugin_callback);
@@ -32,6 +32,9 @@ class SystemLifetimeManager {
   std::unique_ptr m_initializer;
   bool m_initialized = false;
 
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) {};
+  virtual void TerminateDebugger() {};
+
   // Noncopyable.
   SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
   SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = 
delete;
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
new file mode 100644
index 0..81e0b9a382b70
--- /dev/null
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
@@ -0,0 +1,36 @@
+//===-- SystemLifetimeManagerDbg.h --*- C++ 
-*-===//
+//
+// 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_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+
+#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Core/Debugger.h"
+
+namespace lldb_private {
+
+class SystemLifetimeManagerDbg : SystemLifetimeManager {
+public:
+  SystemLifetimeManagerDbg() : SystemLifetimeManager() {};
+
+private:
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) 
override {
+Debugger::Initialize(plugin_callback);
+  };
+
+  virtual void TerminateDebugger() override {
+Debugger::Terminate();
+  };
+
+  // Noncopyable.
+  SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
+  SystemLifetimeManagerDbg &operator=(const SystemLifetimeManagerDbg &other) = 
delete;
+};
+}
+
+#endif
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index e646b09e05852..55ccfd415ca47 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -44,7 +44,7 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Host/XML.h"
-#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -66,7 +66,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static llvm::ManagedStatic g_debugger_lifetime;
+static llvm::ManagedStatic g_debugger_lifetime;
 
 SBError SBInputReader::Initialize(
 lldb::SBDebugger &sb_debugger,
diff --git a/lldb/source/Initialization/SystemLifetimeManager.cpp 
b/lldb/source/Initialization/SystemLifetimeManager.cpp
index f9de41a675356..b07fe71affec7 100644
--- a/lldb/source/Initialization/SystemLifetimeManager.cpp
+++ b/lldb/source/Initialization/SystemLifetimeManager.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Initialization/SystemLifetimeManager.h"
 
-#include "lldb/Core/Debugger.h"
 #include "lldb/Initialization/SystemInitializer.h"
 
 #include 
@@ -36,7 +35,7 @@ llvm::Error SystemLifetimeManager::Initialize(
 if (auto e = m_initializer->Initialize())
   return e;
 
-Debugger::Initialize(plugin_callback);
+InitializeDebugger(plugin_callback);
   }
 
   return llvm::Error::success();
@@ -46,7 +45,7 @@ void SystemLifetimeManager::Terminate() {
   std::lock_guard guard(m_mutex);
 
   if (m_initialized) {
-Debugger::Terminate();
+TerminateDebugger();
 m_initializer->Terminate();
 
 m_initializer.reset();
diff --git a/lldb/tools/lldb-test/lldb-test.cpp 
b/lldb/tools/lldb-test/lldb-test.cpp
index

[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> I'm actually very much opposed to that. lldb-server not need/use a Debugger, 
> nor a thread pool nor any IO handling present in that file. I wouldn't want 
> to create a Debugger "plugin" for the sake of lldb-server. It should be cut 
> off above that.

#134383

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


[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/134383

>From 590d5b47b9f98a8e5f19945334b2a1c34248f9d8 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 4 Apr 2025 17:49:07 +0400
Subject: [PATCH] [LLDB][NFC] Remove Debugger dependency in
 SystemLifetimeManager

It reduces the memory usage in lldb-server.
Later I will try to remove the rest Debugger dependencies to reduce lldb-server 
size.
---
 .../Initialization/SystemLifetimeManager.h|  5 ++-
 .../Initialization/SystemLifetimeManagerDbg.h | 36 +++
 lldb/source/API/SBDebugger.cpp|  4 +--
 .../Initialization/SystemLifetimeManager.cpp  |  5 ++-
 lldb/tools/lldb-test/lldb-test.cpp|  4 +--
 5 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h

diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
index 06328e60133fe..55138b33be712 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
@@ -21,7 +21,7 @@ namespace lldb_private {
 class SystemLifetimeManager {
 public:
   SystemLifetimeManager();
-  ~SystemLifetimeManager();
+  virtual ~SystemLifetimeManager();
 
   llvm::Error Initialize(std::unique_ptr initializer,
  LoadPluginCallbackType plugin_callback);
@@ -32,6 +32,9 @@ class SystemLifetimeManager {
   std::unique_ptr m_initializer;
   bool m_initialized = false;
 
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) {};
+  virtual void TerminateDebugger() {};
+
   // Noncopyable.
   SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
   SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = 
delete;
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
new file mode 100644
index 0..5e728398f71bd
--- /dev/null
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
@@ -0,0 +1,36 @@
+//===-- SystemLifetimeManagerDbg.h --*- C++ 
-*-===//
+//
+// 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_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+
+#include "SystemLifetimeManager.h"
+#include "lldb/Core/Debugger.h"
+
+namespace lldb_private {
+
+class SystemLifetimeManagerDbg : public SystemLifetimeManager {
+public:
+  SystemLifetimeManagerDbg() : SystemLifetimeManager() {};
+
+private:
+  virtual void
+  InitializeDebugger(LoadPluginCallbackType plugin_callback) override {
+Debugger::Initialize(plugin_callback);
+  };
+
+  virtual void TerminateDebugger() override { Debugger::Terminate(); };
+
+  // Noncopyable.
+  SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
+  SystemLifetimeManagerDbg &
+  operator=(const SystemLifetimeManagerDbg &other) = delete;
+};
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index e646b09e05852..55ccfd415ca47 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -44,7 +44,7 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Host/XML.h"
-#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -66,7 +66,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static llvm::ManagedStatic g_debugger_lifetime;
+static llvm::ManagedStatic g_debugger_lifetime;
 
 SBError SBInputReader::Initialize(
 lldb::SBDebugger &sb_debugger,
diff --git a/lldb/source/Initialization/SystemLifetimeManager.cpp 
b/lldb/source/Initialization/SystemLifetimeManager.cpp
index f9de41a675356..b07fe71affec7 100644
--- a/lldb/source/Initialization/SystemLifetimeManager.cpp
+++ b/lldb/source/Initialization/SystemLifetimeManager.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Initialization/SystemLifetimeManager.h"
 
-#include "lldb/Core/Debugger.h"
 #include "lldb/Initialization/SystemInitializer.h"
 
 #include 
@@ -36,7 +35,7 @@ llvm::Error SystemLifetimeManager::Initialize(
 if (auto e = m_initializer->Initialize())
   return e;
 
-Debugger::Initialize(plugin_callback);
+InitializeDebugger(plugin_callback);
   }
 
   return llvm::Error::success();
@@ -46,7 +45,7 @@ void SystemLifetimeManager::Terminate() {
   std::lock_guard guard(m_mutex);
 
   if (m_initialized) {
-

[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

2025-04-04 Thread David Spickett via lldb-commits


@@ -0,0 +1,6 @@
+int func(void) {
+  __builtin_printf("Break here");

DavidSpickett wrote:

This fails to compile on Windows:
https://lab.llvm.org/buildbot/#/builders/141/builds/7573

```
lld-link: error: undefined symbol: printf

>>> referenced by main.o:(func)

clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
No idea why it would complain, perhaps on some platforms the builtin use here 
is compiled to puts and on windows it isn't?

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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [WIP: DO NOT MERGE] [lldb][Format] Add option to highlight function names in backtraces (PR #131836)

2025-04-04 Thread Michael Buch via lldb-commits

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

>From d7e112ed0bc8d5ca3297e3c7b7d7afadd2d79e2d Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 11 Mar 2025 08:57:13 +
Subject: [PATCH 1/4] [llvm][ItaniumDemangle] Add function name location
 tracking

---
 libcxxabi/src/demangle/ItaniumDemangle.h |  64 +++---
 libcxxabi/src/demangle/Utility.h |   7 +
 lldb/include/lldb/Core/Demangle.h|  90 
 lldb/source/Core/CMakeLists.txt  |   1 +
 lldb/source/Core/Demangle.cpp| 221 +++
 lldb/unittests/Core/MangledTest.cpp  | 143 
 llvm/include/llvm/Demangle/ItaniumDemangle.h |  64 +++---
 llvm/include/llvm/Demangle/Utility.h |   7 +
 8 files changed, 541 insertions(+), 56 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Demangle.h
 create mode 100644 lldb/source/Core/Demangle.cpp

diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..89a24def830f2 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -281,9 +281,9 @@ class Node {
   }
 
   void print(OutputBuffer &OB) const {
-printLeft(OB);
+OB.printLeft(*this);
 if (RHSComponentCache != Cache::No)
-  printRight(OB);
+  OB.printRight(*this);
   }
 
   // Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-Child->printLeft(OB);
+OB.printLeft(*Child);
 printQuals(OB);
   }
 
-  void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
+  void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
 };
 
 class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
   template void match(Fn F) const { F(Ty, Postfix); }
 
   void printLeft(OutputBuffer &OB) const override {
-Ty->printLeft(OB);
+OB.printLeft(*Ty);
 OB += Postfix;
   }
 };
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
   std::string_view getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
-Base->printLeft(OB);
+OB.printLeft(*Base);
 OB += "[abi:";
 OB += Tag;
 OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
 // We rewrite objc_object* into id.
 if (Pointee->getKind() != KObjCProtoName ||
 !static_cast(Pointee)->isObjCObject()) {
-  Pointee->printLeft(OB);
+  OB.printLeft(*Pointee);
   if (Pointee->hasArray(OB))
 OB += " ";
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
 !static_cast(Pointee)->isObjCObject()) {
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
 OB += ")";
-  Pointee->printRight(OB);
+  OB.printRight(*Pointee);
 }
   }
 };
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
 std::pair Collapsed = collapse(OB);
 if (!Collapsed.second)
   return;
-Collapsed.second->printLeft(OB);
+OB.printLeft(*Collapsed.second);
 if (Collapsed.second->hasArray(OB))
   OB += " ";
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
   return;
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
   OB += ")";
-Collapsed.second->printRight(OB);
+OB.printRight(*Collapsed.second);
   }
 };
 
@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-MemberType->printLeft(OB);
+OB.printLeft(*MemberType);
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += "(";
 else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
   void printRight(OutputBuffer &OB) const override {
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += ")";
-MemberType->printRight(OB);
+OB.printRight(*MemberType);
   }
 };
 
@@ -798,7 +798,7 @@ class ArrayType final : public Node {
   bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
   bool hasArraySlow(OutputBuffer &) const override { return true; }
 
-  void printLeft(OutputBuffer &OB) const override { Base->printLeft(OB); }
+  void printLeft(OutputBuffer &OB) const override { OB.printLeft(*Base); }
 
   void printRight(OutputBuffer &OB) const override {
 if (OB.back() != ']')
@@ -807,7 +807,7 @@ class ArrayType final : public Node {
 if (Dimension)
   Dimension->print(OB);
 OB += "]";
-Base->printRight(OB);
+OB.printRight(*Base);
   }
 
   bool printInitListAsType(OutputBuffer &OB,
@@ -851,7 +851,7 @@ class FunctionType final : public Node {
   // by printing

[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

2025-04-04 Thread David Spickett via lldb-commits


@@ -0,0 +1,6 @@
+int func(void) {
+  __builtin_printf("Break here");

DavidSpickett wrote:

Skipped for now: 
https://github.com/llvm/llvm-project/commit/d4002b43f517fea0292bf71dccaa3d0f6dd798b9

It could be another case where we link with link.exe which can't handle DWARF 
information, and that's needed for the test. We will try to confirm or deny 
that.

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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb][Format] Add option to highlight function names in backtraces (PR #131836)

2025-04-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

2025-04-04 Thread Michael Buch via lldb-commits


@@ -0,0 +1,6 @@
+int func(void) {
+  __builtin_printf("Break here");

Michael137 wrote:

Oh I fixed this in a follow-up commit. Is the test still failing?

Yea not exactly sure about why the builtin doesnt link. Your theory sounds 
plausible

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

@labath 

> I'm not sure what has changed. This code has been here since 2022, so I 
> suspect it's one of those "perfectly reasonable" changes I mentioned earlier.

https://github.com/llvm/llvm-project/commit/d2a7a249c567cb170f22fe6e932896f9298b581d

Changed the definition of LLVM_ATTRIBUTE_RETAIN and LLVM_DUMP_METHOD

`ConstructionContextItem::getKindAsString` is marked as LLVM_DUMP_METHOD, where 
```
// FIXME: Move this to a private config.h as it's not usable in public headers.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#define LLVM_DUMP_METHOD   \
  LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED LLVM_ATTRIBUTE_RETAIN
#else
#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
#endif
```
So, now `ConstructionContextItem::getKindAsString` is GC root for 
CommandObjectTarget.cpp

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


[Lldb-commits] [clang] [libcxxabi] [lldb] [llvm] [WIP][lldb] Alternative implementation of more reliable function call infrastructure (PR #115245)

2025-04-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-04-04 Thread via lldb-commits


@@ -0,0 +1,175 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+dap.SendErrorResponse(response, "Malformed memory reference: " +
+memoryReference.str());
+return;
+  }
+  lldb::addr_t address =
+  *addr_opt + GetInteger(arguments, "offset").value_or(0);
+
+  llvm::StringRef data64 = GetString(arguments, "data").value_or("");
+  if (data64.empty()) {
+dap.SendErrorResponse(response,
+  "Data cannot be empty value. Provide valid data");
+return;
+  }
+
+  // The VSCode IDE or other DAP clients send memory data as a Base64 string.
+  // This function decodes it into raw binary before writing it to the target
+  // process memory.
+  std::vector output;
+  auto decode_error = llvm::decodeBase64(data64, output);
+
+  if (decode_error) {
+dap.SendErrorResponse(response,
+

[Lldb-commits] [lldb] [lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (PR #134397)

2025-04-04 Thread via lldb-commits

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

I agree these don't belong in ProcessGDBRemote, but this is a small and obvious 
change so it's fine to fix the status quo for now.

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-04 Thread Vy Nguyen via lldb-commits


@@ -965,6 +965,22 @@ SBTarget SBDebugger::GetDummyTarget() {
   return sb_target;
 }
 
+void SBDebugger::DispatchClientTelemetry(const lldb::SBStructuredData &entry) {
+  LLDB_INSTRUMENT_VA(this);
+  // Disable client-telemetry for SWIG.
+  // This prevent arbitrary python client (pretty printers, whatnot) from 
sending
+  // telemetry without vendors knowing.
+#ifndef SWIG

oontvoo wrote:

Ah, ok - now that you mentioned it - I agree we should avoid the #ifdef thing 
on function decl (missing function def and whatnot).

Can we consider going back to my previous impl, which put the ifdef in the 
function's definition so that the function either does nothing (when 
client-telemetry is disabled) or actually dispatches the data to server?
But yes, we can modify the ifdef there - rather than conditioning on SWIG, we 
just make it an explicit `ENABLE_CLIENT_TELEMETRY`. 
Why wasn't that sufficient? 

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


[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2025-04-04 Thread via lldb-commits


@@ -185,6 +185,8 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
+if available_ports := self.getPlatformAvailablePorts():
+return int(random.choice(available_ports))

dlav-sc wrote:

I haven't encountered this issue. 

LLDB testsuite starts `lldb-server` in `gdbserver` mode before running each 
LLGS test. The `get_next_port` function is used to select a port to listen by 
`lldb-server`. At the end of the test, the testsuite kills `lldb-server`, 
making the port available again. If the testsuite is unable to start 
`lldb-server` on the chosen port, it waits for a second or so, selects another 
port using `get_next_port`, and tries to run `lldb-server` again. This can take 
several attempts, but it almost always works on the first try. 

Currently, I pass 10 ports in this option, which is more than enough to 
successfully pass all LLGS tests. 

To remove the randomization, we could introduce a counter and choose ports in 
ascending or descending order by modulo. However, I don't think this would 
significantly change anything.

The initial issue was that `get_next_port` selected a port from a pool of not 
non forwarded ports, so there was no chance to get a suitable port. Now we can 
choose a busy port, but it's not a big problem in fact.

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


[Lldb-commits] [lldb] [lldb-dap] Add a -v/--version command line argument (PR #134114)

2025-04-04 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
lldb/include/lldb/Initialization/SystemLifetimeManager.h 
lldb/source/API/SBDebugger.cpp 
lldb/source/Initialization/SystemLifetimeManager.cpp 
lldb/tools/lldb-test/lldb-test.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
index 81e0b9a38..6caece499 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
@@ -9,8 +9,8 @@
 #ifndef LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
 #define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
 
-#include "lldb/Initialization/SystemLifetimeManager.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Initialization/SystemLifetimeManager.h"
 
 namespace lldb_private {
 
@@ -19,18 +19,18 @@ public:
   SystemLifetimeManagerDbg() : SystemLifetimeManager() {};
 
 private:
-  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) 
override {
+  virtual void
+  InitializeDebugger(LoadPluginCallbackType plugin_callback) override {
 Debugger::Initialize(plugin_callback);
   };
 
-  virtual void TerminateDebugger() override {
-Debugger::Terminate();
-  };
+  virtual void TerminateDebugger() override { Debugger::Terminate(); };
 
   // Noncopyable.
   SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
-  SystemLifetimeManagerDbg &operator=(const SystemLifetimeManagerDbg &other) = 
delete;
+  SystemLifetimeManagerDbg &
+  operator=(const SystemLifetimeManagerDbg &other) = delete;
 };
-}
+} // namespace lldb_private
 
 #endif

``




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


[Lldb-commits] [lldb] [LLDB][NFC] Remove Debugger dependency in SystemLifetimeManager (PR #134383)

2025-04-04 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/134383

>From a6ad0039015bdd3d387e8a4f0762961cdf8db50f Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 4 Apr 2025 17:49:07 +0400
Subject: [PATCH] [LLDB][NFC] Remove Debugger dependency in
 SystemLifetimeManager

It reduces the memory usage in lldb-server.
Later I will try to remove the rest Debugger dependencies to reduce lldb-server 
size.
---
 .../Initialization/SystemLifetimeManager.h|  5 ++-
 .../Initialization/SystemLifetimeManagerDbg.h | 36 +++
 lldb/source/API/SBDebugger.cpp|  4 +--
 .../Initialization/SystemLifetimeManager.cpp  |  5 ++-
 lldb/tools/lldb-test/lldb-test.cpp|  4 +--
 5 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h

diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
index 06328e60133fe..55138b33be712 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
@@ -21,7 +21,7 @@ namespace lldb_private {
 class SystemLifetimeManager {
 public:
   SystemLifetimeManager();
-  ~SystemLifetimeManager();
+  virtual ~SystemLifetimeManager();
 
   llvm::Error Initialize(std::unique_ptr initializer,
  LoadPluginCallbackType plugin_callback);
@@ -32,6 +32,9 @@ class SystemLifetimeManager {
   std::unique_ptr m_initializer;
   bool m_initialized = false;
 
+  virtual void InitializeDebugger(LoadPluginCallbackType plugin_callback) {};
+  virtual void TerminateDebugger() {};
+
   // Noncopyable.
   SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
   SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = 
delete;
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h 
b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
new file mode 100644
index 0..0e74f89e97b13
--- /dev/null
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManagerDbg.h
@@ -0,0 +1,36 @@
+//===-- SystemLifetimeManagerDbg.h --*- C++ 
-*-===//
+//
+// 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_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGERDBG_H
+
+#include "SystemLifetimeManager.h"
+#include "lldb/Core/Debugger.h"
+
+namespace lldb_private {
+
+class SystemLifetimeManagerDbg : SystemLifetimeManager {
+public:
+  SystemLifetimeManagerDbg() : SystemLifetimeManager() {};
+
+private:
+  virtual void
+  InitializeDebugger(LoadPluginCallbackType plugin_callback) override {
+Debugger::Initialize(plugin_callback);
+  };
+
+  virtual void TerminateDebugger() override { Debugger::Terminate(); };
+
+  // Noncopyable.
+  SystemLifetimeManagerDbg(const SystemLifetimeManagerDbg &other) = delete;
+  SystemLifetimeManagerDbg &
+  operator=(const SystemLifetimeManagerDbg &other) = delete;
+};
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index e646b09e05852..55ccfd415ca47 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -44,7 +44,7 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Host/XML.h"
-#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Initialization/SystemLifetimeManagerDbg.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -66,7 +66,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static llvm::ManagedStatic g_debugger_lifetime;
+static llvm::ManagedStatic g_debugger_lifetime;
 
 SBError SBInputReader::Initialize(
 lldb::SBDebugger &sb_debugger,
diff --git a/lldb/source/Initialization/SystemLifetimeManager.cpp 
b/lldb/source/Initialization/SystemLifetimeManager.cpp
index f9de41a675356..b07fe71affec7 100644
--- a/lldb/source/Initialization/SystemLifetimeManager.cpp
+++ b/lldb/source/Initialization/SystemLifetimeManager.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Initialization/SystemLifetimeManager.h"
 
-#include "lldb/Core/Debugger.h"
 #include "lldb/Initialization/SystemInitializer.h"
 
 #include 
@@ -36,7 +35,7 @@ llvm::Error SystemLifetimeManager::Initialize(
 if (auto e = m_initializer->Initialize())
   return e;
 
-Debugger::Initialize(plugin_callback);
+InitializeDebugger(plugin_callback);
   }
 
   return llvm::Error::success();
@@ -46,7 +45,7 @@ void SystemLifetimeManager::Terminate() {
   std::lock_guard guard(m_mutex);
 
   if (m_initialized) {
-Deb

[Lldb-commits] [clang] [libcxxabi] [lldb] [llvm] [WIP][lldb] Alternative implementation of more reliable function call infrastructure (PR #115245)

2025-04-04 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- 
clang/lib/AST/Mangle.cpp clang/lib/Sema/SemaDeclAttr.cpp 
libcxxabi/src/demangle/ItaniumDemangle.h 
lldb/source/Expression/IRExecutionUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
llvm/include/llvm/Demangle/Demangle.h 
llvm/include/llvm/Demangle/ItaniumDemangle.h 
llvm/lib/Demangle/ItaniumDemangle.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 1056195b1..f864b0f38 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -892,43 +892,44 @@ static std::string FindStructorLinkageName(DWARFDIE die,
   return {};
 }
 
-static lldb::addr_t FindSpecialLinkageName(
-LoadAddressResolver &resolver,ConstString name, llvm::StringRef 
symbol) {
+static lldb::addr_t FindSpecialLinkageName(LoadAddressResolver &resolver,
+   ConstString name,
+   llvm::StringRef symbol) {
   uintptr_t module_ptr;
   if (symbol.consumeInteger(0, module_ptr))
 return LLDB_INVALID_ADDRESS;
-  
+
   if (module_ptr == 0) {
 // TODO: log this case. We should ever be putting a null module pointer
 // here
 return LLDB_INVALID_ADDRESS;
   }
-  
+
   auto *mod = (lldb_private::Module *)module_ptr;
   assert(mod);
   auto *sym = mod->GetSymbolFile();
   assert(sym);
-  
+
   if (!symbol.consume_front(":"))
 return LLDB_INVALID_ADDRESS;
-  
+
   lldb::user_id_t die_id;
   if (symbol.consumeInteger(10, die_id))
 return LLDB_INVALID_ADDRESS;
-  
+
   auto *dwarf = llvm::dyn_cast(sym);
   if (!dwarf)
 return LLDB_INVALID_ADDRESS;
-  
+
   auto die = dwarf->GetDIE(die_id);
   if (!die.IsValid())
 return LLDB_INVALID_ADDRESS;
-  
+
   // TODO: account for MS-ABI (where there are no ctor variants in the
   // mangling)
   if (!symbol.consume_front(":"))
 return LLDB_INVALID_ADDRESS;
-  
+
   auto structor_variant_or_err = MakeStructorVariant(symbol);
   if (!structor_variant_or_err) {
 LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions),
@@ -937,13 +938,12 @@ static lldb::addr_t FindSpecialLinkageName(
name.GetStringRef());
 return LLDB_INVALID_ADDRESS;
   }
-  
-  ConstString mangled(
-  FindStructorLinkageName(die, *structor_variant_or_err));
-  
-  Module::LookupInfo lookup_info(
-  mangled, lldb::FunctionNameType::eFunctionNameTypeAny,
-  lldb::LanguageType::eLanguageTypeC_plus_plus);
+
+  ConstString mangled(FindStructorLinkageName(die, *structor_variant_or_err));
+
+  Module::LookupInfo lookup_info(mangled,
+ lldb::FunctionNameType::eFunctionNameTypeAny,
+ lldb::LanguageType::eLanguageTypeC_plus_plus);
   SymbolContextList sc_list;
   dwarf->FindFunctions(lookup_info, {}, false, sc_list);
   if (auto load_addr = resolver.Resolve(sc_list))

``




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


  1   2   3   >