[Lldb-commits] [lldb] 2668167 - [lldb] Disable some lldb-dap tests on Windows

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

Author: David Spickett
Date: 2025-05-08T08:47:12Z
New Revision: 2668167e2cf935528f7d93cb3b12a651a29e52f6

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

LOG: [lldb] Disable some lldb-dap tests on Windows

Since https://github.com/llvm/llvm-project/pull/138981 / 
https://github.com/llvm/llvm-project/commit/aeeb9a3c09f40f42a1e8e5e3c8dbde3b260744bd
were landed and tests re-enabled, these tests have been failing
on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/8523


Unresolved Tests (1):
  lldb-api :: tools/lldb-dap/send-event/TestDAP_sendEvent.py

Failed Tests (2):
  lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py
  lldb-api :: tools/lldb-dap/stackTrace/TestDAP_stackTrace.py

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index e8e9181f8da8d..acbe0366d1ecc 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -546,6 +546,7 @@ def test_terminate_commands(self):
 )
 self.verify_commands("terminateCommands", output, terminateCommands)
 
+@skipIfWindows
 def test_version(self):
 """
 Tests that "initialize" response contains the "version" string the same

diff  --git a/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py 
b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
index 64cec70aa923b..3e015186d4b81 100644
--- a/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
+++ b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
@@ -10,6 +10,7 @@
 
 
 class TestDAP_sendEvent(lldbdap_testcase.DAPTestCaseBase):
+@skipIfWindows
 def test_send_event(self):
 """
 Test sending a custom event.
@@ -42,6 +43,7 @@ def test_send_event(self):
 self.assertEqual(custom_event["event"], "my-custom-event")
 self.assertEqual(custom_event["body"], custom_event_body)
 
+@skipIfWindows
 def test_send_internal_event(self):
 """
 Test sending an internal event produces an error.

diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
index edf4adae14a3b..9c6f1d42feda2 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
@@ -201,6 +201,7 @@ def test_stackTrace(self):
 0, len(stackFrames), "verify zero frames with startFrame out of 
bounds"
 )
 
+@skipIfWindows
 def test_functionNameWithArgs(self):
 """
 Test that the stack frame without a function name is given its pc in 
the response.
@@ -215,6 +216,7 @@ def test_functionNameWithArgs(self):
 frame = self.get_stackFrames()[0]
 self.assertEqual(frame["name"], "recurse(x=1)")
 
