[Lldb-commits] [clang] [flang] [lld] [lldb] [llvm] [mlir] [polly] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (PR #138587)

2025-05-15 Thread via lldb-commits

https://github.com/jeremyd2019 updated 
https://github.com/llvm/llvm-project/pull/138587

>From 052580cd9ee141cd8c79e9588ad1c71e31f58cb3 Mon Sep 17 00:00:00 2001
From: Jeremy Drake 
Date: Mon, 5 May 2025 14:11:44 -0700
Subject: [PATCH 1/7] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS

In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang
standalone against an installed LLVM this definition was not picked up,
resulting in undefined strnlen.  Follow the documentation in
https://llvm.org/docs/CMake.html#developing-llvm-passes-out-of-source
and add the LLVM_DEFINITIONS in standalone projects' cmakes.
---
 clang/CMakeLists.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f12712f55fb96..ab2ac9bc6b9ad 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -68,6 +68,10 @@ if(CLANG_BUILT_STANDALONE)
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
+  separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
+  add_definitions(${LLVM_DEFINITIONS_LIST})
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
+
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)

>From a59bbb92c54d81d06754d49190d7a46ba269b1ef Mon Sep 17 00:00:00 2001
From: Jeremy Drake 
Date: Wed, 7 May 2025 11:24:55 -0700
Subject: [PATCH 2/7] fixup! [CMake] respect LLVMConfig.cmake's
 LLVM_DEFINITIONS

bolt
---
 bolt/CMakeLists.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt
index 52c796518ac05..5c7d51e1e398c 100644
--- a/bolt/CMakeLists.txt
+++ b/bolt/CMakeLists.txt
@@ -46,6 +46,10 @@ if(BOLT_BUILT_STANDALONE)
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
 
+  separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
+  add_definitions(${LLVM_DEFINITIONS_LIST})
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
+
   include(AddLLVM)
   include(TableGen)
   include_directories(${LLVM_INCLUDE_DIRS})

>From 595f483ff1403f282217ff4999f7640465b5dada Mon Sep 17 00:00:00 2001
From: Jeremy Drake 
Date: Wed, 7 May 2025 11:27:53 -0700
Subject: [PATCH 3/7] fixup! [CMake] respect LLVMConfig.cmake's
 LLVM_DEFINITIONS

flang
---
 flang/CMakeLists.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index f358a93fdd792..56a96f590f0a3 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -140,6 +140,11 @@ if (FLANG_STANDALONE_BUILD)
   if (NOT DEFINED LLVM_MAIN_SRC_DIR)
 set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
+
+  separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
+  add_definitions(${LLVM_DEFINITIONS_LIST})
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
+
   include(AddLLVM)
   include(HandleLLVMOptions)
   include(VersionFromVCS)

>From 8eeb00ff57a90ae7e4a775f7fa85a4d3529f143d Mon Sep 17 00:00:00 2001
From: Jeremy Drake 
Date: Wed, 7 May 2025 11:28:22 -0700
Subject: [PATCH 4/7] fixup! [CMake] respect LLVMConfig.cmake's
 LLVM_DEFINITIONS

lld
---
 lld/CMakeLists.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 9b202cc5d4899..80e25204a65ee 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -39,6 +39,10 @@ if(LLD_BUILT_STANDALONE)
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
 
+  separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
+  add_definitions(${LLVM_DEFINITIONS_LIST})
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
+
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)

>From e2510293883ff6499890de1a4a5de4c1d53beac3 Mon Sep 17 00:00:00 2001
From: Jeremy Drake 
Date: Wed, 7 May 2025 11:31:01 -0700
Subject: [PATCH 5/7] fixup! [CMake] respect LLVMConfig.cmake's
 LLVM_DEFINITIONS

lldb
---
 lldb/cmake/modules/LLDBStandalone.cmake | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/cmake/modules/LLDBStandalone.cmake 
b/lldb/cmake/modules/LLDBStandalone.cmake
index c9367214848fd..1a4cdbfbb1cc7 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -85,6 +85,10 @@ endif()
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
+separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
+add_definitions(${LLVM_DEFINITIONS_LIST})
+list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
+
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)

>From f9f30f2871fd3f5eedcf90b6f41c8e17b9d

[Lldb-commits] [clang] [flang] [lld] [lldb] [llvm] [mlir] [polly] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (PR #138587)

2025-05-15 Thread via lldb-commits

jeremyd2019 wrote:

> > I rebased this on top of #138783 and adjusted the title and description. 
> > Now it should be in a good state to push cmake changes for other projects.
> 
> The changes look good, but it looks like the changes from #138783 still show 
> up when viewing the changes; can you check that you've rebased past the 
> merged #138783?

I had not - I have now though.

> (Also, I take it that no other subprojects than clang need the 
> `cmake_push_check_state` change?)

No, the other projects were not messing with `_GNU_SOURCE` like clang was.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Adding an assert that the 'continue' request succeeds caused a number of tests 
to fail. This showed a number of tests that were not specifying if they should 
be stopped or not at key points in the test. This is likely contributing to 
these tests being flaky since the debugger is not in the expected state.

Additionally, I spent a little time trying to improve the readability of the 
dap_server.py and lldbdap_testcase.py.

---

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


18 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+130-98) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
(+57-170) 
- (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py (+9-7) 
- (modified) 
lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py 
(+2-5) 
- (modified) lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py (+1-3) 
- (modified) lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py (+3-2) 
- (modified) lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
(+5-5) 
- (modified) lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py (+5-5) 
- (modified) lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py (+1) 
- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+11-10) 
- (modified) lldb/test/API/tools/lldb-dap/module/TestDAP_module.py (+2-2) 
- (modified) lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py (+21-22) 
- (modified) lldb/test/API/tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py (-5) 
- (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+1-1) 
- (modified) lldb/tools/lldb-dap/DAPError.cpp (+9) 
- (modified) lldb/tools/lldb-dap/DAPError.h (+10-1) 
- (modified) lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp (+4-1) 
- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+40-33) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 73f7b0e91d57a..205b30ff4d2ec 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -12,6 +12,13 @@
 import sys
 import threading
 import time
+from typing import Any, Optional, Union, BinaryIO, TextIO
+
+## DAP type references
+Event = dict[str, Any]
+Request = dict[str, Any]
+Response = dict[str, Any]
+ProtocolMessage = Union[Event, Request, Response]
 
 
 def dump_memory(base_addr, data, num_per_line, outfile):
@@ -98,55 +105,40 @@ def dump_dap_log(log_file):
 print("= END =", file=sys.stderr)
 
 
-def read_packet_thread(vs_comm, log_file):
-done = False
-try:
-while not done:
-packet = read_packet(vs_comm.recv, trace_file=vs_comm.trace_file)
-# `packet` will be `None` on EOF. We want to pass it down to
-# handle_recv_packet anyway so the main thread can handle 
unexpected
-# termination of lldb-dap and stop waiting for new packets.
-done = not vs_comm.handle_recv_packet(packet)
-finally:
-# Wait for the process to fully exit before dumping the log file to
-# ensure we have the entire log contents.
-if vs_comm.process is not None:
-try:
-# Do not wait forever, some logs are better than none.
-vs_comm.process.wait(timeout=20)
-except subprocess.TimeoutExpired:
-pass
-dump_dap_log(log_file)
-
-
 class DebugCommunication(object):
-def __init__(self, recv, send, init_commands, log_file=None):
-self.trace_file = None
+def __init__(
+self,
+recv: BinaryIO,
+send: BinaryIO,
+init_commands: list[str],
+log_file: Optional[TextIO] = None,
+):
+# For debugging test failures, try setting `trace_file = sys.stderr`.
+self.trace_file: Optional[TextIO] = None
+self.log_file = log_file
 self.send = send
 self.recv = recv
-self.recv_packets = []
+self.recv_packets: list[Optional[ProtocolMessage]] = []
 self.recv_condition = threading.Condition()
-self.recv_thread = threading.Thread(
-target=read_packet_thread, args=(self, log_file)
-)
+self.recv_thread = threading.Thread(target=self._read_packet_thread)
 self.process_event_body = None
-self.exit_status = None
+self.exit_status: Optional[int] = None
 self.initialize_body = None
-self.thread_stop_reasons = {}
-self.progress_events = []
+self.progress_events: list[Event] = []
 self.reverse_requests = []
 self.sequence = 1
 self.threads = None
+se

[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd updated 
https://github.com/llvm/llvm-project/pull/138551



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {
+  uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();

kuilpd wrote:

I removed the other 2 of these calls, but this one specifically I couldn't: 
`GetChildAtIndex` for a synthetic value calls 
`ValueObjectSynthetic::GetChildAtIndex`. That one with `can_create = true` 
creates a value regardless of the index and always returns something, like a 0 
value for a out of bounds subscript of a vector; and with `can_create = false` 
it doesn't create anything, even if index is within bounds and always returns 
an error.

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }

kuilpd wrote:

It was for type checks later, I forgot that there is a `GetNonReferenceType()`.

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

I think I addressed everything I could, please take a look again.

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits


@@ -111,7 +111,42 @@ ASTNodeUP DILParser::ParseUnaryExpression() {
   llvm_unreachable("invalid token kind");
 }
   }
