[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket (PR #101283)

2024-08-09 Thread Dmitry Vasilyev via lldb-commits

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

>From 6b2a41ba3d71270e81e24a42d3b4f5dc2f96b939 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 31 Jul 2024 05:41:21 +0400
Subject: [PATCH 1/5] [lldb] Updated lldb-server to spawn the child process and
 share socket on Windows

`lldb-server platform --server` works on Windows now w/o multithreading. The 
rest functionality remains unchanged.

Depends on #101383.

Fixes #90923, fixes #56346.

This is the part 1 of the replacement of #100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen 
a common gdb port for all gdbserver connections. Then we can remove gdb port 
mapping to fix #97537.
---
 lldb/tools/lldb-server/lldb-platform.cpp | 347 ---
 1 file changed, 306 insertions(+), 41 deletions(-)

diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 7148a1d2a30941..e23237ef574c30 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -32,8 +33,10 @@
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/HostGetOpt.h"
 #include "lldb/Host/OptionParser.h"
+#include "lldb/Host/Socket.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Status.h"
 
 using namespace lldb;
@@ -60,6 +63,9 @@ static struct option g_long_options[] = {
 {"max-gdbserver-port", required_argument, nullptr, 'M'},
 {"socket-file", required_argument, nullptr, 'f'},
 {"server", no_argument, &g_server, 1},
+#if defined(_WIN32)
+{"accept", required_argument, nullptr, 'a'},
+#endif
 {nullptr, 0, nullptr, 0}};
 
 #if defined(__APPLE__)
@@ -114,6 +120,249 @@ static Status save_socket_id_to_file(const std::string 
&socket_id,
   return status;
 }
 
+static void client_handle(GDBRemoteCommunicationServerPlatform &platform,
+  const lldb_private::Args &args) {
+  if (!platform.IsConnected())
+return;
+
+  if (args.GetArgumentCount() > 0) {
+lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+std::optional port;
+std::string socket_name;
+Status error = platform.LaunchGDBServer(args,
+"", // hostname
+pid, port, socket_name);
+if (error.Success())
+  platform.SetPendingGdbServer(pid, *port, socket_name);
+else
+  fprintf(stderr, "failed to start gdbserver: %s\n", error.AsCString());
+  }
+
+  bool interrupt = false;
+  bool done = false;
+  Status error;
+  while (!interrupt && !done) {
+if (platform.GetPacketAndSendResponse(std::nullopt, error, interrupt,
+  done) !=
+GDBRemoteCommunication::PacketResult::Success)
+  break;
+  }
+
+  if (error.Fail())
+WithColor::error() << error.AsCString() << '\n';
+}
+
+static GDBRemoteCommunicationServerPlatform::PortMap gdbserver_portmap;
+static std::mutex gdbserver_portmap_mutex;
+
+#if defined(_WIN32)
+static void spawn_process_reaped(lldb::pid_t pid, int signal, int status) {
+  std::lock_guard guard(gdbserver_portmap_mutex);
+  gdbserver_portmap.FreePortForProcess(pid);
+}
+
+static bool spawn_process_parent(const char *progname, Connection *conn,
+ uint16_t gdb_port, uint16_t port_offset,
+ const lldb_private::Args &args,
+ const std::string &log_file,
+ const StringRef log_channels) {
+  Log *log = GetLog(LLDBLog::Platform);
+  Pipe socket_pipe;
+  Status error = socket_pipe.CreateNew(true);
+  if (error.Fail()) {
+LLDB_LOGF(log,
+  "lldb-platform parent: "
+  "cannot create pipe: %s",
+  error.AsCString());
+return false;
+  }
+
+  ProcessLaunchInfo launch_info;
+  FileSpec self_spec(progname, FileSpec::Style::native);
+  launch_info.SetExecutableFile(self_spec, true);
+  Args &self_args = launch_info.GetArguments();
+  self_args.AppendArgument(llvm::StringRef("platform"));
+  self_args.AppendArgument(llvm::StringRef("--accept"));
+  self_args.AppendArgument(llvm::to_string(socket_pipe.GetReadPipe()));
+  if (gdb_port) {
+self_args.AppendArgument(llvm::StringRef("--gdbserver-port"));
+self_args.AppendArgument(llvm::to_string(gdb_port));
+  }
+  if (port_offset > 0) {
+self_args.AppendArgument(llvm::StringRef("--port-offset"));
+self_args.AppendArgument(llvm::to_string(port_offset));
+  }
+  if (!log_file.empty()) {
+self_args.AppendArgument(llvm::StringRef("--log-file"));
+self_args.AppendArgument(log_file);
+  }
+  if (!log_channels.empty()) {
+self_args.AppendA

[Lldb-commits] [lldb] 4bb1396 - [lldb][Platform] Move the GetSDKPathFromDebugInfo helpers from PlatformDarwin into Platform (#102488)

2024-08-09 Thread via lldb-commits

Author: Michael Buch
Date: 2024-08-09T09:41:25+01:00
New Revision: 4bb139622ee318571cb2ef6649ff1766051f0e84

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

LOG: [lldb][Platform] Move the GetSDKPathFromDebugInfo helpers from 
PlatformDarwin into Platform (#102488)

This is needed for relanding
https://github.com/llvm/llvm-project/pull/102497, where we plan on
calling these APIs from generic ExpressionParser code.

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 5ed2fc33356d9d..920f80bc733174 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -27,9 +27,11 @@
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/Utility/XcodeSDK.h"
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
 
@@ -436,6 +438,41 @@ class Platform : public PluginInterface {
 return lldb_private::ConstString();
   }
 
+  /// Search each CU associated with the specified 'module' for
+  /// the SDK paths the CUs were compiled against. In the presence
+  /// of 
diff erent SDKs, we try to pick the most appropriate one
+  /// using \ref XcodeSDK::Merge.
+  ///
+  /// \param[in] module Module whose debug-info CUs to parse for
+  ///   which SDK they were compiled against.
+  ///
+  /// \returns If successful, returns a pair of a parsed XcodeSDK
+  ///  object and a boolean that is 'true' if we encountered
+  ///  a conflicting combination of SDKs when parsing the CUs
+  ///  (e.g., a public and internal SDK).
+  virtual llvm::Expected>
+  GetSDKPathFromDebugInfo(Module &module) {
+return llvm::createStringError(
+llvm::formatv("{0} not implemented for '{1}' platform.",
+  LLVM_PRETTY_FUNCTION, GetName()));
+  }
+
+  /// Returns the full path of the most appropriate SDK for the
+  /// specified 'module'. This function gets this path by parsing
+  /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
+  ///
+  /// \param[in] module Module whose debug-info to parse for
+  ///   which SDK it was compiled against.
+  ///
+  /// \returns If successful, returns the full path to an
+  ///  Xcode SDK.
+  virtual llvm::Expected
+  ResolveSDKPathFromDebugInfo(Module &module) {
+return llvm::createStringError(
+llvm::formatv("{0} not implemented for '{1}' platform.",
+  LLVM_PRETTY_FUNCTION, GetName()));
+  }
+
   const std::string &GetRemoteURL() const { return m_remote_url; }
 
   bool IsHost() const {

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index ff7087da6825d9..66a26d2f496776 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -124,32 +124,11 @@ class PlatformDarwin : public PlatformPOSIX {
   /// located in.
   static FileSpec GetCurrentCommandLineToolsDirectory();
 
-  /// Search each CU associated with the specified 'module' for
-  /// the SDK paths the CUs were compiled against. In the presence
-  /// of 
diff erent SDKs, we try to pick the most appropriate one
-  /// using \ref XcodeSDK::Merge.
-  ///
-  /// \param[in] module Module whose debug-info CUs to parse for
-  ///   which SDK they were compiled against.
-  ///
-  /// \returns If successful, returns a pair of a parsed XcodeSDK
-  ///  object and a boolean that is 'true' if we encountered
-  ///  a conflicting combination of SDKs when parsing the CUs
-  ///  (e.g., a public and internal SDK).
-  static llvm::Expected>
-  GetSDKPathFromDebugInfo(Module &module);
-
-  /// Returns the full path of the most appropriate SDK for the
-  /// specified 'module'. This function gets this path by parsing
-  /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
-  ///
-  /// \param[in] module Module whose debug-info to parse for
-  ///   which SDK it was compiled against.
-  ///
-  /// \returns If successful, returns the full path to an
-  ///  Xcode SDK.
-  static llvm::Expected
-  ResolveSDKPathFromDebugInfo(Module &module);
+  llvm::Expected>
+  GetSDKPathFromDebugInfo(Module &module) override;
+
+  llvm::Expected
+  ResolveSDKPathFromDebugInfo(Module &module) override;
 
 protected:
   static const char *GetCompatibleArch(ArchSpec::Core co

[Lldb-commits] [lldb] [lldb][Platform] Move the GetSDKPathFromDebugInfo helpers from PlatformDarwin into Platform (PR #102488)

2024-08-09 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][ClangExpressionParser] Set BuiltinHeadersInSystemModules depending on SDK version (#102309)" (PR #102497)

2024-08-09 Thread Michael Buch via lldb-commits

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

>From d2f0b68afe6ebfffe5a2ef3ce14a77a5e1025c90 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 8 Aug 2024 16:07:21 +0100
Subject: [PATCH 1/4] [lldb][Platform] Move the GetSDKPathFromDebugInfo helpers
 from PlatformDarwin into Platform

This will soon be needed for
https://github.com/llvm/llvm-project/pull/102309, where we
plan on calling these APIs from generic ExpressionParser code.
---
 lldb/include/lldb/Target/Platform.h   | 34 +++
 .../Plugins/Platform/MacOSX/PlatformDarwin.h  | 31 +++--
 .../SymbolFile/DWARF/XcodeSDKModuleTests.cpp  | 12 +--
 3 files changed, 48 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 5ed2fc33356d9..8cf52a486e2c8 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -27,6 +27,7 @@
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/Utility/UserIDResolver.h"
+#include "lldb/Utility/XcodeSDK.h"
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
@@ -436,6 +437,39 @@ class Platform : public PluginInterface {
 return lldb_private::ConstString();
   }
 
+  /// Search each CU associated with the specified 'module' for
+  /// the SDK paths the CUs were compiled against. In the presence
+  /// of different SDKs, we try to pick the most appropriate one
+  /// using \ref XcodeSDK::Merge.
+  ///
+  /// \param[in] module Module whose debug-info CUs to parse for
+  ///   which SDK they were compiled against.
+  ///
+  /// \returns If successful, returns a pair of a parsed XcodeSDK
+  ///  object and a boolean that is 'true' if we encountered
+  ///  a conflicting combination of SDKs when parsing the CUs
+  ///  (e.g., a public and internal SDK).
+  virtual llvm::Expected>
+  GetSDKPathFromDebugInfo(Module &module) {
+return llvm::createStringError(llvm::formatv(
+"{0} not implemented for '{1}' platform.", __func__, GetName()));
+  }
+
+  /// Returns the full path of the most appropriate SDK for the
+  /// specified 'module'. This function gets this path by parsing
+  /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
+  ///
+  /// \param[in] module Module whose debug-info to parse for
+  ///   which SDK it was compiled against.
+  ///
+  /// \returns If successful, returns the full path to an
+  ///  Xcode SDK.
+  virtual llvm::Expected
+  ResolveSDKPathFromDebugInfo(Module &module) {
+return llvm::createStringError(llvm::formatv(
+"{0} not implemented for '{1}' platform.", __func__, GetName()));
+  }
+
   const std::string &GetRemoteURL() const { return m_remote_url; }
 
   bool IsHost() const {
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index ff7087da6825d..66a26d2f49677 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -124,32 +124,11 @@ class PlatformDarwin : public PlatformPOSIX {
   /// located in.
   static FileSpec GetCurrentCommandLineToolsDirectory();
 
-  /// Search each CU associated with the specified 'module' for
-  /// the SDK paths the CUs were compiled against. In the presence
-  /// of different SDKs, we try to pick the most appropriate one
-  /// using \ref XcodeSDK::Merge.
-  ///
-  /// \param[in] module Module whose debug-info CUs to parse for
-  ///   which SDK they were compiled against.
-  ///
-  /// \returns If successful, returns a pair of a parsed XcodeSDK
-  ///  object and a boolean that is 'true' if we encountered
-  ///  a conflicting combination of SDKs when parsing the CUs
-  ///  (e.g., a public and internal SDK).
-  static llvm::Expected>
-  GetSDKPathFromDebugInfo(Module &module);
-
-  /// Returns the full path of the most appropriate SDK for the
-  /// specified 'module'. This function gets this path by parsing
-  /// debug-info (see \ref `GetSDKPathFromDebugInfo`).
-  ///
-  /// \param[in] module Module whose debug-info to parse for
-  ///   which SDK it was compiled against.
-  ///
-  /// \returns If successful, returns the full path to an
-  ///  Xcode SDK.
-  static llvm::Expected
-  ResolveSDKPathFromDebugInfo(Module &module);
+  llvm::Expected>
+  GetSDKPathFromDebugInfo(Module &module) override;
+
+  llvm::Expected
+  ResolveSDKPathFromDebugInfo(Module &module) override;
 
 protected:
   static const char *GetCompatibleArch(ArchSpec::Core core, size_t idx);
diff --git a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
index c37da89ff79ce..dc5680522e183 100644
--- a/lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/Xco

[Lldb-commits] [lldb] 3fffa6d - Reland "[lldb][ClangExpressionParser] Set BuiltinHeadersInSystemModules depending on SDK version (#102309)" (#102497)

2024-08-09 Thread via lldb-commits

Author: Michael Buch
Date: 2024-08-09T09:43:08+01:00
New Revision: 3fffa6d486ecedaf639927a448701df9fdc19a34

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

LOG: Reland "[lldb][ClangExpressionParser] Set BuiltinHeadersInSystemModules 
depending on SDK version (#102309)" (#102497)

Depends on https://github.com/llvm/llvm-project/pull/102488

This reverts commit
https://github.com/llvm/llvm-project/commit/cf56e265e4b74799aee72a04b634fcc261078084.

The original change was reverted because it was causing linker failures
in the unit-tests:
```
Undefined symbols for architecture arm64:
  
"lldb_private::PlatformDarwin::GetSDKPathFromDebugInfo(lldb_private::Module&)",
referenced from:
  
lldb_private::ClangExpressionParser::ClangExpressionParser(lldb_private::ExecutionContextScope*,
lldb_private::Expression&, bool,
std::__1::vector, std::__1::allocator>,
std::__1::allocator, std::__1::allocator>>>,
std::__1::basic_string,
std::__1::allocator>) in
liblldbPluginExpressionParserClang.a[11](ClangExpressionParser.cpp.o)
ld: symbol(s) not found for architecture arm64
c++: error: linker command failed with exit code 1 (use -v to see
invocation)
```

The relanded version differs only in the fact that we now use the
generic `Platform` abstraction to get to `GetSDKPathFromDebugInfo`.

Added: 


Modified: 
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Utility/XcodeSDK.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index 673ea578ffce85..2720d0d8a44a11 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -85,6 +85,20 @@ class XcodeSDK {
   /// Whether LLDB feels confident importing Clang modules from this SDK.
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
   static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
+
+  /// Returns true if the SDK for the specified triple supports
+  /// builtin modules in system headers.
+  ///
+  /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
+  /// Toolchains/Darwin.cpp
+  ///
+  /// FIXME: this function will be removed once LLDB's ClangExpressionParser
+  /// constructs the compiler instance through the driver/toolchain. See \ref
+  /// SetupImportStdModuleLangOpts
+  ///
+  static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
+llvm::VersionTuple sdk_version);
+
   /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index f41323d32ac863..c441153d1efb05 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -11,6 +11,7 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
@@ -39,6 +40,7 @@
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/TargetSelect.h"
 
@@ -91,6 +93,8 @@
 #include "lldb/Utility/StringList.h"
 
 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwin.h"
+#include "lldb/Utility/XcodeSDK.h"
 
 #include 
 #include 
@@ -279,6 +283,49 @@ class ClangDiagnosticManagerAdapter : public 
clang::DiagnosticConsumer {
   std::string m_output;
 };
 
+/// Returns true if the SDK for the specified triple supports
+/// builtin modules in system headers. This is used to decide
+/// whether to pass -fbuiltin-headers-in-system-modules to
+/// the compiler instance when compiling the `std` module.
+static llvm::Expected
+sdkSupportsBuiltinModules(lldb_private::Target &target) {
+  auto arch_spec = target.GetArchitecture();
+  auto const &triple = arch_spec.GetTriple();
+  auto module_sp = target.GetExecutableModule();
+  if (!module_sp)
+return llvm::createStringError("Executable module not found.");
+
+  // Get SDK path that the target was compiled against.
+  auto platform_sp = target.GetPlatform();
+  if (!platform_sp)
+return llvm::createStringError("No Platform plugin found on target.");
+
+  auto sdk_or

[Lldb-commits] [lldb] Reland "[lldb][ClangExpressionParser] Set BuiltinHeadersInSystemModules depending on SDK version (#102309)" (PR #102497)

2024-08-09 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove Phabricator usernames from Code Owners file (PR #102590)

2024-08-09 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/102590

Removing them simplifies the content and means we don't confuse anyone who 
joined after the Phabricator shutdown.

You could use them for review archaeology but this is only a subset of the 
names you'd encounter there anyway. So I don't think this is a good reason to 
keep them here. With a couple of exceptions the Phabricator/GitHub names are 
the same and/or related to their full name anyway.

>From 749d1ab8af5d71f77a4fc30ab3b32d34c9be169c Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 9 Aug 2024 09:42:51 +
Subject: [PATCH] [lldb] Remove Phabricator usernames from Code Owners file

Removing them simplfies the file a bit and means we don't
confuse anyone who joined after the Phabricator shutdown.

You could use them for review archeology but this is only a
subset of the names you'd encounter there anyway. So I don't
think this is a good reason to keep them here. With a couple
of exceptions the Phabricator/GitHub names are the same
and/or related to their full name anyway.
---
 lldb/CodeOwners.rst | 96 ++---
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/lldb/CodeOwners.rst b/lldb/CodeOwners.rst
index 52e3e550523e5b..3c10c2a28da9e7 100644
--- a/lldb/CodeOwners.rst
+++ b/lldb/CodeOwners.rst
@@ -17,7 +17,7 @@ assistance.
 All parts of LLDB not covered by someone else
 --
 | Jonas Devlieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Components
 --
@@ -27,100 +27,100 @@ LLDB.
 ABI
 ~~~
 | Jason Molenda
-| jmolenda\@apple.com (email), jasonmolenda (Phabricator), jasonmolenda 
(GitHub), jasonmolenda (Discourse), jasonmolenda (Discord)
+| jmolenda\@apple.com (email), jasonmolenda (GitHub), jasonmolenda 
(Discourse), jasonmolenda (Discord)
 
 | David Spickett
-| david.spickett\@linaro.org (email), DavidSpickett (Phabricator), 
DavidSpickett (GitHub), DavidSpickett (Discourse), davidspickett (Discord)
+| david.spickett\@linaro.org (email), DavidSpickett (GitHub), DavidSpickett 
(Discourse), davidspickett (Discord)
 
 
 Breakpoint
 ~~
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 CMake & Build System
 
 | Jonas Devlieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 | Alex Langford
-| alangford\@apple.com (email), bulbazord (Phabricator), bulbazord (GitHub), 
bulbazord (Discourse), bulba_zord (Discord)
+| alangford\@apple.com (email), bulbazord (GitHub), bulbazord (Discourse), 
bulba_zord (Discord)
 
 Commands
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 Expression Parser
 ~
 | Michael Buch
-| michaelbuch12\@gmail.com (email), Michael137 (Phabricator), Michael137 
(GitHub), Michael137 (Discourse)
+| michaelbuch12\@gmail.com (email), Michael137 (GitHub), Michael137 (Discourse)
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 Interpreter
 ~~~
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 | Greg Clayton
-| gclayton\@fb.com (email), clayborg (Phabricator), clayborg (GitHub), 
clayborg (Discourse)
+| gclayton\@fb.com (email), clayborg (GitHub), clayborg (Discourse)
 
 
 Lua
 ~~~
 | Jonas Delvieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Python
 ~~
 | Med Ismail Bennani
-| ismail\@bennani.ma (email), mib (Phabricator), medismailben (GitHub), mib 
(Discourse), mib#8727 (Discord)
+| ismail\@bennani.ma (email), medismailben (GitHub), mib (Discourse), mib#8727 
(Discord)
 
 Target/Process Control
 ~~
 | Med Ismail Bennani
-| ismail\@bennani.ma (email), mib (Phabricator), medismailben (GitHub), mib 
(Discourse), mib#8727 (Discord)
+| ismail\@bennani.ma (email), medismailben (GitHub), mib (Discourse), mib#8727 
(Discord)
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabrica

[Lldb-commits] [lldb] [lldb] Remove Phabricator usernames from Code Owners file (PR #102590)

2024-08-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Removing them simplifies the content and means we don't confuse anyone who 
joined after the Phabricator shutdown.

You could use them for review archaeology but this is only a subset of the 
names you'd encounter there anyway. So I don't think this is a good reason to 
keep them here. With a couple of exceptions the Phabricator/GitHub names are 
the same and/or related to their full name anyway.

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


1 Files Affected:

- (modified) lldb/CodeOwners.rst (+48-48) 


``diff
diff --git a/lldb/CodeOwners.rst b/lldb/CodeOwners.rst
index 52e3e550523e5..3c10c2a28da9e 100644
--- a/lldb/CodeOwners.rst
+++ b/lldb/CodeOwners.rst
@@ -17,7 +17,7 @@ assistance.
 All parts of LLDB not covered by someone else
 --
 | Jonas Devlieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Components
 --
@@ -27,100 +27,100 @@ LLDB.
 ABI
 ~~~
 | Jason Molenda
-| jmolenda\@apple.com (email), jasonmolenda (Phabricator), jasonmolenda 
(GitHub), jasonmolenda (Discourse), jasonmolenda (Discord)
+| jmolenda\@apple.com (email), jasonmolenda (GitHub), jasonmolenda 
(Discourse), jasonmolenda (Discord)
 
 | David Spickett
-| david.spickett\@linaro.org (email), DavidSpickett (Phabricator), 
DavidSpickett (GitHub), DavidSpickett (Discourse), davidspickett (Discord)
+| david.spickett\@linaro.org (email), DavidSpickett (GitHub), DavidSpickett 
(Discourse), davidspickett (Discord)
 
 
 Breakpoint
 ~~
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 CMake & Build System
 
 | Jonas Devlieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 | Alex Langford
-| alangford\@apple.com (email), bulbazord (Phabricator), bulbazord (GitHub), 
bulbazord (Discourse), bulba_zord (Discord)
+| alangford\@apple.com (email), bulbazord (GitHub), bulbazord (Discourse), 
bulba_zord (Discord)
 
 Commands
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 Expression Parser
 ~
 | Michael Buch
-| michaelbuch12\@gmail.com (email), Michael137 (Phabricator), Michael137 
(GitHub), Michael137 (Discourse)
+| michaelbuch12\@gmail.com (email), Michael137 (GitHub), Michael137 (Discourse)
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 Interpreter
 ~~~
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 | Greg Clayton
-| gclayton\@fb.com (email), clayborg (Phabricator), clayborg (GitHub), 
clayborg (Discourse)
+| gclayton\@fb.com (email), clayborg (GitHub), clayborg (Discourse)
 
 
 Lua
 ~~~
 | Jonas Delvieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Python
 ~~
 | Med Ismail Bennani
-| ismail\@bennani.ma (email), mib (Phabricator), medismailben (GitHub), mib 
(Discourse), mib#8727 (Discord)
+| ismail\@bennani.ma (email), medismailben (GitHub), mib (Discourse), mib#8727 
(Discord)
 
 Target/Process Control
 ~~
 | Med Ismail Bennani
-| ismail\@bennani.ma (email), mib (Phabricator), medismailben (GitHub), mib 
(Discourse), mib#8727 (Discord)
+| ismail\@bennani.ma (email), medismailben (GitHub), mib (Discourse), mib#8727 
(Discord)
 
 | Jim Ingham
-| jingham\@apple.com (email), jingham (Phabricator), jimingham (GitHub), 
jingham (Discourse)
+| jingham\@apple.com (email), jimingham (GitHub), jingham (Discourse)
 
 Test Suite
 ~~
 | Jonas Devlieghere
-| jonas\@devlieghere.com (email), jdevlieghere (Phabricator), jdevlieghere 
(GitHub), jdevlieghere (Discourse), jdevlieghere (Discord)
+| jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 | Pavel Labath
-| pavel\@labath.sk (email), labath (Phabricator), labath (GitHub), labath 
(Discourse)
+| pavel\@labath.sk (email), labath (GitHub), labath (Discourse)

[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)

2024-08-09 Thread Michael Buch via lldb-commits


@@ -734,9 +740,13 @@ def update(self):
 # variable tells which element in this NxM array is the 0th
 # one, and the 'size' element gives the number of elements
 # in the deque.
-count = self._get_value_of_compressed_pair(
-self.valobj.GetChildMemberWithName("__size_")
-)
+if has_compressed_pair_layout:
+count = self._get_value_of_compressed_pair(
+self.valobj.GetChildMemberWithName("__size_")
+)
+else:
+count = size_valobj.GetValueAsUnsigned(0)

Michael137 wrote:

Yea I remember looking into an issue like that for some other formatter. Though 
this patch doesn't change behaviour in this case. If we had garbage in 
`__size_`, we previously would've also read its value and treated it as the 
`count`. The only difference here is that we don't unwrap the `compressed_pair` 
anymore.

I'll open a follow-up issue for fixing this in a separate PR. In fact, the 
other issue might still be open somewhere. I'll have a look

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


[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)

2024-08-09 Thread Michael Buch via lldb-commits


@@ -734,9 +740,13 @@ def update(self):
 # variable tells which element in this NxM array is the 0th
 # one, and the 'size' element gives the number of elements
 # in the deque.
-count = self._get_value_of_compressed_pair(
-self.valobj.GetChildMemberWithName("__size_")
-)
+if has_compressed_pair_layout:
+count = self._get_value_of_compressed_pair(
+self.valobj.GetChildMemberWithName("__size_")
+)
+else:
+count = size_valobj.GetValueAsUnsigned(0)

Michael137 wrote:

Ah here's one example: https://github.com/llvm/llvm-project/pull/69614

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 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/102601
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-clang-codegen

Author: None (Dhruv-Srivastava-IBM)


Changes

We have Implemented the necessary code changes required to run LLDB on AIX. 
This PR is for discussion as asked in #101657
With this PR, we request your inputs and feedback about our code changes. 


---

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


128 Files Affected:

- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+5-1) 
- (modified) lldb/CMakeLists.txt (+4) 
- (added) lldb/NOTICE.TXT (+7) 
- (modified) lldb/cmake/modules/LLDBConfig.cmake (+1-1) 
- (modified) lldb/include/lldb/Core/Module.h (+3) 
- (modified) lldb/include/lldb/Core/ModuleSpec.h (+21-2) 
- (modified) lldb/include/lldb/Host/HostGetOpt.h (+1-1) 
- (modified) lldb/include/lldb/Host/HostInfo.h (+3) 
- (modified) lldb/include/lldb/Host/HostInfoBase.h (+1-1) 
- (modified) lldb/include/lldb/Host/XML.h (+5) 
- (added) lldb/include/lldb/Host/aix/AbstractSocket.h (+25) 
- (added) lldb/include/lldb/Host/aix/Host.h (+22) 
- (added) lldb/include/lldb/Host/aix/HostInfoAIX.h (+42) 
- (added) lldb/include/lldb/Host/aix/Ptrace.h (+62) 
- (added) lldb/include/lldb/Host/aix/Support.h (+29) 
- (added) lldb/include/lldb/Host/aix/Uio.h (+23) 
- (modified) lldb/include/lldb/Host/common/GetOptInc.h (+3-3) 
- (modified) lldb/include/lldb/Symbol/ObjectFile.h (+5) 
- (modified) lldb/include/lldb/Target/ABI.h (+6) 
- (modified) lldb/include/lldb/Target/DynamicLoader.h (+6) 
- (modified) lldb/include/lldb/Target/Process.h (+14) 
- (modified) lldb/include/lldb/Target/RegisterContextUnwind.h (+4) 
- (modified) lldb/include/lldb/Target/ThreadPlanCallFunction.h (+6) 
- (modified) lldb/include/lldb/Utility/StringExtractorGDBRemote.h (+1) 
- (modified) lldb/include/lldb/lldb-private-enumerations.h (+1) 
- (modified) lldb/source/API/CMakeLists.txt (+108) 
- (modified) lldb/source/API/SBBreakpoint.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointLocation.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointName.cpp (+2-2) 
- (modified) lldb/source/Core/DynamicLoader.cpp (+10) 
- (modified) lldb/source/Core/Mangled.cpp (+2) 
- (modified) lldb/source/Core/Module.cpp (+12) 
- (modified) lldb/source/Core/Section.cpp (+4) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+5-5) 
- (modified) lldb/source/Host/CMakeLists.txt (+13) 
- (added) lldb/source/Host/aix/AbstractSocket.cpp (+21) 
- (added) lldb/source/Host/aix/Host.cpp (+304) 
- (added) lldb/source/Host/aix/HostInfoAIX.cpp (+215) 
- (added) lldb/source/Host/aix/Support.cpp (+44) 
- (modified) lldb/source/Host/common/GetOptInc.cpp (+1-1) 
- (modified) lldb/source/Host/common/Host.cpp (+174-6) 
- (added) lldb/source/Host/common/LICENSE.aix-netbsd.txt (+125) 
- (modified) lldb/source/Host/common/XML.cpp (+3) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/FileSystemPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+17) 
- (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (+5) 
- (modified) lldb/source/Initialization/CMakeLists.txt (+1-1) 
- (modified) lldb/source/Initialization/SystemInitializerCommon.cpp (+2-2) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+130-1) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h (+6) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/CMakeLists.txt (+11) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.cpp 
(+272) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.h 
(+55) 
- (modified) lldb/source/Plugins/DynamicLoader/CMakeLists.txt (+1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
(+2-2) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+1-1) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp 
(+193-3) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h 
(+14) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
 (+1-1) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
(+7-7) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
 (+1-1) 
- (modified) lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (+4) 
- (modified) lldb/source/Plugins/Language/ObjC/Cocoa.cpp (+2) 
- (modified) lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp 
(+1-1) 
- (modified) 
lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp 
(+1-1) 
- (added) lldb/source/Plugins/ObjectContainer/Big-Archive/CMakeLists.txt (+10) 
- (added) 
lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectContainerBigArchive.cpp 
(+522) 
- (added) 
lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectConta

[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (Dhruv-Srivastava-IBM)


Changes

We have Implemented the necessary code changes required to run LLDB on AIX. 
This PR is for discussion as asked in #101657
With this PR, we request your inputs and feedback about our code changes. 


---

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


128 Files Affected:

- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+5-1) 
- (modified) lldb/CMakeLists.txt (+4) 
- (added) lldb/NOTICE.TXT (+7) 
- (modified) lldb/cmake/modules/LLDBConfig.cmake (+1-1) 
- (modified) lldb/include/lldb/Core/Module.h (+3) 
- (modified) lldb/include/lldb/Core/ModuleSpec.h (+21-2) 
- (modified) lldb/include/lldb/Host/HostGetOpt.h (+1-1) 
- (modified) lldb/include/lldb/Host/HostInfo.h (+3) 
- (modified) lldb/include/lldb/Host/HostInfoBase.h (+1-1) 
- (modified) lldb/include/lldb/Host/XML.h (+5) 
- (added) lldb/include/lldb/Host/aix/AbstractSocket.h (+25) 
- (added) lldb/include/lldb/Host/aix/Host.h (+22) 
- (added) lldb/include/lldb/Host/aix/HostInfoAIX.h (+42) 
- (added) lldb/include/lldb/Host/aix/Ptrace.h (+62) 
- (added) lldb/include/lldb/Host/aix/Support.h (+29) 
- (added) lldb/include/lldb/Host/aix/Uio.h (+23) 
- (modified) lldb/include/lldb/Host/common/GetOptInc.h (+3-3) 
- (modified) lldb/include/lldb/Symbol/ObjectFile.h (+5) 
- (modified) lldb/include/lldb/Target/ABI.h (+6) 
- (modified) lldb/include/lldb/Target/DynamicLoader.h (+6) 
- (modified) lldb/include/lldb/Target/Process.h (+14) 
- (modified) lldb/include/lldb/Target/RegisterContextUnwind.h (+4) 
- (modified) lldb/include/lldb/Target/ThreadPlanCallFunction.h (+6) 
- (modified) lldb/include/lldb/Utility/StringExtractorGDBRemote.h (+1) 
- (modified) lldb/include/lldb/lldb-private-enumerations.h (+1) 
- (modified) lldb/source/API/CMakeLists.txt (+108) 
- (modified) lldb/source/API/SBBreakpoint.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointLocation.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointName.cpp (+2-2) 
- (modified) lldb/source/Core/DynamicLoader.cpp (+10) 
- (modified) lldb/source/Core/Mangled.cpp (+2) 
- (modified) lldb/source/Core/Module.cpp (+12) 
- (modified) lldb/source/Core/Section.cpp (+4) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+5-5) 
- (modified) lldb/source/Host/CMakeLists.txt (+13) 
- (added) lldb/source/Host/aix/AbstractSocket.cpp (+21) 
- (added) lldb/source/Host/aix/Host.cpp (+304) 
- (added) lldb/source/Host/aix/HostInfoAIX.cpp (+215) 
- (added) lldb/source/Host/aix/Support.cpp (+44) 
- (modified) lldb/source/Host/common/GetOptInc.cpp (+1-1) 
- (modified) lldb/source/Host/common/Host.cpp (+174-6) 
- (added) lldb/source/Host/common/LICENSE.aix-netbsd.txt (+125) 
- (modified) lldb/source/Host/common/XML.cpp (+3) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/FileSystemPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+17) 
- (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (+5) 
- (modified) lldb/source/Initialization/CMakeLists.txt (+1-1) 
- (modified) lldb/source/Initialization/SystemInitializerCommon.cpp (+2-2) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+130-1) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h (+6) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/CMakeLists.txt (+11) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.cpp 
(+272) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.h 
(+55) 
- (modified) lldb/source/Plugins/DynamicLoader/CMakeLists.txt (+1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
(+2-2) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+1-1) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp 
(+193-3) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h 
(+14) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
 (+1-1) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
(+7-7) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
 (+1-1) 
- (modified) lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (+4) 
- (modified) lldb/source/Plugins/Language/ObjC/Cocoa.cpp (+2) 
- (modified) lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp 
(+1-1) 
- (modified) 
lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp 
(+1-1) 
- (added) lldb/source/Plugins/ObjectContainer/Big-Archive/CMakeLists.txt (+10) 
- (added) 
lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectContainerBigArchive.cpp 
(+522) 
- (added) 
lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectContainerBigArchive.h 
(+177) 
- (modified) lldb/source/

[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread via lldb-commits

https://github.com/Dhruv-Srivastava-IBM edited 
https://github.com/llvm/llvm-project/pull/102601
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -38,6 +38,10 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  add_definitions("-D__AIX__")

DavidSpickett wrote:

This looks like a macro that a compiler might set for you, is that not the case 
here?

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -11,6 +11,11 @@
 
 #include "lldb/Host/Config.h"
 
+#if defined(__AIX__)
+//FIXME for AIX
+#undef LLDB_ENABLE_LIBXML2

DavidSpickett wrote:

In theory if you configure with `-DLLDB_ENABLE_LIBXML2=OFF`, the libxml2 parts 
will be removed. Was something else being included despite that?

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

It's worth putting the PR into draft mode just to be extra clear this is a 
request for early feedback.

This PR will be later split up of course, so very general comments from me. 
Very impressive effort overall.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -40,6 +40,113 @@ add_custom_target(lldb-sbapi-dwarf-enums
   DEPENDS ${sb_languages_file})
 set_target_properties(lldb-sbapi-dwarf-enums PROPERTIES FOLDER 
"LLDB/Tablegenning")
 
+if(CMAKE_SYSTEM_NAME MATCHES "AIX")
+add_lldb_library(liblldb STATIC ${option_framework}

DavidSpickett wrote:

I'm sure we can find a way to refactor this, deal with that later, but is there 
a reason that it needs to be static? Is this a property of libraries on AIX 
perhaps.

I know we had someone wanting to build a static library elsewhere but I'm not 
sure if it was this one.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -1510,6 +1510,18 @@ bool Module::SetLoadAddress(Target &target, lldb::addr_t 
value,
   return false;
 }
 
+bool Module::SetLoadAddressByType(Target &target, lldb::addr_t value,
+bool value_is_offset, bool &changed, int type_id) {
+  ObjectFile *object_file = GetObjectFile();
+  if (object_file != nullptr) {
+changed = object_file->SetLoadAddressByType(target, value, 
value_is_offset, type_id);
+return true;
+  } else {
+changed = false;
+  }

DavidSpickett wrote:

Tip for later PRs, 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

(but don't bother with style changes at this point of course)

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -342,7 +342,7 @@ uint32_t SBBreakpoint::GetIgnoreCount() const {
   return count;
 }
 
-void SBBreakpoint::SetThreadID(tid_t tid) {
+void SBBreakpoint::SetThreadID(lldb::tid_t tid) {

DavidSpickett wrote:

If these lldb:: are fixing compilation errors they would be welcome as a 
separate patch.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -0,0 +1,62 @@
+//===-- Ptrace.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
+//
+//===--===//
+
+// This file defines ptrace functions & structures
+
+#ifndef liblldb_Host_aix_Ptrace_h_
+#define liblldb_Host_aix_Ptrace_h_
+
+#include 
+
+#define DEBUG_PTRACE_MAXBYTES 20
+
+// Support ptrace extensions even when compiled without required kernel support
+#ifndef PTRACE_GETREGS
+#define PTRACE_GETREGS  (PT_COMMAND_MAX+1)
+#endif
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS  (PT_COMMAND_MAX+2)
+#endif
+#ifndef PTRACE_GETFPREGS
+#define PTRACE_GETFPREGS(PT_COMMAND_MAX+3)
+#endif
+#ifndef PTRACE_SETFPREGS
+#define PTRACE_SETFPREGS(PT_COMMAND_MAX+4)
+#endif
+#ifndef PTRACE_GETREGSET
+#define PTRACE_GETREGSET 0x4204
+#endif
+#ifndef PTRACE_SETREGSET
+#define PTRACE_SETREGSET 0x4205
+#endif
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA  (PT_COMMAND_MAX+5)
+#endif
+#ifndef PTRACE_ARCH_PRCTL
+#define PTRACE_ARCH_PRCTL   (PT_COMMAND_MAX+6)
+#endif
+#ifndef ARCH_GET_FS
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
+#endif
+#ifndef PTRACE_PEEKMTETAGS
+#define PTRACE_PEEKMTETAGS  (PT_COMMAND_MAX+7)

DavidSpickett wrote:

Funny seeing this here, I worked on lldb's MTE support for AArch64. Does AIX 
support a memory tagging feature as well?

If so I'd be quite interested to see how it fits into the memory tagging 
support code. I tried to make it generic but when you've only got one 
implementation, you never know if it's truly flexible or not.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -0,0 +1,7 @@
+
+This product contains small piece of code to support AIX, taken from netbsd.
+
+  * LICENSE:
+* lldb/source/Host/common/LICENSE.aix-netbsd.txt (OpenSSL License)

DavidSpickett wrote:

We'll need to confirm license compatibility for this.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -67,6 +67,10 @@ class RegisterContextUnwind : public 
lldb_private::RegisterContext {
 
   bool ReadPC(lldb::addr_t &start_pc);
 
+#ifdef __AIX__
+  bool ReadLR(lldb::addr_t &lr);
+#endif
+

DavidSpickett wrote:

It's likely we'd ask you to make this a method on all platforms that is only 
called on, or implemented for, AIX.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -0,0 +1,7 @@
+
+This product contains small piece of code to support AIX, taken from netbsd.
+
+  * LICENSE:
+* lldb/source/Host/common/LICENSE.aix-netbsd.txt (OpenSSL License)

DavidSpickett wrote:

And if there is a way not to pull in this code, we're likely going to prefer 
that.

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits


@@ -38,6 +38,10 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  add_definitions("-D__AIX__")

DavidSpickett wrote:

Also remember that users may be debugging AIX from a non-AIX host where the 
compiler would not be setting any macros like that.

(though perhaps this is exactly why you defined this manually, just to get it 
working on AIX only as the first step)

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


[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

2024-08-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits


@@ -0,0 +1,66 @@
+//===-- RealpathPrefixes.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 "lldb/Utility/RealpathPrefixes.h"
+
+#include "lldb/Target/Statistics.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/FileSpecList.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb_private;
+
+RealpathPrefixes::RealpathPrefixes(const FileSpecList &file_spec_list)
+: m_fs(llvm::vfs::getRealFileSystem()), m_target(nullptr) {
+  m_prefixes.reserve(file_spec_list.GetSize());
+  for (const FileSpec &file_spec : file_spec_list) {
+m_prefixes.emplace_back(file_spec.GetPath());
+  }
+}
+
+void RealpathPrefixes::SetFileSystem(
+llvm::IntrusiveRefCntPtr fs) {
+  m_fs = fs;
+}
+
+std::optional
+RealpathPrefixes::ResolveSymlinks(const FileSpec &file_spec) const {
+  if (m_prefixes.empty())
+return std::nullopt;
+
+  auto is_prefix = [](llvm::StringRef a, llvm::StringRef b,
+  bool case_sensitive) -> bool {
+return case_sensitive ? a.consume_front(b) : 
a.consume_front_insensitive(b);

royitaqi wrote:

That's reasonable.

IIUC, the source path logic:
* Say the source-map is: /foo => /bar
* The user set breakpoint for /barqux/main.cpp:1
* It causes `PathMappingList::ReverseRemapPath()`
* STRING prefix match is successful (/bar is prefix of /barqux/main.cpp)
* qux/main.cpp is the remaining list of components
* Each COMPONENT is added onto the other side of the mapping, the /foo, as 
separate path components
* The result is /foo/qux/main.cpp

Overall I'd say this logic cares about components of paths. (Side note: It's a 
bit weird to me that the [prefix 
match](https://github.com/llvm/llvm-project/blob/main/lldb/source/Target/PathMappingList.cpp#L209)
 is done as a pure string match.)

Let me change `is_prefix` into component-sensitive, too. Probably by checking 
if the remaining path is empty or starts with a "/", similar to what the 
`is_suffix` does.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-08-09 Thread via lldb-commits


@@ -0,0 +1,560 @@
+//===-- DILAST.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 "lldb/Core/DILAST.h"
+#include "lldb/API/SBType.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/RegisterContext.h"
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+namespace lldb_private {
+
+namespace DIL {
+
+lldb::ValueObjectSP
+GetDynamicOrSyntheticValue(lldb::ValueObjectSP in_valobj_sp,
+   lldb::DynamicValueType use_dynamic,
+   bool use_synthetic) {
+  Status error;
+
+  if (!in_valobj_sp) {
+error.SetErrorString("invalid value object");
+return in_valobj_sp;
+  }
+
+  lldb::ValueObjectSP value_sp = in_valobj_sp;
+
+  Target *target = value_sp->GetTargetSP().get();
+  // If this ValueObject holds an error, then it is valuable for that.
+  if (value_sp->GetError().Fail())
+return value_sp;
+
+  if (!target)
+return lldb::ValueObjectSP();
+
+  if (use_dynamic != lldb::eNoDynamicValues) {
+lldb::ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(use_dynamic);
+if (dynamic_sp)
+  value_sp = dynamic_sp;
+  }
+
+  if (use_synthetic) {
+lldb::ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
+if (synthetic_sp)
+  value_sp = synthetic_sp;
+  }
+
+  if (!value_sp)
+error.SetErrorString("invalid value object");
+
+  return value_sp;
+}
+
+CompilerType DILASTNode::GetDereferencedResultType() const {
+  auto type = result_type();
+  return type.IsReferenceType() ? type.GetNonReferenceType() : type;
+}
+
+std::optional
+GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string &name, std::vector *idx,
+  CompilerType empty_type, bool use_synthetic,
+  bool is_dynamic) {
+  bool is_synthetic = false;
+  // Go through the fields first.
+  uint32_t num_fields = type.GetNumFields();
+  lldb::ValueObjectSP empty_valobj_sp;
+  for (uint32_t i = 0; i < num_fields; ++i) {
+uint64_t bit_offset = 0;
+uint32_t bitfield_bit_size = 0;
+bool is_bitfield = false;
+std::string name_sstr;
+CompilerType field_type(type.GetFieldAtIndex(
+i, name_sstr, &bit_offset, &bitfield_bit_size, &is_bitfield));
+auto field_name =
+name_sstr.length() == 0 ? std::optional() : name_sstr;
+if (field_type.IsValid()) {
+  std::optional size_in_bits;
+  if (is_bitfield)
+size_in_bits = bitfield_bit_size;
+  struct MemberInfo field = {field_name,   field_type, size_in_bits,
+ is_synthetic, is_dynamic, empty_valobj_sp};
+
+  // Name can be null if this is a padding field.
+  if (field.name == name) {
+if (lhs_val_sp) {
+  lldb::ValueObjectSP child_valobj_sp =
+  lhs_val_sp->GetChildMemberWithName(name);
+  if (child_valobj_sp)
+field.val_obj_sp = child_valobj_sp;
+}
+
+if (idx) {
+  assert(idx->empty());
+  // Direct base classes are located before fields, so field members
+  // needs to be offset by the number of base classes.
+  idx->push_back(i + type.GetNumberOfNonEmptyBaseClasses());
+}
+return field;
+  } else if (field.type.IsAnonymousType()) {
+// Every member of an anonymous struct is considered to be a member of
+// the enclosing struct or union. This applies recursively if the
+// enclosing struct or union is also anonymous.
+
+assert(!field.name && "Field should be unnamed.");
+
+std::optional field_in_anon_type =
+GetFieldWithNameIndexPath(lhs_val_sp, field.type, name, idx,
+  empty_type, use_synthetic, is_dynamic);
+if (field_in_anon_type) {
+  if (idx) {
+idx->push_back(i + type.GetNumberOfNonEmptyBaseClasses());
+  }
+  return field_in_anon_type.value();
+}
+  }
+}
+  }
+
+  // LLDB can't access inherited fields of anonymous struct members.
+  if (type.IsAnonymousType()) {
+return {};
+  }
+
+  // Go through the base classes and look for the field there.
+  uint32_t num_non_empty_bases = 0;
+  uint32_t num_direct_bases = type.GetNumDirectBaseClasses();
+  for (uint32_t i = 0; i < num_direct_bases; ++i) {
+uint32_t bit_offset;
+auto base = type.GetDirectBaseClassAtIndex(i, &bit_offset);
+auto field = GetFieldWithNameIndexPath(
+lhs_val_sp, base

[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Miro Bucko via lldb-commits


@@ -2835,6 +2835,34 @@ void PruneThreadPlans();
   AddressRanges &matches, size_t alignment,
   size_t max_matches);
 
+  template 
+  lldb::addr_t FindInMemoryGeneric(IT &&iterator, lldb::addr_t low,
+   lldb::addr_t high, const uint8_t *buf,
+   size_t size) {
+const size_t region_size = high - low;
+
+if (region_size < size)
+  return LLDB_INVALID_ADDRESS;
+
+std::vector bad_char_heuristic(256, size);
+
+for (size_t idx = 0; idx < size - 1; idx++) {
+  decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
+  bad_char_heuristic[bcu_idx] = size - idx - 1;
+}
+for (size_t s = 0; s <= (region_size - size);) {
+  int64_t j = size - 1;
+  while (j >= 0 && buf[j] == iterator[s + j])
+j--;
+  if (j < 0)
+return low + s;
+  else
+s += bad_char_heuristic[iterator[s + size - 1]];
+}
+
+return LLDB_INVALID_ADDRESS;
+  }
+

mbucko wrote:

Yes, there are two usecases.Process uses ProcessMemoryIterator class as the 
iterator which then uses m_process.ReadMemory() to access the data. Then, the 
PostMortemProcess uses a raw pointer to the memory

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


[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits


@@ -0,0 +1,66 @@
+//===-- RealpathPrefixes.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 "lldb/Utility/RealpathPrefixes.h"
+
+#include "lldb/Target/Statistics.h"
+#include "lldb/Target/Target.h"

royitaqi wrote:

Thanks for all the inspiring options you mentioned, especially the aliasing 
constructor which I didn't know.

> It may also be possible to keep a record of the statistics on the inside the 
> object itself, and only later add it to the ones in the Target. This would 
> make sense if there's a natural place where you can insert the call to gather 
> the stats (either when the object is destructed, when the stats are 
> requested, etc.).

I went for this approach, because it's the easiest to reason about lifecycle 
and there *is* a natural location to gather these stats. This can also be 
easily refactored if/when we move statistics code into Utility.

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


[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Thinking about this some more here are my thoughts: both `ObjectFile::PeekData` 
and `PostMoretemProcess::PeekMemory` should have a way to say "I am not 
implemented".  Using either a llvm::Expected or std::optional. If 
`ObjectFile::PeekData` returns unimplemented, we need to fall back to 
`ObjectFile::CopyData`. If `PostMoretemProcess::PeekMemory` returns 
unimplemented, we need to fall back to standard 
`PostMoretemProcess::ReadMemory`. The main reason being: some core files are 
too large to mmap into memory and at some point we need to be able to not load 
the entire core file at once. If we don't load the entire core file, then we 
need to allow `PostMoretemProcess::PeekMemory` to succeed for areas it does 
have mapped into the process, and fail for areas where it can't. If we build in 
the fallback stuff as mentioned, then this all continues to work.

So the main idea is: if either ObjectFile or PostMortemProcess can return a 
reference to the data in the Peek calls, then should as long as they have this 
data mapped into the LLDB address space and can hand out a pointer to the data. 
If they can't, we should fall back to something that can copy the data into a 
buffer as mentioned with `CopyData` or `ReadMemory`. Core files or object files 
might compress up their data, in which case we wouldn't be able to hande out a 
buffer from calls to Peek, but we would need to unzip the buffer into the 
buffer supplied by CopyData and ReadMemory on the fly.

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


[Lldb-commits] [lldb] [LLDB] Impove ObjectFileELF's .dynamic parsing and usage. (PR #102570)

2024-08-09 Thread Greg Clayton via lldb-commits

clayborg wrote:

@labath this is the same patch you already accepted + fix

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


[Lldb-commits] [lldb] [lldb] Tolerate multiple compile units with the same DWO ID (PR #100577)

2024-08-09 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Tolerate multiple compile units with the same DWO ID (PR #100577)

2024-08-09 Thread Greg Clayton via lldb-commits


@@ -97,12 +97,14 @@ void DWARFUnit::ExtractUnitDIEIfNeeded() {
 *m_dwo_id, m_first_die.GetOffset()));
 return; // Can't fetch the compile unit from the dwo file.
   }
-  // If the skeleton compile unit gets its unit DIE parsed first, then this
-  // will fill in the DWO file's back pointer to this skeleton compile unit.
-  // If the DWO files get parsed on their own first the skeleton back link
-  // can be done manually in DWARFUnit::GetSkeletonCompileUnit() which will
-  // do a reverse lookup and cache the result.
-  dwo_cu->SetSkeletonUnit(this);
+
+  // Link the DWO unit to this object, if it hasn't been linked already (this
+  // can happen when we have an index, and the DWO unit is parsed first).
+  if (!dwo_cu->LinkToSkeletonUnit(*this)) {
+SetDwoError(Status::createWithFormat(
+"multiple compile units with Dwo ID {0:x16}", *m_dwo_id));

clayborg wrote:

Sorry for the delay. Lets start with this and see how things go and if we ever 
see this. 

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


[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Miro Bucko via lldb-commits


@@ -33,6 +34,23 @@ class PostMortemProcess : public Process {
   FileSpec GetCoreFile() const override { return m_core_file; }
 
 protected:
+  typedef lldb_private::Range FileRange;
+  typedef lldb_private::RangeDataVector
+  VMRangeToFileOffset;
+  typedef lldb_private::RangeDataVector
+  VMRangeToPermissions;
+
+  virtual const uint8_t *PeekMemory(lldb::addr_t low, lldb::addr_t high,
+size_t &size) = 0;

mbucko wrote:

It is sufficient to return an empty ArrayRef. Also, that is what all other APIs 
use in lldb. I will keep it the return type as llvm::ArrayRef but let 
me know if you do want me to use std::optional.

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


[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Miro Bucko via lldb-commits

mbucko wrote:

> Thinking about this some more here are my thoughts: both 
> `ObjectFile::PeekData` and `PostMoretemProcess::PeekMemory` should have a way 
> to say "I am not implemented". Using either a llvm::Expected or 
> std::optional. If `ObjectFile::PeekData` returns unimplemented, we need to 
> fall back to `ObjectFile::CopyData`. If `PostMoretemProcess::PeekMemory` 
> returns unimplemented, we need to fall back to standard 
> `PostMoretemProcess::ReadMemory`. The main reason being: some core files are 
> too large to mmap into memory and at some point we need to be able to not 
> load the entire core file at once. If we don't load the entire core file, 
> then we need to allow `PostMoretemProcess::PeekMemory` to succeed for areas 
> it does have mapped into the process, and fail for areas where it can't. If 
> we build in the fallback stuff as mentioned, then this all continues to work.
> 
> So the main idea is: if either ObjectFile or PostMortemProcess can return a 
> reference to the data in the Peek calls, then should as long as they have 
> this data mapped into the LLDB address space and can hand out a pointer to 
> the data. If they can't, we should fall back to something that can copy the 
> data into a buffer as mentioned with `CopyData` or `ReadMemory`. Core files 
> or object files might compress up their data, in which case we wouldn't be 
> able to hande out a buffer from calls to Peek, but we would need to unzip the 
> buffer into the buffer supplied by CopyData and ReadMemory on the fly.

This is already the behavior, if ObjectFile::PeekData returns anything other 
than an array with expected size, we fall back to the default implementation 
which uses the original ReadMemory() method.

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


[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/102223

>From c629defe38a510ffdd23122b2e9cfac68933cf34 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 2 Aug 2024 06:35:45 -0700
Subject: [PATCH 1/6] [lldb] Allow realpathing support files when resolving
 file/line breakpoints

Differential Revision: https://phabricator.intern.facebook.com/D60317677
---
 lldb/include/lldb/Symbol/CompileUnit.h| 10 +-
 lldb/include/lldb/Target/Target.h |  4 +
 lldb/include/lldb/Utility/FileSpecList.h  |  9 +-
 lldb/include/lldb/Utility/RealpathPrefixes.h  | 55 +++
 .../Breakpoint/BreakpointResolverFileLine.cpp |  6 +-
 lldb/source/Symbol/CompileUnit.cpp| 14 +--
 lldb/source/Target/Target.cpp |  8 ++
 lldb/source/Target/TargetProperties.td|  3 +
 lldb/source/Utility/CMakeLists.txt|  1 +
 lldb/source/Utility/FileSpecList.cpp  | 95 ---
 lldb/source/Utility/RealpathPrefixes.cpp  | 57 +++
 11 files changed, 216 insertions(+), 46 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/RealpathPrefixes.h
 create mode 100644 lldb/source/Utility/RealpathPrefixes.cpp

diff --git a/lldb/include/lldb/Symbol/CompileUnit.h 
b/lldb/include/lldb/Symbol/CompileUnit.h
index c20a37e3283075..6a9ef3e6c75bcb 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -24,6 +24,8 @@
 #include "llvm/ADT/DenseSet.h"
 
 namespace lldb_private {
+class RealpathPrefixes;
+
 /// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
 /// A class that describes a compilation unit.
 ///
@@ -390,9 +392,11 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// entries appended to.
   ///
   /// \see enum SymbolContext::Scope
-  void ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
-lldb::SymbolContextItem resolve_scope,
-SymbolContextList &sc_list);
+  void
+  ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
+   lldb::SymbolContextItem resolve_scope,
+   SymbolContextList &sc_list,
+   const RealpathPrefixes *realpath_prefixes = nullptr);
 
   /// Get whether compiler optimizations were enabled for this compile unit
   ///
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 119dff4d498199..d6d5f05e9258f2 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -39,6 +39,8 @@
 
 namespace lldb_private {
 
+class RealpathPrefixes;
+
 OptionEnumValues GetDynamicValueTypes();
 
 enum InlineStrategy {
@@ -117,6 +119,8 @@ class TargetProperties : public Properties {
 
   InlineStrategy GetInlineStrategy() const;
 
+  RealpathPrefixes GetSourceRealpathPrefixes() const;
+
   llvm::StringRef GetArg0() const;
 
   void SetArg0(llvm::StringRef arg);
diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 6eb3bb9971f13a..99a99a45a1dad2 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -17,6 +17,7 @@
 #include 
 
 namespace lldb_private {
+class RealpathPrefixes;
 class Stream;
 
 /// A list of support files for a CompileUnit.
@@ -64,10 +65,16 @@ class SupportFileList {
   /// \param[in] file
   /// The file specification to search for.
   ///
+  /// \param[in] realpath_prefixes
+  /// Paths that start with one of the prefixes in this list will be
+  /// realpath'ed to resolve any symlinks.
+  ///
   /// \return
   /// The index of the file that matches \a file if it is found,
   /// else UINT32_MAX is returned.
-  size_t FindCompatibleIndex(size_t idx, const FileSpec &file) const;
+  size_t FindCompatibleIndex(
+  size_t idx, const FileSpec &file,
+  const RealpathPrefixes *realpath_prefixes = nullptr) const;
 
   template  void EmplaceBack(Args &&...args) {
 m_files.push_back(
diff --git a/lldb/include/lldb/Utility/RealpathPrefixes.h 
b/lldb/include/lldb/Utility/RealpathPrefixes.h
new file mode 100644
index 00..ba39259980c067
--- /dev/null
+++ b/lldb/include/lldb/Utility/RealpathPrefixes.h
@@ -0,0 +1,55 @@
+//===-- RealpathPrefixes.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_CORE_REALPATHPREFIXES_H
+#define LLDB_CORE_REALPATHPREFIXES_H
+
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+class FileSpec;
+class FileSpecList;
+} // namespace lldb_private
+
+namespace lldb_private {
+

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-08-09 Thread Greg Clayton via lldb-commits

clayborg wrote:

> @clayborg as far as I can tell, the ball is currently in your court to 
> respond to @jimingham ... thanks in advance

Sounds like Jim is on the fence with a SetDirection + existing APIs and adding 
a direction to the calls. I am fine with either approach as long as Jim is ok 
with it because Jim is the code owner of the thread plans so he has better 
knowledge. Let me know if I missed any comment I should respond to other than 
this.

It really comes down to how the GUI and command line commands work for reverse 
debugging. So a few questions:
- Do GUI debuggers have different buttons for reverse stepping and running? Or 
is there a direction button and then the existing process control buttons 
remain the same (reverse continue, reverse step in/out/over)
- For command line do we have different comments for forward and reverse, or a 
direction command followed by normal commands?

If the GUI and command line have separate buttons and commands, then we should 
probably go with adding the direction to each API. This means duplicating each 
API and adding a direction enum, then taking the old API and forwarding to the 
new one. So for:

```
void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error);
```
we would now have:
```
void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error, 
lldb::RunDirection direction) {
  ...
}
void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
  return StepOver(stop_other_threads, error, eRunForward);
}
```
Another thing we tend to do if we start getting too many overloads it to create 
an options class. Right now for step over we have two overloads:
```
void SBThread::StepOver(lldb::RunMode stop_other_threads);
void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error);
```
Now we will add a third. If we keep needing more options in the future our 
overloads could start adding up. So what we do to avoid this is make an options 
class like:
```
class SBThreadStepOptions {
  bool GetStopOtherThreads();
  void SetStopOtherThreads(bool);
  lldb::RunDirection GetRunDirection();
  void SetRunDirection(lldb::RunDirection direction);
}
```
And then we have the SBThread::StepXXX calls use this options class
```
SBError SBThread::StepOver(const SBThreadStepOptions &options);
```
This is good because we can add accessors to the `SBThreadStepOptions` class 
without needing to ever add another `SBThread::StepOver` overload in the 
future. I could see us adding more options to the `SBThreadStepOptions` API in 
the future and then our public API for `SBThread::StepOver` doesn't need to 
change.

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


[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)

2024-08-09 Thread Igor Kudrin via lldb-commits


@@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() {
 }
 
 DataExtractor ProcessElfCore::GetAuxvData() {
-  const uint8_t *start = m_auxv.GetDataStart();
-  size_t len = m_auxv.GetByteSize();
-  lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
-  return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
+  assert(m_auxv.GetByteSize() == 0 ||
+ (m_auxv.GetByteOrder() == GetByteOrder() &&
+  m_auxv.GetAddressByteSize() == GetAddressByteSize()));

igorkudrin wrote:

I'd also prefer to return a constant reference, but there are other 
implementations of this virtual function that can't do that, for example, 
`ProcessGDBRemote::GetAuxvData()`.

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


[Lldb-commits] [lldb] 101cf54 - [lldb] Move definition of SBSaveCoreOptions dtor out of header (#102539)

2024-08-09 Thread via lldb-commits

Author: Alex Langford
Date: 2024-08-09T12:50:42-07:00
New Revision: 101cf540e698529d3dd899d00111bcb654a3c12b

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

LOG: [lldb] Move definition of SBSaveCoreOptions dtor out of header (#102539)

This class is technically not usable in its current state. When you use
it in a simple C++ project, your compiler will complain about an
incomplete definition of SaveCoreOptions. Normally this isn't a problem,
other classes in the SBAPI do this. The difference is that
SBSaveCoreOptions has a default destructor in the header, so the
compiler will attempt to generate the code for the destructor with an
incomplete definition of the impl type.

All methods for every class, including constructors and destructors,
must have a separate implementation not in a header.

Added: 


Modified: 
lldb/include/lldb/API/SBSaveCoreOptions.h
lldb/source/API/SBSaveCoreOptions.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index e77496bd3a4a0d..75506fd752e762 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -17,7 +17,7 @@ class LLDB_API SBSaveCoreOptions {
 public:
   SBSaveCoreOptions();
   SBSaveCoreOptions(const lldb::SBSaveCoreOptions &rhs);
-  ~SBSaveCoreOptions() = default;
+  ~SBSaveCoreOptions();
 
   const SBSaveCoreOptions &operator=(const lldb::SBSaveCoreOptions &rhs);
 

diff  --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 6c3f74596203d6..19ca83f932bcf1 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -29,6 +29,8 @@ SBSaveCoreOptions::SBSaveCoreOptions(const SBSaveCoreOptions 
&rhs) {
   m_opaque_up = clone(rhs.m_opaque_up);
 }
 
+SBSaveCoreOptions::~SBSaveCoreOptions() = default;
+
 const SBSaveCoreOptions &
 SBSaveCoreOptions::operator=(const SBSaveCoreOptions &rhs) {
   LLDB_INSTRUMENT_VA(this, rhs);



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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread Alex Langford via lldb-commits

bulbazord wrote:

/cherry-pick 
[101cf54](https://github.com/llvm/llvm-project/commit/101cf540e698529d3dd899d00111bcb654a3c12b)

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread via lldb-commits

llvmbot wrote:


>/cherry-pick 
>[101cf54](https://github.com/llvm/llvm-project/commit/101cf540e698529d3dd899d00111bcb654a3c12b)

Error: Command failed due to missing milestone.

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


[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)

2024-08-09 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)

2024-08-09 Thread Greg Clayton via lldb-commits


@@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() {
 }
 
 DataExtractor ProcessElfCore::GetAuxvData() {
-  const uint8_t *start = m_auxv.GetDataStart();
-  size_t len = m_auxv.GetByteSize();
-  lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
-  return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
+  assert(m_auxv.GetByteSize() == 0 ||
+ (m_auxv.GetByteOrder() == GetByteOrder() &&
+  m_auxv.GetAddressByteSize() == GetAddressByteSize()));

clayborg wrote:

Sorry, I didn't realize this was a virtual function from Process.h... 

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread Alex Langford via lldb-commits

bulbazord wrote:

/cherry-pick 
https://github.com/llvm/llvm-project/commit/101cf540e698529d3dd899d00111bcb654a3c12b

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread via lldb-commits

llvmbot wrote:


>/cherry-pick 
>https://github.com/llvm/llvm-project/commit/101cf540e698529d3dd899d00111bcb654a3c12b

Error: Command failed due to missing milestone.

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


[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Greg Clayton via lldb-commits


@@ -33,6 +34,23 @@ class PostMortemProcess : public Process {
   FileSpec GetCoreFile() const override { return m_core_file; }
 
 protected:
+  typedef lldb_private::Range FileRange;
+  typedef lldb_private::RangeDataVector
+  VMRangeToFileOffset;
+  typedef lldb_private::RangeDataVector
+  VMRangeToPermissions;
+
+  virtual const uint8_t *PeekMemory(lldb::addr_t low, lldb::addr_t high,
+size_t &size) = 0;

clayborg wrote:

> It is sufficient to return an empty ArrayRef. Also, that is what all other 
> APIs use in lldb. I will keep it the return type as llvm::ArrayRef 
> but let me know if you do want me to use std::optional.

If returning a empty `llvm::ArrayRef` is enough for us to be able to 
fall back to `ReadMemory` then this is fine.

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread Alex Langford via lldb-commits

bulbazord wrote:

/cherry-pick 
https://github.com/llvm/llvm-project/commit/101cf540e698529d3dd899d00111bcb654a3c12b

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


[Lldb-commits] [lldb] [lldb] Move definition of SBSaveCoreOptions dtor out of header (PR #102539)

2024-08-09 Thread via lldb-commits

llvmbot wrote:

/pull-request llvm/llvm-project#102680

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


[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-09 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Looks pretty close to me. Lets give some time for others to review

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-08-09 Thread Robert O'Callahan via lldb-commits

rocallahan wrote:

> > @clayborg as far as I can tell, the ball is currently in your court to 
> > respond to @jimingham ... thanks in advance
> 
> Sounds like Jim is on the fence with a SetDirection + existing APIs and 
> adding a direction to the calls. I am fine with either approach as long as 
> Jim is ok with it because Jim is the code owner of the thread plans so he has 
> better knowledge. Let me know if I missed any comment I should respond to 
> other than this.

The initial disagreement here was that you advocated for a `ReverseContinue()` 
function (etc) while Jim didn't want to add `Reverse` versions of functions. It 
sounds like you're on board with the latter now, so thanks for that.

So now the question is whether to expose a persistent "current direction" flag 
or pass the direction as a parameter (defaulting to "forward") to each call to 
a function that advances execution.

> It really comes down to how the GUI and command line commands work for 
> reverse debugging. So a few questions:
> 
> * Do GUI debuggers have different buttons for reverse stepping and 
> running? Or is there a direction button and then the existing process control 
> buttons remain the same (reverse continue, reverse step in/out/over)

I've only seen them use separate buttons, see e.g. [CLion + 
UndoDB](https://blog.jetbrains.com/clion/2016/09/undo-for-clion/).

> * For command line do we have different comments for forward and reverse, 
> or a direction command followed by normal commands?

GDB [supports 
both](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Reverse-Execution.html).
 However, in practice I've never seen anyone use `set exec-direction`. My LLDB 
CLI patch adds a `-R` option to `thread continue`.

> If the GUI and command line have separate buttons and commands, then we 
> should probably go with adding the direction to each API.

OK, then I believe my current code is satisfactory.

> I could see us adding more options to the `SBThreadStepOptions` API in the 
> future and then our public API for `SBThread::StepOver` doesn't need to 
> change.

Sure. My current code doesn't support reverse stepping and the number of 
options to the `Continue()` APIs is small (zero currently for 
`SBProcess::Continue()`) so this isn't an issue yet.

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


[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/102223

>From c629defe38a510ffdd23122b2e9cfac68933cf34 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 2 Aug 2024 06:35:45 -0700
Subject: [PATCH 1/8] [lldb] Allow realpathing support files when resolving
 file/line breakpoints

Differential Revision: https://phabricator.intern.facebook.com/D60317677
---
 lldb/include/lldb/Symbol/CompileUnit.h| 10 +-
 lldb/include/lldb/Target/Target.h |  4 +
 lldb/include/lldb/Utility/FileSpecList.h  |  9 +-
 lldb/include/lldb/Utility/RealpathPrefixes.h  | 55 +++
 .../Breakpoint/BreakpointResolverFileLine.cpp |  6 +-
 lldb/source/Symbol/CompileUnit.cpp| 14 +--
 lldb/source/Target/Target.cpp |  8 ++
 lldb/source/Target/TargetProperties.td|  3 +
 lldb/source/Utility/CMakeLists.txt|  1 +
 lldb/source/Utility/FileSpecList.cpp  | 95 ---
 lldb/source/Utility/RealpathPrefixes.cpp  | 57 +++
 11 files changed, 216 insertions(+), 46 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/RealpathPrefixes.h
 create mode 100644 lldb/source/Utility/RealpathPrefixes.cpp

diff --git a/lldb/include/lldb/Symbol/CompileUnit.h 
b/lldb/include/lldb/Symbol/CompileUnit.h
index c20a37e3283075..6a9ef3e6c75bcb 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -24,6 +24,8 @@
 #include "llvm/ADT/DenseSet.h"
 
 namespace lldb_private {
+class RealpathPrefixes;
+
 /// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
 /// A class that describes a compilation unit.
 ///
@@ -390,9 +392,11 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// entries appended to.
   ///
   /// \see enum SymbolContext::Scope
-  void ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
-lldb::SymbolContextItem resolve_scope,
-SymbolContextList &sc_list);
+  void
+  ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
+   lldb::SymbolContextItem resolve_scope,
+   SymbolContextList &sc_list,
+   const RealpathPrefixes *realpath_prefixes = nullptr);
 
   /// Get whether compiler optimizations were enabled for this compile unit
   ///
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 119dff4d498199..d6d5f05e9258f2 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -39,6 +39,8 @@
 
 namespace lldb_private {
 
+class RealpathPrefixes;
+
 OptionEnumValues GetDynamicValueTypes();
 
 enum InlineStrategy {
@@ -117,6 +119,8 @@ class TargetProperties : public Properties {
 
   InlineStrategy GetInlineStrategy() const;
 
+  RealpathPrefixes GetSourceRealpathPrefixes() const;
+
   llvm::StringRef GetArg0() const;
 
   void SetArg0(llvm::StringRef arg);
diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 6eb3bb9971f13a..99a99a45a1dad2 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -17,6 +17,7 @@
 #include 
 
 namespace lldb_private {
+class RealpathPrefixes;
 class Stream;
 
 /// A list of support files for a CompileUnit.
@@ -64,10 +65,16 @@ class SupportFileList {
   /// \param[in] file
   /// The file specification to search for.
   ///
+  /// \param[in] realpath_prefixes
+  /// Paths that start with one of the prefixes in this list will be
+  /// realpath'ed to resolve any symlinks.
+  ///
   /// \return
   /// The index of the file that matches \a file if it is found,
   /// else UINT32_MAX is returned.
-  size_t FindCompatibleIndex(size_t idx, const FileSpec &file) const;
+  size_t FindCompatibleIndex(
+  size_t idx, const FileSpec &file,
+  const RealpathPrefixes *realpath_prefixes = nullptr) const;
 
   template  void EmplaceBack(Args &&...args) {
 m_files.push_back(
diff --git a/lldb/include/lldb/Utility/RealpathPrefixes.h 
b/lldb/include/lldb/Utility/RealpathPrefixes.h
new file mode 100644
index 00..ba39259980c067
--- /dev/null
+++ b/lldb/include/lldb/Utility/RealpathPrefixes.h
@@ -0,0 +1,55 @@
+//===-- RealpathPrefixes.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_CORE_REALPATHPREFIXES_H
+#define LLDB_CORE_REALPATHPREFIXES_H
+
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+class FileSpec;
+class FileSpecList;
+} // namespace lldb_private
+
+namespace lldb_private {
+

[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/102223

>From c629defe38a510ffdd23122b2e9cfac68933cf34 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 2 Aug 2024 06:35:45 -0700
Subject: [PATCH 1/9] [lldb] Allow realpathing support files when resolving
 file/line breakpoints

Differential Revision: https://phabricator.intern.facebook.com/D60317677
---
 lldb/include/lldb/Symbol/CompileUnit.h| 10 +-
 lldb/include/lldb/Target/Target.h |  4 +
 lldb/include/lldb/Utility/FileSpecList.h  |  9 +-
 lldb/include/lldb/Utility/RealpathPrefixes.h  | 55 +++
 .../Breakpoint/BreakpointResolverFileLine.cpp |  6 +-
 lldb/source/Symbol/CompileUnit.cpp| 14 +--
 lldb/source/Target/Target.cpp |  8 ++
 lldb/source/Target/TargetProperties.td|  3 +
 lldb/source/Utility/CMakeLists.txt|  1 +
 lldb/source/Utility/FileSpecList.cpp  | 95 ---
 lldb/source/Utility/RealpathPrefixes.cpp  | 57 +++
 11 files changed, 216 insertions(+), 46 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/RealpathPrefixes.h
 create mode 100644 lldb/source/Utility/RealpathPrefixes.cpp

diff --git a/lldb/include/lldb/Symbol/CompileUnit.h 
b/lldb/include/lldb/Symbol/CompileUnit.h
index c20a37e3283075..6a9ef3e6c75bcb 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -24,6 +24,8 @@
 #include "llvm/ADT/DenseSet.h"
 
 namespace lldb_private {
+class RealpathPrefixes;
+
 /// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
 /// A class that describes a compilation unit.
 ///
@@ -390,9 +392,11 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// entries appended to.
   ///
   /// \see enum SymbolContext::Scope
-  void ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
-lldb::SymbolContextItem resolve_scope,
-SymbolContextList &sc_list);
+  void
+  ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
+   lldb::SymbolContextItem resolve_scope,
+   SymbolContextList &sc_list,
+   const RealpathPrefixes *realpath_prefixes = nullptr);
 
   /// Get whether compiler optimizations were enabled for this compile unit
   ///
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 119dff4d498199..d6d5f05e9258f2 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -39,6 +39,8 @@
 
 namespace lldb_private {
 
+class RealpathPrefixes;
+
 OptionEnumValues GetDynamicValueTypes();
 
 enum InlineStrategy {
@@ -117,6 +119,8 @@ class TargetProperties : public Properties {
 
   InlineStrategy GetInlineStrategy() const;
 
+  RealpathPrefixes GetSourceRealpathPrefixes() const;
+
   llvm::StringRef GetArg0() const;
 
   void SetArg0(llvm::StringRef arg);
diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 6eb3bb9971f13a..99a99a45a1dad2 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -17,6 +17,7 @@
 #include 
 
 namespace lldb_private {
+class RealpathPrefixes;
 class Stream;
 
 /// A list of support files for a CompileUnit.
@@ -64,10 +65,16 @@ class SupportFileList {
   /// \param[in] file
   /// The file specification to search for.
   ///
+  /// \param[in] realpath_prefixes
+  /// Paths that start with one of the prefixes in this list will be
+  /// realpath'ed to resolve any symlinks.
+  ///
   /// \return
   /// The index of the file that matches \a file if it is found,
   /// else UINT32_MAX is returned.
-  size_t FindCompatibleIndex(size_t idx, const FileSpec &file) const;
+  size_t FindCompatibleIndex(
+  size_t idx, const FileSpec &file,
+  const RealpathPrefixes *realpath_prefixes = nullptr) const;
 
   template  void EmplaceBack(Args &&...args) {
 m_files.push_back(
diff --git a/lldb/include/lldb/Utility/RealpathPrefixes.h 
b/lldb/include/lldb/Utility/RealpathPrefixes.h
new file mode 100644
index 00..ba39259980c067
--- /dev/null
+++ b/lldb/include/lldb/Utility/RealpathPrefixes.h
@@ -0,0 +1,55 @@
+//===-- RealpathPrefixes.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_CORE_REALPATHPREFIXES_H
+#define LLDB_CORE_REALPATHPREFIXES_H
+
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+class FileSpec;
+class FileSpecList;
+} // namespace lldb_private
+
+namespace lldb_private {
+

[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits

royitaqi wrote:

Hi @jimingham and @labath,

Thank you for your review so far. They were very helpful comments. I appreciate 
it.

I *think* I have addressed all of your comments.
When you have the time, it will be great if you can take another look.

Thanks,
Roy

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


[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 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 
396343f17b1182ff8ed698beac3f9b93b1d9dabd...d984f5c367fcc07fc1d1b88791562285c3ce0d67
 
lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
``





View the diff from darker here.


``diff
--- TestBreakpoint.py   2024-08-09 22:52:41.00 +
+++ TestBreakpoint.py   2024-08-09 23:13:07.857254 +
@@ -53,82 +53,122 @@
 cwd = os.getcwd()
 print("DEBUG CWD", cwd)
 
 ##
 # Baseline
-#-
+# -
 # Breakpoints should be resolved with paths which are in the 
line-table.
 lldbutil.run_break_set_by_file_and_line(
 self, "main.c", self.line_in_main, num_expected_locations=1, 
loc_exact=True
 )
 lldbutil.run_break_set_by_file_and_line(
-self, "symlink1/foo.h", self.line_in_foo, 
num_expected_locations=1, loc_exact=True
+self,
+"symlink1/foo.h",
+self.line_in_foo,
+num_expected_locations=1,
+loc_exact=True,
 )
 lldbutil.run_break_set_by_file_and_line(
-self, "symlink2/bar.h", self.line_in_bar, 
num_expected_locations=1, loc_exact=True
+self,
+"symlink2/bar.h",
+self.line_in_bar,
+num_expected_locations=1,
+loc_exact=True,
 )
 lldbutil.run_break_set_by_file_and_line(
-self, "symlink2/qux.h", self.line_in_qux, 
num_expected_locations=1, loc_exact=True
+self,
+"symlink2/qux.h",
+self.line_in_qux,
+num_expected_locations=1,
+loc_exact=True,
 )
 
 ##
 # Symlinked file
-#-
+# -
 # - `symlink1/foo.h` is a symlink file, pointing at `real/foo.h`
 # - main.c includes `symlink1/foo.h`.
 # - As a result, the line-table contains a support file 
`(test_base_dir)/symlink1/foo.h`
 # - Setting a breakpoint for `real/foo.h` won't be resolved, because 
it doesn't match the above path.
 # - Setting a realpath prefix to the current working directory will 
cause the above support file to be realpath'ed to `(test_base_dir)/real/foo.h`
 # - Now setting a breakpoint for `real/foo.h` will be resolved.
 lldbutil.run_break_set_by_file_and_line(
-self, "real/foo.h", self.line_in_foo, num_expected_locations=0, 
loc_exact=True
+self,
+"real/foo.h",
+self.line_in_foo,
+num_expected_locations=0,
+loc_exact=True,
 )
 self.runCmd(f'settings set target.source-realpath-prefixes "{cwd}"')
 lldbutil.run_break_set_by_file_and_line(
-self, "real/foo.h", self.line_in_foo, num_expected_locations=1, 
loc_exact=True
+self,
+"real/foo.h",
+self.line_in_foo,
+num_expected_locations=1,
+loc_exact=True,
 )
 # Clear settings so that the test below won't be affected.
 self.runCmd("settings clear target.source-realpath-prefixes")
 
 ##
 # Symlinked directory
-#-
+# -
 # - `symlink2` is a symlink directory, pointing at `real`.
 # - So, `symlink2/bar.h` will be realpath'ed to `real/bar.h`.
 # - main.c includes `symlink2/bar.h`.
 # - As a result, the line-table contains a support file 
`(test_base_dir)/symlink2/bar.h`
 # - Setting a breakpoint for `real/bar.h` won't be resolved, because 
it doesn't match the above path.
 # - Setting a realpath prefix to the current working directory will 
cause the above support file to be realpath'ed to `(test_base_dir)/real/bar.h`
 # - Now setting a breakpoint for `real/bar.h` will be resolved.
 lldbutil.run_break_set_by_file_and_line(
-self, "real/bar.h", self.line_in_foo, num_expected_locations=0, 
loc_exact=True
+self,
+"real/bar.h",
+self.line_in_foo,
+num_expected_locations=0,
+loc_exact=True,
 )
 self.runCmd(f'settings set target.source-realpath-prefixes "{cwd}"')
   

[Lldb-commits] [lldb] [lldb] Realpath symlinks for breakpoints (PR #102223)

2024-08-09 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-08-09 Thread via lldb-commits


@@ -0,0 +1,560 @@
+//===-- DILAST.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 "lldb/Core/DILAST.h"
+#include "lldb/API/SBType.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/RegisterContext.h"
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+namespace lldb_private {
+
+namespace DIL {
+
+lldb::ValueObjectSP
+GetDynamicOrSyntheticValue(lldb::ValueObjectSP in_valobj_sp,
+   lldb::DynamicValueType use_dynamic,
+   bool use_synthetic) {
+  Status error;
+
+  if (!in_valobj_sp) {
+error.SetErrorString("invalid value object");
+return in_valobj_sp;
+  }
+
+  lldb::ValueObjectSP value_sp = in_valobj_sp;
+
+  Target *target = value_sp->GetTargetSP().get();
+  // If this ValueObject holds an error, then it is valuable for that.
+  if (value_sp->GetError().Fail())
+return value_sp;
+
+  if (!target)
+return lldb::ValueObjectSP();
+
+  if (use_dynamic != lldb::eNoDynamicValues) {
+lldb::ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(use_dynamic);
+if (dynamic_sp)
+  value_sp = dynamic_sp;
+  }
+
+  if (use_synthetic) {
+lldb::ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
+if (synthetic_sp)
+  value_sp = synthetic_sp;
+  }
+
+  if (!value_sp)
+error.SetErrorString("invalid value object");
+
+  return value_sp;
+}
+
+CompilerType DILASTNode::GetDereferencedResultType() const {
+  auto type = result_type();
+  return type.IsReferenceType() ? type.GetNonReferenceType() : type;
+}
+
+std::optional

cmtice wrote:

I've tried that, but the lhs_val_sp does not always have the right type for 
finding the field name. :-(. One of the simplest examples: in one test case I 
have a class "C".  I declare an array variable "C c_arr[2];".  The ValueObject 
for 'c_arr' has the type "C[2]", rather than "C".  Type "C" has named field 
members, but type "C[2]" does not, so GetChildMemberWithName doesn't work on 
it.  I have *many* different test cases where it turns out the the ValueObject 
associated with the variable doesn't have quite the right type for using 
GetChildMemberWithName. By the time I've special-cased and updated the code to 
handle all of them, it doesn't look any better than the function I have here.

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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

2024-08-09 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/102708

This PR adds a statistics provider cache, which allows an individual target to 
keep a rolling tally of it's total time and number of invocations for a given 
summary provider. This information is then available in statistics dump to help 
slow summary providers, and gleam more into insight into LLDB's time use.



>From c0a7286b0107d3161b18de8f05d4d016150e96a5 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 8 Aug 2024 08:58:52 -0700
Subject: [PATCH 1/3] Initial attempt at new classes Summary statistics in
 SummaryStatistics.h/cpp.

---
 lldb/include/lldb/Target/SummaryStatistics.h | 37 
 lldb/include/lldb/Target/Target.h|  5 +++
 lldb/source/Core/ValueObject.cpp |  5 +++
 lldb/source/Target/CMakeLists.txt|  1 +
 lldb/source/Target/SummaryStatistics.cpp | 26 ++
 lldb/source/Target/Target.cpp|  9 +
 6 files changed, 83 insertions(+)
 create mode 100644 lldb/include/lldb/Target/SummaryStatistics.h
 create mode 100644 lldb/source/Target/SummaryStatistics.cpp

diff --git a/lldb/include/lldb/Target/SummaryStatistics.h 
b/lldb/include/lldb/Target/SummaryStatistics.h
new file mode 100644
index 00..0198249ba0b170
--- /dev/null
+++ b/lldb/include/lldb/Target/SummaryStatistics.h
@@ -0,0 +1,37 @@
+//===-- SummaryStatistics.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_TARGET_SUMMARYSTATISTICS_H
+#define LLDB_TARGET_SUMMARYSTATISTICS_H
+
+
+#include "lldb/Target/Statistics.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+class SummaryStatistics {
+public:
+  SummaryStatistics(lldb_private::ConstString name) : 
+m_total_time(), m_name(name), m_summary_count(0) {}
+
+  lldb_private::StatsDuration &GetDurationReference();
+
+  lldb_private::ConstString GetName() const;
+
+  uint64_t GetSummaryCount() const;
+
+private:
+   lldb_private::StatsDuration m_total_time;
+   lldb_private::ConstString m_name;
+   uint64_t m_summary_count;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_SUMMARYSTATISTICS_H
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 119dff4d498199..ee6a009b0af95d 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -30,6 +30,7 @@
 #include "lldb/Target/PathMappingList.h"
 #include "lldb/Target/SectionLoadHistory.h"
 #include "lldb/Target/Statistics.h"
+#include "lldb/Target/SummaryStatistics.h"
 #include "lldb/Target/ThreadSpec.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/Broadcaster.h"
@@ -258,6 +259,7 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+
 private:
   std::optional
   GetExperimentalPropertyValue(size_t prop_idx,
@@ -1221,6 +1223,8 @@ class Target : public 
std::enable_shared_from_this,
 
   void ClearAllLoadedSections();
 
+  lldb_private::StatsDuration& 
GetSummaryProviderDuration(lldb_private::ConstString summary_provider_name);
+
   /// Set the \a Trace object containing processor trace information of this
   /// target.
   ///
@@ -1554,6 +1558,7 @@ class Target : public 
std::enable_shared_from_this,
   std::string m_label;
   ModuleList m_images; ///< The list of images for this process (shared
/// libraries and anything dynamically loaded).
+  std::map 
m_summary_stats_map;
   SectionLoadHistory m_section_load_history;
   BreakpointList m_breakpoint_list;
   BreakpointList m_internal_breakpoint_list;
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 8f72efc2299b4f..bed4ab8d69cbda 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -615,6 +615,11 @@ bool ValueObject::GetSummaryAsCString(TypeSummaryImpl 
*summary_ptr,
   m_synthetic_value->UpdateValueIfNeeded(); // the summary might depend on
 // the synthetic children being
 // up-to-date (e.g. ${svar%#})
+StatsDuration &summary_duration = GetExecutionContextRef()
+.GetProcessSP()
+->GetTarget()
+
.GetSummaryProviderDuration(GetTypeName());
+ElapsedTime elapsed(summary_duration);
 summary_ptr->FormatObject(this, destination, actual_options);
   }
   m_flags.m_is_getting_summary = false;
diff --git a/lldb/source/Target/CMakeLists.txt 
b/lldb/source/Target/CMakeLists.txt
index a42c44b761dc56..e51da37cd84db3 100644
--- a/lldb/sour

[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

2024-08-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

This PR adds a statistics provider cache, which allows an individual target to 
keep a rolling tally of it's total time and number of invocations for a given 
summary provider. This information is then available in statistics dump to help 
slow summary providers, and gleam more into insight into LLDB's time use.



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


8 Files Affected:

- (modified) lldb/include/lldb/Target/Statistics.h (+80) 
- (modified) lldb/include/lldb/Target/Target.h (+5) 
- (modified) lldb/source/Core/ValueObject.cpp (+10-1) 
- (modified) lldb/source/Target/Statistics.cpp (+22) 
- (modified) lldb/source/Target/Target.cpp (+8) 
- (modified) lldb/test/API/commands/statistics/basic/Makefile (+1-1) 
- (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+25-2) 
- (renamed) lldb/test/API/commands/statistics/basic/main.cpp (+7-1) 


``diff
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 35bd7f8a66e055..06ca5c7923f747 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -16,6 +16,7 @@
 #include "llvm/Support/JSON.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +26,7 @@ namespace lldb_private {
 
 using StatsClock = std::chrono::high_resolution_clock;
 using StatsTimepoint = std::chrono::time_point;
+using Duration = std::chrono::duration;
 
 class StatsDuration {
 public:
@@ -174,6 +176,83 @@ struct StatisticsOptions {
   std::optional m_include_transcript;
 };
 
+/// A class that represents statistics about a TypeSummaryProviders invocations
+class SummaryStatistics {
+public:
+  SummaryStatistics() = default;
+  SummaryStatistics(lldb_private::ConstString name) : 
+m_total_time(), m_name(name), m_summary_count(0) {}
+
+  SummaryStatistics(const SummaryStatistics &&rhs)
+  : m_total_time(), m_name(rhs.m_name), 
m_summary_count(rhs.m_summary_count.load(std::memory_order_relaxed)) {}
+
+  lldb_private::ConstString GetName() const { return m_name; };
+  double GetAverageTime() const {
+return m_total_time.get().count() / 
m_summary_count.load(std::memory_order_relaxed);
+  }
+
+  double GetTotalTime() const {
+return m_total_time.get().count();
+  }
+
+  uint64_t GetSummaryCount() const {
+return m_summary_count.load(std::memory_order_relaxed);
+  }
+
+  StatsDuration& GetDurationReference() {
+return m_total_time;
+  }
+
+  llvm::json::Value ToJSON() const;
+
+  // Basic RAII class to increment the summary count when the call is complete.
+  // In the future this can be extended to collect information about the 
+  // elapsed time for a single request.
+  class SummaryInvocation {
+  public:
+SummaryInvocation(SummaryStatistics &summary) : m_summary(summary) {}
+~SummaryInvocation() {
+  m_summary.OnInvoked();
+}
+  private:
+SummaryStatistics &m_summary;
+  };
+
+private:
+  /// Called when Summary Invocation is destructed.
+  void OnInvoked() {
+m_summary_count.fetch_add(1, std::memory_order_relaxed);
+  }
+
+  lldb_private::StatsDuration m_total_time;
+  lldb_private::ConstString m_name;
+  std::atomic m_summary_count;
+};
+
+/// A class that wraps a std::map of SummaryStatistics objects behind a mutex.
+class SummaryStatisticsCache {
+public:
+  SummaryStatisticsCache() = default;
+  /// Get the SummaryStatistics object for a given provider name, or insert
+  /// if statistics for that provider is not in the map.
+  lldb_private::SummaryStatistics 
&GetSummaryStatisticsForProviderName(lldb_private::ConstString 
summary_provider_name) {
+m_map_mutex.lock();
+if (m_summary_stats_map.count(summary_provider_name) == 0) {
+  m_summary_stats_map.emplace(summary_provider_name, 
SummaryStatistics(summary_provider_name));
+}
+
+SummaryStatistics &summary_stats = 
m_summary_stats_map.at(summary_provider_name);
+m_map_mutex.unlock();
+return summary_stats;
+  }
+
+  llvm::json::Value ToJSON();
+
+private:
+  std::map 
m_summary_stats_map;
+  std::mutex m_map_mutex;
+};
+
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
@@ -198,6 +277,7 @@ class TargetStats {
   StatsSuccessFail m_frame_var{"frameVariable"};
   std::vector m_module_identifiers;
   uint32_t m_source_map_deduce_count = 0;
+  SummaryStatisticsCache m_summary_stats_cache;
   void CollectStats(Target &target);
 };
 
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 119dff4d498199..ae1ea43c01003b 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,6 +258,7 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+
 private:
   std::optional
   GetExperimentalPropertyValue(size_t prop_idx,
@@ -1221,6 +1222,9 @@ class Target : public 
std::enabl

[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

2024-08-09 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 
a3ccaed3b9f6a1fe9b7f2ef019259f88072639b2...ad4b20d2074203fce9e4c47fd6045699b1528d86
 lldb/test/API/commands/statistics/basic/TestStats.py
``





View the diff from darker here.


``diff
--- TestStats.py2024-08-10 00:36:10.00 +
+++ TestStats.py2024-08-10 00:39:57.580943 +
@@ -248,11 +248,11 @@
 "firstStopTime",
 "frameVariable",
 "launchOrAttachTime",
 "moduleIdentifiers",
 "targetCreateTime",
-"summaryProviderStatistics"
+"summaryProviderStatistics",
 ]
 self.verify_keys(stats, '"stats"', keys_exist, None)
 self.assertGreater(stats["firstStopTime"], 0.0)
 self.assertGreater(stats["launchOrAttachTime"], 0.0)
 self.assertGreater(stats["targetCreateTime"], 0.0)
@@ -446,11 +446,11 @@
 "expressionEvaluation",
 "frameVariable",
 "targetCreateTime",
 "moduleIdentifiers",
 "totalBreakpointResolveTime",
-"summaryProviderStatistics"
+"summaryProviderStatistics",
 ]
 self.verify_keys(target_stats, '"stats"', keys_exist, None)
 self.assertGreater(target_stats["totalBreakpointResolveTime"], 0.0)
 breakpoints = target_stats["breakpoints"]
 bp_keys_exist = [
@@ -918,14 +918,14 @@
 self.assertEqual(
 debug_stats_0,
 debug_stats_1,
 f"The order of options '{options[0]}' and '{options[1]}' 
should not matter",
 )
-
+
 def test_summary_statistics_providers(self):
 """
-Test summary timing statistics is included in statistics dump when 
+Test summary timing statistics is included in statistics dump when
 a type with a summary provider exists, and is evaluated.
 """
 
 self.build()
 target = self.createTestTarget()

``




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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

2024-08-09 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 a3ccaed3b9f6a1fe9b7f2ef019259f88072639b2 
ad4b20d2074203fce9e4c47fd6045699b1528d86 --extensions h,cpp -- 
lldb/include/lldb/Target/Statistics.h lldb/include/lldb/Target/Target.h 
lldb/source/Core/ValueObject.cpp lldb/source/Target/Statistics.cpp 
lldb/source/Target/Target.cpp lldb/test/API/commands/statistics/basic/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 06ca5c7923..a8c3f84d9d 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -180,49 +180,44 @@ private:
 class SummaryStatistics {
 public:
   SummaryStatistics() = default;
-  SummaryStatistics(lldb_private::ConstString name) : 
-m_total_time(), m_name(name), m_summary_count(0) {}
+  SummaryStatistics(lldb_private::ConstString name)
+  : m_total_time(), m_name(name), m_summary_count(0) {}
 
   SummaryStatistics(const SummaryStatistics &&rhs)
-  : m_total_time(), m_name(rhs.m_name), 
m_summary_count(rhs.m_summary_count.load(std::memory_order_relaxed)) {}
+  : m_total_time(), m_name(rhs.m_name),
+m_summary_count(rhs.m_summary_count.load(std::memory_order_relaxed)) {}
 
   lldb_private::ConstString GetName() const { return m_name; };
   double GetAverageTime() const {
-return m_total_time.get().count() / 
m_summary_count.load(std::memory_order_relaxed);
+return m_total_time.get().count() /
+   m_summary_count.load(std::memory_order_relaxed);
   }
 
-  double GetTotalTime() const {
-return m_total_time.get().count();
-  }
+  double GetTotalTime() const { return m_total_time.get().count(); }
 
   uint64_t GetSummaryCount() const {
 return m_summary_count.load(std::memory_order_relaxed);
   }
 
-  StatsDuration& GetDurationReference() {
-return m_total_time;
-  }
+  StatsDuration &GetDurationReference() { return m_total_time; }
 
   llvm::json::Value ToJSON() const;
 
   // Basic RAII class to increment the summary count when the call is complete.
-  // In the future this can be extended to collect information about the 
+  // In the future this can be extended to collect information about the
   // elapsed time for a single request.
   class SummaryInvocation {
   public:
 SummaryInvocation(SummaryStatistics &summary) : m_summary(summary) {}
-~SummaryInvocation() {
-  m_summary.OnInvoked();
-}
+~SummaryInvocation() { m_summary.OnInvoked(); }
+
   private:
 SummaryStatistics &m_summary;
   };
 
 private:
   /// Called when Summary Invocation is destructed.
-  void OnInvoked() {
-m_summary_count.fetch_add(1, std::memory_order_relaxed);
-  }
+  void OnInvoked() { m_summary_count.fetch_add(1, std::memory_order_relaxed); }
 
   lldb_private::StatsDuration m_total_time;
   lldb_private::ConstString m_name;
@@ -235,13 +230,16 @@ public:
   SummaryStatisticsCache() = default;
   /// Get the SummaryStatistics object for a given provider name, or insert
   /// if statistics for that provider is not in the map.
-  lldb_private::SummaryStatistics 
&GetSummaryStatisticsForProviderName(lldb_private::ConstString 
summary_provider_name) {
+  lldb_private::SummaryStatistics &GetSummaryStatisticsForProviderName(
+  lldb_private::ConstString summary_provider_name) {
 m_map_mutex.lock();
 if (m_summary_stats_map.count(summary_provider_name) == 0) {
-  m_summary_stats_map.emplace(summary_provider_name, 
SummaryStatistics(summary_provider_name));
+  m_summary_stats_map.emplace(summary_provider_name,
+  SummaryStatistics(summary_provider_name));
 }
 
-SummaryStatistics &summary_stats = 
m_summary_stats_map.at(summary_provider_name);
+SummaryStatistics &summary_stats =
+m_summary_stats_map.at(summary_provider_name);
 m_map_mutex.unlock();
 return summary_stats;
   }
@@ -249,7 +247,8 @@ public:
   llvm::json::Value ToJSON();
 
 private:
-  std::map 
m_summary_stats_map;
+  std::map
+  m_summary_stats_map;
   std::mutex m_map_mutex;
 };
 
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index ae1ea43c01..7e53670c39 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,7 +258,6 @@ public:
 
   bool GetDebugUtilityExpression() const;
 
-
 private:
   std::optional
   GetExperimentalPropertyValue(size_t prop_idx,
@@ -1222,8 +1221,9 @@ public:
 
   void ClearAllLoadedSections();
 
-  lldb_private::SummaryStatistics& 
GetSummaryStatisticsForProvider(lldb_private::ConstString 
summary_provider_name);
-  lldb_private::SummaryStatisticsCache& GetSummaryStatisticsCache();
+  lldb_private::SummaryStatistics &GetSummaryStatisticsForProvider(
+  lldb_private::ConstStrin

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-08-09 Thread Robert O'Callahan via lldb-commits

https://github.com/rocallahan updated 
https://github.com/llvm/llvm-project/pull/99736

>From 52b133ee9fda7b6cc3b6300756e7b8ec82a6a9bf Mon Sep 17 00:00:00 2001
From: Robert O'Callahan 
Date: Fri, 19 Jul 2024 22:46:42 +1200
Subject: [PATCH] [lldb] Implement basic support for reverse-continue

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command
for this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`)
providing support for the `bc` and `bs` packets. `lldb-server`
does not support those packets, and there is no plan to change that.
So, for testing purposes, `lldbreverse.py` wraps `lldb-server`
with a Python implementation of *very limited* record-and-replay
functionality.
---
 lldb/include/lldb/API/SBProcess.h |   1 +
 lldb/include/lldb/Target/Process.h|  20 +-
 lldb/include/lldb/Target/StopInfo.h   |   3 +
 lldb/include/lldb/lldb-enumerations.h |   6 +
 .../Python/lldbsuite/test/gdbclientutils.py   |   5 +-
 .../Python/lldbsuite/test/lldbgdbproxy.py | 175 
 .../Python/lldbsuite/test/lldbreverse.py  | 418 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/API/SBProcess.cpp |   8 +-
 lldb/source/API/SBThread.cpp  |   2 +
 .../source/Interpreter/CommandInterpreter.cpp |   3 +-
 .../Process/Linux/NativeThreadLinux.cpp   |   3 +
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   9 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|   2 +-
 .../Process/Windows/Common/ProcessWindows.cpp |   8 +-
 .../Process/Windows/Common/ProcessWindows.h   |   2 +-
 .../GDBRemoteCommunicationClient.cpp  |  22 +
 .../gdb-remote/GDBRemoteCommunicationClient.h |   6 +
 .../GDBRemoteCommunicationServerLLGS.cpp  |   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  78 +++-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  11 +-
 .../Process/scripted/ScriptedProcess.h|   2 +-
 lldb/source/Target/Process.cpp|  23 +-
 lldb/source/Target/StopInfo.cpp   |  29 ++
 lldb/source/Target/Thread.cpp |   8 +-
 .../reverse-execution/Makefile|   3 +
 .../TestReverseContinueBreakpoints.py | 115 +
 .../TestReverseContinueNotSupported.py|  30 ++
 .../functionalities/reverse-execution/main.c  |  14 +
 lldb/tools/lldb-dap/JSONUtils.cpp |   3 +
 lldb/tools/lldb-dap/LLDBUtils.cpp |   1 +
 32 files changed, 974 insertions(+), 41 deletions(-)
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c

diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 778be795839901..ba069014defd24 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,6 +159,7 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
+  lldb::SBError Continue(RunDirection direction);
 
   lldb::SBError Stop();
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index cf16fbc812aa48..5fa6d54838f8c8 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -874,10 +874,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1129,10 +1129,15 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume() {
+  virtual Status DoResume(lldb::RunDirection direction) {
 Status error;
-error.SetErrorStringWithFormatv(
-"error: {0} does not support resuming processes", GetPluginName());
+if (direction == lldb::RunDirection::eRunForward) {
+  error.SetErrorStringWithFormatv(
+  "error: {0} does not support resuming processes", GetPluginName());
+} else {
+  error.SetErrorStringWithFormatv(
+  "error: {0} does not support reverse execution of processes", 
GetPluginName());
+}
 return error;
   }
 
@@ -2373,6 +2378,8 @@ class Proc

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-08-09 Thread Robert O'Callahan via lldb-commits

https://github.com/rocallahan updated 
https://github.com/llvm/llvm-project/pull/99736

>From 3aa5a6f08487314f12b7b0d2d13ccd20f306f16c Mon Sep 17 00:00:00 2001
From: Robert O'Callahan 
Date: Fri, 19 Jul 2024 22:46:42 +1200
Subject: [PATCH] [lldb] Implement basic support for reverse-continue

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command
for this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`)
providing support for the `bc` and `bs` packets. `lldb-server`
does not support those packets, and there is no plan to change that.
So, for testing purposes, `lldbreverse.py` wraps `lldb-server`
with a Python implementation of *very limited* record-and-replay
functionality.
---
 lldb/include/lldb/API/SBProcess.h |   1 +
 lldb/include/lldb/Target/Process.h|  20 +-
 lldb/include/lldb/Target/StopInfo.h   |   3 +
 lldb/include/lldb/lldb-enumerations.h |   6 +
 .../Python/lldbsuite/test/gdbclientutils.py   |   5 +-
 .../Python/lldbsuite/test/lldbgdbproxy.py | 175 
 .../Python/lldbsuite/test/lldbreverse.py  | 418 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/API/SBProcess.cpp |   8 +-
 lldb/source/API/SBThread.cpp  |   2 +
 .../source/Interpreter/CommandInterpreter.cpp |   3 +-
 .../Process/Linux/NativeThreadLinux.cpp   |   3 +
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   9 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|   2 +-
 .../Process/Windows/Common/ProcessWindows.cpp |   8 +-
 .../Process/Windows/Common/ProcessWindows.h   |   2 +-
 .../GDBRemoteCommunicationClient.cpp  |  22 +
 .../gdb-remote/GDBRemoteCommunicationClient.h |   6 +
 .../GDBRemoteCommunicationServerLLGS.cpp  |   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  78 +++-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  11 +-
 .../Process/scripted/ScriptedProcess.h|   2 +-
 lldb/source/Target/Process.cpp|  25 +-
 lldb/source/Target/StopInfo.cpp   |  29 ++
 lldb/source/Target/Thread.cpp |   8 +-
 .../reverse-execution/Makefile|   3 +
 .../TestReverseContinueBreakpoints.py | 115 +
 .../TestReverseContinueNotSupported.py|  30 ++
 .../functionalities/reverse-execution/main.c  |  14 +
 lldb/tools/lldb-dap/JSONUtils.cpp |   3 +
 lldb/tools/lldb-dap/LLDBUtils.cpp |   1 +
 32 files changed, 975 insertions(+), 42 deletions(-)
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c

diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 778be795839901..ba069014defd24 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,6 +159,7 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
+  lldb::SBError Continue(RunDirection direction);
 
   lldb::SBError Stop();
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index cf16fbc812aa48..5fa6d54838f8c8 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -874,10 +874,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1129,10 +1129,15 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume() {
+  virtual Status DoResume(lldb::RunDirection direction) {
 Status error;
-error.SetErrorStringWithFormatv(
-"error: {0} does not support resuming processes", GetPluginName());
+if (direction == lldb::RunDirection::eRunForward) {
+  error.SetErrorStringWithFormatv(
+  "error: {0} does not support resuming processes", GetPluginName());
+} else {
+  error.SetErrorStringWithFormatv(
+  "error: {0} does not support reverse execution of processes", 
GetPluginName());
+}
 return error;
   }
 
@@ -2373,6 +2378,8 @@ class Proc

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-08-09 Thread via lldb-commits

cmtice wrote:

I think I have addressed all the review comments; please take another look. :-)

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-08-09 Thread via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.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_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {

cmtice wrote:

Done.

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