+@skipIfWindows
 def test_StackFrameFormat(self):
 """
 Test the StackFrameFormat.



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


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

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

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

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

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

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

[Lldb-commits] [lldb] [lldb-dap] Re-enable the lldb-dap tests (PR #138791)

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

DavidSpickett wrote:

We have a few failures on Windows on Arm too: 
https://github.com/llvm/llvm-project/commit/2668167e2cf935528f7d93cb3b12a651a29e52f6

I've skipped those tests for now.

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

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


@@ -36,34 +39,49 @@ int main() {
 }
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID:]]
+// CHECK: m_memory_id: [[#MEMORY_ID:]]
 
 // CHECK-LABEL: expr x.i != 42
 // IDs are not changed when executing simple expressions
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID]]
+// CHECK: m_memory_id: [[#MEMORY_ID]]
+
+// CHECK-LABEL: process status -d
+// Remember new values

DavidSpickett wrote:

If the IDs are not changed, why do you need to capture them again here?

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

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

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

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

https://github.com/DavidSpickett commented:

Looks fine just one question.

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


[Lldb-commits] [lldb] [lldb] Change the statusline format to print "no target" (PR #139021)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Implement `runInTerminal` for Windows (PR #121269)

2025-05-08 Thread Hu Jialun via lldb-commits


@@ -24,41 +31,105 @@ using namespace llvm;
 
 namespace lldb_dap {
 
-FifoFile::FifoFile(StringRef path) : m_path(path) {}
+FifoFile::FifoFile(std::string path, FILE *f) : m_path(path), m_file(f) {}
+
+Expected FifoFile::create(StringRef path) {
+  auto file = fopen(path.data(), "r+");
+  if (file == nullptr)
+return createStringError(inconvertibleErrorCode(),
+ "Failed to open fifo file " + path);
+  if (setvbuf(file, NULL, _IONBF, 0))
+return createStringError(inconvertibleErrorCode(),
+ "Failed to setvbuf on fifo file " + path);
+  return FifoFile(path, file);
+}
+
+FifoFile::FifoFile(StringRef path, FILE *f) : m_path(path), m_file(f) {}
 
+FifoFile::FifoFile(FifoFile &&other)
+: m_path(other.m_path), m_file(other.m_file) {
+  other.m_path.clear();
+  other.m_file = nullptr;
+}
 FifoFile::~FifoFile() {
+  if (m_file)
+fclose(m_file);
 #if !defined(_WIN32)
+  // Unreferenced named pipes are deleted automatically on Win32
   unlink(m_path.c_str());
 #endif
 }
 
-Expected> CreateFifoFile(StringRef path) {
-#if defined(_WIN32)
-  return createStringError(inconvertibleErrorCode(), "Unimplemented");
+// This probably belongs to llvm::sys::fs as another FSEntity type
+Error createUniqueNamedPipe(const Twine &prefix, StringRef suffix,
+int &result_fd,
+SmallVectorImpl &result_path) {
+  std::error_code EC;
+#ifdef _WIN32
+  const char *middle = suffix.empty() ? "-%%" : "-%%.";
+  EC = sys::fs::getPotentiallyUniqueFileName(
+  ".\\pipe\\LOCAL\\" + prefix + middle + suffix, result_path);
+#else
+  EC = sys::fs::getPotentiallyUniqueTempFileName(prefix, suffix, result_path);
+#endif
+  if (EC)
+return errorCodeToError(EC);
+  result_path.push_back(0);
+  const char *path = result_path.data();
+#ifdef _WIN32
+  HANDLE h = ::CreateNamedPipeA(
+  path, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,

SuibianP wrote:

> when its opened for reading it blocks until the file is also opened for 
> writing and vice versa

This is implemented with 
[`ConnectNamedPipe`](https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-connectnamedpipe)
 in `FifoFileIO::WaitForPeer` after creation. `WaitNamedPipe` was not needed as 
the server side would already be around by the time the client tries to connect.

> deadlock the process by having it wait on itself accidentally

Intra-process deadlock (waiting on its own pending output) should not be 
possible, since on Windows a process cannot even read back what it wrote into a 
named pipe from the same handle. The data flow is bidirectional, but can only 
be consumed by the other end.

Inter-process deadlock, with the exception of buffering, is also rather 
unlikely. Current protocol over the pipe is strictly synchronous and 
sequential, or "half-duplex" in some sense -- there are no overlapping 
transmissions; in other words, the process will not transmit before expected 
response is fully received, and will not block on read before it sends out the 
message.

Buffering can still cause deadlocks. Without the `rewind`, the process proceeds 
to wait for the response after write, but the payload has somehow not fully 
arrived at the other end, and the peer as a result does not respond yet. I 
speculated it to be due to libc buffering, but did not manage to penetrate 
through MS CRT code to verify.

> Should we instead switch to a communication channel that supports reading and 
> writing for all platforms?

Using sockets feels a bit like overkill, but would definitely make code more 
uniform across platforms I suppose. I can give it a try if you deem it more 
maintainable.

> we have some existing helpers for supporting sockets already.

As an aside, I remember I did also attempt to retrofit the use case into 
`lldb_private::Pipe`, but gave up because duplex was too hard to shoehorn into 
the existing abstraction, and would have very limited utility even if 
implemented.

> Is that something you might have a chance to look into?

I am not too familiar with that so unable to give guarantees, but let me give 
it a try.
Also unsure if the socket rewrite is going to make it for LLVM 21 feature 
freeze in July.

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


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (reland) (PR #138981)

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

DavidSpickett wrote:

A few tests still failing on Windows - 
https://lab.llvm.org/buildbot/#/builders/141/builds/8523
```

Unresolved Tests (1):
  lldb-api :: tools/lldb-dap/send-event/TestDAP_sendEvent.py

Failed Tests (2):
  lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py
  lldb-api :: tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
```
```
FAIL: test_version (TestDAP_launch.TestDAP_launch.test_version)

Tests that "initialize" response contains the "version" string the same 

--

= END =

Traceback (most recent call last):

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\tools\lldb-dap\launch\TestDAP_launch.py",
 line 562, in test_version

self.continue_to_breakpoints(breakpoint_ids)

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 294, in continue_to_breakpoints

self.verify_breakpoint_hit(breakpoint_ids)

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 113, in verify_breakpoint_hit

self.assertTrue(False, "breakpoint not hit")

AssertionError: False is not true : breakpoint not hit
```
Looks like your previous theory, does the test need updating somehow?
```
ERROR: test_send_internal_event 
(TestDAP_sendEvent.TestDAP_sendEvent.test_send_internal_event)

   Test sending an internal event produces an error.

--

Traceback (most recent call last):

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\tools\lldb-dap\send-event\TestDAP_sendEvent.py",
 line 62, in test_send_internal_event

resp["body"]["result"],



TypeError: list indices must be integers or slices, not str

Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
```
Seems like it was expecting one kind of response, but got a different one.
```
==

FAIL: test_StackFrameFormat 
(TestDAP_stackTrace.TestDAP_stackTrace.test_StackFrameFormat)

   Test the StackFrameFormat.

--

Traceback (most recent call last):

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\tools\lldb-dap\stackTrace\TestDAP_stackTrace.py",
 line 229, in test_StackFrameFormat

frame = self.get_stackFrames(format={"parameters": True})[0]

^

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 194, in get_stackFrames

(stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount(

 ^^

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 182, in get_stackFrames_and_totalFramesCount

totalFrames = self.get_dict_value(response, ["body", "totalFrames"])

  ^^

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 164, in get_dict_value

self.assertTrue(

AssertionError: False is not true : key "totalFrames" from key_path "['body', 
'totalFrames']" not in "{'body': {'stackFrames': []}, 'command': 'stackTrace', 
'request_seq': 7, 'seq': 0, 'success': True, 'type': 'response'}"

Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
```
Again could be what you said, if the program never stopped that explains why 
there are no stack frames here.

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

2025-05-08 Thread Mikhail Zakharov via lldb-commits


@@ -36,34 +39,49 @@ int main() {
 }
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID:]]
+// CHECK: m_memory_id: [[#MEMORY_ID:]]
 
 // CHECK-LABEL: expr x.i != 42
 // IDs are not changed when executing simple expressions
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID]]
+// CHECK: m_memory_id: [[#MEMORY_ID]]
+
+// CHECK-LABEL: process status -d
+// Remember new values

real-mikhail wrote:

Sure, we can avoid recapturing them but I decided that it is more readable to 
use the same pattern (all 4 times):
1. Capture variables;
2. Do some "test" command;
3. Check the variables.

Otherwise the fact whether we need to capture variable for "testing" next 
command depends on what was done in the previous command. And some commands 
change one value but not the other and it becomes messy so I decided that it is 
simpler to always recapture them.

I can change that and avoid unnecessary recaptures if you think that it is bad 
idea.

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

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


@@ -36,34 +39,49 @@ int main() {
 }
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID:]]
+// CHECK: m_memory_id: [[#MEMORY_ID:]]
 
 // CHECK-LABEL: expr x.i != 42
 // IDs are not changed when executing simple expressions
 
 // CHECK-LABEL: process status -d
-// CHECK: m_stop_id: 2
-// CHECK: m_memory_id: 0
+// CHECK: m_stop_id: [[#STOP_ID]]
+// CHECK: m_memory_id: [[#MEMORY_ID]]
+
+// CHECK-LABEL: process status -d
+// Remember new values

DavidSpickett wrote:

Oh I see what you mean. Otherwise you have to unravel the sequence to add 
anything new and we're liable to make a mistake.

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

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

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

LGTM, thanks!

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


[Lldb-commits] [lldb] [lldb] Fixed TestProcessModificationIdOnExpr to work on both x86 and x64 architectures (PR #138941)

2025-05-08 Thread Mikhail Zakharov via lldb-commits

real-mikhail wrote:

Thanks for checking @DavidSpickett. Could you please merge this PR for me?

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


[Lldb-commits] [lldb] [lldb][DataFormatters] Change ExtractIndexFromString to return std::optional (PR #138297)

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

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


[Lldb-commits] [lldb] 0d47a45 - [lldb][DataFormatters] Change ExtractIndexFromString to return std::optional (#138297)

2025-05-08 Thread via lldb-commits

Author: Charles Zablit
Date: 2025-05-08T12:21:26+01:00
New Revision: 0d47a4548c17b320e02e33a1e250792626652e59

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

LOG: [lldb][DataFormatters] Change ExtractIndexFromString to return 
std::optional (#138297)

This PR is in continuation of
https://github.com/llvm/llvm-project/pull/136693.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/DataFormatters/VectorType.cpp
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index a98042fd40f93..42699d0a0b1b1 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -53,7 +53,7 @@ void AddFilter(TypeCategoryImpl::SharedPointer category_sp,
llvm::StringRef type_name,
ScriptedSyntheticChildren::Flags flags, bool regex = false);
 
-size_t ExtractIndexFromString(const char *item_name);
+std::optional ExtractIndexFromString(const char *item_name);
 
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 

diff  --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 085ed3d0a2f29..5f5541c352623 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -97,18 +97,17 @@ void lldb_private::formatters::AddFilter(
   category_sp->AddTypeFilter(type_name, match_type, filter_sp);
 }
 
-size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) 
{
+std::optional
+lldb_private::formatters::ExtractIndexFromString(const char *item_name) {
   if (!item_name || !*item_name)
-return UINT32_MAX;
+return std::nullopt;
   if (*item_name != '[')
-return UINT32_MAX;
+return std::nullopt;
   item_name++;
   char *endptr = nullptr;
   unsigned long int idx = ::strtoul(item_name, &endptr, 0);
-  if (idx == 0 && endptr == item_name)
-return UINT32_MAX;
-  if (idx == ULONG_MAX)
-return UINT32_MAX;
+  if ((idx == 0 && endptr == item_name) || idx == ULONG_MAX)
+return std::nullopt;
   return idx;
 }
 

diff  --git a/lldb/source/DataFormatters/VectorType.cpp 
b/lldb/source/DataFormatters/VectorType.cpp
index eab2612d1e941..8a842b8675f57 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -270,10 +270,13 @@ class VectorTypeSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
   }
 
   llvm::Expected GetIndexOfChildWithName(ConstString name) override {
-const char *item_name = name.GetCString();
-uint32_t idx = ExtractIndexFromString(item_name);
-if (idx == UINT32_MAX ||
-(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))
+auto optional_idx = ExtractIndexFromString(name.AsCString());
+if (!optional_idx) {
+  return llvm::createStringError("Type has no child named '%s'",
+ name.AsCString());
+}
+uint32_t idx = *optional_idx;
+if (idx >= CalculateNumChildrenIgnoringErrors())
   return llvm::createStringError("Type has no child named '%s'",
  name.AsCString());
 return idx;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
index 234471d5ba518..f2521ec750875 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
@@ -29,11 +29,12 @@ class GenericBitsetFrontEnd : public 
SyntheticC

[Lldb-commits] [lldb] 4132141 - [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (#137904)

2025-05-08 Thread via lldb-commits

Author: Ely Ronnen
Date: 2025-05-08T14:01:42+02:00
New Revision: 41321416815d74a4a7fd15c78fcfa5af457625bb

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

LOG: [lldb] Expose QueueThreadPlanForStepSingleInstruction function to 
SBThreadPlan (#137904)

Expose `QueueThreadPlanForStepSingleInstruction` function to
SBThreadPlan

Added: 


Modified: 
lldb/include/lldb/API/SBThreadPlan.h
lldb/source/API/SBThreadPlan.cpp
lldb/test/API/functionalities/step_scripted/Steps.py
lldb/test/API/functionalities/step_scripted/TestStepScripted.py
lldb/test/API/functionalities/step_scripted/main.c

Removed: 




diff  --git a/lldb/include/lldb/API/SBThreadPlan.h 
b/lldb/include/lldb/API/SBThreadPlan.h
index d02ab80f76a76..1f0164efcfb98 100644
--- a/lldb/include/lldb/API/SBThreadPlan.h
+++ b/lldb/include/lldb/API/SBThreadPlan.h
@@ -105,6 +105,9 @@ class LLDB_API SBThreadPlan {
   SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
  bool first_insn, SBError &error);
 
+  SBThreadPlan QueueThreadPlanForStepSingleInstruction(bool step_over,
+   SBError &error);
+
   SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address);
   SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address,
   SBError &error);

diff  --git a/lldb/source/API/SBThreadPlan.cpp 
b/lldb/source/API/SBThreadPlan.cpp
index 083a050de8a38..c8ca6c81a3efb 100644
--- a/lldb/source/API/SBThreadPlan.cpp
+++ b/lldb/source/API/SBThreadPlan.cpp
@@ -325,6 +325,29 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t 
frame_idx_to_step_to,
   return SBThreadPlan();
 }
 
+SBThreadPlan
+SBThreadPlan::QueueThreadPlanForStepSingleInstruction(bool step_over,
+  SBError &error) {
+  LLDB_INSTRUMENT_VA(this, step_over, error);
+
+  ThreadPlanSP thread_plan_sp(GetSP());
+  if (thread_plan_sp) {
+Status plan_status;
+SBThreadPlan plan(
+thread_plan_sp->GetThread().QueueThreadPlanForStepSingleInstruction(
+step_over, false, false, plan_status));
+
+if (plan_status.Fail())
+  error.SetErrorString(plan_status.AsCString());
+else
+  plan.GetSP()->SetPrivate(true);
+
+return plan;
+  }
+
+  return SBThreadPlan();
+}
+
 SBThreadPlan
 SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
   LLDB_INSTRUMENT_VA(this, sb_address);

diff  --git a/lldb/test/API/functionalities/step_scripted/Steps.py 
b/lldb/test/API/functionalities/step_scripted/Steps.py
index 3325dba753657..e2a03c9988111 100644
--- a/lldb/test/API/functionalities/step_scripted/Steps.py
+++ b/lldb/test/API/functionalities/step_scripted/Steps.py
@@ -45,6 +45,26 @@ def queue_child_thread_plan(self):
 return self.thread_plan.QueueThreadPlanForStepScripted("Steps.StepOut")
 
 
+class StepSingleInstruction(StepWithChild):
+def __init__(self, thread_plan, dict):
+super().__init__(thread_plan)
+
+def queue_child_thread_plan(self):
+return self.thread_plan.QueueThreadPlanForStepSingleInstruction(
+False, lldb.SBError()
+)
+
+
+class StepSingleInstructionWithStepOver(StepWithChild):
+def __init__(self, thread_plan, dict):
+super().__init__(thread_plan)
+
+def queue_child_thread_plan(self):
+return self.thread_plan.QueueThreadPlanForStepSingleInstruction(
+True, lldb.SBError()
+)
+
+
 # This plan does a step-over until a variable changes value.
 class StepUntil(StepWithChild):
 def __init__(self, thread_plan, args_data):

diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 53901718019f9..54bc154590ed0 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -44,6 +44,48 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+def run_until_branch_instruction(self):
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Break on branch instruction", self.main_source_file
+)
+
+# Check that we landed in a call instruction
+frame = thread.GetFrameAtIndex(0)
+current_instruction = target.ReadInstructions(frame.GetPCAddress(), 
1)[0]
+self.assertEqual(
+lldb.eInstructionControlFlowKindCall,
+current_instruction.GetControlFlowKind(target),
+)
+return (target, process,

[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

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

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


[Lldb-commits] [lldb] [lldb-dap] Migrate 'continue' request to new RequestHandler. (PR #138987)

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

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


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


[Lldb-commits] [lldb] e18f248 - [lldb][test] Disable flaky test_qThreadInfo_matches_qC_attach test on AArch64 Linux (#138940)

2025-05-08 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2025-05-08T11:22:37+04:00
New Revision: e18f248956b317f06f7822920c72d7a2eebcd267

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

LOG: [lldb][test] Disable flaky test_qThreadInfo_matches_qC_attach test on 
AArch64 Linux (#138940)

See #138085 for details.
https://lab.llvm.org/buildbot/#/builders/59/builds/16937 
https://lab.llvm.org/buildbot/#/builders/59/builds/17224

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 2c328125e3058..67690a275f0da 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -202,6 +202,13 @@ def test_qThreadInfo_matches_qC_launch(self):
 self.set_inferior_startup_launch()
 self.qThreadInfo_matches_qC()
 
+# This test is flaky on AArch64 Linux. Sometimes it causes an unhandled 
Error:
+# Operation not permitted in 
lldb_private::process_linux::NativeProcessLinux::Attach(int).
+@skipIf(
+oslist=["linux"],
+archs=["aarch64"],
+bugnumber="github.com/llvm/llvm-project/issues/138085",
+)
 @expectedFailureAll(oslist=["windows"])  # expect one more thread stopped
 def test_qThreadInfo_matches_qC_attach(self):
 self.build()



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


[Lldb-commits] [lldb] [lldb][test] Disable flaky test_qThreadInfo_matches_qC_attach test on AArch64 Linux (PR #138940)

2025-05-08 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb-dap] Migrating breakpointLocations request to use typed RequestHandler (PR #137426)

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

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

>From 84638973a3592411025d5294d1f0e93dddba3bf7 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sat, 26 Apr 2025 01:22:05 +0200
Subject: [PATCH] Migrating breakpointLocations request to use typed
 RequestHandler

---
 .../Handler/BreakpointLocationsHandler.cpp| 156 +++---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  10 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  17 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  38 +
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  14 ++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  21 +++
 llvm/include/llvm/Support/JSON.h  |   8 +
 7 files changed, 125 insertions(+), 139 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
index 7a477f3e97875..2ac886c3a5d2c 100644
--- a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
@@ -9,136 +9,22 @@
 #include "DAP.h"
 #include "JSONUtils.h"
 #include "RequestHandler.h"
+#include 
 
 namespace lldb_dap {
 
-// "BreakpointLocationsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "The `breakpointLocations` request returns all possible
-// locations for source breakpoints in a given range.\nClients should only
-// call this request if the corresponding capability
-// `supportsBreakpointLocationsRequest` is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "breakpointLocations" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/BreakpointLocationsArguments"
-//   }
-// },
-// "required": [ "command" ]
-//   }]
-// },
-// "BreakpointLocationsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `breakpointLocations` request.",
-//   "properties": {
-// "source": {
-//   "$ref": "#/definitions/Source",
-//   "description": "The source location of the breakpoints; either
-//   `source.path` or `source.sourceReference` must be specified."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "Start line of range to search possible breakpoint
-//   locations in. If only the line is specified, the request returns all
-//   possible locations in that line."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "Start position within `line` to search possible
-//   breakpoint locations in. It is measured in UTF-16 code units and the
-//   client capability `columnsStartAt1` determines whether it is 0- or
-//   1-based. If no column is given, the first position in the start line 
is
-//   assumed."
-// },
-// "endLine": {
-//   "type": "integer",
-//   "description": "End line of range to search possible breakpoint
-//   locations in. If no end line is given, then the end line is assumed to
-//   be the start line."
-// },
-// "endColumn": {
-//   "type": "integer",
-//   "description": "End position within `endLine` to search possible
-//   breakpoint locations in. It is measured in UTF-16 code units and the
-//   client capability `columnsStartAt1` determines whether it is 0- or
-//   1-based. If no end column is given, the last position in the end line
-//   is assumed."
-// }
-//   },
-//   "required": [ "source", "line" ]
-// },
-// "BreakpointLocationsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `breakpointLocations` request.\nContains
-// possible locations for source breakpoints.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "breakpoints": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/BreakpointLocation"
-// },
-// "description": "Sorted set of possible breakpoint locations."
-//   }
-// },
-// "required": [ "breakpoints" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "BreakpointLocation": {
-//   "type": "object",
-//   "description": "Properties of a breakpoint location returned from the
-//   `breakpointLocations` request.",
-//   "properties": {
-// "line": {
-//   "type": "integer",
-//   "description": "Start line of breakpoint location."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The start position of a breakpoint location. Position
-//   is measured in UTF-16 code units and the client capability
-//   `columnsStartAt1` determines whether it is 0- or 1-based."
-// },
-// "endLine": {
-//   "type": "integer",
-//

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

2025-05-08 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]Make `list` command work with headers when possible. (PR #139002)

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

https://github.com/oontvoo 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] Fix dynamic type resolutions for core files (PR #138698)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Pushed your suggestion



> Lol, I think its this:
> 
> https://github.com/llvm/llvm-project/blob/6babd63a4bbc094bee4ef8e75f95dccd32325c15/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp#L718-L721
> 
> I'm done for this week, but could someone try if changing that to std::min 
> fixes this?



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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

@eronnen this is breaking the incremental green dragon bots.
Could you revert while you look at this please? 

https://ci.swift.org/view/all/job/llvm.org/job/as-lldb-cmake/25425/changes#41321416815d74a4a7fd15c78fcfa5af457625bb


```
[2025-05-08T12:15:32.021Z] 
==
[2025-05-08T12:15:32.021Z] FAIL: test_step_single_instruction 
(TestStepScripted.StepScriptedTestCase)
[2025-05-08T12:15:32.021Z] 
--
[2025-05-08T12:15:32.021Z] Traceback (most recent call last):
[2025-05-08T12:15:32.021Z]   File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/step_scripted/TestStepScripted.py",
 line 63, in test_step_single_instruction
[2025-05-08T12:15:32.021Z] (target, process, thread, bkpt) = 
self.run_until_branch_instruction()
[2025-05-08T12:15:32.021Z]   File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/step_scripted/TestStepScripted.py",
 line 56, in run_until_branch_instruction
[2025-05-08T12:15:32.021Z] self.assertEqual(
[2025-05-08T12:15:32.021Z] AssertionError: 2 != 0
[2025-05-08T12:15:32.021Z] 
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
```


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


[Lldb-commits] [lldb] bbafa52 - [lldb] Fix asan failure in MinidumpFileBuilder

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2025-05-08T07:27:09-07:00
New Revision: bbafa5214e8d5d5daf7cf428780500b13a7d6cbb

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

LOG: [lldb] Fix asan failure in MinidumpFileBuilder

As per comment in 
https://github.com/llvm/llvm-project/pull/138698#issuecomment-2860369432

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index d2ca5b26c9ec9..2818d31eb2301 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -718,7 +718,7 @@ Status MinidumpFileBuilder::AddExceptions() {
 // We have 120 bytes to work with and it's unlikely description will
 // overflow, but we gotta check.
 memcpy(&exp_record.ExceptionInformation, description.c_str(),
-   std::max(description.size(), Exception::MaxParameterBytes));
+   std::min(description.size(), Exception::MaxParameterBytes));
 exp_record.UnusedAlignment = static_cast(0);
 ExceptionStream exp_stream;
 exp_stream.ThreadId =



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


[Lldb-commits] [lldb] 155bf37 - [lldb-dap] Migrate 'continue' request to new RequestHandler. (#138987)

2025-05-08 Thread via lldb-commits

Author: John Harrison
Date: 2025-05-08T08:43:41-07:00
New Revision: 155bf37ad995fa07baf99ad59294ec5fe2777635

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

LOG: [lldb-dap] Migrate 'continue' request to new RequestHandler. (#138987)

This adds types for the 'continue' request and updates the existing
handler to the new base class.

Added: 


Modified: 
lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp
lldb/tools/lldb-dap/Handler/RequestHandler.h
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h

Removed: 




diff  --git a/lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp
index 214e3c59c594c..ca4c9141eca38 100644
--- a/lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ContinueRequestHandler.cpp
@@ -7,74 +7,41 @@
 
//===--===//
 
 #include "DAP.h"
-#include "JSONUtils.h"
-#include "RequestHandler.h"
+#include "Handler/RequestHandler.h"
+#include "LLDBUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBProcess.h"
+#include "llvm/Support/Error.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap::protocol;
 
 namespace lldb_dap {
 
-// "ContinueRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Continue request; value of command field is 'continue'.
-// The request starts the debuggee to run again.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "continue" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/ContinueArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "ContinueArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'continue' request.",
-//   "properties": {
-// "threadId": {
-//   "type": "integer",
-//   "description": "Continue execution for the specified thread (if
-//   possible). If the backend cannot continue on a single
-//   thread but will continue on all threads, it should
-//   set the allThreadsContinued attribute in the response
-//   to true."
-// }
-//   },
-//   "required": [ "threadId" ]
-// },
-// "ContinueResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'continue' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "allThreadsContinued": {
-// "type": "boolean",
-// "description": "If true, the continue request has ignored the
-// specified thread and continued all threads
-// instead. If this attribute is missing a value
-// of 'true' is assumed for backward
-// compatibility."
-//   }
-// }
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void ContinueRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  lldb::SBProcess process = dap.target.GetProcess();
-  lldb::SBError error = process.Continue();
-  llvm::json::Object body;
-  body.try_emplace("allThreadsContinued", true);
-  response.try_emplace("body", std::move(body));
-  dap.SendJSON(llvm::json::Value(std::move(response)));
+/// The request resumes execution of all threads. If the debug adapter supports
+/// single thread execution (see capability
+/// `supportsSingleThreadExecutionRequests`), setting the `singleThread`
+/// argument to true resumes only the specified thread. If not all threads were
+/// resumed, the `allThreadsContinued` attribute of the response should be set
+/// to false.
+Expected
+ContinueRequestHandler::Run(const ContinueArguments &args) const {
+  SBProcess process = dap.target.GetProcess();
+  SBError error;
+
+  if (args.singleThread)
+dap.GetLLDBThread(args.threadId).Resume(error);
+  else
+error = process.Continue();
+
+  if (error.Fail())
+return ToError(error);
+
+  ContinueResponseBody body;
+  body.allThreadsContinued = args.singleThread;
+  return body;
 }
+
 } // namespace lldb_dap

diff  --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 9e9cfb13d77b8..25534b5675e45 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-

[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

2025-05-08 Thread via lldb-commits

hapee wrote:

Hi @JDevlieghere  @jinmingjian , all required checks have passed and the PR has 
received approvals. Would you mind helping merge this PR? Thanks!


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


[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

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

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


[Lldb-commits] [lldb] b5674cb - [lldb] print a notice when `source list` paging reaches the end of th… (#137515)

2025-05-08 Thread via lldb-commits

Author: Zax
Date: 2025-05-08T07:01:16-07:00
New Revision: b5674cb7be1b010be181883601a3674ceef38683

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

LOG: [lldb] print a notice when `source list` paging reaches the end of th… 
(#137515)

Added: 
lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
lldb/test/Shell/Commands/command-list-reach-end-of-file.test

Modified: 
lldb/include/lldb/Core/SourceManager.h
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Core/SourceManager.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/SourceManager.h 
b/lldb/include/lldb/Core/SourceManager.h
index d929f7bd9bf22..1244291596b73 100644
--- a/lldb/include/lldb/Core/SourceManager.h
+++ b/lldb/include/lldb/Core/SourceManager.h
@@ -155,6 +155,9 @@ class SourceManager {
   ~SourceManager();
 
   FileSP GetLastFile() { return GetFile(m_last_support_file_sp); }
+  bool AtLastLine(bool reverse) {
+return m_last_line == UINT32_MAX || (reverse && m_last_line == 1);
+  }
 
   size_t DisplaySourceLinesWithLineNumbers(
   lldb::SupportFileSP support_file_sp, uint32_t line, uint32_t column,

diff  --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..8c87af590a372 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1067,7 +1067,16 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 &result.GetOutputStream(), m_options.num_lines,
 m_options.reverse, GetBreakpointLocations())) {
   result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
+  if (target.GetSourceManager().AtLastLine(m_options.reverse)) {
+result.AppendNoteWithFormatv(
+"Reached {0} of the file, no more to page",
+m_options.reverse ? "beginning" : "end");
+  } else {
+result.AppendNote("No source available");
+  }
 }
+
   } else {
 if (m_options.num_lines == 0)
   m_options.num_lines = 10;

diff  --git a/lldb/source/Core/SourceManager.cpp 
b/lldb/source/Core/SourceManager.cpp
index d63d42de14e80..f786866a18137 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -360,10 +360,7 @@ size_t SourceManager::DisplayMoreWithLineNumbers(
 GetDefaultFileAndLine();
 
   if (last_file_sp) {
-if (m_last_line == UINT32_MAX)
-  return 0;
-
-if (reverse && m_last_line == 1)
+if (AtLastLine(reverse))
   return 0;
 
 if (count > 0)

diff  --git 
a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
new file mode 100644
index 0..5ca1b5c2306a7
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -0,0 +1,29 @@
+# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
+
+list
+# CHECK: note: No source available 
+
+b main
+# CHECK: Breakpoint 1:
+
+r
+# CHECK: int main()
+
+list
+# CHECK: if (child_pid == 0)
+
+list -
+# CHECK: int main()
+
+list -10
+# CHECK: #include 
+
+list -
+# CHECK: note: Reached beginning of the file, no more to page
+
+list -
+# CHECK: note: Reached beginning of the file, no more to page
+
+list
+# CHECK: int main()

diff  --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
new file mode 100644
index 0..c5e9c8169e7d9
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -0,0 +1,26 @@
+# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
+
+list
+# CHECK: note: No source available 
+
+b main
+# CHECK: Breakpoint 1:
+
+r
+# CHECK: int main()
+
+list
+# CHECK: if (child_pid == 0)
+
+list
+# CHECK: printf("signo = %d\n", SIGCHLD);
+
+list
+# CHECK: return 0;
+
+list 
+# CHECK: note: Reached end of the file, no more to page
+
+list 
+# CHECK: note: Reached end of the file, no more to page
\ No newline at end of file



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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

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

Jlalond wrote:

@clayborg, @dmpots bump if you have time

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


[Lldb-commits] [lldb] [lldb-dap] Migrate 'continue' request to new RequestHandler. (PR #138987)

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

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

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

eronnen wrote:

 @felipepiovezan thanks for the temp fix, I'll try to understand the problem 
soon

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

The following buildbots are broken by this patch too

https://lab.llvm.org/buildbot/#/builders/195/builds/8715

https://lab.llvm.org/buildbot/#/builders/197/builds/5054

Please fix ASAP.


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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -44,6 +44,48 @@ def step_out_with_scripted_plan(self, name):
 stop_desc = thread.GetStopDescription(1000)
 self.assertIn("Stepping out from", stop_desc, "Got right description")
 
+def run_until_branch_instruction(self):
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Break on branch instruction", self.main_source_file
+)
+
+# Check that we landed in a call instruction
+frame = thread.GetFrameAtIndex(0)
+current_instruction = target.ReadInstructions(frame.GetPCAddress(), 
1)[0]
+self.assertEqual(
+lldb.eInstructionControlFlowKindCall,
+current_instruction.GetControlFlowKind(target),

felipepiovezan wrote:

FWIW I don't think is implemented for arm targets

https://github.com/llvm/llvm-project/pull/137904
___
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-08 Thread Ilia Kuklin via lldb-commits

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

>From cfe7359bd16c1e87932e2ebb8bcdfc88130e9729 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 30 Apr 2025 22:03:50 +0500
Subject: [PATCH 1/4] [LLDB] Add array subscription and integer parsing to DIL

---
 lldb/docs/dil-expr-lang.ebnf  |  12 +-
 lldb/include/lldb/ValueObject/DILAST.h|  46 +
 lldb/include/lldb/ValueObject/DILEval.h   |   6 +
 lldb/include/lldb/ValueObject/DILLexer.h  |   3 +
 lldb/include/lldb/ValueObject/DILParser.h |   3 +
 lldb/source/ValueObject/DILAST.cpp|  10 ++
 lldb/source/ValueObject/DILEval.cpp   | 159 ++
 lldb/source/ValueObject/DILLexer.cpp  |  43 -
 lldb/source/ValueObject/DILParser.cpp |  79 -
 .../var-dil/basics/ArraySubscript/Makefile|   3 +
 .../TestFrameVarDILArraySubscript.py  |  88 ++
 .../var-dil/basics/ArraySubscript/main.cpp|  31 
 lldb/unittests/ValueObject/DILLexerTests.cpp  |  34 +++-
 13 files changed, 506 insertions(+), 11 deletions(-)
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/main.cpp

diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..0cbb5403785db 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -6,16 +6,20 @@
 expression = unary_expression ;
 
 unary_expression = unary_operator expression
- | primary_expression ;
+ | postfix_expression ;
 
 unary_operator = "*" | "&" ;
 
-primary_expression = id_expression
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]";
+
+primary_expression = numeric_literal
+   | id_expression
| "(" expression ")";
 
 id_expression = unqualified_id
   | qualified_id
- | register ;
+  | register ;
 
 unqualified_id = identifier ;
 
@@ -24,6 +28,8 @@ qualified_id = ["::"] [nested_name_specifier] unqualified_id
 
 identifier = ? C99 Identifier ? ;
 
+numeric_literal = ? C99 Integer constant ? ;
+
 register = "$" ? Register name ? ;
 
 nested_name_specifier = type_name "::"
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..6908deed7aee3 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -18,8 +18,10 @@ namespace lldb_private::dil {
 
 /// The various types DIL AST nodes (used by the DIL parser).
 enum class NodeKind {
+  eArraySubscriptNode,
   eErrorNode,
   eIdentifierNode,
+  eScalarLiteralNode,
   eUnaryOpNode,
 };
 
@@ -71,6 +73,26 @@ class ErrorNode : public ASTNode {
   }
 };
 
+class ScalarLiteralNode : public ASTNode {
+public:
+  ScalarLiteralNode(uint32_t location, lldb::BasicType type, Scalar value)
+  : ASTNode(location, NodeKind::eScalarLiteralNode), m_type(type),
+m_value(value) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  lldb::BasicType GetType() const { return m_type; }
+  Scalar GetValue() const & { return m_value; }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eScalarLiteralNode;
+  }
+
+private:
+  lldb::BasicType m_type;
+  Scalar m_value;
+};
+
 class IdentifierNode : public ASTNode {
 public:
   IdentifierNode(uint32_t location, std::string name)
@@ -108,6 +130,26 @@ class UnaryOpNode : public ASTNode {
   ASTNodeUP m_operand;
 };
 
+class ArraySubscriptNode : public ASTNode {
+public:
+  ArraySubscriptNode(uint32_t location, ASTNodeUP lhs, ASTNodeUP rhs)
+  : ASTNode(location, NodeKind::eArraySubscriptNode), 
m_lhs(std::move(lhs)),
+m_rhs(std::move(rhs)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *lhs() const { return m_lhs.get(); }
+  ASTNode *rhs() const { return m_rhs.get(); }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eArraySubscriptNode;
+  }
+
+private:
+  ASTNodeUP m_lhs;
+  ASTNodeUP m_rhs;
+};
+
 /// This class contains one Visit method for each specialized type of
 /// DIL AST node. The Visit methods are used to dispatch a DIL AST node to
 /// the correct function in the DIL expression evaluator for evaluating that
@@ -116,9 +158,13 @@ class Visitor {
 public:
   virtual ~Visitor() = default;
   virtual llvm::Expected
+  Visit(const ScalarLiteralNode *node) = 0;
+  virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
+  virtual llvm::Expected
+  Visit(const ArraySubscriptNode *node) = 0;
 };
 
 } // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h 
b/

[Lldb-commits] [lldb] [lldb] Change the statusline format to print "no target" (PR #139021)

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

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/139021
___
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-08 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

> Because I wanted to avoid this getting bogged down in the discussion about 
> the types of numbers. I don't really mind the "extra capability" of indexing 
> an array with a another variable. The part I have problem with is the 
> precedent it sets about the representation of numbers.
> 
> You're right that we can't do math operations without (implicitly or 
> explicitly) assigning them some type, but that's exactly the part I think 
> needs more discussion. Right now, you're assigning the type based on the 
> first type system you find (which is likely going to be C), but I think 
> that's not a good choice. If you're debugging some swift code, I think you'd 
> be surprised if `47` resolves to a C type.

Okay, I see the problem, I didn't really think that retrieving the type system 
when debugging Swift code would return C type system. Why is it like this 
though? Is there a reliable way to get a type system of the main language?
I also found now that the function `TypeSystem::GetBasicTypeFromAST` that the 
code in Eval relies on is not even implemented in 
[`TypeSystemSwift`](https://github.com/swiftlang/llvm-project/blob/a5b0b3daf26fd41b2caf61551b72f74b0e2a4ab7/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h#L296).
 

I don't have any other suggestion how to implement this, so I guess I'll stick 
to having an integer within the subscript node until we have a better idea.



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] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

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

eronnen wrote:

@slydiman Seems this worker is `aarch64` so this test should be disabled after 
@felipepiovezan 's fix.

https://github.com/llvm/llvm-project/pull/137904
___
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-08 Thread Vy Nguyen via lldb-commits

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

>From 5746e997eea55c05cbbb63ad6f78ca225c9ac855 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 7 May 2025 21:37:31 -0400
Subject: [PATCH 1/4] [lldb]Make `list` command work with  headers when
 possible.

---
 lldb/source/Commands/CommandObjectSource.cpp | 36 +++-
 lldb/source/Core/ModuleList.cpp  |  2 +
 lldb/test/Shell/Commands/list-header.test| 59 
 3 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/list-header.test

diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..475317021255c 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   bool check_inlines = false;
   SymbolContextList sc_list;
   size_t num_matches = 0;
+  uint32_t start_line = m_options.start_line;
 
   if (!m_options.modules.empty()) {
 ModuleList matching_modules;
@@ -1114,7 +1115,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),
 sc_list);
@@ -1122,7 +1123,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   } else {
 num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
   }
 
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if 
(llvm::StringRef(file->GetSpecOnly().GetPath()).ends_with(filename)) {
+actual_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+} else if (support_matches_count > 1) {
+  result.AppendErrorWithFormat(
+  "Multiple files found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+}
+  }
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
+  actual_file_sp,
   m_options.start_line, column, 0, m_options.num_lines, "",
   &result.GetOutputStream(), GetBreakpointLocations());
 
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d5ddf6e846112..90c6a62727734 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -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();
   for (const ModuleSP &module_sp : m_modules) {
 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
 resolve_scope, sc_list);
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..ca700cd2b2fb1
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,59 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUIRE

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

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


@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {

oontvoo wrote:

done!

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] print a notice when `source list` paging reaches the end of th… (PR #137515)

2025-05-08 Thread via lldb-commits

github-actions[bot] wrote:



@hapee Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/137515
___
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-08 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo 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] cb0b961 - [lldb] Disable test using GetControlFlowKind on arm

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2025-05-08T08:11:17-07:00
New Revision: cb0b9614f8ca7ffcd5f091b1c9990adfd6cb7e33

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

LOG: [lldb] Disable test using GetControlFlowKind on arm

This is only implemented for x86.
Originally introduced in: https://github.com/llvm/llvm-project/pull/137904

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index 54bc154590ed0..cec2901aa0369 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -59,6 +59,7 @@ def run_until_branch_instruction(self):
 )
 return (target, process, thread, bkpt)
 
+@skipIf(archs=no_match(["x86_64"]))
 def test_step_single_instruction(self):
 (target, process, thread, bkpt) = self.run_until_branch_instruction()
 



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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

To fix the bots, I've disabled your new test in all non x86 archs, feel free to 
update if you want to do something else

https://github.com/llvm/llvm-project/pull/137904
___
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-08 Thread Vy Nguyen via lldb-commits


@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {

oontvoo wrote:

How about we change to check to `if the file that was found has different 
extension from the requested`?
(That should cover most cases?)

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-08 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo 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] 45cd708 - [lldb] Change the statusline format to print "no target" (#139021)

2025-05-08 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-08T09:09:46-07:00
New Revision: 45cd708184e114bb771330d51ec552f7f674ffa0

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

LOG: [lldb] Change the statusline format to print "no target" (#139021)

Change the default statusline format to print "no target" when lldb is
launched without a target. Currently, the statusline is empty, which
looks rather odd.

Added: 


Modified: 
lldb/source/Core/CoreProperties.td
lldb/test/API/functionalities/statusline/TestStatusline.py

Removed: 




diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 2498841b47d9f..78988ce5b732f 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -186,7 +186,7 @@ let Definition = "debugger" in {
   : Property<"statusline-format", "FormatEntity">,
 Global,
 DefaultStringValue<
-"${ansi.negative}{${target.file.basename}}{ "
+"${ansi.negative}{${target.file.basename}|no target}{ "
 "${separator}${line.file.basename}:${line.number}:${line.column}}{ 
"
 "${separator}${thread.stop-reason}}{ "
 "${separator}{${progress.count} }${progress.message}}">,

diff  --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index da6b4e7c8f320..53ac7432f4ba1 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -6,7 +6,17 @@
 from lldbsuite.test.lldbpexpect import PExpectTest
 
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
 class TestStatusline(PExpectTest):
+# Change this value to something smaller to make debugging this test less
+# tedious.
+TIMEOUT = 60
+
+TERMINAL_HEIGHT = 10
+TERMINAL_WIDTH = 60
+
 def do_setup(self):
 # Create a target and run to a breakpoint.
 exe = self.getBuildArtifact("a.out")
@@ -15,36 +25,34 @@ def do_setup(self):
 )
 self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
 self.expect("run", substrs=["stop reason"])
+self.resize()
+
+def resize(self):
+# Change the terminal dimensions. When we launch the tests, we reset
+# all the settings, leaving the terminal dimensions unset.
+self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
 
-# PExpect uses many timeouts internally and doesn't play well
-# under ASAN on a loaded machine..
-@skipIfAsan
 def test(self):
 """Basic test for the statusline."""
 self.build()
-self.launch()
+self.launch(timeout=self.TIMEOUT)
 self.do_setup()
 
-# Change the terminal dimensions.
-terminal_height = 10
-terminal_width = 60
-self.child.setwinsize(terminal_height, terminal_width)
-
 # Enable the statusline and check for the control character and that we
 # can see the target, the location and the stop reason.
 self.expect('set set separator "| "')
 self.expect(
 "set set show-statusline true",
 [
-"\x1b[0;{}r".format(terminal_height - 1),
+"\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
 "a.out | main.c:2:11 | breakpoint 1.1",
 ],
 )
 
 # Change the terminal dimensions and make sure it's reflected 
immediately.
-self.child.setwinsize(terminal_height, 25)
+self.child.setwinsize(self.TERMINAL_HEIGHT, 25)
 self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
-self.child.setwinsize(terminal_height, terminal_width)
+self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
 
 # Change the separator.
 self.expect('set set separator "S "', ["a.out S main.c:2:11"])
@@ -58,23 +66,15 @@ def test(self):
 
 # Hide the statusline and check or the control character.
 self.expect(
-"set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
+"set set show-statusline false", 
["\x1b[0;{}r".format(self.TERMINAL_HEIGHT)]
 )
 
-# PExpect uses many timeouts internally and doesn't play well
-# under ASAN on a loaded machine..
-@skipIfAsan
 def test_no_color(self):
 """Basic test for the statusline with colors disabled."""
 self.build()
-self.launch(use_colors=False)
+self.launch(use_colors=False, timeout=self.TIMEOUT)
 self.do_setup()
 
-# Change the terminal dimensions.
-terminal_height = 10
-termin

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

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


@@ -0,0 +1,58 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUIRES: x86

bulbazord wrote:

Why does this test require x86?

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-dap] Migrate attach to typed RequestHandler. (PR #137911)

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


@@ -183,7 +194,7 @@ struct Configuration {
 
   /// Specify a source path to remap "./" to allow full paths to be used when
   /// setting breakpoints in binaries that have relative source paths.
-  std::optional sourcePath;
+  std::string sourcePath = "";

ashgti wrote:

Removed the `= ""` part here and below.

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


[Lldb-commits] [lldb] [lldb-dap] Migrate attach to typed RequestHandler. (PR #137911)

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


@@ -10,183 +10,133 @@
 #include "EventHelper.h"
 #include "JSONUtils.h"
 #include "LLDBUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
+#include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBListener.h"
+#include "lldb/lldb-defines.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 
+using namespace llvm;
+using namespace lldb_dap::protocol;
+
 namespace lldb_dap {
 
-// "AttachRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Attach request; value of command field is 'attach'.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "attach" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/AttachRequestArguments"
-//   }
-// },
-// "required": [ "command", "arguments" ]
-//   }]
-// },
-// "AttachRequestArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'attach' request.\nThe attach request has no
-//   standardized attributes."
-// },
-// "AttachResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'attach' request. This is just an
-// acknowledgement, so no body field is required."
-//   }]
-// }
-void AttachRequestHandler::operator()(const llvm::json::Object &request) const 
{
-  dap.is_attach = true;
-  llvm::json::Object response;
-  lldb::SBError error;
-  FillResponse(request, response);
-  const int invalid_port = 0;
-  const auto *arguments = request.getObject("arguments");
-  const lldb::pid_t pid =
-  GetInteger(arguments, "pid").value_or(LLDB_INVALID_PROCESS_ID);
-  const auto gdb_remote_port =
-  GetInteger(arguments, 
"gdb-remote-port").value_or(invalid_port);
-  const auto gdb_remote_hostname =
-  GetString(arguments, "gdb-remote-hostname").value_or("localhost");
-  const auto wait_for = GetBoolean(arguments, "waitFor").value_or(false);
-  dap.configuration.initCommands = GetStrings(arguments, "initCommands");
-  dap.configuration.preRunCommands = GetStrings(arguments, "preRunCommands");
-  dap.configuration.postRunCommands = GetStrings(arguments, "postRunCommands");
-  dap.configuration.stopCommands = GetStrings(arguments, "stopCommands");
-  dap.configuration.exitCommands = GetStrings(arguments, "exitCommands");
-  dap.configuration.terminateCommands =
-  GetStrings(arguments, "terminateCommands");
-  auto attachCommands = GetStrings(arguments, "attachCommands");
-  llvm::StringRef core_file = GetString(arguments, "coreFile").value_or("");
-  const uint64_t timeout_seconds =
-  GetInteger(arguments, "timeout").value_or(30);
-  dap.stop_at_entry = core_file.empty()
-  ? GetBoolean(arguments, 
"stopOnEntry").value_or(false)
-  : true;
-  const llvm::StringRef debuggerRoot =
-  GetString(arguments, "debuggerRoot").value_or("");
-  dap.configuration.enableAutoVariableSummaries =
-  GetBoolean(arguments, "enableAutoVariableSummaries").value_or(false);
-  dap.configuration.enableSyntheticChildDebugging =
-  GetBoolean(arguments, "enableSyntheticChildDebugging").value_or(false);
-  dap.configuration.displayExtendedBacktrace =
-  GetBoolean(arguments, "displayExtendedBacktrace").value_or(false);
-  dap.configuration.commandEscapePrefix =
-  GetString(arguments, "commandEscapePrefix").value_or("`");
-  dap.configuration.program = GetString(arguments, "program");
-  dap.configuration.targetTriple = GetString(arguments, "targetTriple");
-  dap.configuration.platformName = GetString(arguments, "platformName");
-  dap.SetFrameFormat(GetString(arguments, "customFrameFormat").value_or(""));
-  dap.SetThreadFormat(GetString(arguments, "customThreadFormat").value_or(""));
+/// The `attach` request is sent from the client to the debug adapter to attach
+/// to a debuggee that is already running.
+///
+/// Since attaching is debugger/runtime specific, the arguments for this 
request
+/// are not part of this specification.
+Error AttachRequestHandler::Run(const AttachRequestArguments &args) const {
+  // Validate that we have a well formed attach request.
+  if (args.attachCommands.empty() && args.coreFile.empty() &&
+  args.configuration.program.empty() &&
+  args.pid == LLDB_INVALID_PROCESS_ID &&
+  args.gdbRemotePort == LLDB_DAP_INVALID_PORT)
+return make_error(
+"expected one of 'pid', 'program', 'attachCommands', "
+"'coreFile' or 'gdb-remote-port' to be specified");
+
+  // Check if we have mutually exclusive arguments.
+  if ((args.pid != LLDB_INVALID_PROCESS_ID) &&
+  (args.gdbRemotePort != LLDB_DAP_INVALID_PORT))
+return make_error(
+"'pid' and 'gdb-remote-port' are mutually exclusive");
+
+  dap.SetConfiguration(args.configuration, /*is_attach=*/true);
+  if (!args.coreFile.empty())
+dap.stop_at_entry = true;
 
   PrintWelcomeMessage();

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

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


@@ -1170,10 +1171,41 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's
+  // file(s) will be found. So if a header was requested and we got a
+  // primary file (ie., something with a different name), then look 
thru
+  // its support file(s) for the header.
+  lldb::SupportFileSP found_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+
+  if (!llvm::StringRef(found_file_sp->GetSpecOnly().GetPath())
+   .ends_with(filename)) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if (llvm::StringRef(file->GetSpecOnly().GetPath())
+  .ends_with(filename)) {
+found_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n", filename);

bulbazord wrote:

The error message implies that you're looking for a header, but maybe 
somebody's not looking for a header per se. You could do something like 
`#include "foo.inc"` and maybe a developer wouldn't conceptualize that as 
including a header.

Maybe a more generic message like `Failed to find requested file`?

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-08 Thread Vy Nguyen via lldb-commits

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

>From 5746e997eea55c05cbbb63ad6f78ca225c9ac855 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 7 May 2025 21:37:31 -0400
Subject: [PATCH 1/5] [lldb]Make `list` command work with  headers when
 possible.

---
 lldb/source/Commands/CommandObjectSource.cpp | 36 +++-
 lldb/source/Core/ModuleList.cpp  |  2 +
 lldb/test/Shell/Commands/list-header.test| 59 
 3 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/list-header.test

diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..475317021255c 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   bool check_inlines = false;
   SymbolContextList sc_list;
   size_t num_matches = 0;
+  uint32_t start_line = m_options.start_line;
 
   if (!m_options.modules.empty()) {
 ModuleList matching_modules;
@@ -1114,7 +1115,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),
 sc_list);
@@ -1122,7 +1123,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   } else {
 num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
   }
 
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if 
(llvm::StringRef(file->GetSpecOnly().GetPath()).ends_with(filename)) {
+actual_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+} else if (support_matches_count > 1) {
+  result.AppendErrorWithFormat(
+  "Multiple files found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+}
+  }
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
+  actual_file_sp,
   m_options.start_line, column, 0, m_options.num_lines, "",
   &result.GetOutputStream(), GetBreakpointLocations());
 
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d5ddf6e846112..90c6a62727734 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -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();
   for (const ModuleSP &module_sp : m_modules) {
 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
 resolve_scope, sc_list);
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..ca700cd2b2fb1
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,59 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUIRE

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

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


@@ -0,0 +1,58 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUIRES: x86

oontvoo wrote:

removed

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-08 Thread Vy Nguyen via lldb-commits


@@ -1170,10 +1171,41 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's
+  // file(s) will be found. So if a header was requested and we got a
+  // primary file (ie., something with a different name), then look 
thru
+  // its support file(s) for the header.
+  lldb::SupportFileSP found_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+
+  if (!llvm::StringRef(found_file_sp->GetSpecOnly().GetPath())
+   .ends_with(filename)) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if (llvm::StringRef(file->GetSpecOnly().GetPath())
+  .ends_with(filename)) {
+found_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n", filename);

oontvoo wrote:

done

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] Revert branch island experiments (PR #139192)

2025-05-08 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/139192

This test is failing because when we step to what is the branch island address 
and ask for its symbol, we can't resolve the symbol, and just call it the last 
padding symbol plus a bajillion.

That has nothing to do with the changes in this patch, but I'll revert this and 
keep trying to figure out why symbol reading on this bot is wrong.



  



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] Provide lr value in faulting frame on arm64 (PR #138805)

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

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

>From 4fc9acd03a58a3617b113352c48e5dd2fdb58eda Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 6 May 2025 22:37:17 -0700
Subject: [PATCH 1/7] [lldb] Provide lr value in faulting frame on arm64

When a frameless function faults or is interrupted asynchronously,
the UnwindPlan MAY have no register location rule for the return
address register (lr on arm64); the value is simply live in the
lr register when it was interrupted, and the frame below this on
the stack -- e.g. sigtramp on a Unix system -- has the full
register context, including that register.

RegisterContextUnwind::SavedLocationForRegister, when asked to find
the caller's pc value, will first see if there is a pc register
location.  If there isn't, on a Return Address Register architecture
like arm/mips/riscv, we rewrite the register request from "pc" to
"RA register", and search for a location.

On frame 0 (the live frame) and an interrupted frame, the UnwindPlan
may have no register location rule for the RA Reg, that is valid.
A frameless function that never calls another may simply keep the
return address in the live register the whole way.  Our instruction
emulation unwind plans explicitly add a rule (see Pavel's May 2024
change https://github.com/llvm/llvm-project/pull/91321 ), but an
UnwindPlan sourced from debug_frame may not.

I've got a case where this exactly happens - clang debug_frame for
arm64 where there is no register location for the lr in a frameless
function.  There is a fault in the middle of this frameless function
and we only get the lr value from the fault handler below this frame
if lr has a register location of `IsSame`, in line with Pavel's
2024 change.

Similar to how we see a request of the RA Reg from frame 0 after
failing to find an unwind location for the pc register, the same
style of special casing is needed when this is a function that
was interrupted.

Without this change, we can find the pc of the frame that was
executing when it was interrupted, but we need $lr to find its
caller, and we don't descend down to the trap handler to get that
value, truncating the stack.

rdar://145614545
---
 lldb/source/Target/RegisterContextUnwind.cpp | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3ed49e12476dd..23a86bee2518b 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1377,6 +1377,7 @@ RegisterContextUnwind::SavedLocationForRegister(
 }
   }
 
+  // Check if the active_row has a register location listed.
   if (regnum.IsValid() &&
   
active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
   unwindplan_regloc)) {
@@ -1390,11 +1391,10 @@ RegisterContextUnwind::SavedLocationForRegister(
   // This is frame 0 and we're retrieving the PC and it's saved in a Return
   // Address register and it hasn't been saved anywhere yet -- that is,
   // it's still live in the actual register. Handle this specially.
-
   if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
-  IsFrameZero()) {
-if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
-LLDB_INVALID_REGNUM) {
+  return_address_reg.GetAsKind(eRegisterKindLLDB) !=
+  LLDB_INVALID_REGNUM) {
+if (IsFrameZero()) {
   lldb_private::UnwindLLDB::ConcreteRegisterLocation new_regloc;
   new_regloc.type = UnwindLLDB::ConcreteRegisterLocation::
   eRegisterInLiveRegisterContext;
@@ -1408,6 +1408,17 @@ RegisterContextUnwind::SavedLocationForRegister(
return_address_reg.GetAsKind(eRegisterKindLLDB),
return_address_reg.GetAsKind(eRegisterKindLLDB));
   return UnwindLLDB::RegisterSearchResult::eRegisterFound;
+} else if (BehavesLikeZerothFrame()) {
+  // This function was interrupted asynchronously -- it faulted,
+  // an async interrupt, a timer fired, a debugger expression etc.
+  // The caller's pc is in the Return Address register, but the
+  // UnwindPlan for this function may have no location rule for
+  // the RA reg.
+  // This means that the caller's return address is in the RA reg
+  // when the function was interrupted--descend down one stack frame
+  // to retrieve it from the trap handler's saved context.
+  unwindplan_regloc.SetSame();
+  have_unwindplan_regloc = true;
 }
   }
 

>From b10162deb49ecddca6439665c2b8ea1995fdd81f Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 7 May 2025 23:24:17 -0700
Subject: [PATCH 2/7] Add the sources for an API test case to be written

---
 .../interrupt-and-trap-funcs.s| 92 +++

[Lldb-commits] [lldb] Revert branch island experiments (PR #139192)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

This test is failing because when we step to what is the branch island address 
and ask for its symbol, we can't resolve the symbol, and just call it the last 
padding symbol plus a bajillion.

That has nothing to do with the changes in this patch, but I'll revert this and 
keep trying to figure out why symbol reading on this bot is wrong.

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


9 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+7-34) 
- (removed) lldb/test/API/macosx/branch-islands/Makefile (-16) 
- (removed) lldb/test/API/macosx/branch-islands/TestBranchIslands.py (-72) 
- (removed) lldb/test/API/macosx/branch-islands/foo.c (-6) 
- (removed) lldb/test/API/macosx/branch-islands/main.c (-6) 
- (removed) lldb/test/API/macosx/branch-islands/padding1.s (-3) 
- (removed) lldb/test/API/macosx/branch-islands/padding2.s (-3) 
- (removed) lldb/test/API/macosx/branch-islands/padding3.s (-3) 
- (removed) lldb/test/API/macosx/branch-islands/padding4.s (-3) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 6c3040ef1a1da..e25c4ff55e408 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,7 +26,6 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -924,15 +923,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
-ConstString current_name =
-current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
+  ConstString trampoline_name =
+  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (current_name) {
+  if (trampoline_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -946,8 +945,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
-  reexported_symbols);
+images.FindSymbolsWithNameAndType(
+trampoline_name, eSymbolTypeReExported, reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -969,7 +968,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1029,32 +1028,6 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
-// One more case we have to consider is "branch islands".  These are 
regular
-// TEXT symbols but their names end in .island plus maybe a .digit suffix.
-// They are to allow arm64 code to branch further than the size of the
-// address slot allows.  We just need to single-instruction step in that
-// case.
-static const char *g_branch_island_pattern = "\\.island\\.?[0-9]*$";
-static RegularExpression g_branch_island_regex(g_branch_island_pattern);
-
-bool is_branch_island = g_branch_island_regex.Execute(current_name);
-// FIXME: this is extra logging so I can figure out why this test is 
failing
-// on the bot but not locally with all the same tools, etc...
-if (thread_plan_sp && is_branch_island) {
-  if (log) {
-StreamString s;
-thread_plan_sp->GetDescription(&s, eDescriptionLevelVerbose);
-LLDB_LOGF(log, "Am at a branch island, but already had plan: \n\t%s", 
s.GetData());
-  }
-}
-if (!thread_plan_sp && is_branch_island) {
-  thread_plan_sp = std::make_shared(
-  thread,
-  /* step_over=

[Lldb-commits] [lldb] Revert branch island experiments (PR #139192)

2025-05-08 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Provide lr value in faulting frame on arm64 (PR #138805)

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

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

>From 4fc9acd03a58a3617b113352c48e5dd2fdb58eda Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 6 May 2025 22:37:17 -0700
Subject: [PATCH 1/6] [lldb] Provide lr value in faulting frame on arm64

When a frameless function faults or is interrupted asynchronously,
the UnwindPlan MAY have no register location rule for the return
address register (lr on arm64); the value is simply live in the
lr register when it was interrupted, and the frame below this on
the stack -- e.g. sigtramp on a Unix system -- has the full
register context, including that register.

RegisterContextUnwind::SavedLocationForRegister, when asked to find
the caller's pc value, will first see if there is a pc register
location.  If there isn't, on a Return Address Register architecture
like arm/mips/riscv, we rewrite the register request from "pc" to
"RA register", and search for a location.

On frame 0 (the live frame) and an interrupted frame, the UnwindPlan
may have no register location rule for the RA Reg, that is valid.
A frameless function that never calls another may simply keep the
return address in the live register the whole way.  Our instruction
emulation unwind plans explicitly add a rule (see Pavel's May 2024
change https://github.com/llvm/llvm-project/pull/91321 ), but an
UnwindPlan sourced from debug_frame may not.

I've got a case where this exactly happens - clang debug_frame for
arm64 where there is no register location for the lr in a frameless
function.  There is a fault in the middle of this frameless function
and we only get the lr value from the fault handler below this frame
if lr has a register location of `IsSame`, in line with Pavel's
2024 change.

Similar to how we see a request of the RA Reg from frame 0 after
failing to find an unwind location for the pc register, the same
style of special casing is needed when this is a function that
was interrupted.

Without this change, we can find the pc of the frame that was
executing when it was interrupted, but we need $lr to find its
caller, and we don't descend down to the trap handler to get that
value, truncating the stack.

rdar://145614545
---
 lldb/source/Target/RegisterContextUnwind.cpp | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3ed49e12476dd..23a86bee2518b 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1377,6 +1377,7 @@ RegisterContextUnwind::SavedLocationForRegister(
 }
   }
 
+  // Check if the active_row has a register location listed.
   if (regnum.IsValid() &&
   
active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
   unwindplan_regloc)) {
@@ -1390,11 +1391,10 @@ RegisterContextUnwind::SavedLocationForRegister(
   // This is frame 0 and we're retrieving the PC and it's saved in a Return
   // Address register and it hasn't been saved anywhere yet -- that is,
   // it's still live in the actual register. Handle this specially.
-
   if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
-  IsFrameZero()) {
-if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
-LLDB_INVALID_REGNUM) {
+  return_address_reg.GetAsKind(eRegisterKindLLDB) !=
+  LLDB_INVALID_REGNUM) {
+if (IsFrameZero()) {
   lldb_private::UnwindLLDB::ConcreteRegisterLocation new_regloc;
   new_regloc.type = UnwindLLDB::ConcreteRegisterLocation::
   eRegisterInLiveRegisterContext;
@@ -1408,6 +1408,17 @@ RegisterContextUnwind::SavedLocationForRegister(
return_address_reg.GetAsKind(eRegisterKindLLDB),
return_address_reg.GetAsKind(eRegisterKindLLDB));
   return UnwindLLDB::RegisterSearchResult::eRegisterFound;
+} else if (BehavesLikeZerothFrame()) {
+  // This function was interrupted asynchronously -- it faulted,
+  // an async interrupt, a timer fired, a debugger expression etc.
+  // The caller's pc is in the Return Address register, but the
+  // UnwindPlan for this function may have no location rule for
+  // the RA reg.
+  // This means that the caller's return address is in the RA reg
+  // when the function was interrupted--descend down one stack frame
+  // to retrieve it from the trap handler's saved context.
+  unwindplan_regloc.SetSame();
+  have_unwindplan_regloc = true;
 }
   }
 

>From b10162deb49ecddca6439665c2b8ea1995fdd81f Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 7 May 2025 23:24:17 -0700
Subject: [PATCH 2/6] Add the sources for an API test case to be written

---
 .../interrupt-and-trap-funcs.s| 92 +++

[Lldb-commits] [lldb] 74120d0 - Revert branch island experiments (#139192)

2025-05-08 Thread via lldb-commits

Author: jimingham
Date: 2025-05-08T18:37:43-07:00
New Revision: 74120d0a389584bd8d74073fb0c0b80af29f0a4c

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

LOG: Revert branch island experiments (#139192)

This test is failing because when we step to what is the branch island
address and ask for its symbol, we can't resolve the symbol, and just
call it the last padding symbol plus a bajillion.

That has nothing to do with the changes in this patch, but I'll revert
this and keep trying to figure out why symbol reading on this bot is
wrong.

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Removed: 
lldb/test/API/macosx/branch-islands/Makefile
lldb/test/API/macosx/branch-islands/TestBranchIslands.py
lldb/test/API/macosx/branch-islands/foo.c
lldb/test/API/macosx/branch-islands/main.c
lldb/test/API/macosx/branch-islands/padding1.s
lldb/test/API/macosx/branch-islands/padding2.s
lldb/test/API/macosx/branch-islands/padding3.s
lldb/test/API/macosx/branch-islands/padding4.s



diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 6c3040ef1a1da..e25c4ff55e408 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,7 +26,6 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -924,15 +923,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
-ConstString current_name =
-current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
+  ConstString trampoline_name =
+  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (current_name) {
+  if (trampoline_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -946,8 +945,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
-  reexported_symbols);
+images.FindSymbolsWithNameAndType(
+trampoline_name, eSymbolTypeReExported, reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -969,7 +968,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1029,32 +1028,6 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
-// One more case we have to consider is "branch islands".  These are 
regular
-// TEXT symbols but their names end in .island plus maybe a .digit suffix.
-// They are to allow arm64 code to branch further than the size of the
-// address slot allows.  We just need to single-instruction step in that
-// case.
-static const char *g_branch_island_pattern = "\\.island\\.?[0-9]*$";
-static RegularExpression g_branch_island_regex(g_branch_island_pattern);
-
-bool is_branch_island = g_branch_island_regex.Execute(current_name);
-// FIXME: this is extra logging so I can figure out why this test is 
failing
-// on the bot but not locally with all the same tools, etc...
-if (thread_plan_sp && is_branch_island) {
-  if (log) {
-StreamString s;
-thread_plan_sp->GetDescription(&s, eDescriptionLevelVerbose);
-LLDB_LOGF(log, "Am at a branch island, but already had plan: \n\t%s", 
s.GetData());
-  }
-

[Lldb-commits] [lldb] [lldb-dap] Move the event and progress event threads into DAP (NFC) (PR #139167)

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

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

>From 724a9e9a13de896e43935b2c77e8398a3ed318c5 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 8 May 2025 15:47:22 -0700
Subject: [PATCH] [lldb-dap] Move the event and progress event threads into DAP
 (NFC)

Move the event and progress event threads into the DAP class. Currently
both are implemented in the InitializeRequestHandler, but it doesn't
really belong there because the threads are not tied to that request,
they just launch them.
---
 lldb/tools/lldb-dap/DAP.cpp   | 261 +-
 lldb/tools/lldb-dap/DAP.h |  14 +-
 .../Handler/InitializeRequestHandler.cpp  | 253 +
 3 files changed, 269 insertions(+), 259 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 62c60cc3a9b3b..552904fe95672 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "DAPLog.h"
+#include "EventHelper.h"
 #include "Handler/RequestHandler.h"
 #include "Handler/ResponseHandler.h"
 #include "JSONUtils.h"
@@ -20,6 +21,7 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBProcess.h"
@@ -52,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -77,6 +80,48 @@ const char DEV_NULL[] = "/dev/null";
 
 namespace lldb_dap {
 
+static std::string GetStringFromStructuredData(lldb::SBStructuredData &data,
+   const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+  if (!keyValue)
+return std::string();
+
+  const size_t length = keyValue.GetStringValue(nullptr, 0);
+
+  if (length == 0)
+return std::string();
+
+  std::string str(length + 1, 0);
+  keyValue.GetStringValue(&str[0], length + 1);
+  return str;
+}
+
+static uint64_t GetUintFromStructuredData(lldb::SBStructuredData &data,
+  const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+
+  if (!keyValue.IsValid())
+return 0;
+  return keyValue.GetUnsignedIntegerValue();
+}
+
+static llvm::StringRef GetModuleEventReason(uint32_t event_mask) {
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded)
+return "new";
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded)
+return "removed";
+  assert(event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded ||
+ event_mask & lldb::SBTarget::eBroadcastBitSymbolsChanged);
+  return "changed";
+}
+
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 llvm::StringRef DAP::debug_adapter_path = "";
 
 DAP::DAP(Log *log, const ReplMode default_repl_mode,
@@ -94,13 +139,6 @@ DAP::DAP(Log *log, const ReplMode default_repl_mode,
 
 DAP::~DAP() = default;
 
-/// Return string with first character capitalized.
-static std::string capitalize(llvm::StringRef str) {
-  if (str.empty())
-return "";
-  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
-}
-
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector{};
@@ -1390,4 +1428,213 @@ protocol::Capabilities DAP::GetCapabilities() {
   return capabilities;
 }
 
+void DAP::StartEventThread() {
+  event_thread = std::thread(&DAP::EventThread, this);
+}
+
+void DAP::StartProgressEventThread() {
+  progress_event_thread = std::thread(&DAP::ProgressEventThread, this);
+}
+
+void DAP::ProgressEventThread() {
+  lldb::SBListener listener("lldb-dap.progress.listener");
+  debugger.GetBroadcaster().AddListener(
+  listener, lldb::SBDebugger::eBroadcastBitProgress |
+lldb::SBDebugger::eBroadcastBitExternalProgress);
+  broadcaster.AddListener(listener, eBroadcastBitStopProgressThread);
+  lldb::SBEvent event;
+  bool done = false;
+  while (!done) {
+if (listener.WaitForEvent(1, event)) {
+  const auto event_mask = event.GetType();
+  if (event.BroadcasterMatchesRef(broadcaster)) {
+if (event_mask & eBroadcastBitStopProgressThread) {
+  done = true;
+}
+  } else {
+lldb::SBStructuredData data =
+lldb::SBDebugger::GetProgressDataFromEvent(event);
+
+const uint64_t progress_id =
+GetUintFromStructuredData(data, "progress_id");
+const uint64_t completed = GetUintFromStructuredData(data, 
"completed");
+const uint64_t total = GetUintFromStructuredData(data, "total");
+const std::string details =
+GetStringFromStructuredData(d

[Lldb-commits] [lldb] [lldb-dap] Adding a modules explorer to lldb-dap ext. (PR #138977)

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

ashgti wrote:

Yea, the address is being encoded as an plain integer not a hex string here 
https://github.com/llvm/llvm-project/blob/fa43e8f7de534984bc56b6319b72fd8ad422cbdf/lldb/tools/lldb-dap/JSONUtils.cpp#L492-L494

We can follow up with other adjustments to either the data.

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


[Lldb-commits] [lldb] 611d81b - [lldb-dap] Adding a modules explorer to lldb-dap ext. (#138977)

2025-05-08 Thread via lldb-commits

Author: John Harrison
Date: 2025-05-08T15:25:28-07:00
New Revision: 611d81bd9304768f3cdb101d37c81d36b9762723

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

LOG: [lldb-dap] Adding a modules explorer to lldb-dap ext. (#138977)

This creates a very basic module explorer for tracking and displaying
loaded modules, reported by lldb-dap for the active debug session.

This includes a basic session tracker that we can use to observe the
debug session and collect specific information for additional
visualizations in the lldb-dap ext.

Here is a screenshot of the current visualization in the tree view.
There is some unfortunate wrapping of the path, but it shows the basic
support that could be extended in the future.

https://github.com/user-attachments/assets/588baa2f-61d5-4434-8692-b1d0cce42875";
/>

Added: 
lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
lldb/tools/lldb-dap/src-ts/ui/modules-data-provider.ts

Modified: 
lldb/tools/lldb-dap/package-lock.json
lldb/tools/lldb-dap/package.json
lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
lldb/tools/lldb-dap/src-ts/disposable-context.ts
lldb/tools/lldb-dap/src-ts/extension.ts

Removed: 




diff  --git a/lldb/tools/lldb-dap/package-lock.json 
b/lldb/tools/lldb-dap/package-lock.json
index ab5c7dc33a8e5..0a2b9e764067e 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -1,16 +1,17 @@
 {
   "name": "lldb-dap",
-  "version": "0.2.10",
+  "version": "0.2.13",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
 "": {
   "name": "lldb-dap",
-  "version": "0.2.10",
+  "version": "0.2.13",
   "license": "Apache 2.0 License with LLVM exceptions",
   "devDependencies": {
 "@types/node": "^18.19.41",
 "@types/vscode": "1.75.0",
+"@vscode/debugprotocol": "^1.68.0",
 "@vscode/vsce": "^3.2.2",
 "prettier": "^3.4.2",
 "prettier-plugin-curly": "^0.3.1",
@@ -405,6 +406,13 @@
   "dev": true,
   "license": "MIT"
 },
+"node_modules/@vscode/debugprotocol": {
+  "version": "1.68.0",
+  "resolved": 
"https://registry.npmjs.org/@vscode/debugprotocol/-/debugprotocol-1.68.0.tgz";,
+  "integrity": 
"sha512-2J27dysaXmvnfuhFGhfeuxfHRXunqNPxtBoR3koiTOA9rdxWNDTa1zIFLCFMSHJ9MPTPKFcBeblsyaCJCIlQxg==",
+  "dev": true,
+  "license": "MIT"
+},
 "node_modules/@vscode/vsce": {
   "version": "3.2.2",
   "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.2.2.tgz";,

diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index a7631464d236a..e3e46526f379f 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -30,9 +30,10 @@
   "devDependencies": {
 "@types/node": "^18.19.41",
 "@types/vscode": "1.75.0",
+"@vscode/debugprotocol": "^1.68.0",
 "@vscode/vsce": "^3.2.2",
-"prettier-plugin-curly": "^0.3.1",
 "prettier": "^3.4.2",
+"prettier-plugin-curly": "^0.3.1",
 "typescript": "^5.7.3"
   },
   "activationEvents": [
@@ -760,6 +761,16 @@
   }
 ]
   }
-]
+],
+"views": {
+  "debug": [
+{
+  "id": "lldb-dap.modules",
+  "name": "Modules",
+  "when": "inDebugMode && debugType == 'lldb-dap'",
+  "icon": "$(symbol-module)"
+}
+  ]
+}
   }
 }

diff  --git a/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts 
b/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
index c91b101f4a9ba..957bc5e1eb956 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
@@ -78,7 +78,7 @@ export class LLDBDapConfigurationProvider
 debugConfiguration: vscode.DebugConfiguration,
 token?: vscode.CancellationToken,
   ): Promise {
-let config = vscode.workspace.getConfiguration("lldb-dap.defaults");
+let config = vscode.workspace.getConfiguration("lldb-dap");
 for (const [key, cfg] of Object.entries(configurations)) {
   if (Reflect.has(debugConfiguration, key)) {
 continue;

diff  --git a/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts 
b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
new file mode 100644
index 0..1ce190938d9c7
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts/debug-session-tracker.ts
@@ -0,0 +1,109 @@
+import { DebugProtocol } from "@vscode/debugprotocol";
+import * as vscode from "vscode";
+
+/** A helper type for mapping event types to their corresponding data type. */
+// prettier-ignore
+interface EventMap {
+  "module": DebugProtocol.ModuleEvent;
+}
+
+/** A type assertion to check if a ProtocolMessage is an event or if it is a 
specific

[Lldb-commits] [lldb] [lldb-dap] Adding a modules explorer to lldb-dap ext. (PR #138977)

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

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


[Lldb-commits] [lldb] Branch island debug (PR #139166)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

This patch allows lldb to step in across "branch islands" which is the Darwin 
linker's way of dealing with immediate branches to targets that are too far 
away for the immediate slot to make the jump.

I submitted this a couple days ago and it failed on the arm64 bot.  I was able 
to match the bot OS and Tool versions (they are a bit old at this point) and 
ran the test there but sadly it succeeded.  The x86_64 bot also failed but that 
was my bad, I did @skipUnlessDarwin when I should have done @skipUnlessAppleSilicon.

So this resubmission is with the proper decoration for the test, and with a 
bunch of debug output printed in case of failure.  With any luck, if this 
resubmission fails again I'll be able to see what's going on.

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


9 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+25-7) 
- (added) lldb/test/API/macosx/branch-islands/Makefile (+16) 
- (added) lldb/test/API/macosx/branch-islands/TestBranchIslands.py (+61) 
- (added) lldb/test/API/macosx/branch-islands/foo.c (+6) 
- (added) lldb/test/API/macosx/branch-islands/main.c (+6) 
- (added) lldb/test/API/macosx/branch-islands/padding1.s (+3) 
- (added) lldb/test/API/macosx/branch-islands/padding2.s (+3) 
- (added) lldb/test/API/macosx/branch-islands/padding3.s (+3) 
- (added) lldb/test/API/macosx/branch-islands/padding4.s (+3) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index e25c4ff55e408..578ab12268ea3 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -26,6 +26,7 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -923,15 +924,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   if (current_symbol != nullptr) {
 std::vector addresses;
 
+ConstString current_name =
+current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 if (current_symbol->IsTrampoline()) {
-  ConstString trampoline_name =
-  current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
 
-  if (trampoline_name) {
+  if (current_name) {
 const ModuleList &images = target_sp->GetImages();
 
 SymbolContextList code_symbols;
-images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode,
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeCode,
   code_symbols);
 for (const SymbolContext &context : code_symbols) {
   Address addr = context.GetFunctionOrSymbolAddress();
@@ -945,8 +946,8 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList reexported_symbols;
-images.FindSymbolsWithNameAndType(
-trampoline_name, eSymbolTypeReExported, reexported_symbols);
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeReExported,
+  reexported_symbols);
 for (const SymbolContext &context : reexported_symbols) {
   if (context.symbol) {
 Symbol *actual_symbol =
@@ -968,7 +969,7 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 }
 
 SymbolContextList indirect_symbols;
-images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeResolver,
+images.FindSymbolsWithNameAndType(current_name, eSymbolTypeResolver,
   indirect_symbols);
 
 for (const SymbolContext &context : indirect_symbols) {
@@ -1028,6 +1029,23 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
   thread_plan_sp = std::make_shared(
   thread, load_addrs, stop_others);
 }
+// One more case we have to consider is "branch islands".  These are 
regular
+// TEXT symbols but their names end in .island plus maybe a .digit suffix.
+// They are to allow arm64 code to branch further than the size of the
+// address slot allows.  We just need to single-instruction step in that
+// case.
+static const char *g_branch_island_pattern = "\\.island\\.?[0-9]*$";
+static RegularExpression g_branch_island_regex(g_branch_island_pattern);
+
+bool is_branch_island = g_branch_island_regex.Execute(current_name);
+if (!thread_plan_sp && is_branch_island) {
+  thread_plan_sp = std::make_shared(
+  thread,
+  /* step_over= */ false, /* stop_others */ false, e

[Lldb-commits] [lldb] Add more logging so I can figure out why TestBranchIslands.py is (PR #139178)

2025-05-08 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Provide lr value in faulting frame on arm64 (PR #138805)

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

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



  



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] Provide lr value in faulting frame on arm64 (PR #138805)

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

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



  



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] Ptrace seize dead process (PR #137041)

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

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



  



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] Ptrace seize dead process (PR #137041)

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

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

This the actual PR to my [SEIZE 
RFC](https://discourse.llvm.org/t/rfc-ptrace-seize-when-attaching-to-dead-processes/85825/8).
 This is currently the bare bones on seizing a dead process, and being able to 
attach and introspect with LLDB.

Additionally, right now I only check proc status before seize, and we should 
double check after seize that the process has not changed. Worth noting is once 
you seize a coredumping process (and it hits trace stop), Coredumping in status 
will now report 0.

This is pretty complicated to test because it requires integration with the 
Kernel, thankfully the setup only involves some very simple toy programs, which 
I have outlined with instructions [in this 
gist](https://gist.github.com/Jlalond/a81a995dd14ff5d88b7f21f00879ce83)

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


2 Files Affected:

- (modified) lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp (+109-6) 
- (modified) lldb/source/Plugins/Process/Linux/NativeProcessLinux.h (+4-1) 


``diff
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 7f2aba0e4eb2c..141e49d8a0b7e 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -312,10 +312,26 @@ NativeProcessLinux::Manager::Attach(
   Log *log = GetLog(POSIXLog::Process);
   LLDB_LOG(log, "pid = {0:x}", pid);
 
-  auto tids_or = NativeProcessLinux::Attach(pid);
-  if (!tids_or)
-return tids_or.takeError();
-  ArrayRef<::pid_t> tids = *tids_or;
+  // This safety check lets us decide if we should
+  // seize or attach.
+  ProcessInstanceInfo process_info;
+  if (!Host::GetProcessInfo(pid, process_info))
+return llvm::make_error("Unable to read process info",
+ llvm::inconvertibleErrorCode());
+
+  std::vector<::pid_t> tids;
+  if (process_info.IsCoreDumping()) {
+auto attached_or = NativeProcessLinux::Seize(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  } else {
+auto attached_or = NativeProcessLinux::Attach(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  }
+
   llvm::Expected arch_or =
   NativeRegisterContextLinux::DetermineArchitecture(tids[0]);
   if (!arch_or)
@@ -444,6 +460,88 @@ NativeProcessLinux::NativeProcessLinux(::pid_t pid, int 
terminal_fd,
   SetState(StateType::eStateStopped, false);
 }
 
+llvm::Expected> NativeProcessLinux::Seize(::pid_t pid) {
+  Log *log = GetLog(POSIXLog::Process);
+
+  uint64_t options = GetDefaultPtraceOpts();
+  Status status;
+  // Use a map to keep track of the threads which we have attached/need to
+  // attach.
+  Host::TidMap tids_to_attach;
+  while (Host::FindProcessThreads(pid, tids_to_attach)) {
+for (Host::TidMap::iterator it = tids_to_attach.begin();
+ it != tids_to_attach.end();) {
+  if (it->second == true) {
+continue;
+  }
+  lldb::tid_t tid = it->first;
+  if ((status = PtraceWrapper(PTRACE_SEIZE, tid, nullptr, (void *)options))
+  .Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  if ((status = PtraceWrapper(PTRACE_INTERRUPT, tid)).Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  int wpid =
+  llvm::sys::RetryAfterSignal(-1, ::waitpid, tid, nullptr, __WALL);
+  // Need to use __WALL otherwise we receive an error with errno=ECHLD At
+  // this point we should have a thread stopped if waitpid succeeds.
+  if (wpid < 0) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (errno == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+return llvm::errorCodeToError(
+std::error_code(errno, std::generic_category()));
+  }
+
+  LLDB_LOG(log

[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

Jlalond wrote:

@labath @DavidSpickett Thanks for the patience.

I've broken down my prototype, and this is now patch 2, where we implement the 
SEIZE functionality. I will follow up with making it so we can't resume the 
process when we're in this state.

@DavidSpickett you mentioned you wanted me to include my gist, to my knowledge 
github will include my summary by default. Did you want me to check in the toy 
program as an example?

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


[Lldb-commits] [lldb] 2815653 - [lldb] Disable test using GetControlFlowKind on arm

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2025-05-08T13:14:40-07:00
New Revision: 28156539a9df3fa0d9db47c405c0006fcee9f77f

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

LOG: [lldb] Disable test using GetControlFlowKind on arm

Added: 


Modified: 
lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Removed: 




diff  --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py 
b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index cec2901aa0369..52763694541ec 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -70,6 +70,7 @@ def test_step_single_instruction(self):
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual("foo", frame.GetFunctionName())
 
+@skipIf(archs=no_match(["x86_64"]))
 def test_step_single_instruction_with_step_over(self):
 (target, process, thread, bkpt) = self.run_until_branch_instruction()
 



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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

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

>From fa08811c7a90b9fd1c644b051ed3d7d1157243fe Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 8 May 2025 12:56:14 -0700
Subject: [PATCH] Implement PTRACE_SEIZE when a process is coredumping

---
 .../lldb/Host/common/NativeProcessProtocol.h  |   2 +
 .../Process/Linux/NativeProcessLinux.cpp  | 120 +-
 .../Process/Linux/NativeProcessLinux.h|   5 +-
 3 files changed, 120 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h 
b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
index 1d5fecfcd5c27..f50e9da0957f5 100644
--- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -189,6 +189,8 @@ class NativeProcessProtocol {
 
   bool CanResume() const { return m_state == lldb::eStateStopped; }
 
+  bool IsStopped() const { return m_state == lldb::eStateStopped; }
+
   lldb::ByteOrder GetByteOrder() const {
 return GetArchitecture().GetByteOrder();
   }
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 7f2aba0e4eb2c..c8e8f47524fb6 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -312,10 +312,26 @@ NativeProcessLinux::Manager::Attach(
   Log *log = GetLog(POSIXLog::Process);
   LLDB_LOG(log, "pid = {0:x}", pid);
 
-  auto tids_or = NativeProcessLinux::Attach(pid);
-  if (!tids_or)
-return tids_or.takeError();
-  ArrayRef<::pid_t> tids = *tids_or;
+  // This safety check lets us decide if we should
+  // seize or attach.
+  ProcessInstanceInfo process_info;
+  if (!Host::GetProcessInfo(pid, process_info))
+return llvm::make_error("Unable to read process info",
+ llvm::inconvertibleErrorCode());
+
+  std::vector<::pid_t> tids;
+  if (process_info.IsCoreDumping()) {
+auto attached_or = NativeProcessLinux::Seize(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  } else {
+auto attached_or = NativeProcessLinux::Attach(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  }
+
   llvm::Expected arch_or =
   NativeRegisterContextLinux::DetermineArchitecture(tids[0]);
   if (!arch_or)
@@ -444,6 +460,93 @@ NativeProcessLinux::NativeProcessLinux(::pid_t pid, int 
terminal_fd,
   SetState(StateType::eStateStopped, false);
 }
 
+llvm::Expected> NativeProcessLinux::Seize(::pid_t pid) {
+  // TODO: Because the Seize during coredumping change introduces the
+  // concept of a non resumable stop, we should also check for
+  // PTRACE_O_TRACEEXIT, which per the man page the status will equal
+  // status >> 8 == (SIGTRAP | (PTRACE_EVENT_EXEC<<8))
+  // and if this is true, we should say we can't resume.
+  Log *log = GetLog(POSIXLog::Process);
+
+  uint64_t options = GetDefaultPtraceOpts();
+  Status status;
+  // Use a map to keep track of the threads which we have attached/need to
+  // attach.
+  Host::TidMap tids_to_attach;
+  while (Host::FindProcessThreads(pid, tids_to_attach)) {
+for (Host::TidMap::iterator it = tids_to_attach.begin();
+ it != tids_to_attach.end();) {
+  if (it->second == true) {
+continue;
+  }
+  lldb::tid_t tid = it->first;
+  if ((status = PtraceWrapper(PTRACE_SEIZE, tid, nullptr, (void *)options))
+  .Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  if ((status = PtraceWrapper(PTRACE_INTERRUPT, tid)).Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  int wpid =
+  llvm::sys::RetryAfterSignal(-1, ::waitpid, tid, nullptr, __WALL);
+  // Need to use __WALL otherwise we receive an error with errno=ECHLD At
+  // this point we should have a thread stopped if waitpid succeeds.
+  if (wpid < 0) {
+// No such thread. The thread may have e

[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

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

>From 42365065305d190aec3206f5d3eb35095050fb69 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 8 May 2025 12:56:14 -0700
Subject: [PATCH] Implement PTRACE_SEIZE when a process is coredumping

---
 .../Process/Linux/NativeProcessLinux.cpp  | 120 +-
 .../Process/Linux/NativeProcessLinux.h|   5 +-
 2 files changed, 118 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 7f2aba0e4eb2c..c8e8f47524fb6 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -312,10 +312,26 @@ NativeProcessLinux::Manager::Attach(
   Log *log = GetLog(POSIXLog::Process);
   LLDB_LOG(log, "pid = {0:x}", pid);
 
-  auto tids_or = NativeProcessLinux::Attach(pid);
-  if (!tids_or)
-return tids_or.takeError();
-  ArrayRef<::pid_t> tids = *tids_or;
+  // This safety check lets us decide if we should
+  // seize or attach.
+  ProcessInstanceInfo process_info;
+  if (!Host::GetProcessInfo(pid, process_info))
+return llvm::make_error("Unable to read process info",
+ llvm::inconvertibleErrorCode());
+
+  std::vector<::pid_t> tids;
+  if (process_info.IsCoreDumping()) {
+auto attached_or = NativeProcessLinux::Seize(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  } else {
+auto attached_or = NativeProcessLinux::Attach(pid);
+if (!attached_or)
+  return attached_or.takeError();
+tids = std::move(*attached_or);
+  }
+
   llvm::Expected arch_or =
   NativeRegisterContextLinux::DetermineArchitecture(tids[0]);
   if (!arch_or)
@@ -444,6 +460,93 @@ NativeProcessLinux::NativeProcessLinux(::pid_t pid, int 
terminal_fd,
   SetState(StateType::eStateStopped, false);
 }
 
+llvm::Expected> NativeProcessLinux::Seize(::pid_t pid) {
+  // TODO: Because the Seize during coredumping change introduces the
+  // concept of a non resumable stop, we should also check for
+  // PTRACE_O_TRACEEXIT, which per the man page the status will equal
+  // status >> 8 == (SIGTRAP | (PTRACE_EVENT_EXEC<<8))
+  // and if this is true, we should say we can't resume.
+  Log *log = GetLog(POSIXLog::Process);
+
+  uint64_t options = GetDefaultPtraceOpts();
+  Status status;
+  // Use a map to keep track of the threads which we have attached/need to
+  // attach.
+  Host::TidMap tids_to_attach;
+  while (Host::FindProcessThreads(pid, tids_to_attach)) {
+for (Host::TidMap::iterator it = tids_to_attach.begin();
+ it != tids_to_attach.end();) {
+  if (it->second == true) {
+continue;
+  }
+  lldb::tid_t tid = it->first;
+  if ((status = PtraceWrapper(PTRACE_SEIZE, tid, nullptr, (void *)options))
+  .Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  if ((status = PtraceWrapper(PTRACE_INTERRUPT, tid)).Fail()) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (status.GetError() == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+if (status.GetError() == EPERM) {
+  // Depending on the value of ptrace_scope, we can return a
+  // different error that suggests how to fix it.
+  return AddPtraceScopeNote(status.ToError());
+}
+return status.ToError();
+  }
+
+  int wpid =
+  llvm::sys::RetryAfterSignal(-1, ::waitpid, tid, nullptr, __WALL);
+  // Need to use __WALL otherwise we receive an error with errno=ECHLD At
+  // this point we should have a thread stopped if waitpid succeeds.
+  if (wpid < 0) {
+// No such thread. The thread may have exited. More error handling
+// may be needed.
+if (errno == ESRCH) {
+  it = tids_to_attach.erase(it);
+  continue;
+}
+return llvm::errorCodeToError(
+std::error_code(errno, std::generic_category()));
+  }
+
+  LLDB_LOG(log, "adding tid = {0}", tid);
+  it->second = true;
+
+  // move the loop forward
+  ++it;
+}
+  }
+
+  size_t tid_count = tids_to_attach.size();
+  if (tid_count == 0)
+return llvm::make_error("No such process",
+ llvm::inconvertibleErrorCode());
+
+  std::vector<::pid_t> tids

[Lldb-commits] [lldb] [llvm] [lldb-dap] Migrating breakpointLocations request to use typed RequestHandler (PR #137426)

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

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

>From da044f5d5391f679cfbba4afc69b46dc30dc8fff Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sat, 26 Apr 2025 01:22:05 +0200
Subject: [PATCH] Migrating breakpointLocations request to use typed
 RequestHandler

---
 .../Handler/BreakpointLocationsHandler.cpp| 156 +++---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  10 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  17 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  38 +
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  14 ++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  21 +++
 llvm/include/llvm/Support/JSON.h  |   8 +
 7 files changed, 125 insertions(+), 139 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
index 7a477f3e97875..2ac886c3a5d2c 100644
--- a/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/BreakpointLocationsHandler.cpp
@@ -9,136 +9,22 @@
 #include "DAP.h"
 #include "JSONUtils.h"
 #include "RequestHandler.h"
+#include 
 
 namespace lldb_dap {
 
-// "BreakpointLocationsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "The `breakpointLocations` request returns all possible
-// locations for source breakpoints in a given range.\nClients should only
-// call this request if the corresponding capability
-// `supportsBreakpointLocationsRequest` is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "breakpointLocations" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/BreakpointLocationsArguments"
-//   }
-// },
-// "required": [ "command" ]
-//   }]
-// },
-// "BreakpointLocationsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `breakpointLocations` request.",
-//   "properties": {
-// "source": {
-//   "$ref": "#/definitions/Source",
-//   "description": "The source location of the breakpoints; either
-//   `source.path` or `source.sourceReference` must be specified."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "Start line of range to search possible breakpoint
-//   locations in. If only the line is specified, the request returns all
-//   possible locations in that line."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "Start position within `line` to search possible
-//   breakpoint locations in. It is measured in UTF-16 code units and the
-//   client capability `columnsStartAt1` determines whether it is 0- or
-//   1-based. If no column is given, the first position in the start line 
is
-//   assumed."
-// },
-// "endLine": {
-//   "type": "integer",
-//   "description": "End line of range to search possible breakpoint
-//   locations in. If no end line is given, then the end line is assumed to
-//   be the start line."
-// },
-// "endColumn": {
-//   "type": "integer",
-//   "description": "End position within `endLine` to search possible
-//   breakpoint locations in. It is measured in UTF-16 code units and the
-//   client capability `columnsStartAt1` determines whether it is 0- or
-//   1-based. If no end column is given, the last position in the end line
-//   is assumed."
-// }
-//   },
-//   "required": [ "source", "line" ]
-// },
-// "BreakpointLocationsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `breakpointLocations` request.\nContains
-// possible locations for source breakpoints.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "breakpoints": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/BreakpointLocation"
-// },
-// "description": "Sorted set of possible breakpoint locations."
-//   }
-// },
-// "required": [ "breakpoints" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "BreakpointLocation": {
-//   "type": "object",
-//   "description": "Properties of a breakpoint location returned from the
-//   `breakpointLocations` request.",
-//   "properties": {
-// "line": {
-//   "type": "integer",
-//   "description": "Start line of breakpoint location."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The start position of a breakpoint location. Position
-//   is measured in UTF-16 code units and the client capability
-//   `columnsStartAt1` determines whether it is 0- or 1-based."
-// },
-// "endLine": {
-//   "type": "integer",
-//

[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

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

eronnen wrote:

@felipepiovezan  Sorry for the trouble, do you know if there's a way for me to 
run the CI on arm/aarch64 before merging the PR next time?

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

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



  



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] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

@eronnen my fix does not seem to have worked

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Ah there were _two_ tests here. I've disabled the other one too.

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-08 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

 28156539a9df 20250508 fpiove.. [lldb] Disable test using GetControlFlowKind on 
arm  (HEAD, llvm/main)


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


[Lldb-commits] [lldb] Branch island debug (PR #139166)

2025-05-08 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/macosx/branch-islands/TestBranchIslands.py
``





View the diff from darker here.


``diff
--- TestBranchIslands.py2025-05-08 21:41:17.00 +
+++ TestBranchIslands.py2025-05-08 21:59:48.164599 +
@@ -39,23 +39,27 @@
 # figure out what went wrong...
 if stop_frame.name.find("foo") == -1:
 stream = lldb.SBStream()
 print("Branch island symbols: ")
 syms[0].GetDescription(stream)
-for i in range (0,6):
+for i in range(0, 6):
 for sep in ["", "."]:
-syms = target.FindSymbols(f"foo.island{sep}{i}", 
lldb.eSymbolTypeCode)
+syms = target.FindSymbols(
+f"foo.island{sep}{i}", lldb.eSymbolTypeCode
+)
 if len(syms) > 0:
 stream.Print("\n")
 syms[0].GetDescription(stream)
-
+
 print(stream.GetData())
 print(f"Start backtrace:")
 print(trace_before)
 print(f"\n'main' disassembly:\n{lldbutil.disassemble(target, 
func_before)}")
 print("\nEnd backtrace:\n")
 lldbutil.print_stacktrace(thread)
-print(f"\nStop disassembly:\n {lldbutil.disassemble(target, 
stop_frame.function)}")
-
+print(
+f"\nStop disassembly:\n {lldbutil.disassemble(target, 
stop_frame.function)}"
+)
+
 self.assertIn("foo", stop_frame.name, "Stepped into foo")
 var = stop_frame.FindVariable("a_variable_in_foo")
 self.assertTrue(var.IsValid(), "Found the variable in foo")

``




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


[Lldb-commits] [lldb] [lldb-dap] Move the event and progress event threads into DAP (NFC) (PR #139167)

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

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/139167

Move the event and progress event threads into the DAP class. Currently both 
are implemented in the InitializeRequestHandler, but it doesn't really belong 
there because the threads are not tied to that request, they just launch them.

>From de9861531afa2fe9a9e7aa1b7669c4d1bd28d43c Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 8 May 2025 14:59:00 -0700
Subject: [PATCH] [lldb-dap] Move the event and progress event threads into DAP
 (NFC)

Move the event and progress event threads into the DAP class. Currently
both are implemented in the InitializeRequestHandler, but it doesn't
really belong there because the threads are not tied to that request,
they just launch them.
---
 lldb/tools/lldb-dap/DAP.cpp   | 261 +-
 lldb/tools/lldb-dap/DAP.h |  14 +-
 .../Handler/InitializeRequestHandler.cpp  | 253 +
 3 files changed, 269 insertions(+), 259 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 62c60cc3a9b3b..7aa2f03894504 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "DAPLog.h"
+#include "EventHelper.h"
 #include "Handler/RequestHandler.h"
 #include "Handler/ResponseHandler.h"
 #include "JSONUtils.h"
@@ -20,6 +21,7 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBProcess.h"
@@ -52,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -77,6 +80,48 @@ const char DEV_NULL[] = "/dev/null";
 
 namespace lldb_dap {
 
+static std::string GetStringFromStructuredData(lldb::SBStructuredData &data,
+   const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+  if (!keyValue)
+return std::string();
+
+  const size_t length = keyValue.GetStringValue(nullptr, 0);
+
+  if (length == 0)
+return std::string();
+
+  std::string str(length + 1, 0);
+  keyValue.GetStringValue(&str[0], length + 1);
+  return str;
+}
+
+static uint64_t GetUintFromStructuredData(lldb::SBStructuredData &data,
+  const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+
+  if (!keyValue.IsValid())
+return 0;
+  return keyValue.GetUnsignedIntegerValue();
+}
+
+static llvm::StringRef GetModuleEventReason(uint32_t event_mask) {
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded)
+return "new";
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded)
+return "removed";
+  assert(event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded ||
+ event_mask & lldb::SBTarget::eBroadcastBitSymbolsChanged);
+  return "changed";
+}
+
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 llvm::StringRef DAP::debug_adapter_path = "";
 
 DAP::DAP(Log *log, const ReplMode default_repl_mode,
@@ -94,13 +139,6 @@ DAP::DAP(Log *log, const ReplMode default_repl_mode,
 
 DAP::~DAP() = default;
 
-/// Return string with first character capitalized.
-static std::string capitalize(llvm::StringRef str) {
-  if (str.empty())
-return "";
-  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
-}
-
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector{};
@@ -1390,4 +1428,213 @@ protocol::Capabilities DAP::GetCapabilities() {
   return capabilities;
 }
 
+void DAP::StartEventThread() {
+  event_thread = std::thread(&DAP::EventThread, this);
+}
+
+void DAP::StartProgressEventThread() {
+  progress_event_thread = std::thread(&DAP::ProgressEventThread, this);
+}
+
+void DAP::ProgressEventThread() {
+  lldb::SBListener listener("lldb-dap.progress.listener");
+  debugger.GetBroadcaster().AddListener(
+  listener, lldb::SBDebugger::eBroadcastBitProgress |
+lldb::SBDebugger::eBroadcastBitExternalProgress);
+  broadcaster.AddListener(listener, eBroadcastBitStopProgressThread);
+  lldb::SBEvent event;
+  bool done = false;
+  while (!done) {
+if (listener.WaitForEvent(1, event)) {
+  const auto event_mask = event.GetType();
+  if (event.BroadcasterMatchesRef(broadcaster)) {
+if (event_mask & eBroadcastBitStopProgressThread) {
+  done = true;
+}
+  } else {
+lldb::SBStructuredData data =
+lldb::SBDebugger::GetProgressDataFromEvent(event);
+
+const uint64_t progress_id =
+GetUintFromStructuredData(data, "progress_id");

[Lldb-commits] [lldb] [lldb-dap] Move the event and progress event threads into DAP (NFC) (PR #139167)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Move the event and progress event threads into the DAP class. Currently both 
are implemented in the InitializeRequestHandler, but it doesn't really belong 
there because the threads are not tied to that request, they just launch them.

---

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


3 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+254-7) 
- (modified) lldb/tools/lldb-dap/DAP.h (+12-2) 
- (modified) lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp (+3-250) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 62c60cc3a9b3b..7aa2f03894504 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -8,6 +8,7 @@
 
 #include "DAP.h"
 #include "DAPLog.h"
+#include "EventHelper.h"
 #include "Handler/RequestHandler.h"
 #include "Handler/ResponseHandler.h"
 #include "JSONUtils.h"
@@ -20,6 +21,7 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBProcess.h"
@@ -52,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -77,6 +80,48 @@ const char DEV_NULL[] = "/dev/null";
 
 namespace lldb_dap {
 
+static std::string GetStringFromStructuredData(lldb::SBStructuredData &data,
+   const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+  if (!keyValue)
+return std::string();
+
+  const size_t length = keyValue.GetStringValue(nullptr, 0);
+
+  if (length == 0)
+return std::string();
+
+  std::string str(length + 1, 0);
+  keyValue.GetStringValue(&str[0], length + 1);
+  return str;
+}
+
+static uint64_t GetUintFromStructuredData(lldb::SBStructuredData &data,
+  const char *key) {
+  lldb::SBStructuredData keyValue = data.GetValueForKey(key);
+
+  if (!keyValue.IsValid())
+return 0;
+  return keyValue.GetUnsignedIntegerValue();
+}
+
+static llvm::StringRef GetModuleEventReason(uint32_t event_mask) {
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded)
+return "new";
+  if (event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded)
+return "removed";
+  assert(event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded ||
+ event_mask & lldb::SBTarget::eBroadcastBitSymbolsChanged);
+  return "changed";
+}
+
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 llvm::StringRef DAP::debug_adapter_path = "";
 
 DAP::DAP(Log *log, const ReplMode default_repl_mode,
@@ -94,13 +139,6 @@ DAP::DAP(Log *log, const ReplMode default_repl_mode,
 
 DAP::~DAP() = default;
 
-/// Return string with first character capitalized.
-static std::string capitalize(llvm::StringRef str) {
-  if (str.empty())
-return "";
-  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
-}
-
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector{};
@@ -1390,4 +1428,213 @@ protocol::Capabilities DAP::GetCapabilities() {
   return capabilities;
 }
 
+void DAP::StartEventThread() {
+  event_thread = std::thread(&DAP::EventThread, this);
+}
+
+void DAP::StartProgressEventThread() {
+  progress_event_thread = std::thread(&DAP::ProgressEventThread, this);
+}
+
+void DAP::ProgressEventThread() {
+  lldb::SBListener listener("lldb-dap.progress.listener");
+  debugger.GetBroadcaster().AddListener(
+  listener, lldb::SBDebugger::eBroadcastBitProgress |
+lldb::SBDebugger::eBroadcastBitExternalProgress);
+  broadcaster.AddListener(listener, eBroadcastBitStopProgressThread);
+  lldb::SBEvent event;
+  bool done = false;
+  while (!done) {
+if (listener.WaitForEvent(1, event)) {
+  const auto event_mask = event.GetType();
+  if (event.BroadcasterMatchesRef(broadcaster)) {
+if (event_mask & eBroadcastBitStopProgressThread) {
+  done = true;
+}
+  } else {
+lldb::SBStructuredData data =
+lldb::SBDebugger::GetProgressDataFromEvent(event);
+
+const uint64_t progress_id =
+GetUintFromStructuredData(data, "progress_id");
+const uint64_t completed = GetUintFromStructuredData(data, 
"completed");
+const uint64_t total = GetUintFromStructuredData(data, "total");
+const std::string details =
+GetStringFromStructuredData(data, "details");
+
+if (completed == 0) {
+  if (total == UINT64_MAX) {
+// This progress is non det

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

2025-05-08 Thread via lldb-commits

https://github.com/royitaqi created 
https://github.com/llvm/llvm-project/pull/139170

# Change

`SymbolFileDWARFDebugMap::CreateInstance()` will return `nullptr` if the file 
is not a Mach-O.


# Benefit

This may improve **Linux** debugger launch time by skipping the creation of 
`SymbolFileDWARFDebugMap` during the [`SymbolFile::FindPlugin()` 
call](https://fburl.com/hi1w8dil), which loops through a list of `SymbolFile` 
plugins and tries to find the one that provides the best abilities.  If the 
`SymbolFileDWARFDebugMap` is created during this loop, it will load the symbol 
table of the file in question and loop through all the compile units in the 
debug map (the OSO entries) to calculate the abilities.


# Tests

Two tests are added to verify the creation and the absence for Mach-O and 
non-Mach-O files.

Ran `ninja check-lldb` on both Darwin and Linux. No regression spotted. See 
results compared for [mac](https://pastebin.com/NdqTK4HC) and 
[linux](https://pastebin.com/bvjVJbi1).

>From c7432d04896c1eea67ed6a6d5f4b4c28941e5a90 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Thu, 8 May 2025 07:38:20 -0700
Subject: [PATCH 1/3] [lldb] Do not create SymbolFileDWARFDebugMap for
 non-Mach-O files

---
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 961c212e2e6dc..f94c756868953 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -10,7 +10,6 @@
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
-
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/PluginManager.h"
@@ -34,12 +33,12 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ScopedPrinter.h"
-
 #include "lldb/Target/StackFrame.h"
 
 #include "LogChannelDWARF.h"
 #include "SymbolFileDWARF.h"
 #include "lldb/lldb-private-enumerations.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 
 #include 
 #include 
@@ -246,6 +245,8 @@ llvm::StringRef 
SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() {
 }
 
 SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFileSP objfile_sp) {
+  if (objfile_sp->GetPluginName() != ObjectFileMachO::GetPluginNameStatic())
+return nullptr;
   return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
 }
 

>From 6c1ce45355ed1f955727e830019e7cafec4b0070 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Thu, 8 May 2025 10:22:25 -0700
Subject: [PATCH 2/3] Add test, but failing

---
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |  1 +
 .../DWARF/SymbolFileDWARFDebugMapTests.cpp| 84 +++
 2 files changed, 85 insertions(+)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp

diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index d5b0be7ea2a28..5aacb24fc5206 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -4,6 +4,7 @@ add_lldb_unittest(SymbolFileDWARFTests
   DWARFDIETest.cpp
   DWARFIndexCachingTest.cpp
   DWARFUnitTest.cpp
+  SymbolFileDWARFDebugMapTests.cpp
   SymbolFileDWARFTests.cpp
   XcodeSDKModuleTests.cpp
 
diff --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
new file mode 100644
index 0..399510e519521
--- /dev/null
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
@@ -0,0 +1,84 @@
+//===-- SymbolFileDWARFDebugMapTests.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Module.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::plugin::dwarf;
+
+TEST(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
+  // Make sure we don't crash parsing a null unit DIE.
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_addr_base
+

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

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (royitaqi)


Changes

# Change

`SymbolFileDWARFDebugMap::CreateInstance()` will return `nullptr` if the file 
is not a Mach-O.


# Benefit

This may improve **Linux** debugger launch time by skipping the creation of 
`SymbolFileDWARFDebugMap` during the [`SymbolFile::FindPlugin()` 
call](https://fburl.com/hi1w8dil), which loops through a list of `SymbolFile` 
plugins and tries to find the one that provides the best abilities.  If the 
`SymbolFileDWARFDebugMap` is created during this loop, it will load the symbol 
table of the file in question and loop through all the compile units in the 
debug map (the OSO entries) to calculate the abilities.


# Tests

Two tests are added to verify the creation and the absence for Mach-O and 
non-Mach-O files.

Ran `ninja check-lldb` on both Darwin and Linux. No regression spotted. See 
results compared for [mac](https://pastebin.com/NdqTK4HC) and 
[linux](https://pastebin.com/bvjVJbi1).

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


3 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+3) 
- (modified) lldb/unittests/SymbolFile/DWARF/CMakeLists.txt (+1) 
- (added) lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp 
(+142) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 961c212e2e6dc..1793c23950d55 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -38,6 +38,7 @@
 #include "lldb/Target/StackFrame.h"
 
 #include "LogChannelDWARF.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
 #include "SymbolFileDWARF.h"
 #include "lldb/lldb-private-enumerations.h"
 
@@ -246,6 +247,8 @@ llvm::StringRef 
SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() {
 }
 
 SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFileSP objfile_sp) {
+  if (objfile_sp->GetPluginName() != ObjectFileMachO::GetPluginNameStatic())
+return nullptr;
   return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
 }
 
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index d5b0be7ea2a28..5aacb24fc5206 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -4,6 +4,7 @@ add_lldb_unittest(SymbolFileDWARFTests
   DWARFDIETest.cpp
   DWARFIndexCachingTest.cpp
   DWARFUnitTest.cpp
+  SymbolFileDWARFDebugMapTests.cpp
   SymbolFileDWARFTests.cpp
   XcodeSDKModuleTests.cpp
 
diff --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
new file mode 100644
index 0..8c65fca889a40
--- /dev/null
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
@@ -0,0 +1,142 @@
+//===-- SymbolFileDWARFDebugMapTests.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Module.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::plugin::dwarf;
+
+class SymbolFileDWARFDebugMapTests : public testing::Test {
+  SubsystemRAII subsystems;
+};
+
+TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
+  // Make sure we don't crash parsing a null unit DIE.
+  const char *yamldata = R"(
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x8003
+  filetype:0x0001
+  ncmds:   1
+  sizeofcmds:  152
+  flags:   0x2000
+  reserved:0x
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 152
+segname: __TEXT
+vmaddr:  0
+vmsize:  4
+fileoff: 184
+filesize:4
+maxprot: 7
+initprot:7
+nsects:  1
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x
+content: 'AABBCCDD'
+size:4
+offset:  184
+align:   0
+reloff:  0x
+nreloc:  0
+ 

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

2025-05-08 Thread via lldb-commits

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


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

2025-05-08 Thread via lldb-commits

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


[Lldb-commits] [lldb] Branch island no dsym (PR #139191)

2025-05-08 Thread via lldb-commits

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


[Lldb-commits] [lldb] Branch island no dsym (PR #139191)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

When we get to the branch island, we don't see the symbol for
it.

The only other thing I can think of that would be a dsymutil bug?
Let's try this just with dwarf, and then I'll have to revert all this
and see if I can reproduce this locally somehow.


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


2 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+9) 
- (modified) lldb/test/API/macosx/branch-islands/TestBranchIslands.py (+9-2) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 578ab12268ea3..6c3040ef1a1da 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1038,6 +1038,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
 static RegularExpression g_branch_island_regex(g_branch_island_pattern);
 
 bool is_branch_island = g_branch_island_regex.Execute(current_name);
+// FIXME: this is extra logging so I can figure out why this test is 
failing
+// on the bot but not locally with all the same tools, etc...
+if (thread_plan_sp && is_branch_island) {
+  if (log) {
+StreamString s;
+thread_plan_sp->GetDescription(&s, eDescriptionLevelVerbose);
+LLDB_LOGF(log, "Am at a branch island, but already had plan: \n\t%s", 
s.GetData());
+  }
+}
 if (!thread_plan_sp && is_branch_island) {
   thread_plan_sp = std::make_shared(
   thread,
diff --git a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py 
b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
index c79840b400432..2d768d35aad03 100644
--- a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
+++ b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
@@ -2,7 +2,7 @@
 Make sure that we can step in across an arm64 branch island
 """
 