-  return ParsePrimaryExpression();
+  return ParsePostfixExpression();
+}
+
+// Parse a postfix_expression.
+//
+//  postfix_expression:
+//primary_expression
+//postfix_expression "[" integer_literal "]"
+//
+ASTNodeUP DILParser::ParsePostfixExpression() {
+  ASTNodeUP lhs = ParsePrimaryExpression();
+  while (CurToken().Is(Token::l_square)) {
+uint32_t loc = CurToken().GetLocation();
+Token token = CurToken();
+switch (token.GetKind()) {
+case Token::l_square: {
+  m_dil_lexer.Advance();
+  auto rhs = ParseIntegerConstant();

kuilpd wrote:

Out of curiosity, why?

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


[Lldb-commits] [lldb] 58b9b86 - [lldb-dap] Setup DAP for unit testing. (#139937)

2025-05-15 Thread via lldb-commits

Author: John Harrison
Date: 2025-05-15T10:45:16-07:00
New Revision: 58b9b865feffede59616cfc05cefa956d5352314

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

LOG: [lldb-dap] Setup DAP for unit testing. (#139937)

This is a very simple case that currently only validates we can create a
DAP instance and send a message over the transport layer. More in-depth
tests will require additional helpers and possibly refactors of DAP to
make it more testable, however this is some ground work to have basic
support for unit tests.

-

Co-authored-by: Jonas Devlieghere 

Added: 
lldb/unittests/DAP/DAPTest.cpp
lldb/unittests/DAP/Handler/DisconnectTest.cpp
lldb/unittests/DAP/TestBase.cpp
lldb/unittests/DAP/TestBase.h

Modified: 
lldb/tools/lldb-dap/DAP.h
lldb/unittests/DAP/CMakeLists.txt
lldb/unittests/DAP/TransportTest.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 9065995f5d722..c1a1130b1e59f 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -226,7 +226,8 @@ struct DAP {
   /// \param[in] default_repl_mode
   /// Default repl mode behavior, as configured by the binary.
   /// \param[in] pre_init_commands
-  /// LLDB commands to execute as soon as the debugger instance is 
allocaed.
+  /// LLDB commands to execute as soon as the debugger instance is
+  /// allocated.
   /// \param[in] transport
   /// Transport for this debug session.
   DAP(Log *log, const ReplMode default_repl_mode,

diff  --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 110733e93b192..af7d11e2e95e2 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,8 +1,11 @@
 add_lldb_unittest(DAPTests
+  DAPTest.cpp
+  Handler/DisconnectTest.cpp
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
-  TransportTest.cpp
   ProtocolTypesTest.cpp
+  TestBase.cpp
+  TransportTest.cpp
 
   LINK_LIBS
 lldbDAP

diff  --git a/lldb/unittests/DAP/DAPTest.cpp b/lldb/unittests/DAP/DAPTest.cpp
new file mode 100644
index 0..5fb6bf7e564ab
--- /dev/null
+++ b/lldb/unittests/DAP/DAPTest.cpp
@@ -0,0 +1,38 @@
+//===-- DAPTest.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "TestBase.h"
+#include "Transport.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap_tests;
+using namespace lldb_dap::protocol;
+
+class DAPTest : public TransportBase {};
+
+TEST_F(DAPTest, SendProtocolMessages) {
+  DAP dap{
+  /*log=*/nullptr,
+  /*default_repl_mode=*/ReplMode::Auto,
+  /*pre_init_commands=*/{},
+  /*transport=*/*to_dap,
+  };
+  dap.Send(Event{/*event=*/"my-event", /*body=*/std::nullopt});
+  ASSERT_THAT_EXPECTED(from_dap->Read(std::chrono::milliseconds(1)),
+   HasValue(testing::VariantWith(testing::FieldsAre(
+   /*event=*/"my-event", /*body=*/std::nullopt;
+}

diff  --git a/lldb/unittests/DAP/Handler/DisconnectTest.cpp 
b/lldb/unittests/DAP/Handler/DisconnectTest.cpp
new file mode 100644
index 0..6f3470239e974
--- /dev/null
+++ b/lldb/unittests/DAP/Handler/DisconnectTest.cpp
@@ -0,0 +1,35 @@
+//===-- DisconnectTest.cpp 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Handler/RequestHandler.h"
+#include "Protocol/ProtocolBase.h"
+#include "TestBase.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap_tests;
+using namespace lldb_dap::protocol;
+
+class DisconnectRequestHandlerTest : public DAPTestBase {};
+
+TEST_F(DisconnectRequestHandlerTest, DisconnectingTriggersTerminated) {
+  DisconnectRequestHandler handler(*dap);
+  EXPECT_FALSE(dap->disconnecting);
+  ASSERT_THAT_ERROR(handler.Run(std::nullopt), Succeeded());
+  EXPECT_TRUE(dap->disconnecting);
+  std::vector messages = DrainOutput();
+  EXPECT_THAT(

[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/140107

Adding an assert that the 'continue' request succeeds caused a number of tests 
to fail. This showed a number of tests that were not specifying if they should 
be stopped or not at key points in the test. This is likely contributing to 
these tests being flaky since the debugger is not in the expected state.

Additionally, I spent a little time trying to improve the readability of the 
dap_server.py and lldbdap_testcase.py.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Setup DAP for unit testing. (PR #139937)

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

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


[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)

2025-05-15 Thread Ilia Kuklin via lldb-commits


@@ -272,4 +272,67 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const ArraySubscriptNode *node) {
+  auto lhs_or_err = Evaluate(node->GetBase());
+  if (!lhs_or_err) {
+return lhs_or_err;
+  }
+  lldb::ValueObjectSP base = *lhs_or_err;
+  const llvm::APInt *index = node->GetIndex();
+
+  Status error;
+  if (base->GetCompilerType().IsReferenceType()) {
+base = base->Dereference(error);
+if (error.Fail())
+  return error.ToError();
+  }
+
+  // Check to see if 'base' has a synthetic value; if so, try using that.
+  uint64_t child_idx = index->getZExtValue();
+  if (base->HasSyntheticValue()) {
+lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+if (synthetic && synthetic != base) {
+  uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();
+  // Verify that the 'index' is not out-of-range for the declared type.
+  if (child_idx >= num_children) {
+auto message = llvm::formatv(
+"array index {0} is not valid for \"({1}) {2}\"", child_idx,
+base->GetTypeName().AsCString(""),
+base->GetName().AsCString());
+return llvm::make_error(m_expr, message,
+node->GetLocation());
+  }
+
+  if (static_cast(child_idx) <
+  synthetic->GetNumChildrenIgnoringErrors()) {
+lldb::ValueObjectSP child_valobj_sp =
+synthetic->GetChildAtIndex(child_idx);
+if (child_valobj_sp) {
+  return child_valobj_sp;
+}
+  }
+}
+  }
+
+  auto base_type = base->GetCompilerType();
+  if (!base_type.IsPointerType() && !base_type.IsArrayType())

kuilpd wrote:

I tried that, but because I need to return `base->GetSyntheticArrayMember` in 
any case other than array, it didn't end up looking better.

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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)

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

ashgti wrote:

I'm working on splitting out the test changes, #140107 is the main set that I 
think are related. If so, this may become a more of a NFC from the test 
perspective.

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

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

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/138116



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

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

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/138116



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

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

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


[Lldb-commits] [lldb] 4ba8f4e - [lldb][lldb-dap] Migrate ScopesRequest to structured types (#138116)

2025-05-15 Thread via lldb-commits

Author: Ebuka Ezike
Date: 2025-05-15T10:16:05+01:00
New Revision: 4ba8f4e213c97733e3b61e5856b0e85e3d7d6a7f

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

LOG: [lldb][lldb-dap] Migrate ScopesRequest to  structured types (#138116)

Migrate ScopesRequest To use the Protocol Types

Added: 


Modified: 
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/Handler/RequestHandler.h
lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
lldb/tools/lldb-dap/JSONUtils.h
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
lldb/unittests/DAP/ProtocolTypesTest.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 51f9da854f4b6..56a0c38b00037 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -559,17 +559,6 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
   return GetLLDBFrame(frame_id);
 }
 
-llvm::json::Value DAP::CreateTopLevelScopes() {
-  llvm::json::Array scopes;
-  scopes.emplace_back(
-  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  variables.globals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  variables.registers.GetSize(), false));
-  return llvm::json::Value(std::move(scopes));
-}
-
 ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.

diff  --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..9065995f5d722 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -283,10 +283,10 @@ struct DAP {
   lldb::SBThread GetLLDBThread(const llvm::json::Object &arguments);
 
   lldb::SBFrame GetLLDBFrame(uint64_t frame_id);
+  /// TODO: remove this function when we finish migrating to the
+  /// new protocol types.
   lldb::SBFrame GetLLDBFrame(const llvm::json::Object &arguments);
 
-  llvm::json::Value CreateTopLevelScopes();
-
   void PopulateExceptionBreakpoints();
 
   /// Attempt to determine if an expression is a variable expression or

diff  --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index b0002440cf72e..eaebaf6619bbd 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -452,11 +452,15 @@ class PauseRequestHandler : public LegacyRequestHandler {
   void operator()(const llvm::json::Object &request) const override;
 };
 
-class ScopesRequestHandler : public LegacyRequestHandler {
+class ScopesRequestHandler final
+: public RequestHandler> {
 public:
-  using LegacyRequestHandler::LegacyRequestHandler;
+  using RequestHandler::RequestHandler;
   static llvm::StringLiteral GetCommand() { return "scopes"; }
-  void operator()(const llvm::json::Object &request) const override;
+
+  llvm::Expected
+  Run(const protocol::ScopesArguments &args) const override;
 };
 
 class SetVariableRequestHandler final

diff  --git a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
index 7d1608f59f9a4..aaad0e20f9c21 100644
--- a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
@@ -7,69 +7,56 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
 #include "RequestHandler.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "ScopesRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Scopes request; value of command field is 'scopes'. The
-// request returns the variable scopes for a given stackframe ID.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "scopes" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/ScopesArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "ScopesArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'scopes' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Retrieve the scopes for this stackframe."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "ScopesResponse": {
-//   "allOf": [ { "$ref": "

[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

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

https://github.com/da-viper created 
https://github.com/llvm/llvm-project/pull/140031

warning for designated initializers

>From 0a8d16445c531f7a65283ab2a9a7db522eeb3a5a Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Thu, 15 May 2025 10:36:39 +0100
Subject: [PATCH] [NFC][lldb][lldb-dap] fix C++20 extension warning

warning for designated initializers
---
 lldb/unittests/DAP/ProtocolTypesTest.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
index 0c119bdb544d8..c34d98cf890ef 100644
--- a/lldb/unittests/DAP/ProtocolTypesTest.cpp
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -305,11 +305,11 @@ TEST(ProtocolTypesTest, Scope) {
   scope.endLine = 10;
   scope.endColumn = 20;
 
-  scope.source =
-  Source{.name = "testName",
- .path = "/path/to/source",
- .sourceReference = 12345,
- .presentationHint = Source::eSourcePresentationHintNormal};
+  // scope.source =
+  scope.source->name = "testName";
+  scope.source->path = "/path/to/source";
+  scope.source->sourceReference = 12345;
+  scope.source->presentationHint = Source::eSourcePresentationHintNormal;
 
   llvm::Expected deserialized_scope = roundtrip(scope);
   ASSERT_THAT_EXPECTED(deserialized_scope, llvm::Succeeded());

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


[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

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

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/140031



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

warning for designated initializers

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


1 Files Affected:

- (modified) lldb/unittests/DAP/ProtocolTypesTest.cpp (+5-5) 


``diff
diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
index 0c119bdb544d8..c34d98cf890ef 100644
--- a/lldb/unittests/DAP/ProtocolTypesTest.cpp
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -305,11 +305,11 @@ TEST(ProtocolTypesTest, Scope) {
   scope.endLine = 10;
   scope.endColumn = 20;
 
-  scope.source =
-  Source{.name = "testName",
- .path = "/path/to/source",
- .sourceReference = 12345,
- .presentationHint = Source::eSourcePresentationHintNormal};
+  // scope.source =
+  scope.source->name = "testName";
+  scope.source->path = "/path/to/source";
+  scope.source->sourceReference = 12345;
+  scope.source->presentationHint = Source::eSourcePresentationHintNormal;
 
   llvm::Expected deserialized_scope = roundtrip(scope);
   ASSERT_THAT_EXPECTED(deserialized_scope, llvm::Succeeded());

``




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


[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

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

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/140031



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

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

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


[Lldb-commits] [lldb] e3867cb - [NFC][lldb][lldb-dap] fix C++20 extension warning (#140031)

2025-05-15 Thread via lldb-commits

Author: Ebuka Ezike
Date: 2025-05-15T11:13:19+01:00
New Revision: e3867cb07ed1ed319609fbea0ce15f40e2a0efad

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

LOG: [NFC][lldb][lldb-dap] fix C++20 extension warning (#140031)

warning for designated initializers

introduced in commit  4ba8f4e

Added: 


Modified: 
lldb/unittests/DAP/ProtocolTypesTest.cpp

Removed: 




diff  --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
index 0c119bdb544d8..5d5125dc78fba 100644
--- a/lldb/unittests/DAP/ProtocolTypesTest.cpp
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -305,11 +305,12 @@ TEST(ProtocolTypesTest, Scope) {
   scope.endLine = 10;
   scope.endColumn = 20;
 
-  scope.source =
-  Source{.name = "testName",
- .path = "/path/to/source",
- .sourceReference = 12345,
- .presentationHint = Source::eSourcePresentationHintNormal};
+  Source source;
+  source.name = "testName";
+  source.path = "/path/to/source";
+  source.sourceReference = 12345;
+  source.presentationHint = Source::eSourcePresentationHintNormal;
+  scope.source = source;
 
   llvm::Expected deserialized_scope = roundtrip(scope);
   ASSERT_THAT_EXPECTED(deserialized_scope, llvm::Succeeded());
@@ -325,7 +326,6 @@ TEST(ProtocolTypesTest, Scope) {
   EXPECT_EQ(scope.endColumn, deserialized_scope->endColumn);
 
   EXPECT_THAT(deserialized_scope->source.has_value(), true);
-  const Source &source = scope.source.value();
   const Source &deserialized_source = deserialized_scope->source.value();
 
   EXPECT_EQ(source.path, deserialized_source.path);



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


[Lldb-commits] [lldb] [NFC][lldb][lldb-dap] fix C++20 extension warning (PR #140031)

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

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-15 Thread via lldb-commits

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-15 Thread via lldb-commits


@@ -1510,6 +1510,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t 
watch_id,
 }
 
 ModuleSP Target::GetExecutableModule() {
+  std::lock_guard guard(m_images.GetMutex());

neverov-test wrote:

done

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


[Lldb-commits] [clang] [flang] [lld] [lldb] [llvm] [mlir] [polly] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (PR #138587)

2025-05-15 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> I rebased this on top of #138783 and adjusted the title and description. Now 
> it should be in a good state to push cmake changes for other projects.

The changes look good, but it looks like the changes from #138783 still show up 
when viewing the changes; can you check that you've rebased past the merged 
#138783?

(Also, I take it that no other subprojects than clang need the 
`cmake_push_check_state` change?)

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


[Lldb-commits] [lldb] 42ee758 - Complete the Implementation of DAP modules explorer. (#139934)

2025-05-15 Thread via lldb-commits

Author: Ebuka Ezike
Date: 2025-05-15T12:21:26+01:00
New Revision: 42ee758bec885deaad08162cc8e97a87d2aba100

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

LOG: Complete the Implementation of DAP modules explorer. (#139934)

This extends the TreeView to show the module property as a tree item instead of 
rendering it through the markdown tooltip.

![image](https://github.com/user-attachments/assets/329fabee-9b4a-490e-9450-3f01314674ea)

Added: 


Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/package.json
lldb/tools/lldb-dap/src-ts/extension.ts
lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts

Removed: 




diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 279e6d3d93814..a8bd672583a5d 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -416,9 +416,11 @@ llvm::json::Value CreateModule(lldb::SBTarget &target, 
lldb::SBModule &module,
   } else {
 object.try_emplace("symbolStatus", "Symbols not found.");
   }
-  std::string loaded_addr = std::to_string(
-  module.GetObjectFileHeaderAddress().GetLoadAddress(target));
-  object.try_emplace("addressRange", loaded_addr);
+  std::string load_address =
+  llvm::formatv("{0:x}",
+module.GetObjectFileHeaderAddress().GetLoadAddress(target))
+  .str();
+  object.try_emplace("addressRange", load_address);
   std::string version_str;
   uint32_t version_nums[3];
   uint32_t num_versions =

diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index e3e46526f379f..d5ca604798799 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -244,6 +244,26 @@
 }
   }
 ],
+"commands": [
+  {
+"command": "lldb-dap.modules.copyProperty",
+"title": "Copy Value"
+  }
+],
+"menus": {
+  "commandPalette": [
+{
+  "command": "lldb-dap.modules.copyProperty",
+  "when": "false"
+}
+  ],
+  "view/item/context": [
+{
+  "command": "lldb-dap.modules.copyProperty",
+  "when": "view == lldb-dap.modules && viewItem == property"
+}
+  ]
+},
 "breakpoints": [
   {
 "language": "ada"

diff  --git a/lldb/tools/lldb-dap/src-ts/extension.ts 
b/lldb/tools/lldb-dap/src-ts/extension.ts
index a5c0a09ae60cf..c8e5146e29cea 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -6,7 +6,10 @@ import { LaunchUriHandler } from "./uri-launch-handler";
 import { LLDBDapConfigurationProvider } from "./debug-configuration-provider";
 import { LLDBDapServer } from "./lldb-dap-server";
 import { DebugSessionTracker } from "./debug-session-tracker";
-import { ModulesDataProvider } from "./ui/modules-data-provider";
+import {
+  ModulesDataProvider,
+  ModuleProperty,
+} from "./ui/modules-data-provider";
 
 /**
  * This class represents the extension and manages its life cycle. Other 
extensions
@@ -40,6 +43,11 @@ export class LLDBDapExtension extends DisposableContext {
   ),
   vscode.window.registerUriHandler(new LaunchUriHandler()),
 );
+
+vscode.commands.registerCommand(
+  "lldb-dap.modules.copyProperty",
+  (node: ModuleProperty) => vscode.env.clipboard.writeText(node.value),
+);
   }
 }
 

diff  --git a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts 
b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
index 478c162de8878..091c1d69ac647 100644
--- a/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts
@@ -2,60 +2,86 @@ import * as vscode from "vscode";
 import { DebugProtocol } from "@vscode/debugprotocol";
 import { DebugSessionTracker } from "../debug-session-tracker";
 
-/** A tree data provider for listing loaded modules for the active debug 
session. */
-export class ModulesDataProvider
-  implements vscode.TreeDataProvider
-{
-  private changeTreeData = new vscode.EventEmitter();
-  readonly onDidChangeTreeData = this.changeTreeData.event;
+export interface ModuleProperty {
+  key: string;
+  value: string;
+}
 
-  constructor(private readonly tracker: DebugSessionTracker) {
-tracker.onDidChangeModules(() => this.changeTreeData.fire());
-vscode.debug.onDidChangeActiveDebugSession(() =>
-  this.changeTreeData.fire(),
-);
+/** Type to represent both Module and ModuleProperty since TreeDataProvider
+ * expects one concrete type */
+type TreeData = DebugProtocol.Module | ModuleProperty;
+
+function isModule(type: TreeData): type is DebugProtocol.Module {
+  return (type as DebugProtocol.Module).id !== undefined;
+}
+
+class ModuleItem extends vscode.TreeIt

[Lldb-commits] [lldb] Complete the Implementation of DAP modules explorer. (PR #139934)

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

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits


@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+return "";
+  const psinfo_t *psinfo =
+  reinterpret_cast(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}

DhruvSrivastavaX wrote:

Yes true, I agree with that. 
Okay, in that case I can drop this change out for now and we can decide on 
whether to add it or not later. 

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

Shall I merge it now? @labath 

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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- 
lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp 
lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
index 7108ba9fb..3bb608168 100644
--- a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
@@ -17,9 +17,7 @@ using namespace lldb_private::process_aix;
 NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
 : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
 
-std::string NativeThreadAIX::GetName() {
-  return "";
-}
+std::string NativeThreadAIX::GetName() { return ""; }
 
 lldb::StateType NativeThreadAIX::GetState() { return m_state; }
 

``




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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Add support for displaying `__float128` variables (PR #98369)

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


@@ -666,7 +667,9 @@ lldb::offset_t lldb_private::DumpDataExtractor(
   const unsigned format_precision = 0;
 
   const llvm::fltSemantics &semantics =
-  GetFloatSemantics(target_sp, item_byte_size);
+  item_format == eFormatFloat128 && item_byte_size == 16
+  ? llvm::APFloat::IEEEquad()
+  : GetFloatSemantics(target_sp, item_byte_size);

Michael137 wrote:

Why can't this byte_size check be part of `GetFloatSemantics`?

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


[Lldb-commits] [lldb] [lldb] Use std::optional::value_or (NFC) (PR #140011)

2025-05-15 Thread Tim Gymnich via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use llvm::unique (NFC) (PR #139910)

2025-05-15 Thread Kazu Hirata via lldb-commits

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


[Lldb-commits] [lldb] 9f569fe - [lldb] Use std::optional::value_or (NFC) (#140011)

2025-05-15 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-15T07:17:18-07:00
New Revision: 9f569fe2e7b68db856716a1ae3b0a6738a281d1e

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

LOG: [lldb] Use std::optional::value_or (NFC) (#140011)

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a3e809f44ed23..e3a866e2b6d48 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2479,8 +2479,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(
 std::unique_ptr decl_up;
 if (decl_file || decl_line || decl_column)
   decl_up = std::make_unique(
-  die.GetCU()->GetFile(decl_file ? *decl_file : 0),
-  decl_line ? *decl_line : 0, decl_column ? *decl_column : 0);
+  die.GetCU()->GetFile(decl_file.value_or(0)), decl_line.value_or(0),
+  decl_column.value_or(0));
 
 SymbolFileDWARF *dwarf = die.GetDWARF();
 // Supply the type _only_ if it has already been parsed

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 907d63eb51afe..0fc7f79be70ec 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1358,15 +1358,15 @@ size_t 
SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
 if (decl_file || decl_line || decl_column)
   decl_up = std::make_unique(
   comp_unit.GetSupportFiles().GetFileSpecAtIndex(
-  decl_file ? *decl_file : 0),
-  decl_line ? *decl_line : 0, decl_column ? *decl_column : 0);
+  decl_file.value_or(0)),
+  decl_line.value_or(0), decl_column.value_or(0));
 
 std::unique_ptr call_up;
 if (call_file || call_line || call_column)
   call_up = std::make_unique(
   comp_unit.GetSupportFiles().GetFileSpecAtIndex(
-  call_file ? *call_file : 0),
-  call_line ? *call_line : 0, call_column ? *call_column : 0);
+  call_file.value_or(0)),
+  call_line.value_or(0), call_column.value_or(0));
 
 block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(),
   call_up.get());



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


[Lldb-commits] [lldb] [lldb] Use std::optional::value_or (NFC) (PR #140011)

2025-05-15 Thread Kazu Hirata via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

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

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/140065

The motivation here is being (un)able to treat pointer values as an array 
consistently. This works for pointers to simple/scalar values, but for 
aggregates, we get a very surprising result:
- GetChildAtIndex(x, ??, true) returns the `x` child of the zeroth array member 
(the one you get by dereferencing the pointer/array) for all `x` which are 
smaller than the number of children of that value.
- for other values of `x`, we get `v[x]`, where `v` is treated like a (C) 
pointer

This patch reimagines this interface so that the value of `true` always treats 
(pointer and array) values as pointers. For `false`, we always dereference 
pointers, while in the case of arrays, we only return the values as far as the 
array bounds will allow.

This has the potential to break existing code, but I have a suspicion that code 
was already broken to begin with, which is why I think this would be better 
than introducing a new API and keeping the old (and surprising behavior). If 
our own test coverage is any indication, breakage should be minimal.

>From 542da1ac1389bb74e2da3385ce1b8d48d47032b4 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 15 May 2025 14:55:09 +0200
Subject: [PATCH] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true)

The motivation here is being (un)able to treat pointer values as an array
consistently. This works for pointers to simple/scalar values, but for
aggregates, we get a very surprising result:
- GetChildAtIndex(x, ??, true) returns the `x` child of the zeroth array member
  (the one you get by dereferencing the pointer/array) for all `x` which are
  smaller than the number of children of that value.
- for other values of `x`, we get `v[x]`, where `v` is treated like a (C)
  pointer

This patch reimagines this interface so that the value of `true` always treats
(pointer and array) values as pointers. For `false`, we always dereference
pointers, while in the case of arrays, we only return the values as far as the
array bounds will allow.

This has the potential to break existing code, but I have a suspicion that code
was already broken to begin with, which is why I think this would be better
than introducing a new API and keeping the old (and surprising behavior). If
our own test coverage is any indication, breakage should be minimal.
---
 lldb/include/lldb/API/SBValue.h   | 39 ---
 lldb/source/API/SBValue.cpp   | 15 ---
 .../sbvalue_synthetic/TestSBValueSynthetic.py | 21 ++
 .../API/python_api/sbvalue_synthetic/main.cpp |  6 +++
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 75d20a4378f09..ad87639960fa0 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -160,31 +160,26 @@ class LLDB_API SBValue {
   /// members (empty base classes are omitted), and all members of the
   /// current class will then follow the base classes.
   ///
-  /// Pointers differ depending on what they point to. If the pointer
-  /// points to a simple type, the child at index zero
-  /// is the only child value available, unless \a synthetic_allowed
-  /// is \b true, in which case the pointer will be used as an array
-  /// and can create 'synthetic' child values using positive or
-  /// negative indexes. If the pointer points to an aggregate type
-  /// (an array, class, union, struct), then the pointee is
-  /// transparently skipped and any children are going to be the indexes
-  /// of the child values within the aggregate type. For example if
-  /// we have a 'Point' type and we have a SBValue that contains a
-  /// pointer to a 'Point' type, then the child at index zero will be
-  /// the 'x' member, and the child at index 1 will be the 'y' member
-  /// (the child at index zero won't be a 'Point' instance).
+  /// For array and pointers the behavior of the function depends on the value
+  /// of the \a use_synthetic argument. If \b false, the function returns
+  /// members of the array as given by the array bounds. If the value is a
+  /// pointer to a simple type, the child at index zero is the only child
+  /// value available. If the pointer points to an aggregate type (an array,
+  /// class, union, etc.), then the pointee is transparently skipped and any
+  /// children are going to be the indexes of the child values within the
+  /// aggregate type. For example if we have a 'Point' type and we have a
+  /// SBValue that contains a pointer to a 'Point' type, then the child at
+  /// index zero will be the 'x' member, and the child at index 1 will be the
+  /// 'y' member (the child at index zero won't be a 'Point' instance). If \a
+  /// use_synthetic is \b true, pointer values will be used as a (C) array and
+  /// and the function will create 'synthetic' child values using positive or
+  /// negative indexes. In case of arrays, 

[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The motivation here is being (un)able to treat pointer values as an array 
consistently. This works for pointers to simple/scalar values, but for 
aggregates, we get a very surprising result:
- GetChildAtIndex(x, ??, true) returns the `x` child of the zeroth array member 
(the one you get by dereferencing the pointer/array) for all `x` which are 
smaller than the number of children of that value.
- for other values of `x`, we get `v[x]`, where `v` is treated like a (C) 
pointer

This patch reimagines this interface so that the value of `true` always treats 
(pointer and array) values as pointers. For `false`, we always dereference 
pointers, while in the case of arrays, we only return the values as far as the 
array bounds will allow.

This has the potential to break existing code, but I have a suspicion that code 
was already broken to begin with, which is why I think this would be better 
than introducing a new API and keeping the old (and surprising behavior). If 
our own test coverage is any indication, breakage should be minimal.

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


4 Files Affected:

- (modified) lldb/include/lldb/API/SBValue.h (+17-22) 
- (modified) lldb/source/API/SBValue.cpp (+7-8) 
- (modified) lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py 
(+21) 
- (modified) lldb/test/API/python_api/sbvalue_synthetic/main.cpp (+6) 


``diff
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 75d20a4378f09..ad87639960fa0 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -160,31 +160,26 @@ class LLDB_API SBValue {
   /// members (empty base classes are omitted), and all members of the
   /// current class will then follow the base classes.
   ///
-  /// Pointers differ depending on what they point to. If the pointer
-  /// points to a simple type, the child at index zero
-  /// is the only child value available, unless \a synthetic_allowed
-  /// is \b true, in which case the pointer will be used as an array
-  /// and can create 'synthetic' child values using positive or
-  /// negative indexes. If the pointer points to an aggregate type
-  /// (an array, class, union, struct), then the pointee is
-  /// transparently skipped and any children are going to be the indexes
-  /// of the child values within the aggregate type. For example if
-  /// we have a 'Point' type and we have a SBValue that contains a
-  /// pointer to a 'Point' type, then the child at index zero will be
-  /// the 'x' member, and the child at index 1 will be the 'y' member
-  /// (the child at index zero won't be a 'Point' instance).
+  /// For array and pointers the behavior of the function depends on the value
+  /// of the \a use_synthetic argument. If \b false, the function returns
+  /// members of the array as given by the array bounds. If the value is a
+  /// pointer to a simple type, the child at index zero is the only child
+  /// value available. If the pointer points to an aggregate type (an array,
+  /// class, union, etc.), then the pointee is transparently skipped and any
+  /// children are going to be the indexes of the child values within the
+  /// aggregate type. For example if we have a 'Point' type and we have a
+  /// SBValue that contains a pointer to a 'Point' type, then the child at
+  /// index zero will be the 'x' member, and the child at index 1 will be the
+  /// 'y' member (the child at index zero won't be a 'Point' instance). If \a
+  /// use_synthetic is \b true, pointer values will be used as a (C) array and
+  /// and the function will create 'synthetic' child values using positive or
+  /// negative indexes. In case of arrays, the function will return values
+  /// which are outside of the array bounds.
   ///
   /// If you actually need an SBValue that represents the type pointed
   /// to by a SBValue for which GetType().IsPointeeType() returns true,
   /// regardless of the pointee type, you can do that with 
SBValue::Dereference.
   ///
-  /// Arrays have a preset number of children that can be accessed by
-  /// index and will returns invalid child values for indexes that are
-  /// out of bounds unless the \a synthetic_allowed is \b true. In this
-  /// case the array can create 'synthetic' child values for indexes
-  /// that aren't in the array bounds using positive or negative
-  /// indexes.
-  ///
   /// \param[in] idx
   /// The index of the child value to get
   ///
@@ -193,7 +188,7 @@ class LLDB_API SBValue {
   /// and also if the target can be run to figure out the dynamic
   /// type of the child value.
   ///
-  /// \param[in] can_create_synthetic
+  /// \param[in] use_synthetic
   /// If \b true, then allow child values to be created by index
   /// for pointers and arrays for indexes that normally wouldn't
   /// be allowed.
@@ -202,7 +197,7 @@ c

[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

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

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

Ship it.

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


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-15 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
``





View the diff from darker here.


``diff
--- TestSBValueSynthetic.py 2025-05-15 12:55:09.00 +
+++ TestSBValueSynthetic.py 2025-05-15 14:25:08.027332 +
@@ -25,20 +25,27 @@
 def test_synth_arr(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
 self, "break here", lldb.SBFileSpec("main.cpp")
 )
-point_arr = self.frame().FindVariable("point_arr");
-point_ptr = self.frame().FindVariable("point_ptr");
+point_arr = self.frame().FindVariable("point_arr")
+point_ptr = self.frame().FindVariable("point_ptr")
 for v in [point_arr, point_ptr]:
-  for i in range(3):
-child = v.GetChildAtIndex(i, lldb.eDynamicDontRunTarget, True)
-check = ValueCheck(name=f"[{i}]", type="Point", 
children=[ValueCheck(name="x", value=str(2*i+1)), ValueCheck(name="y", 
value=str(2*i+2))])
-check.check_value(self, child, f"{child}, child {i} of 
{v.GetName()}")
+for i in range(3):
+child = v.GetChildAtIndex(i, lldb.eDynamicDontRunTarget, True)
+check = ValueCheck(
+name=f"[{i}]",
+type="Point",
+children=[
+ValueCheck(name="x", value=str(2 * i + 1)),
+ValueCheck(name="y", value=str(2 * i + 2)),
+],
+)
+check.check_value(self, child, f"{child}, child {i} of 
{v.GetName()}")
 
-int_arr = self.frame().FindVariable("int_arr");
-int_ptr = self.frame().FindVariable("int_ptr");
+int_arr = self.frame().FindVariable("int_arr")
+int_ptr = self.frame().FindVariable("int_ptr")
 for v in [int_arr, int_ptr]:
-  for i in range(3):
-child = v.GetChildAtIndex(i, lldb.eDynamicDontRunTarget, True)
-check = ValueCheck(name=f"[{i}]", type="int", value=str(i+1))
-check.check_value(self, child, f"{child}, child {i} of 
{v.GetName()}")
+for i in range(3):
+child = v.GetChildAtIndex(i, lldb.eDynamicDontRunTarget, True)
+check = ValueCheck(name=f"[{i}]", type="int", value=str(i + 1))
+check.check_value(self, child, f"{child}, child {i} of 
{v.GetName()}")

``




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


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-15 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- 
lldb/include/lldb/API/SBValue.h lldb/source/API/SBValue.cpp 
lldb/test/API/python_api/sbvalue_synthetic/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/main.cpp 
b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
index 5ec272b7b..d9b65f017 100644
--- a/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
+++ b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
@@ -6,13 +6,16 @@ struct HasFoo {
   Foo f;
 };
 
-struct Point { int x; int y; };
+struct Point {
+  int x;
+  int y;
+};
 
 int main() {
   Foo foo;
   HasFoo has_foo;
-  Point point_arr[] = {{1,2},{3,4},{5,6}};
-  int int_arr[] = {1,2,3,4,5,6};
+  Point point_arr[] = {{1, 2}, {3, 4}, {5, 6}};
+  int int_arr[] = {1, 2, 3, 4, 5, 6};
   Point *point_ptr = point_arr;
   int *int_ptr = int_arr;
   return 0; // break here

``




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


[Lldb-commits] [lldb] 1f570b1 - [lldb] Use llvm::unique (NFC) (#139910)

2025-05-15 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-15T07:15:59-07:00
New Revision: 1f570b1c2df6ec93a90ec8f0751fe8355644f1c6

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

LOG: [lldb] Use llvm::unique (NFC) (#139910)

While I am at it, this patch removes the "if" statement.
std::vector::erase(first, last) doesn't do anything when
first == last.

Added: 


Modified: 
lldb/source/Target/DynamicRegisterInfo.cpp

Removed: 




diff  --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 9ad98a41c688c..b964dc5877a97 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -497,10 +497,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
pos != end; ++pos) {
 if (pos->second.size() > 1) {
   llvm::sort(pos->second);
-  reg_num_collection::iterator unique_end =
-  std::unique(pos->second.begin(), pos->second.end());
-  if (unique_end != pos->second.end())
-pos->second.erase(unique_end, pos->second.end());
+  pos->second.erase(llvm::unique(pos->second), pos->second.end());
 }
 assert(!pos->second.empty());
 if (pos->second.back() != LLDB_INVALID_REGNUM)



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


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

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

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/140065

>From 59829616c0897325795f667a8cd3bdcb309ff91c Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 15 May 2025 14:55:09 +0200
Subject: [PATCH] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true)

The motivation here is being (un)able to treat pointer values as an array
consistently. This works for pointers to simple/scalar values, but for
aggregates, we get a very surprising result:
- GetChildAtIndex(x, ??, true) returns the `x` child of the zeroth array member
  (the one you get by dereferencing the pointer/array) for all `x` which are
  smaller than the number of children of that value.
- for other values of `x`, we get `v[x]`, where `v` is treated like a (C)
  pointer

This patch reimagines this interface so that the value of `true` always treats
(pointer and array) values as pointers. For `false`, we always dereference
pointers, while in the case of arrays, we only return the values as far as the
array bounds will allow.

This has the potential to break existing code, but I have a suspicion that code
was already broken to begin with, which is why I think this would be better
than introducing a new API and keeping the old (and surprising behavior). If
our own test coverage is any indication, breakage should be minimal.
---
 lldb/include/lldb/API/SBValue.h   | 39 ---
 lldb/source/API/SBValue.cpp   | 15 ---
 .../sbvalue_synthetic/TestSBValueSynthetic.py | 28 +
 .../API/python_api/sbvalue_synthetic/main.cpp |  9 +
 4 files changed, 61 insertions(+), 30 deletions(-)

diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 75d20a4378f09..ad87639960fa0 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -160,31 +160,26 @@ class LLDB_API SBValue {
   /// members (empty base classes are omitted), and all members of the
   /// current class will then follow the base classes.
   ///
-  /// Pointers differ depending on what they point to. If the pointer
-  /// points to a simple type, the child at index zero
-  /// is the only child value available, unless \a synthetic_allowed
-  /// is \b true, in which case the pointer will be used as an array
-  /// and can create 'synthetic' child values using positive or
-  /// negative indexes. If the pointer points to an aggregate type
-  /// (an array, class, union, struct), then the pointee is
-  /// transparently skipped and any children are going to be the indexes
-  /// of the child values within the aggregate type. For example if
-  /// we have a 'Point' type and we have a SBValue that contains a
-  /// pointer to a 'Point' type, then the child at index zero will be
-  /// the 'x' member, and the child at index 1 will be the 'y' member
-  /// (the child at index zero won't be a 'Point' instance).
+  /// For array and pointers the behavior of the function depends on the value
+  /// of the \a use_synthetic argument. If \b false, the function returns
+  /// members of the array as given by the array bounds. If the value is a
+  /// pointer to a simple type, the child at index zero is the only child
+  /// value available. If the pointer points to an aggregate type (an array,
+  /// class, union, etc.), then the pointee is transparently skipped and any
+  /// children are going to be the indexes of the child values within the
+  /// aggregate type. For example if we have a 'Point' type and we have a
+  /// SBValue that contains a pointer to a 'Point' type, then the child at
+  /// index zero will be the 'x' member, and the child at index 1 will be the
+  /// 'y' member (the child at index zero won't be a 'Point' instance). If \a
+  /// use_synthetic is \b true, pointer values will be used as a (C) array and
+  /// and the function will create 'synthetic' child values using positive or
+  /// negative indexes. In case of arrays, the function will return values
+  /// which are outside of the array bounds.
   ///
   /// If you actually need an SBValue that represents the type pointed
   /// to by a SBValue for which GetType().IsPointeeType() returns true,
   /// regardless of the pointee type, you can do that with 
SBValue::Dereference.
   ///
-  /// Arrays have a preset number of children that can be accessed by
-  /// index and will returns invalid child values for indexes that are
-  /// out of bounds unless the \a synthetic_allowed is \b true. In this
-  /// case the array can create 'synthetic' child values for indexes
-  /// that aren't in the array bounds using positive or negative
-  /// indexes.
-  ///
   /// \param[in] idx
   /// The index of the child value to get
   ///
@@ -193,7 +188,7 @@ class LLDB_API SBValue {
   /// and also if the target can be run to figure out the dynamic
   /// type of the child value.
   ///
-  /// \param[in] can_create_synthetic
+  /// \param[in] use_synthetic
   /// If \b true, then allow child values

[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

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


@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
 const FileSpec &file_spec, uint32_t line, bool check_inlines,
 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
   std::lock_guard guard(m_modules_mutex);
+  // If we're looking for a header (not source), then need to check inline.
+  check_inlines = check_inlines || !file_spec.IsSourceImplementationFile();

oontvoo wrote:

Done! Thanks for the pointer! :)

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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

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

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

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

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread via lldb-commits


@@ -584,22 +584,26 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch,
   // 64b ELF have a 4 byte pad.
   if (data.GetAddressByteSize() == 8)
 offset += 4;
-  // Not every stop signal has a valid address, but that will get resolved in
-  // the unix_signals.GetSignalDescription() call below.
-  if (unix_signals.GetShouldStop(si_signo)) {
+
+  if (si_code < 0) {
+sifields.kill.pid = data.GetU32(&offset);
+sifields.kill.uid = data.GetU32(&offset);

youngd007 wrote:

Are these populating to the same ints if the offset is the same into the data 
object/struct?

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


[Lldb-commits] [lldb] [LLDB] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread Jacob Lalonde via lldb-commits


@@ -584,22 +584,26 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch,
   // 64b ELF have a 4 byte pad.
   if (data.GetAddressByteSize() == 8)
 offset += 4;
-  // Not every stop signal has a valid address, but that will get resolved in
-  // the unix_signals.GetSignalDescription() call below.
-  if (unix_signals.GetShouldStop(si_signo)) {
+
+  if (si_code < 0) {
+sifields.kill.pid = data.GetU32(&offset);
+sifields.kill.uid = data.GetU32(&offset);

Jlalond wrote:

No, the data extractor will increment the offset for each call, so the first 
call will take the first 0-4 bytes, and the second call the next 4-8 bytes.

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


[Lldb-commits] [lldb] [lldb] Reduce max-children-count default to readable size (PR #139826)

2025-05-15 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.

As an 80x24 terminal user, I approve of this change :-)

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


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

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

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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

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


@@ -1113,17 +1123,25 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 ModuleSpec module_spec(module_file_spec);
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
-num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+FileSpec file_spec(filename);
+re_compute_check_inlines(file_spec);

labath wrote:

What's up why the lambda? Is there any reason to not compute this directly on 
line 1105? AFAICT, nothing between here and there affects the computed result.

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


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

2025-05-15 Thread Dhruv Srivastava via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> I had thought about also including a check on the target to see if it was the 
> `DAP.target`, but again during launch or attach commands we may not know 
> which target we need to focus on yet.

Can we use the selected target until we've decided on the dap target? I guess 
that still leaves the possibility that the launch commands create multiple 
targets and that you temporarily see events belonging to the wrong target 
before another target was selected, but I'm not sure how to avoid that. Unless 
there's a way to queue up events? I'd need to look at the code in more detail 
to figure out how that works exactly (or ask @jimingham). 

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


[Lldb-commits] [lldb] bcb1227 - [lldb][AIX] Adding NativeThreadAIX (#139537)

2025-05-15 Thread via lldb-commits

Author: Dhruv Srivastava
Date: 2025-05-16T11:30:07+05:30
New Revision: bcb1227c3c1cc904fe6bc724b78c8c737234c709

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

LOG: [lldb][AIX] Adding NativeThreadAIX (#139537)

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

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

**Description:**
Adding NativeThreadAIX base files, 
to be integrated with already merged NativeProcessAIX.

Added: 
lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
lldb/source/Plugins/Process/AIX/NativeThreadAIX.h

Modified: 
lldb/source/Plugins/Process/AIX/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
index 9a3c77bd2ffeb..911f30349ef52 100644
--- a/lldb/source/Plugins/Process/AIX/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_library(lldbPluginProcessAIX
   NativeProcessAIX.cpp
+  NativeThreadAIX.cpp
 
   LINK_LIBS
 lldbCore

diff  --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
new file mode 100644
index 0..3bb608168ce30
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
@@ -0,0 +1,58 @@
+//===-- NativeThreadAIX.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() { return ""; }
+
+lldb::StateType NativeThreadAIX::GetState() { return m_state; }
+
+bool NativeThreadAIX::GetStopReason(ThreadStopInfo &stop_info,
+std::string &description) {
+  return false;
+}
+
+Status NativeThreadAIX::SetWatchpoint(lldb::addr_t addr, size_t size,
+  uint32_t watch_flags, bool hardware) {
+  return Status("Unable to Set hardware watchpoint.");
+}
+
+Status NativeThreadAIX::RemoveWatchpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware watchpoint failed.");
+}
+
+Status NativeThreadAIX::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
+  return Status("Unable to set hardware breakpoint.");
+}
+
+Status NativeThreadAIX::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware breakpoint failed.");
+}
+
+NativeProcessAIX &NativeThreadAIX::GetProcess() {
+  return static_cast(m_process);
+}
+
+const NativeProcessAIX &NativeThreadAIX::GetProcess() const {
+  return static_cast(m_process);
+}
+
+llvm::Expected>
+NativeThreadAIX::GetSiginfo() const {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Not implemented");
+}

diff  --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
new file mode 100644
index 0..e32d3db2c5fa2
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
@@ -0,0 +1,53 @@
+//===-- NativeThreadAIX.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_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+#define LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+namespace lldb_private::process_aix {
+
+class NativeProcessAIX;
+
+class NativeThreadAIX : public NativeThreadProtocol {
+  friend class NativeProcessAIX;
+
+public:
+  NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid);
+
+  // NativeThreadProtocol Interface
+  std::string GetName() override;
+
+  lldb::StateType GetState() override;
+
+  bool GetStopReason(ThreadStopInfo &stop_info,
+ std::string &description) override;
+
+  Status

[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-15 Thread Dhruv Srivastava via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> We do support the `startDebugging` reverse request 
> https://microsoft.github.io/debug-adapter-protocol/specification#Reverse_Requests_StartDebugging.
>  I use this to attach to multiple processes when tests are running from some 
> scripts that involve multiple processes. I use the script hook we have
> 
> https://github.com/llvm/llvm-project/blob/680b3b742da02972bc0b5298b6f472d2b95ca90a/lldb/tools/lldb-dap/DAP.h#L135
> 
> to call this from a python script. With the lldb-dap server mode we can 
> handle multiple DAP sessions from the same binary, or you can have lldb-dap 
> launch one instance per debug session. The DAP doesn't really have a way to 
> have multiple processes per debug session, but it does allow for multiple 
> debug sessions in general. Compound launch configurations are one way to get 
> this setup 
> https://code.visualstudio.com/docs/debugtest/debugging-configuration#_compound-launch-configurations
>  for example, you could have a server and a client in a compound launch 
> configuration.

Cool, I knew we supported the request but I didn't know how that was hooked up. 
So it seems like this may be better supported than I thought. In that case we 
should definitely make sure we test that configuration and make sure it keeps 
working.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -78,13 +78,13 @@ def waitUntil(self, condition_callback):
 time.sleep(0.5)
 return False
 
-def verify_breakpoint_hit(self, breakpoint_ids):
+def verify_breakpoint_hit(self, breakpoint_ids, timeout=timeoutval):

JDevlieghere wrote:

Any objections to changing `timeoutval` to `DEFAULT_TIMEOUT`? If that's too 
much churn for this PR, happy have that be a separate PR.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

Overall looks good. Reviewing this, I think this could probably be broken down 
further into NFC-ish changes, but I'm not sure it's worth the overhead of doing 
that. No need to do it on my behalf at least. 

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -67,7 +67,7 @@ def test_core_file_source_mapping_array(self):
 self.create_debug_adapter()
 
 source_map = [["/home/labath/test", current_dir]]
-self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
+self.attach(program=exe_file, coreFile=core_file, sourceMap=source_map)

JDevlieghere wrote:

IIf you use `*args` you don't need this anymore.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -487,115 +453,36 @@ def cleanup():
 
 response = self.dap_server.request_launch(
 program,
-args=args,
-cwd=cwd,
-env=env,
 stopOnEntry=stopOnEntry,
-disableASLR=disableASLR,
-disableSTDIO=disableSTDIO,
-shellExpandArguments=shellExpandArguments,
-trace=trace,
-initCommands=initCommands,
-preRunCommands=preRunCommands,
-stopCommands=stopCommands,
-exitCommands=exitCommands,
-terminateCommands=terminateCommands,
-sourcePath=sourcePath,
-debuggerRoot=debuggerRoot,
-launchCommands=launchCommands,
-sourceMap=sourceMap,
-runInTerminal=runInTerminal,
-postRunCommands=postRunCommands,
-enableAutoVariableSummaries=enableAutoVariableSummaries,
-displayExtendedBacktrace=displayExtendedBacktrace,
-enableSyntheticChildDebugging=enableSyntheticChildDebugging,
-commandEscapePrefix=commandEscapePrefix,
-customFrameFormat=customFrameFormat,
-customThreadFormat=customThreadFormat,
+**kwargs,

JDevlieghere wrote:

Nice :-) 

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -263,46 +262,61 @@ def set_global(self, name, value, id=None):
 return self.dap_server.request_setVariable(2, name, str(value), id=id)
 
 def stepIn(
-self, threadId=None, targetId=None, waitForStop=True, 
granularity="statement"
+self,
+threadId=None,
+targetId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
 ):
 response = self.dap_server.request_stepIn(
 threadId=threadId, targetId=targetId, granularity=granularity
 )
 self.assertTrue(response["success"])
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOver(self, threadId=None, waitForStop=True, 
granularity="statement"):
+def stepOver(
+self,
+threadId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
+):
 self.dap_server.request_next(threadId=threadId, 
granularity=granularity)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOut(self, threadId=None, waitForStop=True):
+def stepOut(self, threadId=None, waitForStop=True, timeout=timeoutval):
 self.dap_server.request_stepOut(threadId=threadId)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def continue_to_next_stop(self):
-self.dap_server.request_continue()
-return self.dap_server.wait_for_stopped()
+def verify_continue(self):

JDevlieghere wrote:

Maybe just:
```suggestion
def continue(self):
```
The "verification" seems like it's an implementation detail and raw calls to 
this look rather weird (I originally thought the "verification" was the stop, 
which it isn't). 

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -487,115 +453,36 @@ def cleanup():
 
 response = self.dap_server.request_launch(
 program,
-args=args,
-cwd=cwd,
-env=env,
 stopOnEntry=stopOnEntry,
-disableASLR=disableASLR,
-disableSTDIO=disableSTDIO,
-shellExpandArguments=shellExpandArguments,
-trace=trace,
-initCommands=initCommands,
-preRunCommands=preRunCommands,
-stopCommands=stopCommands,
-exitCommands=exitCommands,
-terminateCommands=terminateCommands,
-sourcePath=sourcePath,
-debuggerRoot=debuggerRoot,
-launchCommands=launchCommands,
-sourceMap=sourceMap,
-runInTerminal=runInTerminal,
-postRunCommands=postRunCommands,
-enableAutoVariableSummaries=enableAutoVariableSummaries,
-displayExtendedBacktrace=displayExtendedBacktrace,
-enableSyntheticChildDebugging=enableSyntheticChildDebugging,
-commandEscapePrefix=commandEscapePrefix,
-customFrameFormat=customFrameFormat,
-customThreadFormat=customThreadFormat,
+**kwargs,
 )
 
 if expectFailure:
 return response
-
 if not (response and response["success"]):
 self.assertTrue(
 response["success"],
 "launch failed (%s)" % (response["body"]["error"]["format"]),
 )
+if stopOnEntry:
+self.dap_server.wait_for_stopped(timeout)
+
 return response
 
 def build_and_launch(
 self,
 program,
-args=None,
-cwd=None,
-env=None,
-stopOnEntry=False,
-disableASLR=False,
-disableSTDIO=False,
-shellExpandArguments=False,
-trace=False,
-initCommands=None,
-preRunCommands=None,
-stopCommands=None,
-exitCommands=None,
-terminateCommands=None,
-sourcePath=None,
-debuggerRoot=None,
-sourceInitFile=False,
-runInTerminal=False,
-disconnectAutomatically=True,
-postRunCommands=None,
+/,

JDevlieghere wrote:

What's this? Could this use `*args, **kwargs`? 

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


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-15 Thread via lldb-commits


@@ -193,7 +188,7 @@ class LLDB_API SBValue {
   /// and also if the target can be run to figure out the dynamic
   /// type of the child value.
   ///
-  /// \param[in] can_create_synthetic
+  /// \param[in] use_synthetic

jimingham wrote:

I think this change makes sense, but there must be a better term for this.  
use_synthetic doesn't actually tell you anything about what you are going to 
use synthetic FOR, and is confusing because it does NOT mean "use the children 
produced by the synthetic child provider for this type", which is almost always 
what we mean by "using synthetic".
Seems to me this bool is forcing "treat_as_array" behavior for a pointer.  
Would that be an accurate name for what this parameter controls?

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


[Lldb-commits] [lldb] [LLDB][Progress-On-Dap] Have indeterminate progress actually send events. (PR #140162)

2025-05-15 Thread Jacob Lalonde via lldb-commits

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

>From 0673dc530a91cb2dd1bdd60dd5136d64e4ed48e8 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 15 May 2025 16:37:06 -0700
Subject: [PATCH 1/2] Have interderminate events actually broadcast to dap

---
 .../API/tools/lldb-dap/progress/TestDAP_Progress.py   |  2 +-
 lldb/tools/lldb-dap/ProgressEvent.cpp | 11 +++
 lldb/tools/lldb-dap/ProgressEvent.h   |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index fee63655de0da..c87d2afe36821 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -81,7 +81,7 @@ def test(self):
 
 self.verify_progress_events(
 expected_title="Progress tester: Initial Indeterminate Detail",
-expected_message="Step 1",
+expected_message="Step 2",
 only_verify_first_update=True,
 )
 
diff --git a/lldb/tools/lldb-dap/ProgressEvent.cpp 
b/lldb/tools/lldb-dap/ProgressEvent.cpp
index 6a4978c055e51..b6b62efb5f33c 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.cpp
+++ b/lldb/tools/lldb-dap/ProgressEvent.cpp
@@ -77,16 +77,19 @@ ProgressEvent::Create(uint64_t progress_id, 
std::optional message,
   if (event.GetEventType() == progressStart && event.GetEventName().empty())
 return std::nullopt;
 
-  if (prev_event && prev_event->EqualsForIDE(event))
+  if (prev_event && prev_event->EqualsForIDE(event, total))
 return std::nullopt;
 
   return event;
 }
 
-bool ProgressEvent::EqualsForIDE(const ProgressEvent &other) const {
+bool ProgressEvent::EqualsForIDE(const ProgressEvent &other, uint64_t total) 
const {
   return m_progress_id == other.m_progress_id &&
- m_event_type == other.m_event_type &&
- m_percentage == other.m_percentage;
+ m_event_type == other.m_event_type && 
+ // If we check the percentage of a non-deterministic event
+ // we will basically never send the event, because N+1/Uint64_max
+ // will always be an infinitesimally small change.
+ (total != UINT64_MAX && m_percentage == other.m_percentage);
 }
 
 ProgressEventType ProgressEvent::GetEventType() const { return m_event_type; }
diff --git a/lldb/tools/lldb-dap/ProgressEvent.h 
b/lldb/tools/lldb-dap/ProgressEvent.h
index d1b9b9dd887cd..ab3487c1dbc3d 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.h
+++ b/lldb/tools/lldb-dap/ProgressEvent.h
@@ -54,7 +54,7 @@ class ProgressEvent {
   /// \return
   ///   \b true if two event messages would result in the same event for 
the
   ///   IDE, e.g. same rounded percentage.
-  bool EqualsForIDE(const ProgressEvent &other) const;
+  bool EqualsForIDE(const ProgressEvent &other, uint64_t total) const;
 
   llvm::StringRef GetEventName() const;
 

>From ad616dcb2f492f0c56389d629adb8f17a750563d Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 15 May 2025 16:44:56 -0700
Subject: [PATCH 2/2] GCF

---
 lldb/tools/lldb-dap/ProgressEvent.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/ProgressEvent.cpp 
b/lldb/tools/lldb-dap/ProgressEvent.cpp
index b6b62efb5f33c..36ecb3a8cc095 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.cpp
+++ b/lldb/tools/lldb-dap/ProgressEvent.cpp
@@ -83,9 +83,10 @@ ProgressEvent::Create(uint64_t progress_id, 
std::optional message,
   return event;
 }
 
-bool ProgressEvent::EqualsForIDE(const ProgressEvent &other, uint64_t total) 
const {
+bool ProgressEvent::EqualsForIDE(const ProgressEvent &other,
+ uint64_t total) const {
   return m_progress_id == other.m_progress_id &&
- m_event_type == other.m_event_type && 
+ m_event_type == other.m_event_type &&
  // If we check the percentage of a non-deterministic event
  // we will basically never send the event, because N+1/Uint64_max
  // will always be an infinitesimally small change.

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


[Lldb-commits] [lldb] [LLDB][Progress-On-Dap] Have indeterminate progress actually send events. (PR #140162)

2025-05-15 Thread Jacob Lalonde via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB][Progress-On-Dap] Have indeterminate progress actually send events. (PR #140162)

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


@@ -77,16 +77,19 @@ ProgressEvent::Create(uint64_t progress_id, 
std::optional message,
   if (event.GetEventType() == progressStart && event.GetEventName().empty())
 return std::nullopt;
 
-  if (prev_event && prev_event->EqualsForIDE(event))
+  if (prev_event && prev_event->EqualsForIDE(event, total))
 return std::nullopt;
 
   return event;
 }
 
-bool ProgressEvent::EqualsForIDE(const ProgressEvent &other) const {
+bool ProgressEvent::EqualsForIDE(const ProgressEvent &other, uint64_t total) 
const {
   return m_progress_id == other.m_progress_id &&
- m_event_type == other.m_event_type &&
- m_percentage == other.m_percentage;
+ m_event_type == other.m_event_type && 
+ // If we check the percentage of a non-deterministic event

ashgti wrote:

Isn't `m_percentage` a nullopt when the `total` is UINT64_MAX? Or is there a 
logic issue in lines 35-65?

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


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Summarizing the problem to make sure I understand: with the new launch/attach 
flow, we set the breakpoints in the dummy target before the actual target is 
created. If the target is created through launch commands, we're calling 
SetTarget with the currently selected target. By that time, we've already 
missed events belong to the new target. 

With this PR, we mimic what the default event handler does, which is listen to 
all target events. I think the problem with this approach is that now we're 
going to be broadcasting events for targets that are not the focus of the 
current debug session (i.e. the selected target). It should be easy to verify 
this by running a script that creates a second target and seeing if we now 
broadcast the events. If my theory is correct, then we would have to filter 
events not belonging to the selected target. 

Interestingly, I was thinking about multi-target/multi-process support in DAP 
earlier this week. I had someone reach out to ask questions about this. I'll 
file an issue to track this, but we should keep that use case in mind as we 
design this.

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


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

2025-05-15 Thread via lldb-commits

https://github.com/ravindra-shinde2 updated 
https://github.com/llvm/llvm-project/pull/102601



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

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

ashgti wrote:

> Summarizing the problem to make sure I understand: with the new launch/attach 
> flow, we set the breakpoints in the dummy target before the actual target is 
> created. If the target is created through launch commands, we're calling 
> SetTarget with the currently selected target after we're done running the 
> launch commands. By that time, we may have already missed events belong to 
> the new target.
> 
> With this PR, we mimic what the default event handler does, which is listen 
> to all target events. I think the problem with this approach is that now 
> we're going to be broadcasting events for targets that are not the focus of 
> the current debug session (i.e. the selected target). It should be easy to 
> verify this by running a script that creates a second target and seeing if we 
> now broadcast the events. If my theory is correct, then we would have to 
> filter events not belonging to the selected target.

I had thought about also including a check on the target to see if it was the 
`DAP.target`, but again during launch or attach commands we may not know which 
target we need to focus on yet.

> Interestingly, I was thinking about multi-target/multi-process support in DAP 
> earlier this week. I had someone reach out to ask questions about this. I'll 
> file an issue to track this, but we should keep that use case in mind as we 
> design this.

We do support the `startDebugging` reverse request 
https://microsoft.github.io/debug-adapter-protocol/specification#Reverse_Requests_StartDebugging.
 I use this to attach to multiple processes when tests are running from some 
scripts that involve multiple processes. I use the script hook we have 
https://github.com/llvm/llvm-project/blob/680b3b742da02972bc0b5298b6f472d2b95ca90a/lldb/tools/lldb-dap/DAP.h#L135
 to call this from a python script. With the lldb-dap server mode we can handle 
multiple DAP sessions from the same binary, or you can have lldb-dap launch one 
instance per debug session. The DAP doesn't really have a way to have multiple 
processes per debug session, but it does allow for multiple debug sessions in 
general. Compound launch configurations are one way to get this setup 
https://code.visualstudio.com/docs/debugtest/debugging-configuration#_compound-launch-configurations
 for example, you could have a server and a client in a compound launch 
configuration. 

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


[Lldb-commits] [lldb] [lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (PR #139817)

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

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/139817



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Use std::optional::value_or (NFC) (PR #140011)

2025-05-15 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use llvm::unique (NFC) (PR #139910)

2025-05-15 Thread Alex Langford via lldb-commits

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

Makes sense. `std::unique` doesn't invalidate the end iterator, so I believe 
this should be ok.

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-15 Thread via lldb-commits

https://github.com/nd updated https://github.com/llvm/llvm-project/pull/139862

>From f6b1c03607582e580f0b3167c0e337c35c31cbeb Mon Sep 17 00:00:00 2001
From: "Dmitry.Neverov" 
Date: Wed, 14 May 2025 11:09:07 +0200
Subject: [PATCH] [lldb] Fix race condition during iteration through modules
 (#139283)

Use of ModuleIterable ensures modules don't change during iteration.
---
 lldb/source/Target/Target.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7f61f8689fb95..9660fc97970b0 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1511,8 +1511,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t 
watch_id,
 
 ModuleSP Target::GetExecutableModule() {
   // search for the first executable in the module list
-  for (size_t i = 0; i < m_images.GetSize(); ++i) {
-ModuleSP module_sp = m_images.GetModuleAtIndex(i);
+  for (ModuleSP module_sp : m_images.Modules()) {
 lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
 if (obj == nullptr)
   continue;

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


[Lldb-commits] [lldb] Fix race condition during iteration through modules (#139283) (PR #139862)

2025-05-15 Thread Jonas Devlieghere via lldb-commits

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

Thank you!

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -263,46 +262,61 @@ def set_global(self, name, value, id=None):
 return self.dap_server.request_setVariable(2, name, str(value), id=id)
 
 def stepIn(
-self, threadId=None, targetId=None, waitForStop=True, 
granularity="statement"
+self,
+threadId=None,
+targetId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
 ):
 response = self.dap_server.request_stepIn(
 threadId=threadId, targetId=targetId, granularity=granularity
 )
 self.assertTrue(response["success"])
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOver(self, threadId=None, waitForStop=True, 
granularity="statement"):
+def stepOver(
+self,
+threadId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
+):
 self.dap_server.request_next(threadId=threadId, 
granularity=granularity)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOut(self, threadId=None, waitForStop=True):
+def stepOut(self, threadId=None, waitForStop=True, timeout=timeoutval):
 self.dap_server.request_stepOut(threadId=threadId)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def continue_to_next_stop(self):
-self.dap_server.request_continue()
-return self.dap_server.wait_for_stopped()
+def verify_continue(self):

ashgti wrote:

`continue` isn't a valid method name in python, I tried that at first, but its 
a keyword. I'm open to other suggestions.

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


[Lldb-commits] [lldb] [lldb] Limit formatter-section extractor range (PR #140139)

2025-05-15 Thread via lldb-commits

https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/140139

The formatter extraction would look at too much data for one type.
This PR limits the size of the `DataExtractor` to the one specified in the 
record size before - previously, the whole section was looked at.
Similarly, `ForEachFormatterInModule` skipped zero-bytes but didn't stop when 
reaching the end of the extractor.

I hit both cases in an even smaller test than the one currently in the repo, 
but I tried this on Windows[^1]. In my executable, the formatter section 
started with my specified formatter and was padded to 512 bytes with zeroes.
I'd guess this should've come up in the existing test case, so macOS might do 
something different here[?].

Test File

```c
struct Point {
  int x;
  int y;
};

__attribute__((used, section(".lldbformatters"))) const char my_string[] = {
0x01, // version
0x12, // record size
0x05, // type size
'P',  'o', 'i', 'n', 't',
0x00, // flags
0x00, // signature
0x09, // byte-code length
0x01, // drop
0x22, // push str
0x05, // str len
'A',  'A', 'A', 'A', 'A',
0x13, // return
};

int main() {
  Point a{3, 4};
  return a.x + a.y; // break here
}
```
 

[^1]: I had to change the section name matching to use an 8 byte name in the 
[PE/COFF](https://github.com/llvm/llvm-project/blob/acdba28e148ac1e94d6c041f9911230e1e90e9cd/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp#L1003)
 reader, since executables on Windows [can't have section names longer than 8 
bytes](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers)
 (actually they can, and in MinGW they do, but I couldn't get `clang-cl` to 
generate such a binary).



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

2025-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -263,46 +262,61 @@ def set_global(self, name, value, id=None):
 return self.dap_server.request_setVariable(2, name, str(value), id=id)
 
 def stepIn(
-self, threadId=None, targetId=None, waitForStop=True, 
granularity="statement"
+self,
+threadId=None,
+targetId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
 ):
 response = self.dap_server.request_stepIn(
 threadId=threadId, targetId=targetId, granularity=granularity
 )
 self.assertTrue(response["success"])
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOver(self, threadId=None, waitForStop=True, 
granularity="statement"):
+def stepOver(
+self,
+threadId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
+):
 self.dap_server.request_next(threadId=threadId, 
granularity=granularity)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOut(self, threadId=None, waitForStop=True):
+def stepOut(self, threadId=None, waitForStop=True, timeout=timeoutval):
 self.dap_server.request_stepOut(threadId=threadId)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def continue_to_next_stop(self):
-self.dap_server.request_continue()
-return self.dap_server.wait_for_stopped()
+def verify_continue(self):

JDevlieghere wrote:

Gotcha. Hmm, maybe `do_continue` or `send_continue`? They're only marginally 
better. 

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


[Lldb-commits] [lldb] [lldb] Limit formatter-section extractor range (PR #140139)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)


Changes

The formatter extraction would look at too much data for one type.
This PR limits the size of the `DataExtractor` to the one specified in the 
record size before - previously, the whole section was looked at.
Similarly, `ForEachFormatterInModule` skipped zero-bytes but didn't stop when 
reaching the end of the extractor.

I hit both cases in an even smaller test than the one currently in the repo, 
but I tried this on Windows[^1]. In my executable, the formatter section 
started with my specified formatter and was padded to 512 bytes with zeroes.
I'd guess this should've come up in the existing test case, so macOS might do 
something different here[?].

Test File ```c struct Point { int x; int y; }; __attribute__((used, section(".lldbformatters"))) const char my_string[] = { 0x01, // version 0x12, // record size 0x05, // type size 'P', 'o', 'i', 'n', 't', 0x00, // flags 0x00, // signature 0x09, // byte-code length 0x01, // drop 0x22, // push str 0x05, // str len 'A', 'A', 'A', 'A', 'A', 0x13, // return }; int main() { Point a{3, 4}; return a.x + a.y; // break here } ```
[^1]: I had to change the section name matching to use an 8 byte name in the [PE/COFF](https://github.com/llvm/llvm-project/blob/acdba28e148ac1e94d6c041f9911230e1e90e9cd/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp#L1003) reader, since executables on Windows [can't have section names longer than 8 bytes](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers) (actually they can, and in MinGW they do, but I couldn't get `clang-cl` to generate such a binary). --- Full diff: https://github.com/llvm/llvm-project/pull/140139.diff 1 Files Affected: - (modified) lldb/source/DataFormatters/FormatterSection.cpp (+6-2) ``diff diff --git a/lldb/source/DataFormatters/FormatterSection.cpp b/lldb/source/DataFormatters/FormatterSection.cpp index 1de633f4998e0..72979ac1923e8 100644 --- a/lldb/source/DataFormatters/FormatterSection.cpp +++ b/lldb/source/DataFormatters/FormatterSection.cpp @@ -57,11 +57,15 @@ static void ForEachFormatterInModule( cursor.seek(cursor.tell() - 1); break; } +if (!cursor || cursor.tell() >= section_size) + break; + uint64_t version = section.getULEB128(cursor); uint64_t record_size = section.getULEB128(cursor); if (version == 1) { - llvm::DataExtractor record(section.getData().drop_front(cursor.tell()), - le, addr_size); + llvm::DataExtractor record( + section.getData().drop_front(cursor.tell()).take_front(record_size), + le, addr_size); llvm::DataExtractor::Cursor cursor(0); uint64_t type_size = record.getULEB128(cursor); llvm::StringRef type_name = record.getBytes(cursor, type_size); `` https://github.com/llvm/llvm-project/pull/140139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread Jacob Lalonde via lldb-commits


@@ -584,22 +584,26 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch,
   // 64b ELF have a 4 byte pad.
   if (data.GetAddressByteSize() == 8)
 offset += 4;
-  // Not every stop signal has a valid address, but that will get resolved in
-  // the unix_signals.GetSignalDescription() call below.
-  if (unix_signals.GetShouldStop(si_signo)) {
+
+  if (si_code < 0) {

Jlalond wrote:

So this check is my primary concern with my own code. In the Linux source I 
linked they define user space as `<0`, and I followed suite here. I would 
ideally like to make this a static function on LinuxSignals, but wanted to get 
feedback on how we want to implement this.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -78,13 +78,13 @@ def waitUntil(self, condition_callback):
 time.sleep(0.5)
 return False
 
-def verify_breakpoint_hit(self, breakpoint_ids):
+def verify_breakpoint_hit(self, breakpoint_ids, timeout=timeoutval):

ashgti wrote:

Done.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -263,46 +262,61 @@ def set_global(self, name, value, id=None):
 return self.dap_server.request_setVariable(2, name, str(value), id=id)
 
 def stepIn(
-self, threadId=None, targetId=None, waitForStop=True, 
granularity="statement"
+self,
+threadId=None,
+targetId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
 ):
 response = self.dap_server.request_stepIn(
 threadId=threadId, targetId=targetId, granularity=granularity
 )
 self.assertTrue(response["success"])
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOver(self, threadId=None, waitForStop=True, 
granularity="statement"):
+def stepOver(
+self,
+threadId=None,
+waitForStop=True,
+granularity="statement",
+timeout=timeoutval,
+):
 self.dap_server.request_next(threadId=threadId, 
granularity=granularity)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def stepOut(self, threadId=None, waitForStop=True):
+def stepOut(self, threadId=None, waitForStop=True, timeout=timeoutval):
 self.dap_server.request_stepOut(threadId=threadId)
 if waitForStop:
-return self.dap_server.wait_for_stopped()
+return self.dap_server.wait_for_stopped(timeout)
 return None
 
-def continue_to_next_stop(self):
-self.dap_server.request_continue()
-return self.dap_server.wait_for_stopped()
+def verify_continue(self):

ashgti wrote:

I went with `do_continue`.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -16,8 +16,10 @@
 
 
 def spawn_and_wait(program, delay):
+print("spawn_and_wait started...", time.time())

ashgti wrote:

Removed the extra prints.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -67,7 +67,7 @@ def test_core_file_source_mapping_array(self):
 self.create_debug_adapter()
 
 source_map = [["/home/labath/test", current_dir]]
-self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
+self.attach(program=exe_file, coreFile=core_file, sourceMap=source_map)

ashgti wrote:

For `attach` and `launch`, I wanted them to require kwargs because they have so 
many arguments and almost all of them are optional. `launch` I only left 
`program` as a positional arg for the simplicity of `self.launch(program)` but 
the rest, I was using the syntax that requires kwargs.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -487,115 +453,36 @@ def cleanup():
 
 response = self.dap_server.request_launch(
 program,
-args=args,
-cwd=cwd,
-env=env,
 stopOnEntry=stopOnEntry,
-disableASLR=disableASLR,
-disableSTDIO=disableSTDIO,
-shellExpandArguments=shellExpandArguments,
-trace=trace,
-initCommands=initCommands,
-preRunCommands=preRunCommands,
-stopCommands=stopCommands,
-exitCommands=exitCommands,
-terminateCommands=terminateCommands,
-sourcePath=sourcePath,
-debuggerRoot=debuggerRoot,
-launchCommands=launchCommands,
-sourceMap=sourceMap,
-runInTerminal=runInTerminal,
-postRunCommands=postRunCommands,
-enableAutoVariableSummaries=enableAutoVariableSummaries,
-displayExtendedBacktrace=displayExtendedBacktrace,
-enableSyntheticChildDebugging=enableSyntheticChildDebugging,
-commandEscapePrefix=commandEscapePrefix,
-customFrameFormat=customFrameFormat,
-customThreadFormat=customThreadFormat,
+**kwargs,
 )
 
 if expectFailure:
 return response
-
 if not (response and response["success"]):
 self.assertTrue(
 response["success"],
 "launch failed (%s)" % (response["body"]["error"]["format"]),
 )
+if stopOnEntry:
+self.dap_server.wait_for_stopped(timeout)
+
 return response
 
 def build_and_launch(
 self,
 program,
-args=None,
-cwd=None,
-env=None,
-stopOnEntry=False,
-disableASLR=False,
-disableSTDIO=False,
-shellExpandArguments=False,
-trace=False,
-initCommands=None,
-preRunCommands=None,
-stopCommands=None,
-exitCommands=None,
-terminateCommands=None,
-sourcePath=None,
-debuggerRoot=None,
-sourceInitFile=False,
-runInTerminal=False,
-disconnectAutomatically=True,
-postRunCommands=None,
+/,

ashgti wrote:

`/` is a separator to mark the end of the positional args. I switched it to `*` 
which means the remainder of the args are required to be kwargs. 

At a high level its:
```
def name(positional_only_parameters, /, positional_or_keyword_parameters,
 *, keyword_only_parameters):
```

I was trying to DRY up the definitions by using kwargs to forward to the 
dap_server.py method.

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


[Lldb-commits] [lldb] [lldb-dap] Adding additional asserts to unit tests. (PR #140107)

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


@@ -16,8 +16,10 @@
 
 
 def spawn_and_wait(program, delay):
+print("spawn_and_wait started...", time.time())

da-viper wrote:

I don't think print statement works in tests. 

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


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

The recent change to the startup flow has highlighted a problem with breakpoint 
events being missed.

Previously, we would handle `attach`/`launch` commands immediately, leaving the 
process in a suspended until the `configurationDone` command was sent.

If a breakpoint was set between the `attach`/`launch` and the 
`configurationDone` request, it may have been resolved immediately, but there 
was a chance the module was not yet loaded.

With the new startup flow, the breakpoint is always set before the target is 
loaded. For some targets, this is fine and the breakpoint event fires 
eventually and marks the breakpoint as verified. However, if a 
`attach`/`launch` request has `attachCommands`/`launchCommands` that create a 
new target then we will miss the breakpoint events associated with that target 
because we haven't configured the target broadcaster for the debugger. We only 
configure that in the `DAP::SetTarget` call, which happens after the events 
would have occurred.

To address this, I adjusted the `DAP::EventThread` to listen for the broadcast 
class instead of an individual broadcaster.

I think this may also fix the unstable `TestDAP_breakpointEvents` tests.

We're not using the `Debugger::DefaultEventHandler` 
https://github.com/llvm/llvm-project/blob/090f46d8d246762401c41c5486dde299382d6c90/lldb/source/Core/Debugger.cpp#L2048
 which is why these broadcast classes are not registered on our debugger 
instance in lldb-dap.

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


4 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+26-27) 
- (modified) lldb/tools/lldb-dap/DAP.h (+1-2) 
- (modified) lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp (+3-1) 
- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.cpp (+1-1) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 51f9da854f4b6..827ebb1465938 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -26,6 +26,7 @@
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBTarget.h"
 #include "lldb/Utility/IOObject.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-defines.h"
@@ -719,23 +720,7 @@ lldb::SBTarget DAP::CreateTarget(lldb::SBError &error) {
   return target;
 }
 
-void DAP::SetTarget(const lldb::SBTarget target) {
-  this->target = target;
-
-  if (target.IsValid()) {
-// Configure breakpoint event listeners for the target.
-lldb::SBListener listener = this->debugger.GetListener();
-listener.StartListeningForEvents(
-this->target.GetBroadcaster(),
-lldb::SBTarget::eBroadcastBitBreakpointChanged |
-lldb::SBTarget::eBroadcastBitModulesLoaded |
-lldb::SBTarget::eBroadcastBitModulesUnloaded |
-lldb::SBTarget::eBroadcastBitSymbolsLoaded |
-lldb::SBTarget::eBroadcastBitSymbolsChanged);
-listener.StartListeningForEvents(this->broadcaster,
- eBroadcastBitStopEventThread);
-  }
-}
+void DAP::SetTarget(const lldb::SBTarget target) { this->target = target; }
 
 bool DAP::HandleObject(const Message &M) {
   TelemetryDispatcher dispatcher(&debugger);
@@ -1489,17 +1474,31 @@ void DAP::ProgressEventThread() {
 }
 
 // All events from the debugger, target, process, thread and frames are
-// received in this function that runs in its own thread. We are using a
-// "FILE *" to output packets back to VS Code and they have mutexes in them
-// them prevent multiple threads from writing simultaneously so no locking
-// is required.
+// received in this function that runs in its own thread.
 void DAP::EventThread() {
   llvm::set_thread_name(transport.GetClientName() + ".event_handler");
-  lldb::SBEvent event;
+
+  // Configure the debugger listener for all events lldb-dap is interested in.
   lldb::SBListener listener = debugger.GetListener();
-  broadcaster.AddListener(listener, eBroadcastBitStopEventThread);
-  debugger.GetBroadcaster().AddListener(
-  listener, lldb::eBroadcastBitError | lldb::eBroadcastBitWarning);
+  listener.StartListeningForEventClass(
+  debugger, lldb::SBTarget::GetBroadcasterClassName(),
+  lldb::SBTarget::eBroadcastBitBreakpointChanged |
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded |
+  lldb::SBTarget::eBroadcastBitSymbolsChanged);
+  listener.StartListeningForEventClass(
+  debugger, lldb::SBProcess::GetBroadcasterClassName(),
+  lldb::SBProcess::eBroadcastBitStateChanged |
+  lldb::SBProcess::eBroadcastBitSTDOUT |
+  lldb::SBProcess::eBroadcastBitSTDERR);
+  listener.StartListeningForEvents(debugger.GetBroadcaster(),
+   lldb::SBDebugger::eBroadcastBitError |
+   

[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

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

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/140142

The recent change to the startup flow has highlighted a problem with breakpoint 
events being missed.

Previously, we would handle `attach`/`launch` commands immediately, leaving the 
process in a suspended until the `configurationDone` command was sent.

If a breakpoint was set between the `attach`/`launch` and the 
`configurationDone` request, it may have been resolved immediately, but there 
was a chance the module was not yet loaded.

With the new startup flow, the breakpoint is always set before the target is 
loaded. For some targets, this is fine and the breakpoint event fires 
eventually and marks the breakpoint as verified. However, if a 
`attach`/`launch` request has `attachCommands`/`launchCommands` that create a 
new target then we will miss the breakpoint events associated with that target 
because we haven't configured the target broadcaster for the debugger. We only 
configure that in the `DAP::SetTarget` call, which happens after the events 
would have occurred.

To address this, I adjusted the `DAP::EventThread` to listen for the broadcast 
class instead of an individual broadcaster.

I think this may also fix the unstable `TestDAP_breakpointEvents` tests.

We're not using the `Debugger::DefaultEventHandler` 
https://github.com/llvm/llvm-project/blob/090f46d8d246762401c41c5486dde299382d6c90/lldb/source/Core/Debugger.cpp#L2048
 which is why these broadcast classes are not registered on our debugger 
instance in lldb-dap.

>From ea5ee538a1ca384725f8166ec9289883683b52ce Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Thu, 15 May 2025 14:13:48 -0700
Subject: [PATCH] [lldb-dap] Listen for broadcast classes.

The recent change to the startup flow has highlighted a problem with
breakpoint events being missed.

Previously, we would handle `attach`/`launch` commands immediately,
leaving the process in a suspended until the `configurationDone` command
was sent.

If a breakpoint was set between the `attach`/`launch` and the
`configurationDone` request, it may have been resolved immediately, but
there was a chance the module was not yet loaded.

With the new startup flow, the breakpoint is always set before the
target is loaded. For some targets, this is fine and the breakpoint
event fires eventually and marks the breakpoint as verified. However,
if a `attach`/`launch` request has `attachCommands`/`launchCommands`
that create a new target then we will miss the breakpoint events
associated with that target because we haven't configured the target
broadcaster for the debugger. We only configure that in the
`DAP::SetTarget` call, which happens after the events would have
occurred.

To address this, I adjusted the `DAP::EventThread` to listen for the
broadcast class instead of an individual broadcaster.

I think this may also fix the unstable `TestDAP_breakpointEvents` tests.
---
 lldb/tools/lldb-dap/DAP.cpp   | 53 +--
 lldb/tools/lldb-dap/DAP.h |  3 +-
 .../lldb-dap/Handler/AttachRequestHandler.cpp |  4 +-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  2 +-
 4 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 51f9da854f4b6..827ebb1465938 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -26,6 +26,7 @@
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBTarget.h"
 #include "lldb/Utility/IOObject.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-defines.h"
@@ -719,23 +720,7 @@ lldb::SBTarget DAP::CreateTarget(lldb::SBError &error) {
   return target;
 }
 
-void DAP::SetTarget(const lldb::SBTarget target) {
-  this->target = target;
-
-  if (target.IsValid()) {
-// Configure breakpoint event listeners for the target.
-lldb::SBListener listener = this->debugger.GetListener();
-listener.StartListeningForEvents(
-this->target.GetBroadcaster(),
-lldb::SBTarget::eBroadcastBitBreakpointChanged |
-lldb::SBTarget::eBroadcastBitModulesLoaded |
-lldb::SBTarget::eBroadcastBitModulesUnloaded |
-lldb::SBTarget::eBroadcastBitSymbolsLoaded |
-lldb::SBTarget::eBroadcastBitSymbolsChanged);
-listener.StartListeningForEvents(this->broadcaster,
- eBroadcastBitStopEventThread);
-  }
-}
+void DAP::SetTarget(const lldb::SBTarget target) { this->target = target; }
 
 bool DAP::HandleObject(const Message &M) {
   TelemetryDispatcher dispatcher(&debugger);
@@ -1489,17 +1474,31 @@ void DAP::ProgressEventThread() {
 }
 
 // All events from the debugger, target, process, thread and frames are
-// received in this function that runs in its own thread. We are using a
-// "FILE *" to output packets back to VS Code and they have mutexes in them
-// them prevent multiple threads from writing simultaneously

[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-15 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/139969

>From ae324862f516ebb5be3206485476b586b22488b7 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sat, 10 May 2025 20:45:17 +0200
Subject: [PATCH 1/4] support assembly in BreakpointLocationsRequestHandler

---
 .../breakpoint/TestDAP_setBreakpoints.py  |  1 -
 .../TestDAP_setExceptionBreakpoints.py|  1 -
 .../TestDAP_setFunctionBreakpoints.py |  1 -
 lldb/tools/lldb-dap/DAP.h |  3 +
 .../Handler/BreakpointLocationsHandler.cpp| 77 +++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  | 11 +++
 .../lldb-dap/Handler/SourceRequestHandler.cpp |  4 +-
 7 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
index aae1251b17c93..26df2573555df 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
@@ -12,7 +12,6 @@
 import os
 
 
-@skip("Temporarily disable the breakpoint tests")
 class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
 def setUp(self):
 lldbdap_testcase.DAPTestCaseBase.setUp(self)
diff --git 
a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py
index 4dc8c5b3c7ded..92ac66cd44c5d 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py
@@ -10,7 +10,6 @@
 import lldbdap_testcase
 
 
-@skip("Temporarily disable the breakpoint tests")
 class TestDAP_setExceptionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
 @skipIfWindows
 def test_functionality(self):
diff --git 
a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py
index baaca4d974d5d..946595f639edc 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py
@@ -10,7 +10,6 @@
 import lldbdap_testcase
 
 
-@skip("Temporarily disable the breakpoint tests")
 class TestDAP_setFunctionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
 @skipIfWindows
 def test_set_and_clear(self):
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c1a1130b1e59f..587d15891530e 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -219,6 +219,9 @@ struct DAP {
   llvm::StringSet<> modules;
   /// @}
 
+  /// Number of lines of assembly code to show when no debug info is available.
+  uint32_t number_of_assembly_lines_for_nodebug = 32;
+
   /// Creates a new DAP sessions.
   ///
   /// \param[in] log
diff --git a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
index 2ac886c3a5d2c..9eea549d72b00 100644
--- a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
@@ -7,7 +7,7 @@
 
//===--===//
 
 #include "DAP.h"
-#include "JSONUtils.h"
+#include "LLDBUtils.h"
 #include "RequestHandler.h"
 #include 
 
@@ -19,19 +19,50 @@ namespace lldb_dap {
 llvm::Expected
 BreakpointLocationsRequestHandler::Run(
 const protocol::BreakpointLocationsArguments &args) const {
-  std::string path = args.source.path.value_or("");
   uint32_t start_line = args.line;
   uint32_t start_column = args.column.value_or(LLDB_INVALID_COLUMN_NUMBER);
   uint32_t end_line = args.endLine.value_or(start_line);
   uint32_t end_column =
   args.endColumn.value_or(std::numeric_limits::max());
 
+  // Find all relevant lines & columns
+  llvm::SmallVector, 8> locations;
+  if (args.source.sourceReference) {
+AddAssemblyBreakpointLocations(locations, *args.source.sourceReference,
+   start_line, end_line);
+  } else {
+std::string path = args.source.path.value_or("");
+AddSourceBreakpointLocations(locations, std::move(path), start_line,
+ start_column, end_line, end_column);
+  }
+
+  // The line entries are sorted by addresses, but we must return the list
+  // ordered by line / column position.
+  std::sort(locations.begin(), locations.end());
+  locations.erase(llvm::unique(locations), locations.end());
+
+  std::vector breakpoint_locations;
+  for (auto &l : locations) {
+protocol::BreakpointLocation lc;
+lc.line = l.first;
+lc.column = l.second;
+breakpoint_locations.push_back(std::move(lc));
+  }
+
+  return protocol::BreakpointLocationsResponseBody{
+  /*breakpoints=*/std::move(breakpoint_locations)};
+}
+
+template 
+void BreakpointLocat

[Lldb-commits] [lldb] [LLDB] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread Jacob Lalonde via lldb-commits

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

Recently, I was on an issue that generated a large number of Coredumps, and 
every time in both LLDB and GDB the signal was just `SIGSEGV`.

This was frustrating because we would expect a `SIGSEGV` to have an address, or 
ideally even bounds. After some digging I found the `si_code` consistently was 
-6. With some help from [@cdown](https://github.com/cdown), we found neither 
LLDB or GDB supports the si_codes sent from [user 
space](https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/siginfo.h#L185).

Excerpted from the sigaction man page.
```
   For a regular signal, the following list shows the values which
   can be placed in si_code for any signal, along with the reason
   that the signal was generated.
```

For which I added all of the si_codes to every Linux signal. Now for the 
Coredump that triggered this whole investigation we get the accurate and now 
very informative summary.

https://github.com/user-attachments/assets/5149f781-ef21-4491-a077-8fac862fbc20";
 />


Importantly, I didn't add an equivalent of `siginfo_t` to ELFSigInfo, and I 
think we should open an issue for this to make a (build) platform agnostic 
struct of siginfo_t. I'll defer to your expertise @labath and @DavidSpickett 


>From 86ec6c076b9cf8e7afeb7d6bb0e334434f6e0d9e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 15 May 2025 13:57:11 -0700
Subject: [PATCH 1/4] Update ThreadElfCore

---
 lldb/include/lldb/Target/UnixSignals.h  |  6 --
 .../Plugins/Process/Utility/LinuxSignals.cpp| 17 ++---
 .../Plugins/Process/elf-core/ThreadElfCore.cpp  | 10 +++---
 .../Plugins/Process/elf-core/ThreadElfCore.h|  6 ++
 lldb/source/Target/UnixSignals.cpp  |  9 +++--
 5 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..a1807d69f329b 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -36,7 +36,9 @@ class UnixSignals {
std::optional code = std::nullopt,
std::optional addr = std::nullopt,
std::optional lower = std::nullopt,
-   std::optional upper = std::nullopt) const;
+   std::optional upper = std::nullopt,
+   std::optional pid = std::nullopt,
+   std::optional uid = std::nullopt) const;
 
   bool SignalIsValid(int32_t signo) const;
 
@@ -105,7 +107,7 @@ class UnixSignals {
  llvm::StringRef description,
  llvm::StringRef alias = llvm::StringRef());
 
-  enum SignalCodePrintOption { None, Address, Bounds };
+  enum SignalCodePrintOption { None, Address, Bounds, Sender };
 
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 9c4fe55147a28..25d4e4609bbb8 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -38,6 +38,17 @@
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) 
\
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
 #endif /* if defined(__linux__) && !defined(__mips__) */
+// See siginfo.h in the Linux Kernel, these codes can be sent for any signal.
+#define ADD_LINUX_SIGNAL(signo, name, ...) \
+  AddSignal(signo, name, __VA_ARGS__); \
+  ADD_SIGCODE(signo, signo, SI_QUEUE, -1, "sent by sigqueue"); \
+  ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration"); \
+  ADD_SIGCODE(signo, signo, SI_MESGQ, -3, "sent by real time mesq state 
change"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCIO, -4, "sent by AIO completion"); \
+  ADD_SIGCODE(signo, signo, SI_SIGIO, -5, "sent by queued SIGIO"); \
+  ADD_SIGCODE(signo, signo, SI_TKILL, -6, "sent by tkill system call"); \
+  ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, "sent by execve() killing 
subsidiary threads"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCNL, -60, "sent by glibc async name lookup 
completion"); 
 
 using namespace lldb_private;
 
@@ -46,9 +57,9 @@ LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
 void LinuxSignals::Reset() {
   m_signals.clear();
   // clang-format off
-  //SIGNO   NAMESUPPRESS  STOPNOTIFY  DESCRIPTION
-  //==  ==    ==  ==  
===
-  AddSignal(1,  "SIGHUP",   false,true,   true,   "hangup");
+  //   SIGNO   NAMESUPPRESS  STOPNOTIFY  
DESCRIPTION
+  //   ==  ==    ==  ==  
===
+  A

[Lldb-commits] [lldb] [LLDB] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

Recently, I was on an issue that generated a large number of Coredumps, and 
every time in both LLDB and GDB the signal was just `SIGSEGV`.

This was frustrating because we would expect a `SIGSEGV` to have an address, or 
ideally even bounds. After some digging I found the `si_code` consistently was 
-6. With some help from [@cdown](https://github.com/cdown), we found 
neither LLDB or GDB supports the si_codes sent from [user 
space](https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/siginfo.h#L185).

Excerpted from the sigaction man page.
```
   For a regular signal, the following list shows the values which
   can be placed in si_code for any signal, along with the reason
   that the signal was generated.
```

For which I added all of the si_codes to every Linux signal. Now for the 
Coredump that triggered this whole investigation we get the accurate and now 
very informative summary.

image


Importantly, I didn't add an equivalent of `siginfo_t` to ELFSigInfo, and I 
think we should open an issue for this to make a (build) platform agnostic 
struct of siginfo_t. I'll defer to your expertise @labath and @DavidSpickett 


---

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


6 Files Affected:

- (modified) lldb/include/lldb/Target/UnixSignals.h (+4-2) 
- (modified) lldb/source/Plugins/Process/Utility/LinuxSignals.cpp (+88-66) 
- (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+25-16) 
- (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.h (+23-15) 
- (modified) lldb/source/Target/UnixSignals.cpp (+9-6) 
- (modified) lldb/unittests/Signals/UnixSignalsTest.cpp (+9) 


``diff
diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..a1807d69f329b 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -36,7 +36,9 @@ class UnixSignals {
std::optional code = std::nullopt,
std::optional addr = std::nullopt,
std::optional lower = std::nullopt,
-   std::optional upper = std::nullopt) const;
+   std::optional upper = std::nullopt,
+   std::optional pid = std::nullopt,
+   std::optional uid = std::nullopt) const;
 
   bool SignalIsValid(int32_t signo) const;
 
@@ -105,7 +107,7 @@ class UnixSignals {
  llvm::StringRef description,
  llvm::StringRef alias = llvm::StringRef());
 
-  enum SignalCodePrintOption { None, Address, Bounds };
+  enum SignalCodePrintOption { None, Address, Bounds, Sender };
 
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 9c4fe55147a28..76c32e376eb4b 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -38,6 +38,28 @@
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) 
\
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
 #endif /* if defined(__linux__) && !defined(__mips__) */
+// See siginfo.h in the Linux Kernel, these codes can be sent for any signal.
+#define ADD_LINUX_SIGNAL(signo, name, ...) 
\
+  AddSignal(signo, name, __VA_ARGS__); 
\
+  ADD_SIGCODE(signo, signo, SI_QUEUE, -1, "sent by sigqueue",  
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration",  
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_MESGQ, -3,  
\
+  "sent by real time mesq state change",   
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_ASYNCIO, -4, "sent by AIO completion",  
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_SIGIO, -5, "sent by queued SIGIO",  
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_TKILL, -6, "sent by tkill system call", 
\
+  SignalCodePrintOption::Sender);  
\
+  ADD_SIGCODE(signo, signo, SI_DETHREAD, -7,   
\
+