[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-09 Thread Abhina Sree via lldb-commits

abhina-sree wrote:

> The default is set to OF_Text instead of OF_None, this change in value does 
> not affect any other platforms other than z/OS. Setting this parameter 
> correctly is required to open files on z/OS in the correct encoding. The 
> IsText parameter is based on the context of where we open files, for example, 
> the embed directive requires that files always be opened in binary even 
> though they might be tagged as text.

Thanks for your patience. I've put up this PR 
https://github.com/llvm/llvm-project/pull/111723 to implement your suggestion. 
I kept the IsText parameter in the getBufferForFile, getBufferForFileImpl 
because it already has other attributes like IsVolatile, RequiresNullTerminator 
but created a new virtual function for openFileForReadBinary which greatly 
reduces the number of files touched compared to this PR. The current `#embed` 
lit tests seem to work without additional changes but I will experiment with 
creating a testcase with inputs that are non-ascii to expose any issues

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 



@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
+else()
+  message(STATUS "Not found: make")
+  message(SEND_ERROR

JDevlieghere wrote:

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

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


[Lldb-commits] [lldb] [lldb] Use SEND_ERROR instead of FATAL_ERROR in test/CMakeLists.txt (PR #111729)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Use SEND_ERROR (continue processing, but skip generation) instead of 
FATAL_ERROR (stop processing and generation). This means that developers get to 
see all errors at once, instead of seeing just the first error and having to 
reconfigure to discover the next one.

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


1 Files Affected:

- (modified) lldb/test/CMakeLists.txt (+6-6) 


``diff
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 25037934f636c7..1abab96ba7bb1f 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -3,7 +3,7 @@
 # Lit requires a Python3 interpreter, let's be careful and fail early if it's
 # not present.
 if (NOT DEFINED Python3_EXECUTABLE)
-  message(FATAL_ERROR
+  message(SEND_ERROR
 "LLDB test suite requires a Python3 interpreter but none "
 "was found. Please install Python3 or disable tests with "
 "`LLDB_INCLUDE_TESTS=OFF`.")
@@ -22,7 +22,7 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   foreach(module ${useful_python_modules})
 lldb_find_python_module(${module})
 if (NOT PY_${module}_FOUND)
-  message(FATAL_ERROR
+  message(SEND_ERROR
 "Python module '${module}' not found. Please install it via pip or via 
"
 "your operating system's package manager. Alternatively, disable "
 "strict testing requirements with "
@@ -66,10 +66,10 @@ if (LLDB_TEST_OBJC_GNUSTEP)
   find_package(GNUstepObjC)
   if (NOT GNUstepObjC_FOUND)
 if (LLDB_TEST_OBJC_GNUSTEP_DIR)
-  message(FATAL_ERROR "Failed to find GNUstep libobjc2 in 
${LLDB_TEST_OBJC_GNUSTEP_DIR}. "
+  message(SEND_ERROR "Failed to find GNUstep libobjc2 in 
${LLDB_TEST_OBJC_GNUSTEP_DIR}. "
   "Please check LLDB_TEST_OBJC_GNUSTEP_DIR or turn off 
LLDB_TEST_OBJC_GNUSTEP.")
 else()
-  message(FATAL_ERROR "Failed to find GNUstep libobjc2. "
+  message(SEND_ERROR "Failed to find GNUstep libobjc2. "
   "Please set LLDB_TEST_OBJC_GNUSTEP_DIR or turn off 
LLDB_TEST_OBJC_GNUSTEP.")
 endif()
   endif()
@@ -185,7 +185,7 @@ if(TARGET clang)
 set(LIBCXX_LIBRARY_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}")
 set(LIBCXX_GENERATED_INCLUDE_DIR 
"${LLDB_TEST_LIBCXX_ROOT_DIR}/include/c++/v1")
   else()
-message(FATAL_ERROR
+message(SEND_ERROR
 "Couldn't find libcxx build in '${LLDB_TEST_LIBCXX_ROOT_DIR}'. To 
run the "
 "test-suite for a standalone LLDB build please build libcxx and 
point "
 "LLDB_TEST_LIBCXX_ROOT_DIR to it.")
@@ -194,7 +194,7 @@ if(TARGET clang)
   # We require libcxx for the test suite, so if we aren't building it,
   # provide a helpful error about how to resolve the situation.
   if(NOT LLDB_HAS_LIBCXX)
-message(FATAL_ERROR
+message(SEND_ERROR
   "LLDB test suite requires libc++, but it is currently disabled. "
   "Please add `libcxx` to `LLVM_ENABLE_RUNTIMES` or disable tests via "
   "`LLDB_INCLUDE_TESTS=OFF`.")

``




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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 



@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
+else()
+  message(STATUS "Not found: make")
+  message(SEND_ERROR

JDevlieghere wrote:

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

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


[Lldb-commits] [lldb] [lldb] Add missing include to SBLanguages.h (PR #111763)

2024-10-09 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Check for Python 'packaging' module at configuration time (PR #111747)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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

I could have sworn I added it here, but apparently not. Thanks! 

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits


@@ -126,6 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
+  static bool GetExtendedInfo(thread_t threadID,
+  struct thread_extended_info *extended_info);
 
   bool GetIdentifierInfo();

ldm0 wrote:

Thanks, I didn't notice that.

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,79 @@
+//===-- DiagnosticsRendering.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_UTILITY_DIAGNOSTICSRENDERING_H
+#define LLDB_UTILITY_DIAGNOSTICSRENDERING_H
+
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/Support/WithColor.h"
+
+namespace lldb_private {
+
+/// A compiler-independent representation of an \c
+/// lldb_private::Diagnostic. Expression evaluation failures often
+/// have more than one diagnostic that a UI layer might want to render
+/// differently, for example to colorize it.
+///
+/// Running example:
+///   (lldb) expr 1 + foo
+///   error: :1:3: use of undeclared identifier 'foo'
+///   1 + foo
+///   ^~~
+struct DiagnosticDetail {
+  /// A source location consisting of a file name and position.
+  struct SourceLocation {
+/// \c "" in the example above.
+FileSpec file;
+/// \c 1 in the example above.
+unsigned line = 0;
+/// \c 5 in the example above.
+uint16_t column = 0;
+/// \c 3 in the example above.
+uint16_t length = 0;
+/// Whether this source location should be surfaced to the
+/// user. For example, syntax errors diagnosed in LLDB's
+/// expression wrapper code have this set to true.
+bool hidden = false;
+/// Whether this source location refers to something the user
+/// typed as part of the command, i.e., if this qualifies for
+/// inline display, or if the source line would need to be echoed
+/// again for the message to make sense.
+bool in_user_input = false;
+  };
+  /// Contains this diagnostic's source location, if applicable.
+  std::optional source_location;
+  /// Contains \c eSeverityError in the example above.
+  lldb::Severity severity = lldb::eSeverityInfo;
+  /// Contains "use of undeclared identifier 'foo'" in the example above.
+  std::string message;
+  /// Contains the fully rendered error message, without "error: ",
+  /// but including the source context.

adrian-prantl wrote:

@jimingham I don't understand the question. Concretely, in the example 
`rendered` is
```
 :1:3: use of undeclared identifier 'foo'
 ///   1 + foo
 ///   ^~~
```
this is what a client can use if they choose to *not* show diagnostics inline.

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,79 @@
+//===-- DiagnosticsRendering.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_UTILITY_DIAGNOSTICSRENDERING_H
+#define LLDB_UTILITY_DIAGNOSTICSRENDERING_H
+
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/Support/WithColor.h"
+
+namespace lldb_private {
+
+/// A compiler-independent representation of an \c
+/// lldb_private::Diagnostic. Expression evaluation failures often
+/// have more than one diagnostic that a UI layer might want to render
+/// differently, for example to colorize it.
+///
+/// Running example:
+///   (lldb) expr 1 + foo
+///   error: :1:3: use of undeclared identifier 'foo'
+///   1 + foo
+///   ^~~
+struct DiagnosticDetail {
+  /// A source location consisting of a file name and position.
+  struct SourceLocation {
+/// \c "" in the example above.
+FileSpec file;
+/// \c 1 in the example above.
+unsigned line = 0;
+/// \c 5 in the example above.
+uint16_t column = 0;
+/// \c 3 in the example above.
+uint16_t length = 0;
+/// Whether this source location should be surfaced to the
+/// user. For example, syntax errors diagnosed in LLDB's
+/// expression wrapper code have this set to true.
+bool hidden = false;
+/// Whether this source location refers to something the user
+/// typed as part of the command, i.e., if this qualifies for
+/// inline display, or if the source line would need to be echoed
+/// again for the message to make sense.
+bool in_user_input = false;
+  };
+  /// Contains this diagnostic's source location, if applicable.
+  std::optional source_location;
+  /// Contains \c eSeverityError in the example above.
+  lldb::Severity severity = lldb::eSeverityInfo;
+  /// Contains "use of undeclared identifier 'foo'" in the example above.
+  std::string message;
+  /// Contains the fully rendered error message, without "error: ",
+  /// but including the source context.
+  std::string rendered;
+};
+
+class DiagnosticError
+: public llvm::ErrorInfo {
+public:
+  using llvm::ErrorInfo::ErrorInfo;
+  DiagnosticError(std::error_code ec, std::string msg = {}) : ErrorInfo(ec) {}
+  lldb::ErrorType GetErrorType() const override;
+  virtual llvm::ArrayRef GetDetails() const;
+  static char ID;
+};
+
+const char *ExpressionResultAsCString(lldb::ExpressionResults result);

adrian-prantl wrote:

I did not know about this file!

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread via lldb-commits

jimingham wrote:

I asked some folks who know and the proc_pidinfo call and the 
extended_thread_info read the same data, so this should be NFC...

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread via lldb-commits


@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *basicInfoPtr) {

jimingham wrote:

It's confusing to have a variable called "basicInfoPtr" actually be an 
"extended_info"...  Can you change this name?

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


[Lldb-commits] [lldb] [lldb][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-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 e85fcb763173590fdcd5cb922b7ca1fc97cf170b 
aefa120446a4c31fe9569d76ae3950c29d8d35e9 --extensions cpp,h -- 
lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
lldb/tools/debugserver/source/MacOSX/MachThread.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index bce60ed94e..de2bebfcec 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -274,8 +274,9 @@ bool MachThread::GetExtendedInfo(thread_t thread,
  struct thread_extended_info *extendedInfoPtr) 
{
   if (MachPortNumberIsValid(thread)) {
 mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
-kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
-  (thread_info_t)extendedInfoPtr, 
&info_count);
+kern_return_t err =
+::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)extendedInfoPtr, &info_count);
 if (err == KERN_SUCCESS)
   return true;
   }

``




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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -126,6 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
+  static bool GetExtendedInfo(thread_t threadID,
+  struct thread_extended_info *extended_info);
 
   bool GetIdentifierInfo();

JDevlieghere wrote:

`MachThread::GetIdentifierInfo` is now gone, right? 

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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
+else()
+  message(STATUS "Not found: make")
+  message(SEND_ERROR

JDevlieghere wrote:

TIL about `SEND_ERROR`. I think it would be nice to use that for the rest of 
the strict requirements, but obviously that's outside the scope of this PR. 

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 



@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")

JDevlieghere wrote:

Is there a reason to conditionalize this on 
`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS`? I would hoist this up so that we 
always have CMake configure `make` and only conditionalize the warning. 

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Jonas Devlieghere via lldb-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 


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

LGTM with detection hoisted. 

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


[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

2024-10-09 Thread Jason Molenda via lldb-commits

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

Fine by me.

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

https://github.com/ldm0 updated https://github.com/llvm/llvm-project/pull/111684

>From c700dd4b5bf5009b934d259becddab9fc10b9cb2 Mon Sep 17 00:00:00 2001
From: Liu Dingming 
Date: Wed, 9 Oct 2024 21:57:24 +0800
Subject: [PATCH] [lldb] Simplify macOS thread name fetching.

Remove unnecessary `proc_pidinfo` calling.
---
 .../debugserver/source/MacOSX/MachThread.cpp  | 47 ++-
 .../debugserver/source/MacOSX/MachThread.h|  8 ++--
 2 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..1568157286a52d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *basicInfoPtr) {
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)basicInfoPtr, 
&info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(basicInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +597,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..0c78ef1a337ed3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,8 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
-
-  bool GetIdentifierInfo();
+  static bool GetExtendedInfo(thread_t threadID,
+  struct thread_e

[Lldb-commits] [lldb] [lldb] Generalize make tool detection in CMake (PR #111744)

2024-10-09 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail created 
https://github.com/llvm/llvm-project/pull/111744

This is a draft. Only the last 2 commits will remain after rebase.

From c7356d3c265869ff387c977dd18e9c617dc31c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 8 Oct 2024 15:40:37 +0200
Subject: [PATCH 1/5] [lldb] Add early CMake check for 'make' tool

Around 400 of LLDB's dotest.py based tests require the make tool to be found in 
Path. If it's not found, they fail with an obscure error and show up as 
UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but 
make is not part of that. Let's catch the situation early and raise an error if 
LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the 
configuration process. There might be other issues further down the line that 
can be caught in the same buildbot run.
---
 lldb/test/CMakeLists.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+message(STATUS "Not found: make")
+message(SEND_ERROR
+  "LLDB tests require 'make' tool. Please install and add it to Path "
+  "(or otherwise disable strict testing requirements with "
+  "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

From 5e7bc2d26b54440936b3d756e12d708ae5218c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Wed, 9 Oct 2024 13:07:27 +0200
Subject: [PATCH 2/5] Pass make as an explicit argument to dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py |  2 ++
 lldb/test/API/CMakeLists.txt  |  1 +
 lldb/test/API/lit.cfg.py  |  3 +++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/test/CMakeLists.txt  | 20 +++
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index b1ae896d3fd3b4..40294aec166381 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'
 
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 27f285230cafaf..c426d76f7d9e76 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -58,6 +58,7 @@ endif()
 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb 
executable used for testing")
 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler 
to use for building LLDB test inferiors")
 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil 
used for generating dSYM bundles")
+set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for 
building test executables")
 
 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
   message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 96520c7c826246..c6fa20a63424d4 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+
 if is_configured("llvm_tools_dir"):
 dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2a..9f647034dc9f97 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,6 +31,7 @@ config.lldb_executable = 
lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
+config.make = lit_config.substitute('@LLDB_TEST_MAKE@')
 config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
diff --git a/lldb/test/CMakeLists.txt b/ll

[Lldb-commits] [lldb] [lldb] Check for Python 'packaging' module at configuration time (PR #111747)

2024-10-09 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail created 
https://github.com/llvm/llvm-project/pull/111747

This module is used in various helper scripts since 
https://github.com/llvm/llvm-project/pull/93712

From 6abfaf205142ffeaec76e72fcaf33bac72d2c51d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Wed, 9 Oct 2024 19:09:17 +0200
Subject: [PATCH] [lldb] Check for Python 'packaging' module at configuration
 time

This module is used in various helper scripts since 
https://github.com/llvm/llvm-project/pull/93712
---
 lldb/test/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..ceec782f19f4c7 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
 if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   message(STATUS "Enforcing strict test requirements for LLDB")
   # Lit uses psutil to do per-test timeouts.
-  set(useful_python_modules psutil)
+  set(useful_python_modules psutil packaging)
 
   if(NOT WIN32)
 # We no longer vendor pexpect and it is not used on Windows.

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


[Lldb-commits] [lldb] [lldb] Check for Python 'packaging' module at configuration time (PR #111747)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Stefan Gränitz (weliveindetail)


Changes

This module is used in various helper scripts since 
https://github.com/llvm/llvm-project/pull/93712

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


1 Files Affected:

- (modified) lldb/test/CMakeLists.txt (+1-1) 


``diff
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..ceec782f19f4c7 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
 if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   message(STATUS "Enforcing strict test requirements for LLDB")
   # Lit uses psutil to do per-test timeouts.
-  set(useful_python_modules psutil)
+  set(useful_python_modules psutil packaging)
 
   if(NOT WIN32)
 # We no longer vendor pexpect and it is not used on Windows.

``




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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/110901

>From 6ec95d9321072323755783ed3f5e56acbfaf37cc Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 9 Oct 2024 09:45:53 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 38 ++---
 .../lldb/Interpreter/CommandReturnObject.h| 18 +++--
 .../lldb/Utility/DiagnosticsRendering.h   | 77 +++
 lldb/include/lldb/Utility/Status.h| 12 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  7 ++
 .../Commands/CommandObjectExpression.cpp  |  5 +-
 lldb/source/Expression/DiagnosticManager.cpp  |  4 +-
 lldb/source/Expression/FunctionCaller.cpp |  4 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  4 +-
 .../source/Interpreter/CommandInterpreter.cpp | 17 +++-
 .../Interpreter/CommandReturnObject.cpp   | 34 +++-
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 31 
 lldb/source/Utility/Status.cpp| 31 
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +-
 18 files changed, 195 insertions(+), 112 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (83%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..cc802b6f48334a 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -23,49 +24,22 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
-: public llvm::ErrorInfo {
+: public llvm::ErrorInfo {
   std::string m_message;
   std::vector m_details;
 
 public:
   static char ID;
-  using llvm::ErrorInfo::ErrorInfo;
+  using llvm::ErrorInfo::ErrorInfo;
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..c3c15d94e8e3bf 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -10,6 +10,7 @@
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/StreamTee.h"
 #include "lldb/lldb-private.h"
@@ -29,6 +30,8 @@ class CommandReturnObject {
 
   ~CommandReturnObject() = default;
 
+  llvm::StringRef GetInlineDiagnosticsData(unsigned indent);
+
   llvm::StringRef GetOutputData() {
 lldb::StreamSP 
stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
 if (stream_sp)
@@ -36,12 +39,7 

[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/110901

>From 0be5ebe9109e10f340431b3ff8c56febedf64b6b Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 9 Oct 2024 09:45:53 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 38 ++
 .../lldb/Interpreter/CommandReturnObject.h| 18 +++--
 .../lldb/Utility/DiagnosticsRendering.h   | 75 +++
 lldb/include/lldb/Utility/Status.h| 12 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  7 ++
 .../Commands/CommandObjectExpression.cpp  |  5 +-
 lldb/source/Expression/DiagnosticManager.cpp  |  4 +-
 lldb/source/Expression/FunctionCaller.cpp |  4 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  4 +-
 .../source/Interpreter/CommandInterpreter.cpp | 17 -
 .../Interpreter/CommandReturnObject.cpp   | 34 -
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 28 +++
 lldb/source/Utility/Status.cpp| 31 
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +-
 18 files changed, 192 insertions(+), 110 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (86%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..cc802b6f48334a 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -23,49 +24,22 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
-: public llvm::ErrorInfo {
+: public llvm::ErrorInfo {
   std::string m_message;
   std::vector m_details;
 
 public:
   static char ID;
-  using llvm::ErrorInfo::ErrorInfo;
+  using llvm::ErrorInfo::ErrorInfo;
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..c3c15d94e8e3bf 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -10,6 +10,7 @@
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/StreamTee.h"
 #include "lldb/lldb-private.h"
@@ -29,6 +30,8 @@ class CommandReturnObject {
 
   ~CommandReturnObject() = default;
 
+  llvm::StringRef GetInlineDiagnosticsData(unsigned indent);
+
   llvm::StringRef GetOutputData() {
 lldb::StreamSP 
stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
 if (stream_sp)
@@ -36,12 +39,

[Lldb-commits] [lldb] [lldb] Only send "posix" error codes through the gdb-remote protocol (PR #108170)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Use SEND_ERROR instead of FATAL_ERROR in test/CMakeLists.txt (PR #111729)

2024-10-09 Thread Stefan Gränitz via lldb-commits

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

Yes agree, LGTM

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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

LGTM if this makes sense to @jasonmolenda 

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread via lldb-commits


@@ -0,0 +1,79 @@
+//===-- DiagnosticsRendering.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_UTILITY_DIAGNOSTICSRENDERING_H
+#define LLDB_UTILITY_DIAGNOSTICSRENDERING_H
+
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/Support/WithColor.h"
+
+namespace lldb_private {
+
+/// A compiler-independent representation of an \c
+/// lldb_private::Diagnostic. Expression evaluation failures often
+/// have more than one diagnostic that a UI layer might want to render
+/// differently, for example to colorize it.
+///
+/// Running example:
+///   (lldb) expr 1 + foo
+///   error: :1:3: use of undeclared identifier 'foo'
+///   1 + foo
+///   ^~~
+struct DiagnosticDetail {
+  /// A source location consisting of a file name and position.
+  struct SourceLocation {
+/// \c "" in the example above.
+FileSpec file;
+/// \c 1 in the example above.
+unsigned line = 0;
+/// \c 5 in the example above.
+uint16_t column = 0;
+/// \c 3 in the example above.
+uint16_t length = 0;
+/// Whether this source location should be surfaced to the
+/// user. For example, syntax errors diagnosed in LLDB's
+/// expression wrapper code have this set to true.
+bool hidden = false;
+/// Whether this source location refers to something the user
+/// typed as part of the command, i.e., if this qualifies for
+/// inline display, or if the source line would need to be echoed
+/// again for the message to make sense.
+bool in_user_input = false;
+  };
+  /// Contains this diagnostic's source location, if applicable.
+  std::optional source_location;
+  /// Contains \c eSeverityError in the example above.
+  lldb::Severity severity = lldb::eSeverityInfo;
+  /// Contains "use of undeclared identifier 'foo'" in the example above.
+  std::string message;
+  /// Contains the fully rendered error message, without "error: ",
+  /// but including the source context.

jimingham wrote:

I was confused because it didn't seem like there was a way to get the inline 
rendering if you wanted to use that, for instance if you were writing your own 
driver.   Presumably there's no way to do that?  That set me to wondering 
whether `is_user_input = true` would affect what you see in rendered?  
You are using "the fully rendered error message" to mean "the one not rendered 
for inline display".  That wasn't clear to me.

BTW, I don't actually think it's necessary to have a way to fetch the inline 
rendered form (properly offset for the prompt string, etc.)  The possibility 
set me wondering, however.

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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

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

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/110065

>From ce87c9d2b62c9b05e8ef76d7cc4036420ee563f3 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 24 Sep 2024 17:42:49 -0700
Subject: [PATCH 01/13] Add the addr info when appropriate for NIX' crash
 signals

---
 .../Process/elf-core/ProcessElfCore.cpp   |  1 +
 .../Process/elf-core/ThreadElfCore.cpp| 44 ---
 .../Plugins/Process/elf-core/ThreadElfCore.h  | 18 ++--
 .../postmortem/elf-core/TestLinuxCore.py  | 17 +++
 .../elf-core/linux-x86_64-sigsev.yaml |  8 
 5 files changed, 80 insertions(+), 8 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/postmortem/elf-core/linux-x86_64-sigsev.yaml

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 7955594bf5d94c..468a3b8934e741 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -931,6 +931,7 @@ llvm::Error 
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
 return status.ToError();
   thread_data.signo = siginfo.si_signo;
   thread_data.code = siginfo.si_code;
+  thread_data.description = siginfo.GetDescription();
   break;
 }
 case ELF::NT_FILE: {
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 52b96052bdbeca..3260caabd70ac6 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -6,9 +6,11 @@
 //
 
//===--===//
 
+#include "Plugins/Process/POSIX/CrashReason.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/UnixSignals.h"
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -41,6 +43,7 @@
 #include "RegisterContextPOSIXCore_x86_64.h"
 #include "ThreadElfCore.h"
 
+#include "bits/types/siginfo_t.h"
 #include 
 
 using namespace lldb;
@@ -49,8 +52,8 @@ using namespace lldb_private;
 // Construct a Thread object with given data
 ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
 : Thread(process, td.tid), m_thread_name(td.name), m_thread_reg_ctx_sp(),
-  m_signo(td.signo), m_code(td.code), m_gpregset_data(td.gpregset),
-  m_notes(td.notes) {}
+  m_signo(td.signo), m_code(td.code), m_sig_description(td.description),
+  m_gpregset_data(td.gpregset), m_notes(td.notes) {}
 
 ThreadElfCore::~ThreadElfCore() { DestroyThread(); }
 
@@ -241,7 +244,7 @@ bool ThreadElfCore::CalculateStopInfo() {
 return false;
 
   SetStopInfo(StopInfo::CreateStopReasonWithSignal(
-  *this, m_signo, /*description=*/nullptr, m_code));
+  *this, m_signo, m_sig_description.c_str(), m_code));
   return true;
 }
 
@@ -543,7 +546,8 @@ size_t ELFLinuxSigInfo::GetSize(const 
lldb_private::ArchSpec &arch) {
 
 Status ELFLinuxSigInfo::Parse(const DataExtractor &data, const ArchSpec &arch) 
{
   Status error;
-  if (GetSize(arch) > data.GetByteSize()) {
+  uint64_t size = GetSize(arch);
+  if (size > data.GetByteSize()) {
 error = Status::FromErrorStringWithFormat(
 "NT_SIGINFO size should be %zu, but the remaining bytes are: %" PRIu64,
 GetSize(arch), data.GetByteSize());
@@ -556,6 +560,36 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch) {
   si_signo = data.GetU32(&offset);
   si_errno = data.GetU32(&offset);
   si_code = data.GetU32(&offset);
+  // 64b ELF have a 4 byte pad.
+  if (data.GetAddressByteSize() == 8)
+offset += 4;
+  switch (si_signo) {
+case SIGFPE:
+case SIGILL:
+case SIGSEGV:
+case SIGBUS:
+case SIGTRAP:
+  addr = (void*)data.GetAddress(&offset);
+  addr_lsb = data.GetU16(&offset);
+  return error;
+default:
+  return error;
+  }
+}
 
-  return error;
+std::string ELFLinuxSigInfo::GetDescription() {
+  switch (si_signo) {
+case SIGFPE:
+case SIGILL:
+case SIGSEGV:
+case SIGBUS:
+case SIGTRAP:
+  return lldb_private::UnixSignals::CreateForHost()->GetSignalDescription(
+si_signo, si_code,
+reinterpret_cast(addr));
+default:
+  return lldb_private::UnixSignals::CreateForHost()->GetSignalDescription(
+si_signo, si_code
+  );
+  }
 }
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
index 3fa0b8b0eedb0b..0dc21a10ded5e5 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -75,16 +75,25 @@ struct ELFLinuxPrStatus {
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
   "sizeof ELFLinuxPrStatus is not correct!");

[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)

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

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/108448

>From 2fece4588cf99f268b6e6e91b1225fe63cd91898 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 12 Sep 2024 13:10:58 -0700
Subject: [PATCH 01/10] Create set for the stop reasons we collect, and add
 breakpoint to it.

---
 .../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 13 +++--
 .../ObjectFile/Minidump/MinidumpFileBuilder.h   |  4 +++-
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index f6c16b6e3d96ae..8f43c06ec14b79 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -75,8 +75,7 @@ Status 
MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 if (stop_info_sp) {
   const StopReason &stop_reason = stop_info_sp->GetStopReason();
-  if (stop_reason == StopReason::eStopReasonException ||
-  stop_reason == StopReason::eStopReasonSignal)
+  if (m_thread_stop_reasons.count(stop_reason) > 0)
 m_expected_directories++;
 }
   }
@@ -686,16 +685,10 @@ Status MinidumpFileBuilder::AddExceptions() {
   for (const ThreadSP &thread_sp : thread_list) {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 bool add_exception = false;
-if (stop_info_sp) {
-  switch (stop_info_sp->GetStopReason()) {
-  case eStopReasonSignal:
-  case eStopReasonException:
+if (stop_info_sp && 
m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
 add_exception = true;
-break;
-  default:
-break;
-  }
 }
+
 if (add_exception) {
   constexpr size_t minidump_exception_size =
   sizeof(llvm::minidump::ExceptionStream);
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index a4240f871c8a2f..f555a0fc9fbff1 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -173,7 +173,9 @@ class MinidumpFileBuilder {
   std::unordered_map
   m_tid_to_reg_ctx;
   lldb::FileUP m_core_file;
-  lldb_private::SaveCoreOptions m_save_core_options;
+  lldb_private::SaveCoreOptions m_save_core_options; 
+  const std::unordered_set m_thread_stop_reasons = 
{lldb::StopReason::eStopReasonException, lldb::StopReason::eStopReasonSignal,
+  lldb::StopReason::eStopReasonBreakpoint };
 };
 
 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_MINIDUMPFILEBUILDER_H

>From 70aeeb68c83e8b1b954543103a1ed74d7f9146ce Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 12 Sep 2024 13:30:04 -0700
Subject: [PATCH 02/10] Make const set with the stop reasons

---
 .../ObjectFile/Minidump/MinidumpFileBuilder.cpp   | 11 +--
 .../Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h |  4 +---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 8f43c06ec14b79..58a59c4ee6ddef 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -54,6 +54,13 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::minidump;
 
+// Set of all the stop reasons minidumps will collect.
+const std::unordered_set 
MinidumpFileBuilder::thread_stop_reasons {
+  lldb::StopReason::eStopReasonException,
+  lldb::StopReason::eStopReasonSignal,
+  lldb::StopReason::eStopReasonBreakpoint,
+};
+
 Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
   // First set the offset on the file, and on the bytes saved
   m_saved_data_size = HEADER_SIZE;
@@ -75,7 +82,7 @@ Status 
MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 if (stop_info_sp) {
   const StopReason &stop_reason = stop_info_sp->GetStopReason();
-  if (m_thread_stop_reasons.count(stop_reason) > 0)
+  if (thread_stop_reasons.count(stop_reason) > 0)
 m_expected_directories++;
 }
   }
@@ -685,7 +692,7 @@ Status MinidumpFileBuilder::AddExceptions() {
   for (const ThreadSP &thread_sp : thread_list) {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 bool add_exception = false;
-if (stop_info_sp && 
m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
+if (stop_info_sp && 
thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
 add_exception = true;
 }
 
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index f555a0fc9fbff1..a952

[Lldb-commits] [lldb] [lldb] Check for Python 'packaging' module at configuration time (PR #111747)

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

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


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


[Lldb-commits] [lldb] [lldb] Add missing include to SBLanguages.h (PR #111763)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

SBLanguages.h uses a uint16_t but is missing the include for ``, 
if any file includes this without including that it will cause a build error so 
this commit adds this include.

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


1 Files Affected:

- (modified) lldb/scripts/generate-sbapi-dwarf-enum.py (+2) 


``diff
diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 7fd6037986317e..689c7f81bfda01 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -16,6 +16,8 @@
 #ifndef LLDB_API_SBLANGUAGE_H
 #define LLDB_API_SBLANGUAGE_H
 
+#include 
+
 namespace lldb {
 /// Used by \\ref SBExpressionOptions.
 /// These enumerations use the same language enumerations as the DWARF

``




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


[Lldb-commits] [lldb] [lldb] Add missing include to SBLanguages.h (PR #111763)

2024-10-09 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/111763

SBLanguages.h uses a uint16_t but is missing the include for ``, if 
any file includes this without including that it will cause a build error so 
this commit adds this include.

>From f652fa49979306cf38bdb9e1b463c55a5c930ac1 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 9 Oct 2024 14:31:29 -0700
Subject: [PATCH] [lldb] Add missing include to SBLanguages.h

SBLanguages.h uses a uint16_t but is missing the include for
``, if any file includes this without including that it will
cause a build error so this commit adds this include.
---
 lldb/scripts/generate-sbapi-dwarf-enum.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 7fd6037986317e..689c7f81bfda01 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -16,6 +16,8 @@
 #ifndef LLDB_API_SBLANGUAGE_H
 #define LLDB_API_SBLANGUAGE_H
 
+#include 
+
 namespace lldb {
 /// Used by \\ref SBExpressionOptions.
 /// These enumerations use the same language enumerations as the DWARF

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


[Lldb-commits] [lldb] [lldb] Add missing include to SBLanguages.h (PR #111763)

2024-10-09 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] ac3321f - [lldb] Add missing include to SBLanguages.h (#111763)

2024-10-09 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2024-10-09T14:41:50-07:00
New Revision: ac3321f104ae2a0639845f860b05c97568bb24e2

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

LOG: [lldb] Add missing include to SBLanguages.h (#111763)

SBLanguages.h uses a uint16_t but is missing the include for
``, if any file includes this without including that it will
cause a build error so this commit adds this include.

Added: 


Modified: 
lldb/scripts/generate-sbapi-dwarf-enum.py

Removed: 




diff  --git a/lldb/scripts/generate-sbapi-dwarf-enum.py 
b/lldb/scripts/generate-sbapi-dwarf-enum.py
index 7fd6037986317e..689c7f81bfda01 100755
--- a/lldb/scripts/generate-sbapi-dwarf-enum.py
+++ b/lldb/scripts/generate-sbapi-dwarf-enum.py
@@ -16,6 +16,8 @@
 #ifndef LLDB_API_SBLANGUAGE_H
 #define LLDB_API_SBLANGUAGE_H
 
+#include 
+
 namespace lldb {
 /// Used by \\ref SBExpressionOptions.
 /// These enumerations use the same language enumerations as the DWARF



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


[Lldb-commits] [lldb] [lldb] Check for Python 'packaging' module at configuration time (PR #111747)

2024-10-09 Thread Med Ismail Bennani via lldb-commits

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

Nice! LGTM!

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


[Lldb-commits] [lldb] Improve type lookup using .debug_names parent chain (PR #108907)

2024-10-09 Thread via lldb-commits


@@ -374,6 +375,21 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
   m_fallback.GetFullyQualifiedType(context, callback);
 }
 
+bool DebugNamesDWARFIndex::SameAsEntryContext(
+const CompilerContext &query_context,
+const DebugNames::Entry &entry) const {
+  // TODO: check dwarf tag matches.

jeffreytan81 wrote:

No, it is not a long term todo. My 3rd PR in the stack will implement it. 

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add Extension to Save a thread and N pointers deep (PR #111601)

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

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/111601

>From b128131f457a013102b2a0b2fcb968956d980076 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 8 Oct 2024 15:52:45 -0700
Subject: [PATCH 1/4] Create new extension for save core to save a thread and N
 pointers deep

---
 .../interface/SBSaveCoreOptionsExtensions.i   | 31 +++
 lldb/bindings/interfaces.swig |  1 +
 .../TestProcessSaveCoreMinidump.py| 22 +
 3 files changed, 54 insertions(+)
 create mode 100644 lldb/bindings/interface/SBSaveCoreOptionsExtensions.i

diff --git a/lldb/bindings/interface/SBSaveCoreOptionsExtensions.i 
b/lldb/bindings/interface/SBSaveCoreOptionsExtensions.i
new file mode 100644
index 00..668efbf0f932f1
--- /dev/null
+++ b/lldb/bindings/interface/SBSaveCoreOptionsExtensions.i
@@ -0,0 +1,31 @@
+#extend lldb::SBSaveCoreOptions {
+#ifdef SWIGPYTHON
+%pythoncode% {
+'''Add a thread to the SaveCoreOptions thread list, and follow it's 
children N pointers deep, adding each memory region to the SaveCoreOptions 
Memory region list.'''
+def save_thread_with_heaps(self, thread, num_heaps_deep = 3):
+self.AddThread(thread)
+frame = thread.GetFrameAtIndex(0)
+process = thread.GetProcess()
+queue = []
+for var in frame.locals:
+if var.TypeIsPointerType():
+queue.append(var.Dereference())
+
+while (num_heaps_deep > 0 and len(queue) > 0):
+queue_size = len(queue)
+for i in range(0, queue_size):
+var = queue.pop(0)
+memory_region = lldb.SBMemoryRegionInfo()
+process.GetMemoryRegionInfo(var.GetAddress().GetOffset(), 
memory_region)
+self.AddMemoryRegionToSave(memory_region)
+/* 
+We only check for direct pointer children T*, should 
probably scan 
+internal to the children themselves. 
+*/
+for x in var.children:
+if x.TypeIsPointerType():
+queue.append(x.Dereference())
+
+num_heaps_deep -= 1
+}
+#endif SWIGPYTHON
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 8a6fed95f0b729..8a82ba28d3f2ae 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -26,6 +26,7 @@
 %include "./interface/SBCommunicationDocstrings.i"
 %include "./interface/SBCompileUnitDocstrings.i"
 %include "./interface/SBSaveCoreOptionsDocstrings.i"
+#include "./interface/SBSaveCoreOptionsExtensions.i"
 %include "./interface/SBDataDocstrings.i"
 %include "./interface/SBDebuggerDocstrings.i"
 %include "./interface/SBDeclarationDocstrings.i"
diff --git 
a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
index 03cc415924e0bb..cb5d625f4bffa4 100644
--- 
a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
+++ 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
@@ -3,6 +3,7 @@
 """
 
 import os
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -470,6 +471,27 @@ def save_core_with_region(self, process, region_index):
 if os.path.isfile(custom_file):
 os.unlink(custom_file)
 
+def save_core_one_thread_one_heap(self, process, region_index):
+try:
+custom_file = self.getBuildArtifact("core.one_thread_one_heap.dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(custom_file))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+thread = process.GetThreadAtIndex(0)
+options.save_thread_with_heaps(thread)
+
+error = process.SaveCore(options)
+self.assertTrue(error.Success())
+core_target = self.dbg.CreateTarget(None)
+core_proc = core_target.LoadCore(custom_file)
+# proc/pid maps prevent us from checking the number of regions, but
+# this is mostly a smoke test for the extension.
+self.assertEqual(core_proc.GetNumThreads(), 1)
+finally:
+if os.path.isfile(custom_file):
+os.unlink(custom_file)
+
 @skipUnlessArch("x86_64")
 @skipUnlessPlatform(["linux"])
 def test_save_minidump_custom_save_style_duplicated_regions(self):

>From e4c9404eaec18f69e7f3490712c98c626e5bd984 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 8 Oct 2024 15:53:19 -0700
Subject: [PATCH 2/4] Reword the variable

---
 lldb/bindings/interface/SBSaveCoreOptionsExtensions.i | 6 +++---
 1

[Lldb-commits] [lldb] Improve type lookup using .debug_names parent chain (PR #108907)

2024-10-09 Thread via lldb-commits


@@ -444,6 +499,72 @@ void DebugNamesDWARFIndex::GetNamespaces(
   m_fallback.GetNamespaces(name, callback);
 }
 
+llvm::SmallVector
+DebugNamesDWARFIndex::GetTypeQueryParentContexts(TypeQuery &query) {
+  std::vector &query_decl_context =
+  query.GetContextRef();
+  llvm::SmallVector parent_contexts;
+  if (!query_decl_context.empty()) {
+// Skip the last entry, it is the type we are looking for.

jeffreytan81 wrote:

The vector returned from `TypeQuery::GetContextRef()` stores from outmost to 
innermost namespace which is reversed from what's we wanted (and .debug_names 
encoded in parent chain).

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


[Lldb-commits] [lldb] Improve type lookup using .debug_names parent chain (PR #108907)

2024-10-09 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/108907

>From 6e84ab9a14e63c58e1facdbf9a695c093882b37b Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 19 Aug 2024 10:57:35 -0700
Subject: [PATCH 1/3] Fix StartDebuggingRequestHandler/ReplModeRequestHandler
 in lldb-dap

---
 lldb/tools/lldb-dap/DAP.h| 2 --
 lldb/tools/lldb-dap/lldb-dap.cpp | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 57562a14983519..7828272aa15a7d 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -192,8 +192,6 @@ struct DAP {
   std::mutex call_mutex;
   std::map
   inflight_reverse_requests;
-  StartDebuggingRequestHandler start_debugging_request_handler;
-  ReplModeRequestHandler repl_mode_request_handler;
   ReplMode repl_mode;
   std::string command_escape_prefix = "`";
   lldb::SBFormat frame_format;
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index ea84f31aec3a6c..f50a6c17310739 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1627,12 +1627,12 @@ void request_initialize(const llvm::json::Object 
&request) {
   "lldb-dap", "Commands for managing lldb-dap.");
   if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
 cmd.AddCommand(
-"startDebugging", &g_dap.start_debugging_request_handler,
+"startDebugging", new StartDebuggingRequestHandler(),
 "Sends a startDebugging request from the debug adapter to the client "
 "to start a child debug session of the same type as the caller.");
   }
   cmd.AddCommand(
-  "repl-mode", &g_dap.repl_mode_request_handler,
+  "repl-mode", new ReplModeRequestHandler(),
   "Get or set the repl behavior of lldb-dap evaluation requests.");
 
   g_dap.progress_event_thread = std::thread(ProgressEventThreadFunction);

>From 750362e2c5e5cba7f7cd385698ff6c95c025f5c8 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 23 Sep 2024 16:40:16 -0700
Subject: [PATCH 2/3] Improve type query using .debug_names parent chain

---
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  25 
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  12 ++
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 123 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  34 +
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   5 +-
 5 files changed, 196 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..dee90804c52584 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -126,3 +126,28 @@ bool DWARFIndex::GetFullyQualifiedTypeImpl(
 return callback(die);
   return true;
 }
+
+void DWARFIndex::GetTypesWithQuery(
+TypeQuery &query, llvm::function_ref callback) {
+  GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+return ProcessTypeDIEMatchQuery(query, die, callback);
+  });
+}
+
+bool DWARFIndex::ProcessTypeDIEMatchQuery(
+TypeQuery &query, DWARFDIE die,
+llvm::function_ref callback) {
+  // Nothing to match from query
+  if (query.GetContextRef().size() <= 1)
+return callback(die);
+
+  std::vector die_context;
+  if (query.GetModuleSearch())
+die_context = die.GetDeclContext();
+  else
+die_context = die.GetTypeLookupContext();
+
+  if (!query.ContextMatches(die_context))
+return true;
+  return callback(die);
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index cb3ae8a06d7885..fea3a4fd697389 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -64,6 +64,13 @@ class DWARFIndex {
   virtual void
   GetNamespaces(ConstString name,
 llvm::function_ref callback) = 0;
+  /// Get type DIEs meeting requires of \a query.
+  /// in its decl parent chain as subset.  A base implementation is provided,
+  /// Specializations should override this if they are able to provide a faster
+  /// implementation.
+  virtual void
+  GetTypesWithQuery(TypeQuery &query,
+llvm::function_ref callback);
   virtual void
   GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -115,6 +122,11 @@ class DWARFIndex {
   bool
   GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
 llvm::function_ref callback);
+
+  /// Check if the type \a die can meet the requirements of \a query.
+  bool
+  ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
+   llvm::function_ref callback);
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/Deb

[Lldb-commits] [lldb] Improve type lookup using .debug_names parent chain (PR #108907)

2024-10-09 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/108907

>From 37bcf4470a6771a196c528e16d3fa1b50b60f63a Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 23 Sep 2024 16:40:16 -0700
Subject: [PATCH 1/2] Improve type query using .debug_names parent chain

---
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  25 
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  12 ++
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 123 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  34 +
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   5 +-
 5 files changed, 196 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..dee90804c52584 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -126,3 +126,28 @@ bool DWARFIndex::GetFullyQualifiedTypeImpl(
 return callback(die);
   return true;
 }
+
+void DWARFIndex::GetTypesWithQuery(
+TypeQuery &query, llvm::function_ref callback) {
+  GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+return ProcessTypeDIEMatchQuery(query, die, callback);
+  });
+}
+
+bool DWARFIndex::ProcessTypeDIEMatchQuery(
+TypeQuery &query, DWARFDIE die,
+llvm::function_ref callback) {
+  // Nothing to match from query
+  if (query.GetContextRef().size() <= 1)
+return callback(die);
+
+  std::vector die_context;
+  if (query.GetModuleSearch())
+die_context = die.GetDeclContext();
+  else
+die_context = die.GetTypeLookupContext();
+
+  if (!query.ContextMatches(die_context))
+return true;
+  return callback(die);
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index cb3ae8a06d7885..fea3a4fd697389 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -64,6 +64,13 @@ class DWARFIndex {
   virtual void
   GetNamespaces(ConstString name,
 llvm::function_ref callback) = 0;
+  /// Get type DIEs meeting requires of \a query.
+  /// in its decl parent chain as subset.  A base implementation is provided,
+  /// Specializations should override this if they are able to provide a faster
+  /// implementation.
+  virtual void
+  GetTypesWithQuery(TypeQuery &query,
+llvm::function_ref callback);
   virtual void
   GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -115,6 +122,11 @@ class DWARFIndex {
   bool
   GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
 llvm::function_ref callback);
+
+  /// Check if the type \a die can meet the requirements of \a query.
+  bool
+  ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
+   llvm::function_ref callback);
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 373b3d9ed2eaa9..694c4a5a16ece6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -301,7 +301,8 @@ using Entry = llvm::DWARFDebugNames::Entry;
 /// If any parent does not have an `IDX_parent`, or the Entry data is 
corrupted,
 /// nullopt is returned.
 std::optional>
-getParentChain(Entry entry, uint32_t max_parents) {
+getParentChain(Entry entry,
+   uint32_t max_parents = std::numeric_limits::max()) {
   llvm::SmallVector parent_entries;
 
   do {
@@ -374,6 +375,21 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
   m_fallback.GetFullyQualifiedType(context, callback);
 }
 
+bool DebugNamesDWARFIndex::SameAsEntryContext(
+const CompilerContext &query_context,
+const DebugNames::Entry &entry) const {
+  // TODO: check dwarf tag matches.
+  // Peek at the AT_name of `entry` and test equality to `name`.
+  auto maybe_dieoffset = entry.getDIEUnitOffset();
+  if (!maybe_dieoffset)
+return false;
+  DWARFUnit *unit = GetNonSkeletonUnit(entry);
+  if (!unit)
+return false;
+  return query_context.name ==
+ unit->PeekDIEName(unit->GetOffset() + *maybe_dieoffset);
+}
+
 bool DebugNamesDWARFIndex::SameParentChain(
 llvm::ArrayRef parent_names,
 llvm::ArrayRef parent_entries) const {
@@ -402,6 +418,45 @@ bool DebugNamesDWARFIndex::SameParentChain(
   return true;
 }
 
+bool DebugNamesDWARFIndex::SameParentChain(
+llvm::ArrayRef parent_contexts,
+llvm::ArrayRef parent_entries) const {
+  if (parent_entries.size() != parent_contexts.size())
+return false;
+
+  // If the AT_name of any parent fails to match the expected name, we don't
+  // have a match.
+  for (auto [parent_context, parent_entry]

[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

https://github.com/ldm0 updated https://github.com/llvm/llvm-project/pull/111684

>From 09a65dc9729938d5920174cac180164a8e3eb7a2 Mon Sep 17 00:00:00 2001
From: Liu Dingming 
Date: Wed, 9 Oct 2024 21:57:24 +0800
Subject: [PATCH] [lldb] Simplify macOS thread name fetching.

Remove unnecessary `proc_pidinfo` calling.
---
 .../debugserver/source/MacOSX/MachThread.cpp  | 47 ++-
 .../debugserver/source/MacOSX/MachThread.h|  8 ++--
 2 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..bce60ed94e36de 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *extendedInfoPtr) 
{
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)extendedInfoPtr, 
&info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(extendedInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +597,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..0c78ef1a337ed3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,8 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
-
-  bool GetIdentifierInfo();
+  static bool GetExtendedInfo(thread_t threadID,
+  struc

[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits


@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")

weliveindetail wrote:

Well, no there is no GOOD reason. For the moment it was easy to keep it guarded 
by `LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS` since it is `OFF` by default and 
won't fall on people's feet immediately. However, I am afraid we should 
special-case NetBSD and FreeBSD here to look for `gmake` instead of `make`.

Let me fix this in a follow-up PR that includes the author of 
https://github.com/llvm/llvm-project/pull/93883

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


[Lldb-commits] [lldb] [lldb][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits


@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *basicInfoPtr) {

ldm0 wrote:

fixed

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


[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

https://github.com/ldm0 updated https://github.com/llvm/llvm-project/pull/111684

>From aefa120446a4c31fe9569d76ae3950c29d8d35e9 Mon Sep 17 00:00:00 2001
From: Liu Dingming 
Date: Wed, 9 Oct 2024 21:57:24 +0800
Subject: [PATCH] [lldb] Simplify macOS thread name fetching (NFC)

Remove unnecessary `proc_pidinfo` calling.
---
 .../debugserver/source/MacOSX/MachThread.cpp  | 47 ++-
 .../debugserver/source/MacOSX/MachThread.h|  8 ++--
 2 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..bce60ed94e36de 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *extendedInfoPtr) 
{
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)extendedInfoPtr, 
&info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(extendedInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +597,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..0c78ef1a337ed3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,8 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
-
-  bool GetIdentifierInfo();
+  static bool GetExtendedInfo(thread_t threadID,
+  

[Lldb-commits] [lldb] [lldb][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

ldm0 wrote:

> I asked some folks who know and the proc_pidinfo call and the 
> extended_thread_info read the same data, so this should be NFC...

Yes, this PR does not intend to change the behavior: 
[`thread_info`](https://github.com/apple/darwin-xnu/blob/a1babec6b135d1f35b2590a1990af3c5c5393479/osfmk/kern/thread.c#L1984),
 
[`proc_pidinfo`](https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/osfmk/kern/bsd_kern.c#L1076).
 Just a drive-by optimization to reduce syscalls.

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


[Lldb-commits] [lldb] [lldb] Introduce an always-on system log category/channel (PR #108495)

2024-10-09 Thread Jonas Devlieghere via lldb-commits

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

>From 98f1b5e8a37987e185038380ccc5203a8fae8063 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 25 Sep 2024 11:04:56 -0700
Subject: [PATCH] [lldb] Introduce an always-on system log category/channel

Add an "always on" log category and channel. Unlike other, existing log
channels, it is not exposed to users. The channel is meant to be used
sparsely and deliberately for logging high-value information to the
system log.

We have a similar concept in the downstream Swift fork and this has
proven to be extremely valuable. This is especially true on macOS where
system log messages are automatically captured as part of a sysdiagnose.

This patch revives https://reviews.llvm.org/D135621 although the purpose
is slightly different (logging to the system log rather than to a ring
buffer dumped as part of the diagnostics). This patch addresses all the
remaining outstanding comments.
---
 lldb/include/lldb/Host/Host.h | 19 +++
 lldb/include/lldb/Utility/Log.h   | 11 +++---
 lldb/source/API/SystemInitializerFull.cpp |  3 ++
 lldb/source/Host/common/Host.cpp  | 16 +
 lldb/source/Host/common/HostInfoBase.cpp  |  2 ++
 lldb/source/Utility/Log.cpp   | 34 ---
 lldb/test/Shell/Host/TestSytemLogChannel.test |  3 ++
 7 files changed, 70 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/Shell/Host/TestSytemLogChannel.test

diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 9d0994978402f7..d8113a5fceeada 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -31,6 +31,25 @@ class ProcessInstanceInfo;
 class ProcessInstanceInfoMatch;
 typedef std::vector ProcessInstanceInfoList;
 
+// System log category and channel. This log channel is always enabled and
+// therefore is supposed to be used sparsely. Use this log channel to log
+// critical information that is expected to be relevant to the majority of bug
+// reports.
+enum class SystemLog : Log::MaskType {
+  System = Log::ChannelFlag<0>,
+  LLVM_MARK_AS_BITMASK_ENUM(System)
+};
+
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+
+class LogChannelSystem {
+public:
+  static void Initialize();
+  static void Terminate();
+};
+
+template <> Log::Channel &LogChannelFor();
+
 // Exit Type for inferior processes
 struct WaitStatus {
   enum Type : uint8_t {
diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index 27707c17f9b824..ac6347153a1014 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -272,6 +272,12 @@ class Log final {
   void VAFormatf(llvm::StringRef file, llvm::StringRef function,
  const char *format, va_list args);
 
+  void Enable(const std::shared_ptr &handler_sp,
+  std::optional flags = std::nullopt,
+  uint32_t options = 0);
+
+  void Disable(std::optional flags = std::nullopt);
+
 private:
   Channel &m_channel;
 
@@ -297,11 +303,6 @@ class Log final {
 return m_handler;
   }
 
-  void Enable(const std::shared_ptr &handler_sp, uint32_t options,
-  MaskType flags);
-
-  void Disable(MaskType flags);
-
   bool Dump(llvm::raw_ostream &stream);
 
   typedef llvm::StringMap ChannelMap;
diff --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 995d14f7c1fa1e..8a992a6889a91b 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Target/ProcessTrace.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/Version/Version.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/TargetSelect.h"
 
@@ -83,6 +84,8 @@ llvm::Error SystemInitializerFull::Initialize() {
   // Use the Debugger's LLDBAssert callback.
   SetLLDBAssertCallback(Debugger::AssertCallback);
 
+  LLDB_LOG(GetLog(SystemLog::System), "{0}", GetVersion());
+
   return llvm::Error::success();
 }
 
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index f08adea6546ae1..abca6068d3604a 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -125,6 +125,22 @@ void Host::SystemLog(Severity severity, llvm::StringRef 
message) {
 #endif
 #endif
 
+static constexpr Log::Category g_categories[] = {
+{{"system"}, {"system log"}, SystemLog::System}};
+
+static Log::Channel g_system_channel(g_categories, SystemLog::System);
+static Log g_system_log(g_system_channel);
+
+template <> Log::Channel &lldb_private::LogChannelFor() {
+  return g_system_channel;
+}
+
+void LogChannelSystem::Initialize() {
+  g_system_log.Enable(std::make_shared());
+}
+
+void LogChannelSystem::Terminate() { g_system_log.Disable(); }
+
 #if !defined(__APPLE__) && !defined(_WIN32)
 static thread_result_t
 MonitorChildProcessT

[Lldb-commits] [lldb] de4f2c9 - [lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures (#111543)

2024-10-09 Thread via lldb-commits

Author: David Spickett
Date: 2024-10-09T09:14:48+01:00
New Revision: de4f2c976f9fa11173c71b2b070225c9be89ceef

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

LOG: [lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures 
(#111543)

I don't see an obvious reason it has to be x86 specific and local
testing on Arm and AArch64 is fine.

Originally disabled in 50337fb933e0f666d34d747a43d46840b3982bf7 in
response to failures apparently caused by
https://reviews.llvm.org/D93951.

Perhaps those still exist but worth trying this and checking I think.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index ac96bcc1364a27..38a3c4d68eb280 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -44,7 +44,6 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
 return
@@ -90,7 +89,6 @@ def test_runInTerminal(self):
 env = self.dap_server.request_evaluate("foo")["body"]["result"]
 self.assertIn("bar", env)
 
-@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalWithObjectEnv(self):
 if not self.isTestSupported():
 return
@@ -114,7 +112,6 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertEqual("BAR", request_envs["FOO"])
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
 return
@@ -133,7 +130,6 @@ def test_runInTerminalInvalidTarget(self):
 )
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return
@@ -148,7 +144,6 @@ def test_missingArgInRunInTerminalLauncher(self):
 )
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 if not self.isTestSupported():
 return
@@ -175,7 +170,6 @@ def 
test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 self.assertIn("No such file or directory", stderr)
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 if not self.isTestSupported():
 return
@@ -202,7 +196,6 @@ def 
test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 self.assertIn("foo", stdout)
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 if not self.isTestSupported():
 return
@@ -223,7 +216,6 @@ def 
test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 self.assertIn("FOO=BAR", stdout)
 
 @skipIfWindows
-@skipIf(archs=no_match(["x86_64"]))
 def test_NonAttachedRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return



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


[Lldb-commits] [lldb] [lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures (PR #111543)

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

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits


@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'

weliveindetail wrote:

The default install path on Windows is `C:\Program Files 
(x86)\GnuWin32\bin\make.exe` unfortunately.

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits


@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+

weliveindetail wrote:

`--make` is added if `LLDB_TEST_MAKE` is defined explicitly or 
`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON`

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail commented:

Two notes inline

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/111531

From c7356d3c265869ff387c977dd18e9c617dc31c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 8 Oct 2024 15:40:37 +0200
Subject: [PATCH 1/3] [lldb] Add early CMake check for 'make' tool

Around 400 of LLDB's dotest.py based tests require the make tool to be found in 
Path. If it's not found, they fail with an obscure error and show up as 
UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but 
make is not part of that. Let's catch the situation early and raise an error if 
LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the 
configuration process. There might be other issues further down the line that 
can be caught in the same buildbot run.
---
 lldb/test/CMakeLists.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+message(STATUS "Not found: make")
+message(SEND_ERROR
+  "LLDB tests require 'make' tool. Please install and add it to Path "
+  "(or otherwise disable strict testing requirements with "
+  "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

From 5e7bc2d26b54440936b3d756e12d708ae5218c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Wed, 9 Oct 2024 13:07:27 +0200
Subject: [PATCH 2/3] Pass make as an explicit argument to dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py |  2 ++
 lldb/test/API/CMakeLists.txt  |  1 +
 lldb/test/API/lit.cfg.py  |  3 +++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/test/CMakeLists.txt  | 20 +++
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index b1ae896d3fd3b4..40294aec166381 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'
 
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 27f285230cafaf..c426d76f7d9e76 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -58,6 +58,7 @@ endif()
 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb 
executable used for testing")
 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler 
to use for building LLDB test inferiors")
 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil 
used for generating dSYM bundles")
+set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for 
building test executables")
 
 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
   message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 96520c7c826246..c6fa20a63424d4 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+
 if is_configured("llvm_tools_dir"):
 dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2a..9f647034dc9f97 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,6 +31,7 @@ config.lldb_executable = 
lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
+config.make = lit_config.substitute('@LLDB_TEST_MAKE@')
 config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 7993be2602e538..5b00e10af136f1 100644
-

[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

https://github.com/ldm0 created https://github.com/llvm/llvm-project/pull/111684

Remove unnecessary `proc_pidinfo` calling.

>From e8432f711822d605b5136574967f7c7f133dfe73 Mon Sep 17 00:00:00 2001
From: Liu Dingming 
Date: Wed, 9 Oct 2024 21:57:24 +0800
Subject: [PATCH] [lldb] Simplify macOS thread name fetching.

Remove unnecessary `proc_pidinfo` calling.
---
 .../debugserver/source/MacOSX/MachThread.cpp  | 47 ++-
 .../debugserver/source/MacOSX/MachThread.h|  6 ++-
 2 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..1568157286a52d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *basicInfoPtr) {
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)basicInfoPtr, 
&info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(basicInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +597,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..cf9b4cbb61a681 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,6 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
+  static bool GetExtendedInfo(thread_t threadID,
+  str

[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Donough Liu (ldm0)


Changes

Remove unnecessary `proc_pidinfo` calling.

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


2 Files Affected:

- (modified) lldb/tools/debugserver/source/MacOSX/MachThread.cpp (+25-22) 
- (modified) lldb/tools/debugserver/source/MacOSX/MachThread.h (+4-2) 


``diff
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..1568157286a52d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,25 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *basicInfoPtr) {
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err = ::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)basicInfoPtr, 
&info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(basicInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +597,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..cf9b4cbb61a681 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,6 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
+  static bool GetExtendedInfo(thread_t threadID,
+  struct thread_extended_info *extended_info);
 
   bool GetIdentifierInfo();
 
@@ -152,8 +155,7 @@ class MachThread {
   const DNBRegisterSetInfo
   *m_reg_sets; //

[Lldb-commits] [lldb] [lldb] Simplify macOS thread name fetching. (PR #111684)

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

https://github.com/omjavaid updated 
https://github.com/llvm/llvm-project/pull/108072

>From ac61e5a75ce59f7834034494a03b43e81bf02d41 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid 
Date: Tue, 10 Sep 2024 18:03:29 +0500
Subject: [PATCH 1/4] WoA hardware breakpoint/watchpoint support

---
 .../Windows/Common/NativeProcessWindows.cpp   | 52 ---
 .../Common/NativeRegisterContextWindows.cpp   |  3 -
 .../Common/NativeRegisterContextWindows.h |  6 +-
 .../NativeRegisterContextWindows_WoW64.cpp|  4 +-
 .../NativeRegisterContextWindows_arm.cpp  |  4 +-
 .../NativeRegisterContextWindows_arm64.cpp| 86 ++-
 .../NativeRegisterContextWindows_arm64.h  | 32 ++-
 .../NativeRegisterContextWindows_i386.cpp |  4 +-
 .../NativeRegisterContextWindows_x86_64.cpp   |  4 +-
 .../Windows/Common/NativeThreadWindows.cpp| 32 +++
 10 files changed, 135 insertions(+), 92 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 24c9aa6b32659d..87a811123d5de8 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -491,24 +491,47 @@ NativeProcessWindows::OnDebugException(bool first_chance,
 return ExceptionResult::MaskException;
   }
   case DWORD(STATUS_BREAKPOINT):
-  case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
-
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
+  case STATUS_WX86_BREAKPOINT: {
+bool breakpoint_hit = false;
+NativeThreadWindows *stop_thread = GetThreadByID(record.GetThreadID());
+
+if (stop_thread) {
+  uint32_t hw_id = LLDB_INVALID_INDEX32;
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  reg_ctx.GetHardwareBreakHitIndex(hw_id, record.GetExceptionAddress());
+  if (hw_id != LLDB_INVALID_INDEX32) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit hardware breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
+  } else if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
 uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
 // The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+uint64_t pc = reg_ctx.GetPC() - breakpoint_size;
+reg_ctx.SetPC(pc);
   }
 
-  SetState(eStateStopped, true);
-  return ExceptionResult::MaskException;
+  if (breakpoint_hit) {
+StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  } else {
+const std::vector &args = record.GetExceptionArguments();
+if (args.size() >= 2) {
+  reg_ctx.GetWatchpointHitIndex(hw_id, args[1]);
+  if (hw_id != LLDB_INVALID_INDEX32) {
+addr_t wp_pc = record.GetExceptionAddress();
+std::string desc =
+formatv("{0} {1} {2}", args[1], hw_id, wp_pc).str();
+StopThread(record.GetThreadID(), StopReason::eStopReasonWatchpoint,
+   desc);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  }
+}
+  }
 }
 
 if (!initial_stop) {
@@ -531,6 +554,7 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   // Hit the initial stop. Continue the application.
   return ExceptionResult::BreakInDebugger;
 }
+  }
 
 [[fallthrough]];
   default:
diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
index 9128363eaa577a..95be1183abb759 100644
--- 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
+++ 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
@@ -18,9 +18,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-NativeRegisterContextWindows::NativeRegisterContextWindows(
-NativeThreadProtocol &thread, RegisterInfoInterface *reg_info_interface_p)
-: NativeRegisterContextRegisterInfo(thread, reg_info_interface_p) {}
 
 lldb::thread_t NativeRegisterContextWindows::GetThreadHandle() const {
   auto wthread = static_cast(&m_thread);
diff --git 
a/lldb/source/Plugins

[Lldb-commits] [lldb] 146d3f0 - [lldb][test] Disable TestSharedLibStrippedSymbols on Arm

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

Author: David Spickett
Date: 2024-10-09T08:51:38Z
New Revision: 146d3f04ff92e396ea40ab581304e65e8511d8ac

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

LOG: [lldb][test] Disable TestSharedLibStrippedSymbols on Arm

This has been flakey lately for example:
https://lab.llvm.org/buildbot/#/builders/18/builds/5139

Added: 


Modified: 

lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py

Removed: 




diff  --git 
a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
 
b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
index 55857d703978c6..fec0a7a037d67d 100644
--- 
a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
+++ 
b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
@@ -10,6 +10,10 @@
 
 class SharedLibStrippedTestCase(TestBase):
 @expectedFailureAll(oslist=["windows"])
+# Sometimes fails with:
+# error: Couldn't allocate space for materialized struct: Couldn't malloc: 
address space is full
+# On 32 bit Arm Linux.
+@skipIf(archs=["arm"])
 def test_expr(self):
 """Test that types work when defined in a shared library and 
forward-declared in the main executable"""
 if "clang" in self.getCompiler() and "3.4" in 
self.getCompilerVersion():



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


[Lldb-commits] [lldb] Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures" (PR #111648)

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

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

Reverts llvm/llvm-project#111543

https://lab.llvm.org/buildbot/#/builders/18/builds/5140 failed here again. 
Clearly there is something different on Arm but I don't know what it is yet.

>From 358ad5760066ef415012732c03fb28ec823f3205 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 9 Oct 2024 09:54:53 +0100
Subject: [PATCH] =?UTF-8?q?Revert=20"[lldb][test]=20Enable=20TestDAP=5Frun?=
 =?UTF-8?q?InTerminal=20on=20non-x86=20architectures=20(#=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit de4f2c976f9fa11173c71b2b070225c9be89ceef.
---
 .../tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py | 8 
 1 file changed, 8 insertions(+)

diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 38a3c4d68eb280..ac96bcc1364a27 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -44,6 +44,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
 return
@@ -89,6 +90,7 @@ def test_runInTerminal(self):
 env = self.dap_server.request_evaluate("foo")["body"]["result"]
 self.assertIn("bar", env)
 
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalWithObjectEnv(self):
 if not self.isTestSupported():
 return
@@ -112,6 +114,7 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertEqual("BAR", request_envs["FOO"])
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
 return
@@ -130,6 +133,7 @@ def test_runInTerminalInvalidTarget(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return
@@ -144,6 +148,7 @@ def test_missingArgInRunInTerminalLauncher(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 if not self.isTestSupported():
 return
@@ -170,6 +175,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 self.assertIn("No such file or directory", stderr)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 if not self.isTestSupported():
 return
@@ -196,6 +202,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 self.assertIn("foo", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 if not self.isTestSupported():
 return
@@ -216,6 +223,7 @@ def 
test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 self.assertIn("FOO=BAR", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_NonAttachedRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return

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


[Lldb-commits] [lldb] b43e003 - Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures" (#111648)

2024-10-09 Thread via lldb-commits

Author: David Spickett
Date: 2024-10-09T09:55:39+01:00
New Revision: b43e003d90f0a7c045e9961a80013fc9c6d6e9b3

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

LOG: Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 
architectures" (#111648)

Reverts llvm/llvm-project#111543

https://lab.llvm.org/buildbot/#/builders/18/builds/5140 failed here
again. Clearly there is something different on Arm but I don't know what
it is yet.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 38a3c4d68eb280..ac96bcc1364a27 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -44,6 +44,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
 return
@@ -89,6 +90,7 @@ def test_runInTerminal(self):
 env = self.dap_server.request_evaluate("foo")["body"]["result"]
 self.assertIn("bar", env)
 
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalWithObjectEnv(self):
 if not self.isTestSupported():
 return
@@ -112,6 +114,7 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertEqual("BAR", request_envs["FOO"])
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
 return
@@ -130,6 +133,7 @@ def test_runInTerminalInvalidTarget(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return
@@ -144,6 +148,7 @@ def test_missingArgInRunInTerminalLauncher(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 if not self.isTestSupported():
 return
@@ -170,6 +175,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 self.assertIn("No such file or directory", stderr)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 if not self.isTestSupported():
 return
@@ -196,6 +202,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 self.assertIn("foo", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 if not self.isTestSupported():
 return
@@ -216,6 +223,7 @@ def 
test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 self.assertIn("FOO=BAR", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_NonAttachedRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return



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


[Lldb-commits] [lldb] Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures" (PR #111648)

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

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


[Lldb-commits] [lldb] Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures" (PR #111648)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Reverts llvm/llvm-project#111543

https://lab.llvm.org/buildbot/#/builders/18/builds/5140 failed here again. 
Clearly there is something different on Arm but I don't know what it is yet.

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


1 Files Affected:

- (modified) 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py (+8) 


``diff
diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 38a3c4d68eb280..ac96bcc1364a27 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -44,6 +44,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
 return
@@ -89,6 +90,7 @@ def test_runInTerminal(self):
 env = self.dap_server.request_evaluate("foo")["body"]["result"]
 self.assertIn("bar", env)
 
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalWithObjectEnv(self):
 if not self.isTestSupported():
 return
@@ -112,6 +114,7 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertEqual("BAR", request_envs["FOO"])
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
 return
@@ -130,6 +133,7 @@ def test_runInTerminalInvalidTarget(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return
@@ -144,6 +148,7 @@ def test_missingArgInRunInTerminalLauncher(self):
 )
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 if not self.isTestSupported():
 return
@@ -170,6 +175,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
 self.assertIn("No such file or directory", stderr)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 if not self.isTestSupported():
 return
@@ -196,6 +202,7 @@ def 
test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
 self.assertIn("foo", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 if not self.isTestSupported():
 return
@@ -216,6 +223,7 @@ def 
test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
 self.assertIn("FOO=BAR", stdout)
 
 @skipIfWindows
+@skipIf(archs=no_match(["x86_64"]))
 def test_NonAttachedRunInTerminalLauncher(self):
 if not self.isTestSupported():
 return

``




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


[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-09 Thread Emre Kultursay via lldb-commits

emrekultursay wrote:

> With this in mind, deleting the file is representative of an editor wanting 
> to save the file using the deletion strategy,...
Yes. I had meant it is not representative of what Android Studio (or _some_ 
editors) does. 

> think it's not our goal here to ensure the editor cannot save the file if the 
> setting is true.

I agree that having a test that sets `use_source_cache=true` and expects 
failure behavior is not a goal. But, it is how we _observe_ that the test input 
`cpp` source file we use satisfies the condition to use mmap. If the condition 
to use mmap changes (e.g., from filesize=16K to filesize=32K), then the test 
input source file will no longer trigger mmap, yet the `use_source_cache=false` 
test will keep passing. So, I think having that negative test case, despite 
being weird, still serves some purpose.




 

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Break and Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

https://github.com/omjavaid updated 
https://github.com/llvm/llvm-project/pull/108072

>From ac61e5a75ce59f7834034494a03b43e81bf02d41 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid 
Date: Tue, 10 Sep 2024 18:03:29 +0500
Subject: [PATCH 1/3] WoA hardware breakpoint/watchpoint support

---
 .../Windows/Common/NativeProcessWindows.cpp   | 52 ---
 .../Common/NativeRegisterContextWindows.cpp   |  3 -
 .../Common/NativeRegisterContextWindows.h |  6 +-
 .../NativeRegisterContextWindows_WoW64.cpp|  4 +-
 .../NativeRegisterContextWindows_arm.cpp  |  4 +-
 .../NativeRegisterContextWindows_arm64.cpp| 86 ++-
 .../NativeRegisterContextWindows_arm64.h  | 32 ++-
 .../NativeRegisterContextWindows_i386.cpp |  4 +-
 .../NativeRegisterContextWindows_x86_64.cpp   |  4 +-
 .../Windows/Common/NativeThreadWindows.cpp| 32 +++
 10 files changed, 135 insertions(+), 92 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 24c9aa6b32659d..87a811123d5de8 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -491,24 +491,47 @@ NativeProcessWindows::OnDebugException(bool first_chance,
 return ExceptionResult::MaskException;
   }
   case DWORD(STATUS_BREAKPOINT):
-  case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
-
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
+  case STATUS_WX86_BREAKPOINT: {
+bool breakpoint_hit = false;
+NativeThreadWindows *stop_thread = GetThreadByID(record.GetThreadID());
+
+if (stop_thread) {
+  uint32_t hw_id = LLDB_INVALID_INDEX32;
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  reg_ctx.GetHardwareBreakHitIndex(hw_id, record.GetExceptionAddress());
+  if (hw_id != LLDB_INVALID_INDEX32) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit hardware breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
+  } else if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
 uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
 // The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+uint64_t pc = reg_ctx.GetPC() - breakpoint_size;
+reg_ctx.SetPC(pc);
   }
 
-  SetState(eStateStopped, true);
-  return ExceptionResult::MaskException;
+  if (breakpoint_hit) {
+StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  } else {
+const std::vector &args = record.GetExceptionArguments();
+if (args.size() >= 2) {
+  reg_ctx.GetWatchpointHitIndex(hw_id, args[1]);
+  if (hw_id != LLDB_INVALID_INDEX32) {
+addr_t wp_pc = record.GetExceptionAddress();
+std::string desc =
+formatv("{0} {1} {2}", args[1], hw_id, wp_pc).str();
+StopThread(record.GetThreadID(), StopReason::eStopReasonWatchpoint,
+   desc);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  }
+}
+  }
 }
 
 if (!initial_stop) {
@@ -531,6 +554,7 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   // Hit the initial stop. Continue the application.
   return ExceptionResult::BreakInDebugger;
 }
+  }
 
 [[fallthrough]];
   default:
diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
index 9128363eaa577a..95be1183abb759 100644
--- 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
+++ 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
@@ -18,9 +18,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-NativeRegisterContextWindows::NativeRegisterContextWindows(
-NativeThreadProtocol &thread, RegisterInfoInterface *reg_info_interface_p)
-: NativeRegisterContextRegisterInfo(thread, reg_info_interface_p) {}
 
 lldb::thread_t NativeRegisterContextWindows::GetThreadHandle() const {
   auto wthread = static_cast(&m_thread);
diff --git 
a/lldb/source/Plugins

[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Break and Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

https://github.com/omjavaid updated 
https://github.com/llvm/llvm-project/pull/108072

>From ac61e5a75ce59f7834034494a03b43e81bf02d41 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid 
Date: Tue, 10 Sep 2024 18:03:29 +0500
Subject: [PATCH 1/2] WoA hardware breakpoint/watchpoint support

---
 .../Windows/Common/NativeProcessWindows.cpp   | 52 ---
 .../Common/NativeRegisterContextWindows.cpp   |  3 -
 .../Common/NativeRegisterContextWindows.h |  6 +-
 .../NativeRegisterContextWindows_WoW64.cpp|  4 +-
 .../NativeRegisterContextWindows_arm.cpp  |  4 +-
 .../NativeRegisterContextWindows_arm64.cpp| 86 ++-
 .../NativeRegisterContextWindows_arm64.h  | 32 ++-
 .../NativeRegisterContextWindows_i386.cpp |  4 +-
 .../NativeRegisterContextWindows_x86_64.cpp   |  4 +-
 .../Windows/Common/NativeThreadWindows.cpp| 32 +++
 10 files changed, 135 insertions(+), 92 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 24c9aa6b32659d..87a811123d5de8 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -491,24 +491,47 @@ NativeProcessWindows::OnDebugException(bool first_chance,
 return ExceptionResult::MaskException;
   }
   case DWORD(STATUS_BREAKPOINT):
-  case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
-
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
+  case STATUS_WX86_BREAKPOINT: {
+bool breakpoint_hit = false;
+NativeThreadWindows *stop_thread = GetThreadByID(record.GetThreadID());
+
+if (stop_thread) {
+  uint32_t hw_id = LLDB_INVALID_INDEX32;
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  reg_ctx.GetHardwareBreakHitIndex(hw_id, record.GetExceptionAddress());
+  if (hw_id != LLDB_INVALID_INDEX32) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit hardware breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
+  } else if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
+breakpoint_hit = true;
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
 uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
 // The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+uint64_t pc = reg_ctx.GetPC() - breakpoint_size;
+reg_ctx.SetPC(pc);
   }
 
-  SetState(eStateStopped, true);
-  return ExceptionResult::MaskException;
+  if (breakpoint_hit) {
+StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  } else {
+const std::vector &args = record.GetExceptionArguments();
+if (args.size() >= 2) {
+  reg_ctx.GetWatchpointHitIndex(hw_id, args[1]);
+  if (hw_id != LLDB_INVALID_INDEX32) {
+addr_t wp_pc = record.GetExceptionAddress();
+std::string desc =
+formatv("{0} {1} {2}", args[1], hw_id, wp_pc).str();
+StopThread(record.GetThreadID(), StopReason::eStopReasonWatchpoint,
+   desc);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  }
+}
+  }
 }
 
 if (!initial_stop) {
@@ -531,6 +554,7 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   // Hit the initial stop. Continue the application.
   return ExceptionResult::BreakInDebugger;
 }
+  }
 
 [[fallthrough]];
   default:
diff --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
index 9128363eaa577a..95be1183abb759 100644
--- 
a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
+++ 
b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.cpp
@@ -18,9 +18,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-NativeRegisterContextWindows::NativeRegisterContextWindows(
-NativeThreadProtocol &thread, RegisterInfoInterface *reg_info_interface_p)
-: NativeRegisterContextRegisterInfo(thread, reg_info_interface_p) {}
 
 lldb::thread_t NativeRegisterContextWindows::GetThreadHandle() const {
   auto wthread = static_cast(&m_thread);
diff --git 
a/lldb/source/Plugins

[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-09 Thread Omair Javaid via lldb-commits

omjavaid wrote:

@DavidSpickett @labath I have updated this PR and dropped hardware breakpoint 
support for the unresolved "set hw break on main" issue As x86_64 windows also 
does not support hardware breakpoints (probably for the same reason). 

This PR now only implements HW watchpoint support. 



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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/111531

From c7356d3c265869ff387c977dd18e9c617dc31c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 8 Oct 2024 15:40:37 +0200
Subject: [PATCH 1/2] [lldb] Add early CMake check for 'make' tool

Around 400 of LLDB's dotest.py based tests require the make tool to be found in 
Path. If it's not found, they fail with an obscure error and show up as 
UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but 
make is not part of that. Let's catch the situation early and raise an error if 
LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the 
configuration process. There might be other issues further down the line that 
can be caught in the same buildbot run.
---
 lldb/test/CMakeLists.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+message(STATUS "Not found: make")
+message(SEND_ERROR
+  "LLDB tests require 'make' tool. Please install and add it to Path "
+  "(or otherwise disable strict testing requirements with "
+  "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

From 5e7bc2d26b54440936b3d756e12d708ae5218c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Wed, 9 Oct 2024 13:07:27 +0200
Subject: [PATCH 2/2] Pass make as an explicit argument to dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py |  2 ++
 lldb/test/API/CMakeLists.txt  |  1 +
 lldb/test/API/lit.cfg.py  |  3 +++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/test/CMakeLists.txt  | 20 +++
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index b1ae896d3fd3b4..40294aec166381 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'
 
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 27f285230cafaf..c426d76f7d9e76 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -58,6 +58,7 @@ endif()
 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb 
executable used for testing")
 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler 
to use for building LLDB test inferiors")
 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil 
used for generating dSYM bundles")
+set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for 
building test executables")
 
 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
   message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 96520c7c826246..c6fa20a63424d4 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+
 if is_configured("llvm_tools_dir"):
 dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2a..9f647034dc9f97 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,6 +31,7 @@ config.lldb_executable = 
lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
+config.make = lit_config.substitute('@LLDB_TEST_MAKE@')
 config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 7993be2602e538..5b00e10af136f1 100644
-

[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

Thanks for the quick feedback. Yes, makes sense. Here we go.

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-09 Thread via lldb-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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 
40b8a0fd174397e87925da3f1837d74d5d663a50...5e7bc2d26b54440936b3d756e12d708ae5218c4d
 lldb/packages/Python/lldbsuite/test/dotest.py lldb/test/API/lit.cfg.py
``





View the diff from darker here.


``diff
--- packages/Python/lldbsuite/test/dotest.py2024-10-09 11:11:30.00 +
+++ packages/Python/lldbsuite/test/dotest.py2024-10-09 11:19:35.128595 +
@@ -270,11 +270,11 @@
 configuration.make_path = args.make
 elif platform_system == "FreeBSD" or platform_system == "NetBSD":
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
-if ' ' in configuration.make_path:
+if " " in configuration.make_path:
 configuration.make_path = f'"{configuration.make_path}"'
 
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
 elif platform_system == "Darwin":

``




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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

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

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

To align with the new policy: 
https://llvm.org/docs/DeveloperPolicy.html#maintainers

I've assumed that Jonas will be the "Lead Maintainer" as he was the default 
Code Owner.

I know the past Code Owners weren't "Maintainers" but it's the same energy so 
I've changed it there too.

>From 06272fadab85058f859a0514965c140178812ab3 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 9 Oct 2024 15:18:37 +0100
Subject: [PATCH] [lldb] Replace Code Owners with Maintainers

To align with the new policy: 
https://llvm.org/docs/DeveloperPolicy.html#maintainers

I've assumed that Jonas will be the "Lead Maintainer" as he was
the default Code Owner.

I know the past Code Owners weren't "Maintainers" but it's
the same energy so I've changed it there too.
---
 lldb/{CodeOwners.rst => Maintainers.rst} | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)
 rename lldb/{CodeOwners.rst => Maintainers.rst} (91%)

diff --git a/lldb/CodeOwners.rst b/lldb/Maintainers.rst
similarity index 91%
rename from lldb/CodeOwners.rst
rename to lldb/Maintainers.rst
index 3c10c2a28da9e7..e83591d5f162b4 100644
--- a/lldb/CodeOwners.rst
+++ b/lldb/Maintainers.rst
@@ -1,27 +1,31 @@
 
-LLDB Code Owners
+LLDB Maintainers
 
 
-This file is a list of the `code owners 
`_ for LLDB.
+This file is a list of the `maintainers 
`_ for LLDB.
 
 .. contents::
:depth: 2
:local:
 
-Current Code Owners
+Current Maintainers
 ===
-The following people are the active code owners for the project. Please reach
+The following people are the active maintainers for the project. Please reach
 out to them for code reviews, questions about their area of expertise, or other
 assistance.
 
-All parts of LLDB not covered by someone else
---
+Lead Maintainer
+---
+
+Responsible for project as a whole, and for any areas not covered by a specific
+maintainer.
+
 | Jonas Devlieghere
 | jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Components
 --
-These code owners are responsible for particular high-level components within
+These maintainers are responsible for particular high-level components within
 LLDB.
 
 ABI
@@ -242,10 +246,10 @@ lldb-dap
 | Walter Erquinigo
 | a20012251\@gmail.com (email), walter-erquinigo (GitHub), wallace 
(Discourse), werquinigo (Discord)
 
-Former Code Owners
+Former Maintainers
 ==
-The following people have graciously spent time performing code ownership
-responsibilities but are no longer active in that role. Thank you for all your
+The following people have graciously spent time performing maintainership
+duties but are no longer active in that role. Thank you for all your
 help with the success of the project!
 
 | Kamil Rytarowski (kamil\@netbsd.org)

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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

2024-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

To align with the new policy: 
https://llvm.org/docs/DeveloperPolicy.html#maintainers

I've assumed that Jonas will be the "Lead Maintainer" as he was the default 
Code Owner.

I know the past Code Owners weren't "Maintainers" but it's the same energy so 
I've changed it there too.

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


1 Files Affected:

- (renamed) lldb/Maintainers.rst (+14-10) 


``diff
diff --git a/lldb/CodeOwners.rst b/lldb/Maintainers.rst
similarity index 91%
rename from lldb/CodeOwners.rst
rename to lldb/Maintainers.rst
index 3c10c2a28da9e7..e83591d5f162b4 100644
--- a/lldb/CodeOwners.rst
+++ b/lldb/Maintainers.rst
@@ -1,27 +1,31 @@
 
-LLDB Code Owners
+LLDB Maintainers
 
 
-This file is a list of the `code owners 
`_ for LLDB.
+This file is a list of the `maintainers 
`_ for LLDB.
 
 .. contents::
:depth: 2
:local:
 
-Current Code Owners
+Current Maintainers
 ===
-The following people are the active code owners for the project. Please reach
+The following people are the active maintainers for the project. Please reach
 out to them for code reviews, questions about their area of expertise, or other
 assistance.
 
-All parts of LLDB not covered by someone else
---
+Lead Maintainer
+---
+
+Responsible for project as a whole, and for any areas not covered by a specific
+maintainer.
+
 | Jonas Devlieghere
 | jonas\@devlieghere.com (email), jdevlieghere (GitHub), jdevlieghere 
(Discourse), jdevlieghere (Discord)
 
 Components
 --
-These code owners are responsible for particular high-level components within
+These maintainers are responsible for particular high-level components within
 LLDB.
 
 ABI
@@ -242,10 +246,10 @@ lldb-dap
 | Walter Erquinigo
 | a20012251\@gmail.com (email), walter-erquinigo (GitHub), wallace 
(Discourse), werquinigo (Discord)
 
-Former Code Owners
+Former Maintainers
 ==
-The following people have graciously spent time performing code ownership
-responsibilities but are no longer active in that role. Thank you for all your
+The following people have graciously spent time performing maintainership
+duties but are no longer active in that role. Thank you for all your
 help with the success of the project!
 
 | Kamil Rytarowski (kamil\@netbsd.org)

``




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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

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

DavidSpickett wrote:

Folks may want to read the new wording for themselves, but at least by my 
interpretation there's not much change from what I myself have been doing and 
what I've seen the folks listed in this file doing. So I don't think you're 
opting into a whole lot more work.

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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

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

DavidSpickett wrote:

Added a bunch of you on review not because this is some complex change, but 
just as a heads up in case you did want to reconsider being listed here or 
suggest alternatives.

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


[Lldb-commits] [lldb] [lldb] Replace Code Owners with Maintainers (PR #111686)

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

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


[Lldb-commits] [lldb] Improve namespace lookup review (PR #110062)

2024-10-09 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/110062

>From c5bbc5f17dd5039fb9d5a01ade2397afd5d4c967 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Tue, 24 Sep 2024 14:43:44 -0700
Subject: [PATCH] Improve namespace lookup

---
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   | 16 +++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h | 11 +
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 42 +++
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  4 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  2 +-
 5 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index dee90804c52584..c18edd10b96819 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -151,3 +151,19 @@ bool DWARFIndex::ProcessTypeDIEMatchQuery(
 return true;
   return callback(die);
 }
+
+void DWARFIndex::GetNamespacesWithParents(
+ConstString name, const CompilerDeclContext &parent_decl_ctx,
+llvm::function_ref callback) {
+  GetNamespaces(name, [&](DWARFDIE die) {
+return ProcessNamespaceDieMatchParents(parent_decl_ctx, die, callback);
+  });
+}
+
+bool DWARFIndex::ProcessNamespaceDieMatchParents(
+const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
+llvm::function_ref callback) {
+  if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
+return true;
+  return callback(die);
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index fea3a4fd697389..ac1f75e91c2195 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -71,6 +71,14 @@ class DWARFIndex {
   virtual void
   GetTypesWithQuery(TypeQuery &query,
 llvm::function_ref callback);
+  /// Get namespace DIEs whose base name match \param name with \param
+  /// parent_decl_ctx in its decl parent chain.  A base implementation
+  /// is provided. Specializations should override this if they are able to
+  /// provide a faster implementation.
+  virtual void
+  GetNamespacesWithParents(ConstString name,
+   const CompilerDeclContext &parent_decl_ctx,
+   llvm::function_ref callback);
   virtual void
   GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -127,6 +135,9 @@ class DWARFIndex {
   bool
   ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
llvm::function_ref callback);
+  bool ProcessNamespaceDieMatchParents(
+  const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
+  llvm::function_ref callback);
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index c809e5ff7f8535..aeeb6b91c80fa3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -565,6 +565,48 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   m_fallback.GetTypesWithQuery(query, callback);
 }
 
+void DebugNamesDWARFIndex::GetNamespacesWithParents(
+ConstString name, const CompilerDeclContext &parent_decl_ctx,
+llvm::function_ref callback) {
+  std::vector parent_contexts =
+  parent_decl_ctx.GetCompilerContext();
+  if (parent_contexts.empty())
+return GetNamespaces(name, callback);
+
+  llvm::SmallVector parent_named_contexts;
+  std::copy_if(parent_contexts.rbegin(), parent_contexts.rend(),
+   std::back_inserter(parent_named_contexts),
+   [](const CompilerContext &ctx) { return !ctx.name.IsEmpty(); });
+  for (const DebugNames::Entry &entry :
+   m_debug_names_up->equal_range(name.GetStringRef())) {
+lldb_private::dwarf::Tag entry_tag = entry.tag();
+if (entry_tag == DW_TAG_namespace ||
+entry_tag == DW_TAG_imported_declaration) {
+  std::optional> parent_chain =
+  getParentChain(entry);
+  if (!parent_chain) {
+// Fallback: use the base class implementation.
+if (!ProcessEntry(entry, [&](DWARFDIE die) {
+  return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
+ callback);
+}))
+  return;
+continue;
+  }
+
+  if (WithinParentChain(parent_named_contexts, *parent_chain) &&
+  !ProcessEntry(entry, [&](DWARFDIE die) {
+// After .debug_names filtering still sending to base class for
+// further filtering before calling the callback.
+return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
+

[Lldb-commits] [lldb] [lldb][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

https://github.com/ldm0 updated https://github.com/llvm/llvm-project/pull/111684

>From 8573fde9b7ffa035b2ee9da132c910515a6d1d26 Mon Sep 17 00:00:00 2001
From: Liu Dingming 
Date: Wed, 9 Oct 2024 21:57:24 +0800
Subject: [PATCH] [lldb] Simplify macOS thread name fetching (NFC)

Remove unnecessary `proc_pidinfo` calling.
---
 .../debugserver/source/MacOSX/MachThread.cpp  | 48 ++-
 .../debugserver/source/MacOSX/MachThread.h|  8 ++--
 2 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
index d34914be802041..de2bebfcec7090 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -31,9 +31,8 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
   m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
   m_suspend_count(0), m_stop_exception(),
   m_arch_up(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
-  m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
-  m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
-  m_pthread_qos_class_decode(nullptr) {
+  m_num_reg_sets(0), m_extended_info(), m_dispatch_queue_name(),
+  m_is_64_bit(is_64_bit), m_pthread_qos_class_decode(nullptr) {
   nub_size_t num_reg_sets = 0;
   m_reg_sets = m_arch_up->GetRegisterSetInfo(&num_reg_sets);
   m_num_reg_sets = num_reg_sets;
@@ -255,7 +254,7 @@ struct thread_basic_info *MachThread::GetBasicInfo() {
 bool MachThread::GetBasicInfo(thread_t thread,
   struct thread_basic_info *basicInfoPtr) {
   if (MachPortNumberIsValid(thread)) {
-unsigned int info_count = THREAD_BASIC_INFO_COUNT;
+mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
   (thread_info_t)basicInfoPtr, 
&info_count);
 if (err == KERN_SUCCESS)
@@ -265,6 +264,26 @@ bool MachThread::GetBasicInfo(thread_t thread,
   return false;
 }
 
+struct thread_extended_info *MachThread::GetExtendedInfo() {
+  if (MachThread::GetExtendedInfo(m_mach_port_number, &m_extended_info))
+return &m_extended_info;
+  return NULL;
+}
+
+bool MachThread::GetExtendedInfo(thread_t thread,
+ struct thread_extended_info *extendedInfoPtr) 
{
+  if (MachPortNumberIsValid(thread)) {
+mach_msg_type_number_t info_count = THREAD_EXTENDED_INFO_COUNT;
+kern_return_t err =
+::thread_info(thread, THREAD_EXTENDED_INFO,
+  (thread_info_t)extendedInfoPtr, &info_count);
+if (err == KERN_SUCCESS)
+  return true;
+  }
+  ::memset(extendedInfoPtr, 0, sizeof(struct thread_extended_info));
+  return false;
+}
+
 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
 
 bool MachThread::MachPortNumberIsValid(thread_t thread) {
@@ -579,28 +598,13 @@ uint32_t MachThread::NumSupportedHardwareWatchpoints() 
const {
   return m_arch_up->NumSupportedHardwareWatchpoints();
 }
 
-bool MachThread::GetIdentifierInfo() {
+const char *MachThread::GetName() {
   // Don't try to get the thread info once and cache it for the life of the
   // thread.  It changes over time, for instance
   // if the thread name changes, then the thread_handle also changes...  So you
   // have to refetch it every time.
-  mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
-  kern_return_t kret = ::thread_info(m_mach_port_number, 
THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
-  return kret == KERN_SUCCESS;
-
-  return false;
-}
-
-const char *MachThread::GetName() {
-  if (GetIdentifierInfo()) {
-int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
-if (len && m_proc_threadinfo.pth_name[0])
-  return m_proc_threadinfo.pth_name;
-  }
+  if (GetExtendedInfo() && m_extended_info.pth_name[0])
+return m_extended_info.pth_name;
   return NULL;
 }
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h 
b/lldb/tools/debugserver/source/MacOSX/MachThread.h
index 5466c6f9f95095..0c78ef1a337ed3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThread.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h
@@ -108,6 +108,7 @@ class MachThread {
 
   bool IsUserReady();
   struct thread_basic_info *GetBasicInfo();
+  struct thread_extended_info *GetExtendedInfo();
   const char *GetBasicInfoAsString() const;
   const char *GetName();
 
@@ -126,8 +127,8 @@ class MachThread {
 protected:
   static bool GetBasicInfo(thread_t threadID,
struct thread_basic_info *basic_info);
-
-  bool GetIdentifierInfo();
+  static bool GetExtendedInfo(thread_t threadID,
+  struct t

[Lldb-commits] [lldb] 61a4678 - Improve type lookup using .debug_names parent chain (#108907)

2024-10-09 Thread via lldb-commits

Author: jeffreytan81
Date: 2024-10-09T16:29:39-07:00
New Revision: 61a46780d10c8f4e12c9b5496f5ca3f2cc7fba66

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

LOG: Improve type lookup using .debug_names parent chain (#108907)

## Summary
This PR improves `SymbolFileDWARF::FindTypes()` by utilizing the newly
added parent chain `DW_IDX_parent` in `.debug_names`. The proposal was
originally discussed in [this
RFC](https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151).

## Implementation
To leverage the parent chain for `SymbolFileDWARF::FindTypes()`, this PR
adds a new API: `GetTypesWithQuery` in `DWARFIndex` base class. The API
performs the same function as `GetTypes` with additional filtering using
`TypeQuery`. Since this only introduces filtering, the callback
mechanisms at all call sites remain unchanged. A default implementation
is given in `DWARFIndex` class which parses debug info and performs the
matching. In the `DebugNameDWARFIndex` override, the parent_contexts in
the `TypeQuery` is cross checked with parent chain in `.debug_names` for
for much faster filtering before fallback to base implementation for
final filtering.

Unlike the `GetFullyQualifiedType` API, which fully consumes the
`DW_IDX_parent` parent chain for exact matching, these new APIs perform
partial subset matching for type/namespace queries. This is necessary to
support queries involving anonymous or inline namespaces. For instance,
a user might request `NS1::NS2::NS3::Foo`, while the index table's
parent chain might contain `NS1::inline_NS2::NS3::Foo`, which would fail
exact matching.

## Performance Results
In one of our internal target using `.debug_names` + split dwarf.
Expanding a "this" pointer in locals view in VSCode:
94s => 48s. (Not sure why I got 94s this time instead of 70s last week).

-

Co-authored-by: jeffreytan81 

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..dee90804c52584 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -126,3 +126,28 @@ bool DWARFIndex::GetFullyQualifiedTypeImpl(
 return callback(die);
   return true;
 }
+
+void DWARFIndex::GetTypesWithQuery(
+TypeQuery &query, llvm::function_ref callback) {
+  GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+return ProcessTypeDIEMatchQuery(query, die, callback);
+  });
+}
+
+bool DWARFIndex::ProcessTypeDIEMatchQuery(
+TypeQuery &query, DWARFDIE die,
+llvm::function_ref callback) {
+  // Nothing to match from query
+  if (query.GetContextRef().size() <= 1)
+return callback(die);
+
+  std::vector die_context;
+  if (query.GetModuleSearch())
+die_context = die.GetDeclContext();
+  else
+die_context = die.GetTypeLookupContext();
+
+  if (!query.ContextMatches(die_context))
+return true;
+  return callback(die);
+}

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index cb3ae8a06d7885..fea3a4fd697389 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -64,6 +64,13 @@ class DWARFIndex {
   virtual void
   GetNamespaces(ConstString name,
 llvm::function_ref callback) = 0;
+  /// Get type DIEs meeting requires of \a query.
+  /// in its decl parent chain as subset.  A base implementation is provided,
+  /// Specializations should override this if they are able to provide a faster
+  /// implementation.
+  virtual void
+  GetTypesWithQuery(TypeQuery &query,
+llvm::function_ref callback);
   virtual void
   GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -115,6 +122,11 @@ class DWARFIndex {
   bool
   GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
 llvm::function_ref callback);
+
+  /// Check if the type \a die can meet the requirements of \a query.
+  bool
+  ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
+   llvm::function_ref callback);
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DW

[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)

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

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


[Lldb-commits] [lldb] [lldb][debugserver][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Donough Liu via lldb-commits

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


[Lldb-commits] [lldb] Improve namespace lookup review (PR #110062)

2024-10-09 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/110062

>From 37bcf4470a6771a196c528e16d3fa1b50b60f63a Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Mon, 23 Sep 2024 16:40:16 -0700
Subject: [PATCH 1/3] Improve type query using .debug_names parent chain

---
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  25 
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  12 ++
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 123 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  34 +
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |   5 +-
 5 files changed, 196 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..dee90804c52584 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -126,3 +126,28 @@ bool DWARFIndex::GetFullyQualifiedTypeImpl(
 return callback(die);
   return true;
 }
+
+void DWARFIndex::GetTypesWithQuery(
+TypeQuery &query, llvm::function_ref callback) {
+  GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+return ProcessTypeDIEMatchQuery(query, die, callback);
+  });
+}
+
+bool DWARFIndex::ProcessTypeDIEMatchQuery(
+TypeQuery &query, DWARFDIE die,
+llvm::function_ref callback) {
+  // Nothing to match from query
+  if (query.GetContextRef().size() <= 1)
+return callback(die);
+
+  std::vector die_context;
+  if (query.GetModuleSearch())
+die_context = die.GetDeclContext();
+  else
+die_context = die.GetTypeLookupContext();
+
+  if (!query.ContextMatches(die_context))
+return true;
+  return callback(die);
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index cb3ae8a06d7885..fea3a4fd697389 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -64,6 +64,13 @@ class DWARFIndex {
   virtual void
   GetNamespaces(ConstString name,
 llvm::function_ref callback) = 0;
+  /// Get type DIEs meeting requires of \a query.
+  /// in its decl parent chain as subset.  A base implementation is provided,
+  /// Specializations should override this if they are able to provide a faster
+  /// implementation.
+  virtual void
+  GetTypesWithQuery(TypeQuery &query,
+llvm::function_ref callback);
   virtual void
   GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -115,6 +122,11 @@ class DWARFIndex {
   bool
   GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
 llvm::function_ref callback);
+
+  /// Check if the type \a die can meet the requirements of \a query.
+  bool
+  ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
+   llvm::function_ref callback);
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 373b3d9ed2eaa9..694c4a5a16ece6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -301,7 +301,8 @@ using Entry = llvm::DWARFDebugNames::Entry;
 /// If any parent does not have an `IDX_parent`, or the Entry data is 
corrupted,
 /// nullopt is returned.
 std::optional>
-getParentChain(Entry entry, uint32_t max_parents) {
+getParentChain(Entry entry,
+   uint32_t max_parents = std::numeric_limits::max()) {
   llvm::SmallVector parent_entries;
 
   do {
@@ -374,6 +375,21 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
   m_fallback.GetFullyQualifiedType(context, callback);
 }
 
+bool DebugNamesDWARFIndex::SameAsEntryContext(
+const CompilerContext &query_context,
+const DebugNames::Entry &entry) const {
+  // TODO: check dwarf tag matches.
+  // Peek at the AT_name of `entry` and test equality to `name`.
+  auto maybe_dieoffset = entry.getDIEUnitOffset();
+  if (!maybe_dieoffset)
+return false;
+  DWARFUnit *unit = GetNonSkeletonUnit(entry);
+  if (!unit)
+return false;
+  return query_context.name ==
+ unit->PeekDIEName(unit->GetOffset() + *maybe_dieoffset);
+}
+
 bool DebugNamesDWARFIndex::SameParentChain(
 llvm::ArrayRef parent_names,
 llvm::ArrayRef parent_entries) const {
@@ -402,6 +418,45 @@ bool DebugNamesDWARFIndex::SameParentChain(
   return true;
 }
 
+bool DebugNamesDWARFIndex::SameParentChain(
+llvm::ArrayRef parent_contexts,
+llvm::ArrayRef parent_entries) const {
+  if (parent_entries.size() != parent_contexts.size())
+return false;
+
+  // If the AT_name of any parent fails to match the expected name, we don't
+  // have a match.
+  for (auto [parent_context, parent_entry]

[Lldb-commits] [lldb] Improve namespace lookup using .debug_names parent chain (PR #110062)

2024-10-09 Thread via lldb-commits

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/110901

>From 0a78922cc8e21c62ed7b09a88a14ff6119697cd9 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 9 Oct 2024 09:45:53 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) and the command option
parser (in one place thus far) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 38 ++
 .../lldb/Interpreter/CommandReturnObject.h| 21 --
 lldb/include/lldb/Utility/Args.h  |  6 +-
 .../lldb/Utility/DiagnosticsRendering.h   | 75 +++
 lldb/include/lldb/Utility/Status.h| 12 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  9 +++
 .../Commands/CommandObjectExpression.cpp  |  5 +-
 lldb/source/Expression/DiagnosticManager.cpp  |  4 +-
 lldb/source/Expression/FunctionCaller.cpp |  4 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  4 +-
 .../source/Interpreter/CommandInterpreter.cpp | 24 +-
 lldb/source/Interpreter/CommandObject.cpp | 11 +--
 .../Interpreter/CommandReturnObject.cpp   | 34 -
 lldb/source/Interpreter/Options.cpp   | 43 +--
 lldb/source/Utility/Args.cpp  | 41 ++
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 28 +++
 lldb/source/Utility/Status.cpp| 31 
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/test/Shell/Commands/command-options.test | 11 +++
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +-
 23 files changed, 284 insertions(+), 142 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (86%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 create mode 100644 lldb/test/Shell/Commands/command-options.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..cc802b6f48334a 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -23,49 +24,22 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
-: public llvm::ErrorInfo {
+: public llvm::ErrorInfo {
   std::string m_message;
   std::vector m_details;
 
 public:
   static char ID;
-  using llvm::ErrorInfo::ErrorInfo;
+  using llvm::ErrorInfo::ErrorInfo;
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..e13c3b7b8e0437 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -10,6 +10,7 @@
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/DiagnosticsRendering.

[Lldb-commits] [lldb] 68a5f5d - [lldb] Fix TestGlobalModuleCache.py for remote debugging (#111483)

2024-10-09 Thread via lldb-commits

Author: Igor Kudrin
Date: 2024-10-09T18:11:05-07:00
New Revision: 68a5f5db7c970d22dc40637d7951b627fa50d5c1

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

LOG: [lldb] Fix TestGlobalModuleCache.py for remote debugging (#111483)

`SBDebugger().Create()` returns a debugger with only the host platform
in its platform list. If the test suite is running for a remote
platform, it should be explicitly added and selected in the new debugger
created within the test, otherwise, the test will fail because the host
platform may not be able to launch the built binary.

Added: 


Modified: 
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py 
b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
index ccefc28946e062..5dd268be4cb05f 100644
--- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -111,6 +111,7 @@ def do_test(self, one_target, one_debugger):
 else:
 if one_target:
 new_debugger = lldb.SBDebugger().Create()
+new_debugger.SetSelectedPlatform(lldb.selected_platform)
 new_debugger.SetAsync(False)
 self.old_debugger = self.dbg
 self.dbg = new_debugger



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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/110901

>From 49b51bad4dd2ca41e61da38b1e35ffcb1eb9e7d6 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 9 Oct 2024 09:45:53 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) and the command option
parser (in one place thus far) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 38 ++
 .../lldb/Interpreter/CommandReturnObject.h| 21 --
 lldb/include/lldb/Utility/Args.h  |  6 +-
 .../lldb/Utility/DiagnosticsRendering.h   | 75 +++
 lldb/include/lldb/Utility/Status.h| 12 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  9 +++
 .../Commands/CommandObjectExpression.cpp  |  5 +-
 lldb/source/Expression/DiagnosticManager.cpp  |  4 +-
 lldb/source/Expression/FunctionCaller.cpp |  4 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  4 +-
 .../source/Interpreter/CommandInterpreter.cpp | 24 +-
 lldb/source/Interpreter/CommandObject.cpp | 11 +--
 .../Interpreter/CommandReturnObject.cpp   | 36 -
 lldb/source/Interpreter/Options.cpp   | 44 +--
 lldb/source/Utility/Args.cpp  | 41 ++
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 58 +-
 lldb/source/Utility/Status.cpp| 31 
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/test/Shell/Commands/command-options.test | 11 +++
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +-
 23 files changed, 311 insertions(+), 148 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (72%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 create mode 100644 lldb/test/Shell/Commands/command-options.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..cc802b6f48334a 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -23,49 +24,22 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
-: public llvm::ErrorInfo {
+: public llvm::ErrorInfo {
   std::string m_message;
   std::vector m_details;
 
 public:
   static char ID;
-  using llvm::ErrorInfo::ErrorInfo;
+  using llvm::ErrorInfo::ErrorInfo;
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..e13c3b7b8e0437 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -10,6 +10,7 @@
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/DiagnosticsRen

[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -38,19 +38,23 @@ class Args {
 
 std::unique_ptr ptr;
 char quote = '\0';
+/// The position of the argument in the original argument string.
+std::optional column;
 
 char *data() { return ptr.get(); }
 
   public:
 ArgEntry() = default;
-ArgEntry(llvm::StringRef str, char quote);
+ArgEntry(llvm::StringRef str, char quote, std::optional column);
 
 llvm::StringRef ref() const { return c_str(); }
 const char *c_str() const { return ptr.get(); }
 
 /// Returns true if this argument was quoted in any way.
 bool IsQuoted() const { return quote != '\0'; }
 char GetQuoteChar() const { return quote; }
+std::optional GetPos() const { return column; }
+uint16_t GetLength() const { return ref().size(); }

JDevlieghere wrote:

Why not `size_t`? This seems arbitrary. 

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -160,6 +166,9 @@ class CommandReturnObject {
 
   StreamTee m_out_stream;
   StreamTee m_err_stream;
+  std::vector m_diagnostics;
+  StreamString m_diag_stream;
+  std::optional m_diagnostic_indent;

JDevlieghere wrote:

Maybe this will make sense later, but why is this a property of 
CommandReturnObject and not DiagnosticDetail?

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -19,12 +19,45 @@
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+namespace lldb_private {
+
+/// An llvm::Error that represents an optino parsing diagnostic.

JDevlieghere wrote:

```suggestion
/// An llvm::Error that represents an option parsing diagnostic.
```

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


[Lldb-commits] [lldb] [lldb][debugserver][NFC] Simplify macOS thread name fetching. (PR #111684)

2024-10-09 Thread Jason Molenda via lldb-commits

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

Looks good to me, thanks for putting this PR together.  I can merge the PR for 
you, if you don't have permissions to do that on llvm-project currently.

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


[Lldb-commits] [lldb] DynamicLoaderDarwin load images in parallel (PR #110439)

2024-10-09 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> > Was the setting intended for testing purposes only, or did you intend to 
> > include that in a final PR?
> 
> The latter. IMO the risks involved by parallelization are a bit too high to 
> do it without a flag. I'm even thinking about having it opt-in rather than 
> opt-out for some time.

I'm fine with having a temporary setting to disable it, which we can remove 
after it has been in a release or two and we've had time for people to live on 
it in many different environments.  But it should definitely be enabled by 
default when we're at the point to merge it, and the setting should only be a 
safety mechanism if this turns out to cause a problem for a configuration we 
weren't able to test.

We're not at that point yet, but just outlining my thinking on this.  I would 
even put it explicitly under an experimental node (e.g. see 
`target.experimental.inject-local-vars` we have currently) so if someone does 
disable it in their ~/.lldbinit file, and we remove the setting in a year or 
two, they won't get errors starting lldb, it will be silently ignored.

I was playing with the performance in a couple of different scenarios.  For 
some reason that I haven't looked into, we're getting less parallelism when 
many of the binaries are in the shared cache in lldb.  Maybe there is locking 
around the code which finds the binary in lldb's own shared cache, so when 9 
threads try to do it at the same time, we have additional lock contention.  
That's why the simulator speedup is better than a macos-native process speedup, 
and the speedup for a remote iOS debug process with an expanded shared cache on 
the mac (so all the libraries are in separate mach-o files) was faster still.

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


[Lldb-commits] [lldb] DynamicLoaderDarwin load images in parallel (PR #110439)

2024-10-09 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

For what it's worth, this thread pool for parallel processing has been used in 
another part of lldb - it's used on ELF systems when processing DWARF, when we 
need to scan the debug info in the individual .o files iirc.  So we've had some 
living-on time with the thread pool approach there, not used on Darwin, but 
used on other targets.

I was chatting with Jim Ingham and he was a little bummed that we're looking at 
doing this in a single DynamicLoader plugin, instead of having the 
DynamicLoader plugin create a list of ModuleSpec's and having a central method 
in ModuleList or something, create Modules for each of them via a thread pool, 
and then the DynamicLoader plugin would set the section load addresses in the 
Target, run any scripting resources (python in .dSYMs), call ModulesDidLoad 
etc.  I don't think you should have to do the more generalized approach in this 
PR, but a scheme where other targets like Linux can benefit from the same 
approach would be interesting, without duplicating the thread pool code in 
their plugins.  More like something for future work.

I still haven't looked at the specific code changes yet :) I've been trying to 
exercise this approach in a few different environments and it seems like a 
benefit in nearly every case, to varying degrees.   

(the only case where it didn't benefit was when lldb had no binaries locally, 
and had to read them all over the gdb remote serial protocol.  In that case all 
threads were blocked on the communication over the USB cable, reading all the 
libraries.  The multithreaded approach didn't make this slower, and didn't seem 
to cause a problem, those were the main things I was looking for.)

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


[Lldb-commits] [lldb] Improve type lookup using .debug_names parent chain (PR #108907)

2024-10-09 Thread via lldb-commits

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