-
+import os
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -15,7 +15,7 @@ class TestBranchIslandStepping(TestBase):
 @skipUnlessAppleSilicon
 def test_step_in_branch_island(self):
 """Make sure we can step in across a branch island"""
-self.build()
+self.build(debug_info="dwarf")
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.do_test()
 
@@ -32,6 +32,9 @@ def do_test(self):
 trace_before = lldbutil.print_stacktrace(thread, True)
 func_before = thread.frames[0].function
 
+log_file_path = os.path.join(self.getBuildDir(), "step-log.txt")
+self.runCmd(f"log enable -f {log_file_path} lldb step")
+
 thread.StepInto()
 stop_frame = thread.frames[0]
 # This is failing on the bot, but I can't reproduce the failure
@@ -59,6 +62,10 @@ def do_test(self):
 print(
 f"\nStop disassembly:\n {lldbutil.disassemble(target, 
stop_frame.function)}"
 )
+with open(log_file_path, "r") as f:
+data = f.read()
+print("Step Log:")
+print(data)
 
 self.assertIn("foo", stop_frame.name, "Stepped into foo")
 var = stop_frame.FindVariable("a_variable_in_foo")

``




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


[Lldb-commits] [lldb] [lldb] Provide lr value in faulting frame on arm64 (PR #138805)

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

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

>From 4fc9acd03a58a3617b113352c48e5dd2fdb58eda Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 6 May 2025 22:37:17 -0700
Subject: [PATCH 1/5] [lldb] Provide lr value in faulting frame on arm64

When a frameless function faults or is interrupted asynchronously,
the UnwindPlan MAY have no register location rule for the return
address register (lr on arm64); the value is simply live in the
lr register when it was interrupted, and the frame below this on
the stack -- e.g. sigtramp on a Unix system -- has the full
register context, including that register.

RegisterContextUnwind::SavedLocationForRegister, when asked to find
the caller's pc value, will first see if there is a pc register
location.  If there isn't, on a Return Address Register architecture
like arm/mips/riscv, we rewrite the register request from "pc" to
"RA register", and search for a location.

On frame 0 (the live frame) and an interrupted frame, the UnwindPlan
may have no register location rule for the RA Reg, that is valid.
A frameless function that never calls another may simply keep the
return address in the live register the whole way.  Our instruction
emulation unwind plans explicitly add a rule (see Pavel's May 2024
change https://github.com/llvm/llvm-project/pull/91321 ), but an
UnwindPlan sourced from debug_frame may not.

I've got a case where this exactly happens - clang debug_frame for
arm64 where there is no register location for the lr in a frameless
function.  There is a fault in the middle of this frameless function
and we only get the lr value from the fault handler below this frame
if lr has a register location of `IsSame`, in line with Pavel's
2024 change.

Similar to how we see a request of the RA Reg from frame 0 after
failing to find an unwind location for the pc register, the same
style of special casing is needed when this is a function that
was interrupted.

Without this change, we can find the pc of the frame that was
executing when it was interrupted, but we need $lr to find its
caller, and we don't descend down to the trap handler to get that
value, truncating the stack.

rdar://145614545
---
 lldb/source/Target/RegisterContextUnwind.cpp | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 3ed49e12476dd..23a86bee2518b 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1377,6 +1377,7 @@ RegisterContextUnwind::SavedLocationForRegister(
 }
   }
 
+  // Check if the active_row has a register location listed.
   if (regnum.IsValid() &&
   
active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
   unwindplan_regloc)) {
@@ -1390,11 +1391,10 @@ RegisterContextUnwind::SavedLocationForRegister(
   // This is frame 0 and we're retrieving the PC and it's saved in a Return
   // Address register and it hasn't been saved anywhere yet -- that is,
   // it's still live in the actual register. Handle this specially.
-
   if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
-  IsFrameZero()) {
-if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
-LLDB_INVALID_REGNUM) {
+  return_address_reg.GetAsKind(eRegisterKindLLDB) !=
+  LLDB_INVALID_REGNUM) {
+if (IsFrameZero()) {
   lldb_private::UnwindLLDB::ConcreteRegisterLocation new_regloc;
   new_regloc.type = UnwindLLDB::ConcreteRegisterLocation::
   eRegisterInLiveRegisterContext;
@@ -1408,6 +1408,17 @@ RegisterContextUnwind::SavedLocationForRegister(
return_address_reg.GetAsKind(eRegisterKindLLDB),
return_address_reg.GetAsKind(eRegisterKindLLDB));
   return UnwindLLDB::RegisterSearchResult::eRegisterFound;
+} else if (BehavesLikeZerothFrame()) {
+  // This function was interrupted asynchronously -- it faulted,
+  // an async interrupt, a timer fired, a debugger expression etc.
+  // The caller's pc is in the Return Address register, but the
+  // UnwindPlan for this function may have no location rule for
+  // the RA reg.
+  // This means that the caller's return address is in the RA reg
+  // when the function was interrupted--descend down one stack frame
+  // to retrieve it from the trap handler's saved context.
+  unwindplan_regloc.SetSame();
+  have_unwindplan_regloc = true;
 }
   }
 

>From b10162deb49ecddca6439665c2b8ea1995fdd81f Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 7 May 2025 23:24:17 -0700
Subject: [PATCH 2/5] Add the sources for an API test case to be written

---
 .../interrupt-and-trap-funcs.s| 92 +++

[Lldb-commits] [lldb] Branch island no dsym (PR #139191)

2025-05-08 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/139191

When we get to the branch island, we don't see the symbol for
it.

The only other thing I can think of that would be a dsymutil bug?
Let's try this just with dwarf, and then I'll have to revert all this
and see if I can reproduce this locally somehow.




  



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] 803fd73 - Branch island no dsym (#139191)

2025-05-08 Thread via lldb-commits

Author: jimingham
Date: 2025-05-08T18:22:10-07:00
New Revision: 803fd732ae634b49c308e88e9b508fdbff664034

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

LOG: Branch island no dsym (#139191)

When we get to the branch island, we don't see the symbol for
it.

The only other thing I can think of that would be a dsymutil bug?
Let's try this just with dwarf, and then I'll have to revert all this
and see if I can reproduce this locally somehow.

Added: 


Modified: 
lldb/test/API/macosx/branch-islands/TestBranchIslands.py

Removed: 




diff  --git a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py 
b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
index a8dd1886d5568..2d768d35aad03 100644
--- a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
+++ b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
@@ -15,7 +15,7 @@ class TestBranchIslandStepping(TestBase):
 @skipUnlessAppleSilicon
 def test_step_in_branch_island(self):
 """Make sure we can step in across a branch island"""
-self.build()
+self.build(debug_info="dwarf")
 self.main_source_file = lldb.SBFileSpec("main.c")
 self.do_test()
 



___
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 a modules explorer to lldb-dap ext. (PR #138977)

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

da-viper wrote:

LGTM, 

Except the load address seems to be in decimal. It does not specify in the dap 
specification if it is decimal or hex. I assume it is implementation based. 

if it is the case we should show it as hex as that is default format for 
address in lldb. 


We could later extend it to show children instead of using the tool-tip.  

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


[Lldb-commits] [lldb] [lldb-dap] Migrate attach to typed RequestHandler. (PR #137911)

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

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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-05-08 Thread via lldb-commits

https://github.com/royitaqi created 
https://github.com/llvm/llvm-project/pull/139174

# Benefit

This patch fixes:
1. After `platform select ios-simulator`, `platform process list` will now 
print processes which are running in the iOS simulator. Previously, no process 
will be listed.
2. After `platform select ios-simulator`, `platform attach --name ` will 
succeed. Previously, it will error out saying no process is found.


# Changes

1. During the process listing, add `aarch64` to the list of CPU types for which 
iOS simulators are checked for.
2. Fix a bug in the code which checks for simulators, where for a process 
running on simulator, the original code will find the desired environment 
variable and set the OS to iOS, but then the immediate next environment 
variable will set it back to macOS.
3. For processes running on simulator, set the triple's `Environment` to 
`Simulator`, so that such processes can pass the filtering [in this 
line](https://fburl.com/8nivnrjx). The original code leave it as the default 
`UnknownEnvironment`.



# Manual test

**With this patch:**
```
royshi-mac-home ~/public_llvm/build % bin/lldb
(lldb) platform select ios-simulator

(lldb) platform process list
240 matching processes were found on "ios-simulator"

PIDPARENT USER   TRIPLE NAME
== == == == 

40511  28844  royshi arm64-apple-ios-simulator  FocusPlayground // my 
toy iOS app running on simulator
... // omit
28844  1  royshi arm64-apple-ios-simulator  launchd_sim

(lldb) process attach --name FocusPlayground
Process 40511 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x000104e3cb70 libsystem_kernel.dylib`mach_msg2_trap + 8
libsystem_kernel.dylib`mach_msg2_trap:
->  0x104e3cb70 <+8>: ret
... // omit
```

**Without this patch:**
```
royshi-mac-home ~/public_llvm/build % bin/lldb
(lldb) platform select ios-simulator

(lldb) platform process list
error: no processes were found on the "ios-simulator" platform

(lldb) process attach --name FocusPlayground
error: attach failed: could not find a process named FocusPlayground
```


# Unittest

I did a couple of code searches 
([1](https://github.com/search?q=repo%3Allvm%2Fllvm-project+FindProcessesImpl+test&type=code),
 
[2](https://github.com/search?q=repo%3Allvm%2Fllvm-project+GetMacOSXProcessArgs+test&type=code))
 and didn't seem to find any existing tests.

Any suggestion about how to test this?

>From d98210b81f7b49f5384e968b1a18e00e432aaf2c Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Thu, 8 May 2025 16:21:53 -0700
Subject: [PATCH] Fix macOS FindProcessImpl()

---
 lldb/source/Host/macosx/objcxx/Host.mm | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index e187bf98188ae..e8a1c597eea53 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -595,7 +595,9 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   const llvm::Triple::ArchType triple_arch = triple.getArch();
   const bool check_for_ios_simulator =
   (triple_arch == llvm::Triple::x86 ||
-   triple_arch == llvm::Triple::x86_64);
+   triple_arch == llvm::Triple::x86_64 ||
+   triple_arch == llvm::Triple::aarch64);
+
   const char *cstr = data.GetCStr(&offset);
   if (cstr) {
 process_info.GetExecutableFile().SetFile(cstr, 
FileSpec::Style::native);
@@ -621,22 +623,25 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   }
 
   Environment &proc_env = process_info.GetEnvironment();
+  bool is_simulator = false;
   while ((cstr = data.GetCStr(&offset))) {
 if (cstr[0] == '\0')
   break;
 
-if (check_for_ios_simulator) {
-  if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) 
==
-  0)
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::IOS);
-  else
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::MacOSX);
-}
+if (check_for_ios_simulator &&
+strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) ==
+0)
+  is_simulator = true;
 
 proc_env.insert(cstr);
   }
+  llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
+  if (is_simulator) {
+triple.setOS(llvm::Triple::IOS);
+triple.setEnvironment(llvm::Triple::Simulator);
+  } else {
+triple.setOS(llvm::Triple::MacOSX);
+  }
   return true;
 }
   }

___
lldb-commits mailing list
lldb-commits@lis

[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-05-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (royitaqi)


Changes

# Benefit

This patch fixes:
1. After `platform select ios-simulator`, `platform process list` will now 
print processes which are running in the iOS simulator. Previously, no process 
will be listed.
2. After `platform select ios-simulator`, `platform attach --name ` 
will succeed. Previously, it will error out saying no process is found.


# Changes

1. During the process listing, add `aarch64` to the list of CPU types for which 
iOS simulators are checked for.
2. Fix a bug in the code which checks for simulators, where for a process 
running on simulator, the original code will find the desired environment 
variable and set the OS to iOS, but then the immediate next environment 
variable will set it back to macOS.
3. For processes running on simulator, set the triple's `Environment` to 
`Simulator`, so that such processes can pass the filtering [in this 
line](https://fburl.com/8nivnrjx). The original code leave it as the default 
`UnknownEnvironment`.



# Manual test

**With this patch:**
```
royshi-mac-home ~/public_llvm/build % bin/lldb
(lldb) platform select ios-simulator

(lldb) platform process list
240 matching processes were found on "ios-simulator"

PIDPARENT USER   TRIPLE NAME
== == == == 

40511  28844  royshi arm64-apple-ios-simulator  FocusPlayground // my 
toy iOS app running on simulator
... // omit
28844  1  royshi arm64-apple-ios-simulator  launchd_sim

(lldb) process attach --name FocusPlayground
Process 40511 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal 
SIGSTOP
frame #0: 0x000104e3cb70 libsystem_kernel.dylib`mach_msg2_trap 
+ 8
libsystem_kernel.dylib`mach_msg2_trap:
->  0x104e3cb70 <+8>: ret
... // omit
```

**Without this patch:**
```
royshi-mac-home ~/public_llvm/build % bin/lldb
(lldb) platform select ios-simulator

(lldb) platform process list
error: no processes were found on the "ios-simulator" platform

(lldb) process attach --name FocusPlayground
error: attach failed: could not find a process named FocusPlayground
```


# Unittest

I did a couple of code searches 
([1](https://github.com/search?q=repo%3Allvm%2Fllvm-project+FindProcessesImpl+test&type=code),
 
[2](https://github.com/search?q=repo%3Allvm%2Fllvm-project+GetMacOSXProcessArgs+test&type=code))
 and didn't seem to find any existing tests.

Any suggestion about how to test this?

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


1 Files Affected:

- (modified) lldb/source/Host/macosx/objcxx/Host.mm (+15-10) 


``diff
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index e187bf98188ae..e8a1c597eea53 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -595,7 +595,9 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   const llvm::Triple::ArchType triple_arch = triple.getArch();
   const bool check_for_ios_simulator =
   (triple_arch == llvm::Triple::x86 ||
-   triple_arch == llvm::Triple::x86_64);
+   triple_arch == llvm::Triple::x86_64 ||
+   triple_arch == llvm::Triple::aarch64);
+
   const char *cstr = data.GetCStr(&offset);
   if (cstr) {
 process_info.GetExecutableFile().SetFile(cstr, 
FileSpec::Style::native);
@@ -621,22 +623,25 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   }
 
   Environment &proc_env = process_info.GetEnvironment();
+  bool is_simulator = false;
   while ((cstr = data.GetCStr(&offset))) {
 if (cstr[0] == '\0')
   break;
 
-if (check_for_ios_simulator) {
-  if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) 
==
-  0)
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::IOS);
-  else
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::MacOSX);
-}
+if (check_for_ios_simulator &&
+strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) ==
+0)
+  is_simulator = true;
 
 proc_env.insert(cstr);
   }
+  llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
+  if (is_simulator) {
+triple.setOS(llvm::Triple::IOS);
+triple.setEnvironment(llvm::Triple::Simulator);
+  } else {
+triple.setOS(llvm::Triple::MacOSX);
+  }
   return true;
 }
   }

``




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

[Lldb-commits] [lldb] [lldb-dap] Move the event and progress event threads into DAP (NFC) (PR #139167)

2025-05-08 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/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/DAP.h 
lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 169afd258..f6754b1f8 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1624,7 +1624,7 @@ void DAP::EventThread() {
 std::string type = GetStringValue(data.GetValueForKey("type"));
 std::string message = GetStringValue(data.GetValueForKey("message"));
 SendOutput(OutputType::Important,
-   llvm::formatv("{0}: {1}", type, message).str());
+   llvm::formatv("{0}: {1}", type, message).str());
   } else if (event.BroadcasterMatchesRef(broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;

``




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


  1   2   >