[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)
DavidSpickett wrote: > remote-gdb-server That though, might skip dyld altogether. https://github.com/llvm/llvm-project/pull/157432 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f3b7ad4 - [lldb][NFC] Update testsuite skip comment
Author: Jason Molenda Date: 2025-09-09T16:47:26-07:00 New Revision: f3b7ad4859037254afc0ee6d938018376c7c03d3 URL: https://github.com/llvm/llvm-project/commit/f3b7ad4859037254afc0ee6d938018376c7c03d3 DIFF: https://github.com/llvm/llvm-project/commit/f3b7ad4859037254afc0ee6d938018376c7c03d3.diff LOG: [lldb][NFC] Update testsuite skip comment to explain why the skip was added. Added: Modified: lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py Removed: diff --git a/lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py b/lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py index 267f8c805f360..30b2a525eaab1 100644 --- a/lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py +++ b/lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py @@ -12,7 +12,24 @@ class TestCortexMExceptionUnwind(TestBase): NO_DEBUG_INFO_TESTCASE = True -@skipUnlessDarwin # on the lldb-remote-linux-ubuntu CI, only get 1 stack frame not 6 +# on the lldb-remote-linux-ubuntu CI, the binary.json's triple of +# armv7m-apple is not being set in the Target triple, and we're +# picking the wrong ABI plugin, ABISysV_arm. +# ABISysV_arm::CreateDefaultUnwindPlan() doesn't have a way to detect +# arm/thumb for a stack frame, or even the Target's triple for a +# Cortex-M part that is always thumb. It hardcodes r11 as the frame +# pointer register, which is correct for arm code but not thumb. +# It is never correct # on a Cortex-M target. +# The Darwin ABIMacOSX_arm diverges from AAPCS and always uses r7 for +# the frame pointer -- the thumb convention -- whether executing arm or +# thumb. So its CreateDefaultUnwindPlan picks the correct register for +# the frame pointer, and we can walk the stack. +# ABISysV_arm::CreateDefaultUnwindPlan will only get one frame and +# not be able to continue. +# +# This may only be occuring on a 32-bit Ubuntu bot; need to test +# 64-bit Ubuntu and confirm. +@skipUnlessDarwin def test_no_fpu(self): """Test that we can backtrace correctly through an ARM Cortex-M Exception return stack""" ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add command line option `--connection-timeout` (PR #156803)
royitaqi wrote: @walter-erquinigo: Added documentation. Also fixed an error in existing documentation about how to open the Settings page. LMK if it looks alright (if not, feel free to give me the specific change that you want me to put in). Also LMK if you are okay with skipping the `auto` change. See [my comment](https://github.com/llvm/llvm-project/pull/156803#discussion_r2334239029). https://github.com/llvm/llvm-project/pull/156803 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
@@ -440,6 +441,8 @@ def _handle_event(self, packet: Event) -> None: elif event == "capabilities" and body: # Update the capabilities with new ones from the event. self.capabilities.update(body["capabilities"]) +elif event == "invalidated": +self.invalidated_event = packet ashgti wrote: Should this be a list in case we get more invalidate events? Or when does this reset? https://github.com/llvm/llvm-project/pull/157530 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary plus and minus to DIL (PR #155617)
jimingham wrote: Do we ever want to support - in the DIL - something like: swift_integer = c_integer + rust_integer We do know how to do that (variations on the details of integer promotion and the like aside) and given these are data objects we can query for their integer values it seems somewhat artificial to disallow it. But in that case, whose promotion rules should we use? That's why I've been arguing that we should have a DIL set of promotion rules where integers are not sized. That way all these sort of computations can be done naturally. So I would argue that the DIL code should be its own plugin, not trying to either be C++ or something in the background, nor trying to figure out based on the expression what "Real" Typesystem we should dispatch to. When people want to answer the question "what would this expression do at this point in my code" they should be using the expression evaluator for that language. The DIL is there to support the widest range of data introspection tasks we can offer on generic structured data objects. https://github.com/llvm/llvm-project/pull/155617 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const
DebugNames::Entry &entry) const {
unit_offset = entry.getLocalTUOffset();
if (unit_offset) {
if (DWARFUnit *cu =
m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
- *unit_offset))
- return &cu->GetNonSkeletonUnit();
+ *unit_offset)) {
+ DWARFUnit &ret = cu->GetNonSkeletonUnit();
dmpots wrote:
It seems suprising that the `GetNonSkeletonUnit()` call can actually return a
skeleton unit. Maybe a better approach here would be to model the fact that we
can actually fail to find the non-skeleton unit by returning an `Expected`
```
llvm::Expected DWARFUnit::GetNonSkeletonUnit()
```
I did a quick search and see other
[examples](https://github.com/llvm/llvm-project/blob/a76dc5599d4bf55a9bd7347e1a4ca22c7768/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp#L258)
where it looks like we might hit this same bug.
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Auto connect to the first running lldb mcp instance. (PR #157503)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/157503 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bdf645b - [lldb][test] TestTsanBasic.py: fix function name assertion
Author: Michael Buch
Date: 2025-09-08T19:27:18+01:00
New Revision: bdf645bb9b509b60bdb6a71d865b4f8999187977
URL:
https://github.com/llvm/llvm-project/commit/bdf645bb9b509b60bdb6a71d865b4f8999187977
DIFF:
https://github.com/llvm/llvm-project/commit/bdf645bb9b509b60bdb6a71d865b4f8999187977.diff
LOG: [lldb][test] TestTsanBasic.py: fix function name assertion
Since https://github.com/llvm/llvm-project/pull/133079 we no longer stop
in the stanitizer library when hitting a sanitizer breakpoint. Adjust
the test accordingly.
Added:
Modified:
lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
Removed:
diff --git a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
index ca8b74e35dff6..2747b2b442195 100644
--- a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
+++ b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
@@ -63,11 +63,11 @@ def tsan_tests(self):
substrs=["1 match found"],
)
-# We should be stopped in __tsan_on_report
+# We should not be stopped in the sanitizer library.
process = self.dbg.GetSelectedTarget().process
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
-self.assertIn("__tsan_on_report", frame.GetFunctionName())
+self.assertIn("f2", frame.GetFunctionName())
# The stopped thread backtrace should contain either line1 or line2
# from main.c.
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -0,0 +1,29 @@
+/// Check that LLDB does not emit "GetDIE for DIE {{0x[0-9a-f]+}} is outside
of its CU"
+/// error message when user is searching for a matching symbol from
.debug_names
+/// and fail to locate the corresponding .dwo file.
+
+/// -gsplit-dwarf is supported only on Linux.
+// REQUIRES: system-linux
+
+// RUN: echo "Temp directory: %t.compdir"
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
jeffreytan81 wrote:
Good point, updated.
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Implement `AddSymbols` (PR #154121)
Nerixyz wrote: > Seems to align with how the PDB plugin does it The only difference is that PDB doesn't set the `debug` flag. I think the debug flag is more correct here, since the symbols we're adding aren't exposed in the binary but only in the debug info. https://github.com/llvm/llvm-project/pull/154121 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5326b3b - [lldb][test] Only assert function name is in user-code on Darwin platforms
Author: Michael Buch
Date: 2025-09-08T22:48:34+01:00
New Revision: 5326b3b176e82191b18ffc368118b36e0103af3d
URL:
https://github.com/llvm/llvm-project/commit/5326b3b176e82191b18ffc368118b36e0103af3d
DIFF:
https://github.com/llvm/llvm-project/commit/5326b3b176e82191b18ffc368118b36e0103af3d.diff
LOG: [lldb][test] Only assert function name is in user-code on Darwin platforms
The frame recognizer for the instrumentation runtimes (added in
https://github.com/llvm/llvm-project/pull/133079) only triggers on Darwin
for `libclang_rt`. Adjust the tests accordingly.
Added:
Modified:
lldb/test/API/functionalities/asan/TestMemoryHistory.py
lldb/test/API/functionalities/asan/TestReportData.py
lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py
Removed:
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index a8f400de8ab08..8ae2d4a60d60c 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -2,7 +2,6 @@
Test that ASan memory history provider returns correct stack traces
"""
-
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -10,6 +9,7 @@
from lldbsuite.test import lldbutil
from lldbsuite.test_event.build_exception import BuildError
+
class MemoryHistoryTestCase(TestBase):
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
@expectedFailureNetBSD
@@ -94,9 +94,10 @@ def libsanitizers_asan_tests(self):
)
self.check_traces()
-# Make sure we're not stopped in the sanitizer library but instead at
the
-# point of failure in the user-code.
-self.assertEqual(self.frame().GetFunctionName(), "main")
+if self.platformIsDarwin():
+# Make sure we're not stopped in the sanitizer library but instead
at the
+# point of failure in the user-code.
+self.assertEqual(self.frame().GetFunctionName(), "main")
# do the same using SB API
process = self.dbg.GetSelectedTarget().process
@@ -222,9 +223,10 @@ def compiler_rt_asan_tests(self):
self.check_traces()
-# Make sure we're not stopped in the sanitizer library but instead at
the
-# point of failure in the user-code.
-self.assertEqual(self.frame().GetFunctionName(), "main")
+if self.platformIsDarwin():
+# Make sure we're not stopped in the sanitizer library but instead
at the
+# point of failure in the user-code.
+self.assertEqual(self.frame().GetFunctionName(), "main")
# make sure the 'memory history' command still works even when we're
# generating a report now
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py
b/lldb/test/API/functionalities/asan/TestReportData.py
index ccc1b846d1607..c832436b0f447 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -2,7 +2,6 @@
Test the AddressSanitizer runtime support for report breakpoint and data
extraction.
"""
-
import json
import lldb
from lldbsuite.test.decorators import *
@@ -10,6 +9,7 @@
from lldbsuite.test import lldbutil
from lldbsuite.test_event.build_exception import BuildError
+
class AsanTestReportDataCase(TestBase):
@skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
@expectedFailureNetBSD
@@ -67,9 +67,10 @@ def asan_tests(self, libsanitizers=False):
lldb.eStopReasonInstrumentation,
)
-# Make sure we're not stopped in the sanitizer library but instead at
the
-# point of failure in the user-code.
-self.assertEqual(self.frame().GetFunctionName(), "main")
+if self.platformIsDarwin():
+# Make sure we're not stopped in the sanitizer library but instead
at the
+# point of failure in the user-code.
+self.assertEqual(self.frame().GetFunctionName(), "main")
self.expect(
"bt",
diff --git a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
index 2747b2b442195..51a28c5013071 100644
--- a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
+++ b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
@@ -63,11 +63,14 @@ def tsan_tests(self):
substrs=["1 match found"],
)
-# We should not be stopped in the sanitizer library.
process = self.dbg.GetSelectedTarget().process
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
-self.assertIn("f2", frame.GetFunctionName())
+if self.platformIsDarwin():
+
[Lldb-commits] [lldb] [lldb] Unwind through ARM Cortex-M exceptions automatically (PR #153922)
dzhidzhoev wrote: Please note that this patch has broken [lldb-remote-linux-ubuntu](https://lab.llvm.org/buildbot/#/builders/195). ``` FAIL: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_no_fpu (TestCortexMExceptionUnwind.TestCortexMExceptionUnwind.test_no_fpu) == FAIL: test_no_fpu (TestCortexMExceptionUnwind.TestCortexMExceptionUnwind.test_no_fpu) Test that we can backtrace correctly through an ARM Cortex-M Exception return stack -- Traceback (most recent call last): File "/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/unwind/cortex-m-exception/TestCortexMExceptionUnwind.py", line 42, in test_no_fpu self.assertEqual(thread.GetNumFrames(), 6) AssertionError: 1 != 6 Config=aarch64-/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang -- ``` https://lab.llvm.org/buildbot/#/builders/195/builds/14363 https://github.com/llvm/llvm-project/pull/153922 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Druzhkov Sergei (DrSergei)
Changes
This patch fixes the problem, when after a `setVariable` request pointers and
references to the variable are not updated. VSCode doesn't send a `variables`
request after a `setVariable` request, so we should trigger it explicitly
via`invalidated` event .Also, updated `writeMemory` request in similar way.
---
Full diff: https://github.com/llvm/llvm-project/pull/157530.diff
8 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
(+3)
- (modified)
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+18-2)
- (modified) lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py (+1-3)
- (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
(+10-24)
- (modified) lldb/tools/lldb-dap/EventHelper.cpp (+22)
- (modified) lldb/tools/lldb-dap/EventHelper.h (+10)
- (modified) lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp (+4)
- (modified) lldb/tools/lldb-dap/Handler/WriteMemoryRequestHandler.cpp (+6)
``diff
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 66aa070a537e0..db3efd3bcb30c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -215,6 +215,7 @@ def __init__(
self.terminated: bool = False
self.events: List[Event] = []
self.progress_events: List[Event] = []
+self.invalidated_event: Event = None
self.reverse_requests: List[Request] = []
self.module_events: List[Dict] = []
self.sequence: int = 1
@@ -440,6 +441,8 @@ def _handle_event(self, packet: Event) -> None:
elif event == "capabilities" and body:
# Update the capabilities with new ones from the event.
self.capabilities.update(body["capabilities"])
+elif event == "invalidated":
+self.invalidated_event = packet
def _handle_reverse_request(self, request: Request) -> None:
if request in self.reverse_requests:
diff --git
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index fffd4c23d6fcd..a0a009ae6cc9a 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -241,6 +241,13 @@ def verify_commands(self, flavor: str, output: str,
commands: list[str]):
f"Command '{flavor}' - '{cmd}' not found in output: {output}",
)
+def verify_invalidated_event(self, expected_areas):
+event = self.dap_server.invalidated_event
+self.dap_server.invalidated_event = None
+self.assertIsNotNone(event)
+areas = event["body"].get("areas", [])
+self.assertEqual(set(expected_areas), set(areas))
+
def get_dict_value(self, d: dict, key_path: list[str]) -> Any:
"""Verify each key in the key_path array is in contained in each
dictionary within "d". Assert if any key isn't in the
@@ -352,13 +359,20 @@ def get_local_as_int(self, name, threadId=None):
else:
return int(value)
+def set_variable(self, varRef, name, value, id=None):
+"""Set a variable."""
+response = self.dap_server.request_setVariable(varRef, name,
str(value), id=id)
+if response["success"]:
+self.verify_invalidated_event(["variables"])
+return response
+
def set_local(self, name, value, id=None):
"""Set a top level local variable only."""
-return self.dap_server.request_setVariable(1, name, str(value), id=id)
+return self.set_variable(1, name, str(value), id=id)
def set_global(self, name, value, id=None):
"""Set a top level global variable only."""
-return self.dap_server.request_setVariable(2, name, str(value), id=id)
+return self.set_variable(2, name, str(value), id=id)
def stepIn(
self,
@@ -577,4 +591,6 @@ def writeMemory(self, memoryReference, data=None, offset=0,
allowPartial=False):
response = self.dap_server.request_writeMemory(
memoryReference, encodedData, offset=offset,
allowPartial=allowPartial
)
+if response["success"]:
+self.verify_invalidated_event(["all"])
return response
diff --git a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
index f51056d7020c6..7c9ad0c0f75ee 100644
--- a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
+++ b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
@@ -72,9 +72,7 @@ def test_memory_refs_set_variable(self):
ptr_value = self.get_local_as_int("rawptr")
self.assertIn
[Lldb-commits] [lldb] [lldb][test] Re-enable import-std-module tests on Linux (PR #157649)
https://github.com/dmpots approved this pull request. I tested locally with this PR and no longer see the segmentation fault from #137046. https://github.com/llvm/llvm-project/pull/157649 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
@@ -1073,3 +1073,17 @@ TEST(ProtocolTypesTest, CompletionsResponseBody) {
ASSERT_THAT_EXPECTED(expected, llvm::Succeeded());
EXPECT_EQ(pp(*expected), pp(response));
}
+
+TEST(ProtocolTypesTest, InvalidatedEventBody) {
+ InvalidatedEventBody body;
+ body.areas = {InvalidatedEventBody::eAreaStacks,
+InvalidatedEventBody::eAreaThreads};
+ StringRef json = R"({
+ "areas": [
+"stacks",
+"threads"
+ ]
+})";
+ // Validate toJSON
JDevlieghere wrote:
```suggestion
```
https://github.com/llvm/llvm-project/pull/157530
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
https://github.com/da-viper approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/157530 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
@@ -91,8 +94,13 @@ WriteMemoryRequestHandler::Run(
if (bytes_written == 0) {
return llvm::make_error(write_error.GetCString());
}
- protocol::WriteMemoryResponseBody response;
+ WriteMemoryResponseBody response;
response.bytesWritten = bytes_written;
+
+ // Also send invalidated event to signal client that some things
+ // (e.g. variables) can be changed.
+ SendInvalidatedEvent(dap, {InvalidatedEventBody::eAreaAll});
ashgti wrote:
Does this change everything? Or just variables? I am not sure if writing into
memory like this prevents changing the current stack or PC counter or not.
https://github.com/llvm/llvm-project/pull/157530
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SBProgress] Quick fix to the progress formatting (PR #157561)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes Earlier today I was looking at the SBProgress documentation with a colleague and found another instance where the swig block wasn't formatting correctly. I've adjusted the docs slightly to fix this. I don't actually know how to see a preview of our docstrings but I believe this will fix it.--- Full diff: https://github.com/llvm/llvm-project/pull/157561.diff 1 Files Affected: - (modified) lldb/bindings/interface/SBProgressDocstrings.i (+2-1) ``diff diff --git a/lldb/bindings/interface/SBProgressDocstrings.i b/lldb/bindings/interface/SBProgressDocstrings.i index 4c001d7d5ebcb..218d0c973cc40 100644 --- a/lldb/bindings/interface/SBProgressDocstrings.i +++ b/lldb/bindings/interface/SBProgressDocstrings.i @@ -57,8 +57,9 @@ Additionally for Python, progress is supported in a with statement. :: with lldb.SBProgress('Non deterministic progress', 'Detail', lldb.SBDebugger) as progress: for i in range(10): progress.Increment(1) -# The progress object is automatically finalized when the with statement +... +The progress object is automatically finalized on the exit of the with block. ") lldb::SBProgress; %feature("docstring", `` https://github.com/llvm/llvm-project/pull/157561 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -0,0 +1,29 @@
+/// Check that LLDB does not emit "GetDIE for DIE {{0x[0-9a-f]+}} is outside
of its CU"
+/// error message when user is searching for a matching symbol from
.debug_names
+/// and fail to locate the corresponding .dwo file.
+
+/// -gsplit-dwarf is supported only on Linux.
+// REQUIRES: system-linux
+
+// RUN: echo "Temp directory: %t.compdir"
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named /b/main-main.dwo, with dwarf5 .debug_names
+// RUN: %clang_host -g -gsplit-dwarf -gpubnames -gdwarf-5
-fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move the DWO file away from the expected location.
+// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/
+/// LLDB won't find the DWO next to the binary or by adding the relative path
+/// to any of the search paths. So it should find the DWO file at
+/// %t.compdir/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/b/main \
+// RUN: -o "b main" --batch 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}}main unable to locate separate debug file (dwo, dwp).
Debugging will be degraded.
jeffreytan81 wrote:
Left over from another copied test. Removed.
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add new optional argument `time-to-live` when using `--connection` (PR #156803)
royitaqi wrote: @JDevlieghere, @walter-erquinigo: I have updated the patch according to your suggestions. LMK if it looks alright. Changes: 1. Rename the option to `--connection-timeout`. 2. Print a warning and exit lldb-dap when `--connection-timeout` is given and `--connection` isn't. 3. Add an extension setting (similar to `Server Mode`) and pass that down to `--connection-timeout` when starting the server. 4. Add api tests. Caveats: * The existing tests in `TestDAP_server.py` don't test with concurrent clients. My newly added tests don't either. * Wanted to update `lldb/tools/lldb-dap/README.md`, but realize that the "Server Mode" isn't mentioned there. @walter-erquinigo LMK if you want me to add a section to mention both (if so, where in the doc and suggestive new section name?). https://github.com/llvm/llvm-project/pull/156803 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add new optional argument `time-to-live` when using `--connection` (PR #156803)
https://github.com/royitaqi updated
https://github.com/llvm/llvm-project/pull/156803
>From 9af1b0029e3e19b521d472d8c94596709f990166 Mon Sep 17 00:00:00 2001
From: Roy Shi
Date: Wed, 3 Sep 2025 22:23:20 -0700
Subject: [PATCH 1/6] [lldb-dap] Add optional TTL argument when using
--connection
---
lldb/tools/lldb-dap/Options.td| 7
lldb/tools/lldb-dap/tool/lldb-dap.cpp | 53 ++-
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/lldb/tools/lldb-dap/Options.td b/lldb/tools/lldb-dap/Options.td
index 867753e9294a6..754b8c7d03568 100644
--- a/lldb/tools/lldb-dap/Options.td
+++ b/lldb/tools/lldb-dap/Options.td
@@ -61,3 +61,10 @@ def pre_init_command: S<"pre-init-command">,
def: Separate<["-"], "c">,
Alias,
HelpText<"Alias for --pre-init-command">;
+
+def time_to_live: S<"time-to-live">,
+ MetaVarName<"">,
+ HelpText<"When using --connection, the number of milliseconds to wait "
+"for new connections at the beginning and after all clients have "
+"disconnected. Not specifying this argument or specifying "
+"non-positive values will wait indefinitely.">;
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index b74085f25f4e2..8b53e4d5cda83 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -258,7 +258,7 @@ validateConnection(llvm::StringRef conn) {
static llvm::Error
serveConnection(const Socket::SocketProtocol &protocol, const std::string
&name,
Log *log, const ReplMode default_repl_mode,
-const std::vector &pre_init_commands) {
+const std::vector &pre_init_commands, int ttl) {
Status status;
static std::unique_ptr listener = Socket::Create(protocol, status);
if (status.Fail()) {
@@ -283,6 +283,21 @@ serveConnection(const Socket::SocketProtocol &protocol,
const std::string &name,
g_loop.AddPendingCallback(
[](MainLoopBase &loop) { loop.RequestTermination(); });
});
+ static MainLoopBase::TimePoint ttl_time_point;
+ static std::mutex ttl_mutex;
+ if (ttl > 0) {
+std::scoped_lock lock(ttl_mutex);
+MainLoopBase::TimePoint future =
+std::chrono::steady_clock::now() + std::chrono::milliseconds(ttl);
+ttl_time_point = future;
+g_loop.AddCallback(
+[future](MainLoopBase &loop) {
+ if (ttl_time_point == future) {
+loop.RequestTermination();
+ }
+},
+future);
+ }
std::condition_variable dap_sessions_condition;
std::mutex dap_sessions_mutex;
std::map dap_sessions;
@@ -291,6 +306,12 @@ serveConnection(const Socket::SocketProtocol &protocol,
const std::string &name,
&dap_sessions_mutex, &dap_sessions,
&clientCount](
std::unique_ptr sock) {
+if (ttl > 0) {
+ // Reset the keep alive timer, because we won't be killing the server
+ // while this connection is being served.
+ std::scoped_lock lock(ttl_mutex);
+ ttl_time_point = MainLoopBase::TimePoint();
+}
std::string client_name = llvm::formatv("client_{0}", clientCount++).str();
DAP_LOG(log, "({0}) client connected", client_name);
@@ -327,6 +348,23 @@ serveConnection(const Socket::SocketProtocol &protocol,
const std::string &name,
std::unique_lock lock(dap_sessions_mutex);
dap_sessions.erase(&loop);
std::notify_all_at_thread_exit(dap_sessions_condition, std::move(lock));
+
+ if (ttl > 0) {
+// Start the countdown to kill the server at the end of each
connection.
+std::scoped_lock lock(ttl_mutex);
+MainLoopBase::TimePoint future =
+std::chrono::steady_clock::now() + std::chrono::milliseconds(ttl);
+// We don't need to take the max of `keep_alive_up_to` and `future`,
+// because `future` must be the latest.
+ttl_time_point = future;
+g_loop.AddCallback(
+[future](MainLoopBase &loop) {
+ if (ttl_time_point == future) {
+loop.RequestTermination();
+ }
+},
+future);
+ }
});
client.detach();
});
@@ -509,6 +547,17 @@ int main(int argc, char *argv[]) {
}
if (!connection.empty()) {
+int ttl = 0;
+llvm::opt::Arg *time_to_live = input_args.getLastArg(OPT_time_to_live);
+if (time_to_live) {
+ llvm::StringRef time_to_live_value = time_to_live->getValue();
+ if (time_to_live_value.getAsInteger(10, ttl)) {
+llvm::errs() << "'" << time_to_live_value
+ << "' is not a valid time-to-live value\n";
+return EXIT_FAILURE;
+ }
+}
+
auto maybeProtoclAndName = validateConnection(connection);
if (auto Err = maybeProtoclAndName.takeError()) {
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(),
@@ -520,7
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
https://github.com/tgs-sc updated
https://github.com/llvm/llvm-project/pull/157674
>From 9ee07b283f5bb3d289b41154914e8d4b630dd75e Mon Sep 17 00:00:00 2001
From: Timur Golubovich
Date: Tue, 9 Sep 2025 13:39:33 +
Subject: [PATCH] [lldb][TypeSystemClang] Added unique builtins types for
__bf16 and _Float16
During debugging applization with __bf16 and _Float16 float types it
was discovered that lldb creates the same CompilerType for them. This
can cause an infinite recursion error, if one tries to create two
struct specializations with these types and then inherit one
specialization from another. This is an example, provided by @Michael137:
```c++
template struct Foo;
template <> struct Foo<__bf16> {};
template <> struct Foo<_Float16> : Foo<__bf16> {};
int main() {
Foo<_Float16> f1;
return 0;
}
```
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 7 ++
.../floating-types-specialization/Makefile| 3 +++
.../TestCppFloatingTypesSpecialization.py | 22 +++
.../floating-types-specialization/main.cpp| 11 ++
.../TestCppTemplateArguments.py | 2 +-
5 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/Makefile
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index c4a917f59fb88..804ddd042574e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -959,6 +959,12 @@ CompilerType
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
if (type_name == "long double" &&
QualTypeMatchesBitSize(bit_size, ast, ast.LongDoubleTy))
return GetType(ast.LongDoubleTy);
+if (type_name == "__bf16" &&
+QualTypeMatchesBitSize(bit_size, ast, ast.BFloat16Ty))
+ return GetType(ast.BFloat16Ty);
+if (type_name == "_Float16" &&
+QualTypeMatchesBitSize(bit_size, ast, ast.Float16Ty))
+ return GetType(ast.Float16Ty);
// As Rust currently uses `TypeSystemClang`, match `f128` here as well so
it
// doesn't get misinterpreted as `long double` on targets where they are
// the same size but different formats.
@@ -1791,6 +1797,7 @@ bool TypeSystemClang::RecordHasFields(const RecordDecl
*record_decl) {
for (base_class = cxx_record_decl->bases_begin(),
base_class_end = cxx_record_decl->bases_end();
base_class != base_class_end; ++base_class) {
+ assert(record_decl != base_class->getType()->getAsCXXRecordDecl());
if (RecordHasFields(base_class->getType()->getAsCXXRecordDecl()))
return true;
}
diff --git a/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
b/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git
a/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
b/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
new file mode 100644
index 0..9564a0bc31809
--- /dev/null
+++
b/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+self.expect_expr("f0", result_type="Foo<__bf16>")
+self.expect_expr("f1", result_type="Foo<__fp16>")
+
+# Test sizeof to ensure while computing layout we don't do
+# infinite recursion.
+v = self.frame().EvaluateExpression("sizeof(f0)")
+self.assertEqual(v.GetValueAsUnsigned() > 0, True)
+v = self.frame().EvaluateExpression("sizeof(f1)")
+self.assertEqual(v.GetValueAsUnsigned() > 0, True)
diff --git a/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
b/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
new file mode 100644
index 0..e3e8a3767fef8
--- /dev/null
+++ b/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
@@ -0,0 +1,11 @@
+template struct Foo;
+
+template <> struct Foo<__bf16> {};
+
+template <> struct Foo<_Float16> : Foo<__bf16> {};
+
+int main() {
+ Foo<__bf16> f0;
+ Foo<_Float16> f1;
+ return 0; // break here
+}
diff --git
a/lldb/test/API/lang/cpp/template-arguments/TestCppTem
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
https://github.com/tgs-sc updated
https://github.com/llvm/llvm-project/pull/157674
>From a18616f5463b1f2313d68063616c6accacf48243 Mon Sep 17 00:00:00 2001
From: Timur Golubovich
Date: Tue, 9 Sep 2025 13:39:33 +
Subject: [PATCH] [lldb][TypeSystemClang] Added unique builtins types for
__bf16 and _Float16
During debugging applization with __bf16 and _Float16 float types it
was discovered that lldb creates the same CompilerType for them. This
can cause an infinite recursion error, if one tries to create two
struct specializations with these types and then inherit one
specialization from another.
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 7 ++
.../floating-types-specialization/Makefile| 3 +++
.../TestCppFloatingTypesSpecialization.py | 22 +++
.../floating-types-specialization/main.cpp| 11 ++
.../TestCppTemplateArguments.py | 2 +-
5 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/Makefile
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
create mode 100644
lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index c4a917f59fb88..804ddd042574e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -959,6 +959,12 @@ CompilerType
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
if (type_name == "long double" &&
QualTypeMatchesBitSize(bit_size, ast, ast.LongDoubleTy))
return GetType(ast.LongDoubleTy);
+if (type_name == "__bf16" &&
+QualTypeMatchesBitSize(bit_size, ast, ast.BFloat16Ty))
+ return GetType(ast.BFloat16Ty);
+if (type_name == "_Float16" &&
+QualTypeMatchesBitSize(bit_size, ast, ast.Float16Ty))
+ return GetType(ast.Float16Ty);
// As Rust currently uses `TypeSystemClang`, match `f128` here as well so
it
// doesn't get misinterpreted as `long double` on targets where they are
// the same size but different formats.
@@ -1791,6 +1797,7 @@ bool TypeSystemClang::RecordHasFields(const RecordDecl
*record_decl) {
for (base_class = cxx_record_decl->bases_begin(),
base_class_end = cxx_record_decl->bases_end();
base_class != base_class_end; ++base_class) {
+ assert(record_decl != base_class->getType()->getAsCXXRecordDecl());
if (RecordHasFields(base_class->getType()->getAsCXXRecordDecl()))
return true;
}
diff --git a/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
b/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/floating-types-specialization/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git
a/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
b/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
new file mode 100644
index 0..9564a0bc31809
--- /dev/null
+++
b/lldb/test/API/lang/cpp/floating-types-specialization/TestCppFloatingTypesSpecialization.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+self.expect_expr("f0", result_type="Foo<__bf16>")
+self.expect_expr("f1", result_type="Foo<__fp16>")
+
+# Test sizeof to ensure while computing layout we don't do
+# infinite recursion.
+v = self.frame().EvaluateExpression("sizeof(f0)")
+self.assertEqual(v.GetValueAsUnsigned() > 0, True)
+v = self.frame().EvaluateExpression("sizeof(f1)")
+self.assertEqual(v.GetValueAsUnsigned() > 0, True)
diff --git a/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
b/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
new file mode 100644
index 0..e3e8a3767fef8
--- /dev/null
+++ b/lldb/test/API/lang/cpp/floating-types-specialization/main.cpp
@@ -0,0 +1,11 @@
+template struct Foo;
+
+template <> struct Foo<__bf16> {};
+
+template <> struct Foo<_Float16> : Foo<__bf16> {};
+
+int main() {
+ Foo<__bf16> f0;
+ Foo<_Float16> f1;
+ return 0; // break here
+}
diff --git
a/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py
b/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py
index eac7b5ef1099a..f26d382bf8582 100644
--- a/lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py
+++ b/
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
tgs-sc wrote: @Michael137, Hi, I have added here a test you proposed. Can you please look at this patch as it is blocking merging PR(https://github.com/llvm/llvm-project/pull/154123). https://github.com/llvm/llvm-project/pull/157674 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
https://github.com/tgs-sc edited https://github.com/llvm/llvm-project/pull/157674 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
https://github.com/tgs-sc updated
https://github.com/llvm/llvm-project/pull/154123
>From eebd3ce655f59cdcf529b637b5d38a74478e4830 Mon Sep 17 00:00:00 2001
From: Timur Golubovich
Date: Mon, 8 Sep 2025 14:43:50 +0300
Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the
specialization existence
While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 11 +
.../TypeSystem/Clang/TypeSystemClang.cpp | 5 +
.../unittests/SymbolFile/DWARF/CMakeLists.txt | 3 +-
.../DWARF/DWARFASTParserClangTests.cpp| 34 +
.../Inputs/DW_AT_spec_decl_exists-test.yaml | 677 ++
5 files changed, 729 insertions(+), 1 deletion(-)
create mode 100644
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a429ea848b7f7..88440dc2a3198 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1899,6 +1899,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const
SymbolContext &sc,
m_ast.CreateClassTemplateSpecializationDecl(
containing_decl_ctx, GetOwningClangModule(die),
class_template_decl,
tag_decl_kind, template_param_infos);
+if (!class_specialization_decl) {
+ if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Failed to create specialization for "
+"clang::ClassTemplateDecl({1}, {2:p}).",
+this, llvm::StringRef(attrs.name), class_template_decl);
+ }
+ return TypeSP();
+}
+
clang_type =
m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index c4a917f59fb88..e431222ebb5f8 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1674,6 +1674,11 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
class_template_specialization_decl->setInstantiationOf(class_template_decl);
class_template_specialization_decl->setTemplateArgs(
TemplateArgumentList::CreateCopy(ast, args));
+ void *insert_pos = nullptr;
+ if (class_template_decl->findSpecialization(args, insert_pos))
+return nullptr;
+ class_template_decl->AddSpecialization(class_template_specialization_decl,
+ insert_pos);
class_template_specialization_decl->setDeclName(
class_template_decl->getDeclName());
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
set(test_inputs
test-dwarf.exe
- DW_AT_default_value-test.yaml)
+ DW_AT_default_value-test.yaml
+ DW_AT_spec_decl_exists-test.yaml)
add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 0cae01de2902a..1abce6999874e 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,40 @@ TEST_F(DWARFASTParserClangTests,
TestDefaultTemplateParamParsing) {
}
}
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+ // Tests that parsing a ClassTemplateSpecializationDecl that already exists
+ // is handled gracefully.
+ auto BufferOrError = llvm::MemoryBuffer::getFile(
+ GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+ ASSERT_TRUE(BufferOrError);
+ YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+ DWARFUnit *unit = t.GetDwarfUnit();
+ ASSERT_NE(unit, nullptr);
+ const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+ ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+ DWARFDIE cu_die(unit, cu_entry);
+
+ auto holder = std::make_unique("ast");
+ auto &ast_ctx = *holder->GetAST();
+ DWARFASTParserClangStub ast_parser(ast_ctx);
+
+ llvm::SmallVector specializations;
+ for (DWARFDIE die : cu_die.children()) {
+SymbolC
[Lldb-commits] [lldb] [lldb-dap] Add command line option `--connection-timeout` (PR #156803)
@@ -519,8 +591,9 @@ int main(int argc, char *argv[]) {
Socket::SocketProtocol protocol;
std::string name;
std::tie(protocol, name) = *maybeProtoclAndName;
-if (auto Err = serveConnection(protocol, name, log.get(),
default_repl_mode,
- pre_init_commands)) {
+if (auto Err =
walter-erquinigo wrote:
oh okay, that's fine.
Well, for lldb-dap llvm::Error is kind of obvious, but not for all llvm code,
where llvm::ErrorOr can be used as well.
Anyway, all good with this change
https://github.com/llvm/llvm-project/pull/156803
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] StepUntil disable test for unsupported linkers. (PR #157474)
https://github.com/Michael137 approved this pull request. LGTM if this works for your use-case, thanks! I'd give @JDevlieghere some time to look at this before merging https://github.com/llvm/llvm-project/pull/157474 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Pass execution context to CompilerType::GetByteSize - in CommandObjectMemoryRead (NFC) (PR #157750)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/157750 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Create functions with mangled name (PR #149701)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/149701
>From 70c954ae5d95e13aa4b29dca928b7c02b59981fc Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Sun, 20 Jul 2025 13:25:56 +0200
Subject: [PATCH 1/6] [LLDB][NativePDB] Create functions with mangled name
---
.../SymbolFile/NativePDB/PdbAstBuilder.cpp| 18 +++--
.../Plugins/SymbolFile/NativePDB/PdbUtil.h| 10 +++
.../NativePDB/SymbolFileNativePDB.cpp | 69 ++-
.../NativePDB/SymbolFileNativePDB.h | 3 +
.../NativePDB/break-by-function.cpp | 6 +-
.../SymbolFile/NativePDB/break-by-line.cpp| 2 +-
.../SymbolFile/NativePDB/disassembly.cpp | 2 +-
.../SymbolFile/NativePDB/local-variables.cpp | 10 +--
.../NativePDB/stack_unwinding01.cpp | 12 ++--
9 files changed, 110 insertions(+), 22 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index f01fba3c48ce9..5d43684d29e4f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -38,16 +38,18 @@ struct CreateMethodDecl : public TypeVisitorCallbacks {
TypeIndex func_type_index,
clang::FunctionDecl *&function_decl,
lldb::opaque_compiler_type_t parent_ty,
- llvm::StringRef proc_name, CompilerType func_ct)
+ llvm::StringRef proc_name, ConstString mangled_name,
+ CompilerType func_ct)
: m_index(m_index), m_clang(m_clang), func_type_index(func_type_index),
function_decl(function_decl), parent_ty(parent_ty),
-proc_name(proc_name), func_ct(func_ct) {}
+proc_name(proc_name), mangled_name(mangled_name), func_ct(func_ct) {}
PdbIndex &m_index;
TypeSystemClang &m_clang;
TypeIndex func_type_index;
clang::FunctionDecl *&function_decl;
lldb::opaque_compiler_type_t parent_ty;
llvm::StringRef proc_name;
+ ConstString mangled_name;
CompilerType func_ct;
llvm::Error visitKnownMember(CVMemberRecord &cvr,
@@ -88,7 +90,7 @@ struct CreateMethodDecl : public TypeVisitorCallbacks {
MethodOptions::CompilerGenerated;
function_decl = m_clang.AddMethodToCXXRecordType(
parent_ty, proc_name,
-/*asm_label=*/{}, func_ct, /*access=*/access_type,
+mangled_name, func_ct, /*access=*/access_type,
/*is_virtual=*/is_virtual, /*is_static=*/is_static,
/*is_inline=*/false, /*is_explicit=*/false,
/*is_attr_used=*/false, /*is_artificial=*/is_artificial);
@@ -891,6 +893,11 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId
func_id,
tag_record = CVTagRecord::create(index.tpi().getType(*eti)).asTag();
}
}
+
+ConstString mangled_name;
+if (auto mangled_name_opt = pdb->FindMangledFunctionName(func_id))
+ mangled_name = ConstString(*mangled_name_opt);
+
if (!tag_record.FieldList.isSimple()) {
CVType field_list_cvt = index.tpi().getType(tag_record.FieldList);
FieldListRecord field_list;
@@ -898,7 +905,8 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
field_list_cvt, field_list))
llvm::consumeError(std::move(error));
CreateMethodDecl process(index, m_clang, func_ti, function_decl,
- parent_opaque_ty, func_name, func_ct);
+ parent_opaque_ty, func_name, mangled_name,
+ func_ct);
if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
llvm::consumeError(std::move(err));
}
@@ -906,7 +914,7 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
if (!function_decl) {
function_decl = m_clang.AddMethodToCXXRecordType(
parent_opaque_ty, func_name,
- /*asm_label=*/{}, func_ct,
+ mangled_name, func_ct,
/*access=*/lldb::AccessType::eAccessPublic,
/*is_virtual=*/false, /*is_static=*/false,
/*is_inline=*/false, /*is_explicit=*/false,
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
index 36e075b04f26f..f09fa7e24f775 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
@@ -99,6 +99,16 @@ struct SegmentOffset {
SegmentOffset(uint16_t s, uint32_t o) : segment(s), offset(o) {}
uint16_t segment = 0;
uint32_t offset = 0;
+
+ bool operator==(SegmentOffset rhs) const {
+return segment == rhs.segment && offset == rhs.offset;
+ }
+
+ bool operator<(SegmentOffset rhs) const {
+if (segment == rhs.segment)
+ return offset < rhs.offset;
+return segment < rhs.segment;
+ }
};
struct SegmentOffsetLength {
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
b/l
[Lldb-commits] [lldb] [lldb] Remove unused swig macro (NFC) (PR #157905)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/157905 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] skip test `TestRerunAndExprDylib.py` on remote (PR #157916)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/157916.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py (+1) ``diff diff --git a/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py b/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py index a8f98ef0f0182..19edaac964e62 100644 --- a/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py +++ b/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py @@ -28,6 +28,7 @@ def isUbuntu18_04(): class TestRerunExprDylib(TestBase): @skipTestIfFn(isUbuntu18_04, bugnumber="rdar://103831050") @skipIfWindows +@skipIfRemote def test(self): """ Tests whether re-launching a process without destroying `` https://github.com/llvm/llvm-project/pull/157916 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Re-enable `TestRerunAndExprDylib.py` (PR #157872)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/157872 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] StepUntil disable test for unsupported linkers. (PR #157474)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/157474 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fix test: TestDAP_server.py (PR #157924)
https://github.com/royitaqi created https://github.com/llvm/llvm-project/pull/157924 See https://github.com/llvm/llvm-project/pull/156803#issuecomment-3275911510 for full context. TL;DR * In https://github.com/llvm/llvm-project/pull/156803, we see a builtbot failure for `TestDAP_server.py` on Debian. Note that macOS and other Linux distributions (like CentOS) seem to pass the tests (verified by buildbot in the PR and my local tests). * In the 3 newly added tests, the most complex test case passed, while the other easier ones failed. ``` PASS: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_connection_timeout_multiple_sessions (TestDAP_server.TestDAP_server.test_connection_timeout_multiple_sessions) FAIL: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_connection_timeout_long_debug_session (TestDAP_server.TestDAP_server.test_connection_timeout_long_debug_session) FAIL: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_connection_timeout_at_server_start (TestDAP_server.TestDAP_server.test_connection_timeout_at_server_start) ``` * The failure is that the `process.wait()` timed out. * The above suggested that maybe the root cause is that the timeout is set too strictly (and that maybe the server termination on Debian is slower than the other Linux distribution for some reason). * This patch loosens that timeout from 2s to 5s. Let's see if this works. >From f5cfe38c237484c296c25c33de0911bd32f4ad16 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 10 Sep 2025 11:24:19 -0700 Subject: [PATCH] [lldb-dap] Fix test: TestDAP_server.py --- lldb/test/API/tools/lldb-dap/server/TestDAP_server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py index 2ab6c7ed24710..12b321cf42778 100644 --- a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py +++ b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py @@ -127,7 +127,7 @@ def test_connection_timeout_at_server_start(self): self.start_server( connection="listen://localhost:0", connection_timeout=1, -wait_seconds_for_termination=2, +wait_seconds_for_termination=5, ) @skipIfWindows @@ -139,7 +139,7 @@ def test_connection_timeout_long_debug_session(self): (_, connection) = self.start_server( connection="listen://localhost:0", connection_timeout=1, -wait_seconds_for_termination=2, +wait_seconds_for_termination=5, ) # The connection timeout should not cut off the debug session self.run_debug_session(connection, "Alice", 1.5) @@ -153,7 +153,7 @@ def test_connection_timeout_multiple_sessions(self): (_, connection) = self.start_server( connection="listen://localhost:0", connection_timeout=1, -wait_seconds_for_termination=2, +wait_seconds_for_termination=5, ) time.sleep(0.5) # Should be able to connect to the server. ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fix test: TestDAP_server.py (PR #157924)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/157924 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fix test: TestDAP_server.py (PR #157924)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/157924 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
https://github.com/jeffreytan81 updated
https://github.com/llvm/llvm-project/pull/157574
>From 01ca83a440c9169c5f695ef67a16f503cbb51bd5 Mon Sep 17 00:00:00 2001
From: Jeffrey Tan
Date: Mon, 8 Sep 2025 15:43:48 -0700
Subject: [PATCH] Fix GetDIE is outside of its CU error from .debug_names
---
.../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 8 ++--
.../DWARF/dwo-miss-getdie-ouside-cu-error.c | 19 +++
2 files changed, 25 insertions(+), 2 deletions(-)
create mode 100644
lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index fa5baf1a0eeb1..08089a4e5ad39 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const
DebugNames::Entry &entry) const {
unit_offset = entry.getLocalTUOffset();
if (unit_offset) {
if (DWARFUnit *cu =
m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
- *unit_offset))
- return &cu->GetNonSkeletonUnit();
+ *unit_offset)) {
+ DWARFUnit &ret = cu->GetNonSkeletonUnit();
+ if (ret.IsSkeletonUnit())
+return nullptr;
+ return &ret;
+}
}
return nullptr;
}
diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c
b/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c
new file mode 100644
index 0..4f847590bab8a
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c
@@ -0,0 +1,19 @@
+/// Check that LLDB does not emit "GetDIE for DIE {{0x[0-9a-f]+}} is outside
of its CU"
+/// error message when user is searching for a matching symbol from
.debug_names
+/// and fail to locate the corresponding .dwo file.
+
+/// -gsplit-dwarf is supported only on Linux.
+// REQUIRES: system-linux
+
+// RUN: %clang_host -g -gsplit-dwarf -gpubnames -gdwarf-5 %s -o main
+/// Remove the DWO file away from the expected location so that LLDB won't
find the DWO next to the binary.
+// RUN: rm *.dwo
+// RUN: %lldb --no-lldbinit main \
+// RUN: -o "b main" --batch 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}}main unable to locate separate debug file (dwo, dwp).
Debugging will be degraded.
+// CHECK-NOT: main GetDIE for DIE {{0x[0-9a-f]+}} is outside of its CU
{{0x[0-9a-f]+}}
+
+int num = 5;
+
+int main(void) { return 0; }
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const
DebugNames::Entry &entry) const {
unit_offset = entry.getLocalTUOffset();
if (unit_offset) {
if (DWARFUnit *cu =
m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
- *unit_offset))
- return &cu->GetNonSkeletonUnit();
+ *unit_offset)) {
+ DWARFUnit &ret = cu->GetNonSkeletonUnit();
jeffreytan81 wrote:
I agree with this in general. Actually, that's the original approach I
suggested while discussing with Greg.
Unfortunately, there are many existing other callers/code paths of
`DWARFUnit::GetNonSkeletonUnit` are expecting the default behavior to fallback
to return skeleton unit if failing to find dwo files. Changing
`DWARFUnit::GetNonSkeletonUnit`'s semantics requiring auditing all other
callers/code paths to ensure the behaviors are expected which is a much bigger
task than thought. Yesterday, I tried to change all callers of
`DWARFUnit::GetNonSkeletonUnit` to use new API/semantics, it is failing several
tests. Some tests are related with apple debug names, -gmodules flag, PCH
modules containing CU with only dwo_id without dwo_name (resulting in dwo
error) which I am not feeling comfortable/justified to fix.
Overall, I feel fixing this known code path is safer (not failing any tests)
with better scope to reason about.
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
https://github.com/jeffreytan81 edited https://github.com/llvm/llvm-project/pull/157574 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ElfCore] Improve main executable detection in core files (PR #157170)
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 origin/main HEAD --extensions cpp,h --
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from clang-format here.
``diff
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 46b2e3e2e..e083647fd 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -295,8 +295,7 @@ llvm::StringRef ProcessElfCore::GetMainExecutablePath() {
llvm::StringRef executable_path = m_nt_file_entries[0].path;
// Prefer the NT_FILE entry matching m_executable_name as main executable.
for (const NT_FILE_Entry &file_entry : m_nt_file_entries)
-if (llvm::StringRef(file_entry.path)
-.ends_with("/" + m_executable_name)) {
+if (llvm::StringRef(file_entry.path).ends_with("/" + m_executable_name)) {
executable_path = file_entry.path;
break;
}
``
https://github.com/llvm/llvm-project/pull/157170
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb][ElfCore] Improve main executable detection in core files (PR #157170)
https://github.com/GeorgeHuyubo updated
https://github.com/llvm/llvm-project/pull/157170
>From 056abe4ebed7c2e08728e0dda20374e32292ff0c Mon Sep 17 00:00:00 2001
From: George Hu
Date: Fri, 5 Sep 2025 13:23:48 -0700
Subject: [PATCH] [lldb][ElfCore] Improve main executable detection in core
files
---
clang/tools/clang-format/git-clang-format | 2 +-
.../Process/elf-core/ProcessElfCore.cpp | 41 +--
.../Plugins/Process/elf-core/ProcessElfCore.h | 10 +
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/clang/tools/clang-format/git-clang-format
b/clang/tools/clang-format/git-clang-format
index fe2dd283d403e..e9133bd52a158 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -482,7 +482,7 @@ def filter_symlinks(dictionary):
def filter_ignored_files(dictionary, binary):
"""Delete every key in `dictionary` that is ignored by clang-format."""
-ignored_files = run(binary, "-list-ignored", *dictionary.keys())
+ignored_files = run(binary)
if not ignored_files:
return
ignored_files = ignored_files.split("\n")
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 88eeddf178788..a6331619a835a 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -99,7 +99,7 @@ bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
const FileSpec &core_file)
-: PostMortemProcess(target_sp, listener_sp, core_file) {}
+: PostMortemProcess(target_sp, listener_sp, core_file), m_uuids() {}
// Destructor
ProcessElfCore::~ProcessElfCore() {
@@ -257,12 +257,12 @@ Status ProcessElfCore::DoLoadCore() {
// the main executable using data we found in the core file notes.
lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
if (!exe_module_sp) {
-// The first entry in the NT_FILE might be our executable
if (!m_nt_file_entries.empty()) {
+ llvm::StringRef executable_path = GetMainExecutablePath();
ModuleSpec exe_module_spec;
exe_module_spec.GetArchitecture() = arch;
- exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
- exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
+ exe_module_spec.GetUUID() = FindModuleUUID(executable_path);
+ exe_module_spec.GetFileSpec().SetFile(executable_path,
FileSpec::Style::native);
if (exe_module_spec.GetFileSpec()) {
exe_module_sp =
@@ -277,20 +277,36 @@ Status ProcessElfCore::DoLoadCore() {
void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
Log *log = GetLog(LLDBLog::Process);
+ m_uuids.clear();
for (NT_FILE_Entry &entry : m_nt_file_entries) {
entry.uuid = FindBuidIdInCoreMemory(entry.start);
-if (log && entry.uuid.IsValid())
- LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"",
-__FUNCTION__, entry.start, entry.uuid.GetAsString().c_str(),
-entry.path.c_str());
+if (entry.uuid.IsValid()) {
+ m_uuids[entry.path] = entry.uuid;
+ if (log)
+LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"",
+ __FUNCTION__, entry.start, entry.uuid.GetAsString().c_str(),
+ entry.path.c_str());
+}
}
}
+llvm::StringRef ProcessElfCore::GetMainExecutablePath() {
+ // The first entry in the NT_FILE might be our executable
+ llvm::StringRef executable_path = m_nt_file_entries[0].path;
+ // Prefer the NT_FILE entry matching m_executable_name as main executable.
+ for (const NT_FILE_Entry &file_entry : m_nt_file_entries)
+if (llvm::StringRef(file_entry.path).ends_with("/" + m_executable_name)) {
+ executable_path = file_entry.path;
+ break;
+}
+ return executable_path;
+}
+
UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
- // Returns the gnu uuid from matched NT_FILE entry
- for (NT_FILE_Entry &entry : m_nt_file_entries)
-if (path == entry.path && entry.uuid.IsValid())
- return entry.uuid;
+ // Look up UUID in the map for fast access
+ auto it = m_uuids.find(path);
+ if (it != m_uuids.end())
+return it->second;
return UUID();
}
@@ -935,6 +951,7 @@ llvm::Error
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
return status.ToError();
thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname,
sizeof (prpsinfo.pr_fname)));
SetID(prpsinfo.pr_pid);
+ m_executable_name = prpsinfo.pr_fname;
break;
}
case ELF::NT_SIGINFO: {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index a91c04a277f60..e73d80cd1c8c4 1
[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)
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 origin/main...HEAD
lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/TestArmPointerMetadataCFADwarfExpr.py
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from darker here.
``diff
--- TestArmPointerMetadataCFADwarfExpr.py 2025-09-10 21:43:20.00 +
+++ TestArmPointerMetadataCFADwarfExpr.py 2025-09-10 21:46:49.183334 +
@@ -16,10 +16,10 @@
# orr x29, x29, #0x1000
# stp x29, x30, [sp, #-16]!
thread.StepInstruction(False)
thread.StepInstruction(False)
-argv_addr = thread.frames[1].GetValueForVariablePath("&argv");
+argv_addr = thread.frames[1].GetValueForVariablePath("&argv")
self.assertTrue(argv_addr.IsValid())
argv_addr_uint = argv_addr.GetValueAsUnsigned()
self.assertNotEqual((argv_addr_uint & (1 << 60)), 0)
``
https://github.com/llvm/llvm-project/pull/157498
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/157498
>From 7ab0dfad28de552f796aaf9c6f2a021d4ad766a7 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Mon, 8 Sep 2025 08:30:19 -0700
Subject: [PATCH 1/2] [lldb] Track CFA pointer metadata in StackID
In this commit:
9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)
We made StackID keep track of the CFA without any pointer metadata in
it. This is necessary when comparing two StackIDs to determine which one
is "younger".
However, the CFA inside StackIDs is also used in other contexts through
the method StackID::GetCallFrameAddress. One notable case is
DWARFExpression: the computation of `DW_OP_call_frame_address` is done
using StackID. This feeds into many other places, e.g. expression
evaluation may require the address of a variable that is computed from
the CFA; to access the variable without faulting, we may need to
preserve the pointer metadata. As such, StackID must be able to provide
both versions of the CFA.
In the spirit of allowing consumers of pointers to decide what to do
with pointer metadata, this patch changes StackID to store both versions
of the cfa pointer. Two getter methods are provided, and all call sites
except DWARFExpression preserve their existing behavior (stripped
pointer). Other alternatives were considered:
* Just store the raw pointer. This would require changing the
comparisong operator `<` to also receive a Process, as the comparison
requires stripped pointers. It wasn't clear if all call-sites had a
non-null process, whereas we know we have a process when creating a
StackID.
* Store a weak pointer to the process inside the class, and then strip
metadata as needed. This would require a `weak_ptr::lock` in many
operations of LLDB, and it felt wasteful. It also prevents stripping
of the pointer if the process has gone away.
This patch also changes RegisterContextUnwind::ReadFrameAddress, which
is the method computing the CFA fed into StackID, to also preserve the
signature pointers.
---
lldb/include/lldb/Target/StackID.h| 11 +-
lldb/source/API/SBFrame.cpp | 2 +-
lldb/source/Expression/DWARFExpression.cpp| 2 +-
lldb/source/Target/RegisterContextUnwind.cpp | 8 -
lldb/source/Target/StackFrameList.cpp | 2 +-
lldb/source/Target/StackID.cpp| 11 +-
.../Makefile | 11 +
.../TestArmPointerMetadataCFADwarfExpr.py | 25 ++
.../main.s| 226 ++
9 files changed, 281 insertions(+), 17 deletions(-)
create mode 100644
lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/Makefile
create mode 100644
lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/TestArmPointerMetadataCFADwarfExpr.py
create mode 100644
lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/main.s
diff --git a/lldb/include/lldb/Target/StackID.h
b/lldb/include/lldb/Target/StackID.h
index c2a5d733dcd69..754f80d001647 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -26,7 +26,11 @@ class StackID {
lldb::addr_t GetPC() const { return m_pc; }
- lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
+ lldb::addr_t GetCallFrameAddressWithMetadata() const {
+return m_cfa_with_metadata;
+ }
+
+ lldb::addr_t GetCallFrameAddressWithoutMetadata() const { return m_cfa; }
SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
@@ -59,9 +63,12 @@ class StackID {
/// The call frame address (stack pointer) value at the beginning of the
/// function that uniquely identifies this frame (along with m_symbol_scope
- /// below)
+ /// below).
lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
+ /// The cfa with metadata (i.e. prior to Process::FixAddress).
+ lldb::addr_t m_cfa_with_metadata = LLDB_INVALID_ADDRESS;
+
/// If nullptr, there is no block or symbol for this frame. If not nullptr,
/// this will either be the scope for the lexical block for the frame, or the
/// scope for the symbol. Symbol context scopes are always be unique pointers
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index b6724bb0c4119..42dbed490a33d 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -267,7 +267,7 @@ lldb::addr_t SBFrame::GetCFA() const {
}
if (StackFrame *frame = exe_ctx->GetFramePtr())
-return frame->GetStackID().GetCallFrameAddress();
+return frame->GetStackID().GetCallFrameAddressWithoutMetadata();
return LLDB_INVALID_ADDRESS;
}
diff --git a/lldb/source/Expression/DWARFExpression.cpp
b/lldb/source/Expression/DWARFExpression.cpp
index 332cf2c86024a..5040351f4975b 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2195,7 +2195,7 @@ llvm::Expected DWARFExpression::Evaluate(
// Note that we
[Lldb-commits] [lldb] [lldb][ElfCore] Improve main executable detection in core files (PR #157170)
https://github.com/GeorgeHuyubo updated
https://github.com/llvm/llvm-project/pull/157170
>From e3de722ac708f9d8780c3c0838fdce4a90d6fbe4 Mon Sep 17 00:00:00 2001
From: George Hu
Date: Fri, 5 Sep 2025 13:23:48 -0700
Subject: [PATCH] [lldb][ElfCore] Improve main executable detection in core
files
---
.../Process/elf-core/ProcessElfCore.cpp | 46 +-
.../elf-core/ProcessElfCore.cpp.backup| 1131 +
.../Plugins/Process/elf-core/ProcessElfCore.h | 14 +-
3 files changed, 1173 insertions(+), 18 deletions(-)
create mode 100644
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp.backup
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 88eeddf178788..8f5f1242116f5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -99,7 +99,7 @@ bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
const FileSpec &core_file)
-: PostMortemProcess(target_sp, listener_sp, core_file) {}
+: PostMortemProcess(target_sp, listener_sp, core_file), m_uuids() {}
// Destructor
ProcessElfCore::~ProcessElfCore() {
@@ -257,12 +257,12 @@ Status ProcessElfCore::DoLoadCore() {
// the main executable using data we found in the core file notes.
lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
if (!exe_module_sp) {
-// The first entry in the NT_FILE might be our executable
if (!m_nt_file_entries.empty()) {
+ llvm::StringRef executable_path = GetMainExecutablePath();
ModuleSpec exe_module_spec;
exe_module_spec.GetArchitecture() = arch;
- exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
- exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
+ exe_module_spec.GetUUID() = FindModuleUUID(executable_path);
+ exe_module_spec.GetFileSpec().SetFile(executable_path,
FileSpec::Style::native);
if (exe_module_spec.GetFileSpec()) {
exe_module_sp =
@@ -277,21 +277,38 @@ Status ProcessElfCore::DoLoadCore() {
void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
Log *log = GetLog(LLDBLog::Process);
+ m_uuids.clear();
for (NT_FILE_Entry &entry : m_nt_file_entries) {
-entry.uuid = FindBuidIdInCoreMemory(entry.start);
-if (log && entry.uuid.IsValid())
- LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"",
-__FUNCTION__, entry.start, entry.uuid.GetAsString().c_str(),
-entry.path.c_str());
+UUID uuid = FindBuidIdInCoreMemory(entry.start);
+if (uuid.IsValid()) {
+ // Assert that either the path is not in the map or the UUID matches
+ assert(m_uuids.count(entry.path) == 0 || m_uuids[entry.path] == uuid);
+ m_uuids[entry.path] = uuid;
+ if (log)
+LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"",
+ __FUNCTION__, entry.start, uuid.GetAsString().c_str(),
+ entry.path.c_str());
+}
}
}
+llvm::StringRef ProcessElfCore::GetMainExecutablePath() {
+ if (m_nt_file_entries.empty())
+return "";
+
+ // The first entry in the NT_FILE might be our executable
+ llvm::StringRef executable_path = m_nt_file_entries[0].path;
+ // Prefer the NT_FILE entry matching m_executable_name as main executable.
+ for (const NT_FILE_Entry &file_entry : m_nt_file_entries)
+if (llvm::StringRef(file_entry.path).ends_with("/" + m_executable_name)) {
+ executable_path = file_entry.path;
+ break;
+}
+ return executable_path;
+}
+
UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
- // Returns the gnu uuid from matched NT_FILE entry
- for (NT_FILE_Entry &entry : m_nt_file_entries)
-if (path == entry.path && entry.uuid.IsValid())
- return entry.uuid;
- return UUID();
+ return m_uuids[std::string(path)];
}
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
@@ -935,6 +952,7 @@ llvm::Error
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
return status.ToError();
thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname,
sizeof (prpsinfo.pr_fname)));
SetID(prpsinfo.pr_pid);
+ m_executable_name = prpsinfo.pr_fname;
break;
}
case ELF::NT_SIGINFO: {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp.backup
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp.backup
new file mode 100644
index 0..e88daebebfa7e
--- /dev/null
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp.backup
@@ -0,0 +1,1131 @@
+//===-- ProcessElfCore.cpp
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exception
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -0,0 +1,19 @@
+/// Check that LLDB does not emit "GetDIE for DIE {{0x[0-9a-f]+}} is outside
of its CU"
+/// error message when user is searching for a matching symbol from
.debug_names
+/// and fail to locate the corresponding .dwo file.
+
+/// -gsplit-dwarf is supported only on Linux.
+// REQUIRES: system-linux
+
+// RUN: %clang_host -g -gsplit-dwarf -gpubnames -gdwarf-5 %s -o main
dmpots wrote:
Thanks the test looks much easier to understand now.
I think there is a problem with where it is writing the files though. The lit
tests to not automatically get a unique build directory for the test outputs,
but uses a shared directory for all the tests in that directory. That means
writing and deleting files can interfere with other tests in the directory.
We can use the [%t](https://llvm.org/docs/CommandGuide/lit.html#substitutions)
to create unique a temporary directory for the test.
```
// RUN: mkdir -p %t.dir
// RUN: %clang_host -g -gsplit-dwarf -gpubnames -gdwarf-5 %s -o %t.dir/main
// RUN: rm %t.dir/*.dwo
// RUN: %lldb --no-lldbinit %t.dir/main \
// RUN: -o "b main" --batch 2>&1 | FileCheck %s
```
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from .debug_names (PR #157574)
@@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const
DebugNames::Entry &entry) const {
unit_offset = entry.getLocalTUOffset();
if (unit_offset) {
if (DWARFUnit *cu =
m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
- *unit_offset))
- return &cu->GetNonSkeletonUnit();
+ *unit_offset)) {
+ DWARFUnit &ret = cu->GetNonSkeletonUnit();
dmpots wrote:
Thanks for trying out that approach. Do you have a WIP patch you can push to a
branch somewhere? Might be something we want to tackle later.
Your fix seems targeted and reasonable given the amount of code relying on
existing behavior.
https://github.com/llvm/llvm-project/pull/157574
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)
https://github.com/jasonmolenda approved this pull request. https://github.com/llvm/llvm-project/pull/157498 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add `debugAdapterEnv` for `attach` requests & improve regex (PR #157980)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/157980 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add boolean literals to DIL. (PR #157992)
https://github.com/cmtice created
https://github.com/llvm/llvm-project/pull/157992
This adds the ability to recognize (and create ValueObjects for) boolean
literals ("true", "false") to DIL. This is a preliminary step to adding type
casting (and also for the ternary op).
>From 097c19c6f7e76f055cbcc56ec14e5098dcee Mon Sep 17 00:00:00 2001
From: Caroline Tice
Date: Wed, 10 Sep 2025 21:58:07 -0700
Subject: [PATCH] [LLDB] Add boolean literals to DIL.
This adds the ability to recognize (and create ValueObjects for)
boolean literals ("true", "false") to DIL. This is a preliminary
step to adding type casting (and also for the ternary op).
---
lldb/docs/dil-expr-lang.ebnf | 3 +++
lldb/include/lldb/ValueObject/DILAST.h| 20 ++
lldb/include/lldb/ValueObject/DILEval.h | 2 ++
lldb/include/lldb/ValueObject/DILLexer.h | 2 ++
lldb/include/lldb/ValueObject/DILParser.h | 3 +++
lldb/source/ValueObject/DILAST.cpp| 5 +
lldb/source/ValueObject/DILEval.cpp | 6 ++
lldb/source/ValueObject/DILLexer.cpp | 15 +++---
lldb/source/ValueObject/DILParser.cpp | 25 +++
9 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index 67328939ba420..70eda3bf40650 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -16,6 +16,7 @@ postfix_expression = primary_expression
| postfix_expression "->" id_expression ;
primary_expression = numeric_literal
+ | boolean_literal
| id_expression
| "(" expression ")" ;
@@ -35,6 +36,8 @@ integer_literal = ? Integer constant: hexademical, decimal,
octal, binary ? ;
numeric_literal = ? Integer constant: hexademical, decimal, octal, binary ?
| ? Floating constant ? ;
+boolean_literal = "true" | "false" ;
+
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 1d10755c46e39..0f05d753f1b56 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
enum class NodeKind {
eArraySubscriptNode,
eBitExtractionNode,
+ eBooleanLiteralNode,
eErrorNode,
eFloatLiteralNode,
eIdentifierNode,
@@ -226,6 +227,23 @@ class FloatLiteralNode : public ASTNode {
llvm::APFloat m_value;
};
+class BooleanLiteralNode : public ASTNode {
+public:
+ BooleanLiteralNode(uint32_t location, bool value)
+ : ASTNode(location, NodeKind::eBooleanLiteralNode), m_value(value) {}
+
+ llvm::Expected Accept(Visitor *v) const override;
+
+ bool GetValue() const & { return m_value; }
+
+ static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eBooleanLiteralNode;
+ }
+
+private:
+ bool m_value;
+};
+
/// 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
@@ -247,6 +265,8 @@ class Visitor {
Visit(const IntegerLiteralNode *node) = 0;
virtual llvm::Expected
Visit(const FloatLiteralNode *node) = 0;
+ virtual llvm::Expected
+ Visit(const BooleanLiteralNode *node) = 0;
};
} // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h
b/lldb/include/lldb/ValueObject/DILEval.h
index 5a48c2c989f4d..eab3218ff828f 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -58,6 +58,8 @@ class Interpreter : Visitor {
Visit(const IntegerLiteralNode *node) override;
llvm::Expected
Visit(const FloatLiteralNode *node) override;
+ llvm::Expected
+ Visit(const BooleanLiteralNode *node) override;
llvm::Expected
PickIntegerType(lldb::TypeSystemSP type_system,
diff --git a/lldb/include/lldb/ValueObject/DILLexer.h
b/lldb/include/lldb/ValueObject/DILLexer.h
index 4345e6ce7f26b..28b94a79c5902 100644
--- a/lldb/include/lldb/ValueObject/DILLexer.h
+++ b/lldb/include/lldb/ValueObject/DILLexer.h
@@ -31,6 +31,8 @@ class Token {
float_constant,
identifier,
integer_constant,
+kw_false,
+kw_true,
l_paren,
l_square,
minus,
diff --git a/lldb/include/lldb/ValueObject/DILParser.h
b/lldb/include/lldb/ValueObject/DILParser.h
index 90df109337dcf..d17ed66d9b3ee 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -99,11 +99,14 @@ class DILParser {
ASTNodeUP ParseNumericLiteral();
ASTNodeUP ParseIntegerLiteral();
ASTNodeUP ParseFloatingPointLiteral();
+ ASTNodeUP ParseBooleanLiteral();
void BailOut(const std::string &error, uint32_t loc, uint16_t err_len);
void Expect(Token::Kind kind);
+ void ExpectOneOf(std::vector kinds_vec);
+
voi
[Lldb-commits] [lldb] [LLDB] Add boolean literals to DIL. (PR #157992)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: None (cmtice)
Changes
This adds the ability to recognize (and create ValueObjects for) boolean
literals ("true", "false") to DIL. This is a preliminary step to adding type
casting (and also for the ternary op).
---
Full diff: https://github.com/llvm/llvm-project/pull/157992.diff
9 Files Affected:
- (modified) lldb/docs/dil-expr-lang.ebnf (+3)
- (modified) lldb/include/lldb/ValueObject/DILAST.h (+20)
- (modified) lldb/include/lldb/ValueObject/DILEval.h (+2)
- (modified) lldb/include/lldb/ValueObject/DILLexer.h (+2)
- (modified) lldb/include/lldb/ValueObject/DILParser.h (+3)
- (modified) lldb/source/ValueObject/DILAST.cpp (+5)
- (modified) lldb/source/ValueObject/DILEval.cpp (+6)
- (modified) lldb/source/ValueObject/DILLexer.cpp (+12-3)
- (modified) lldb/source/ValueObject/DILParser.cpp (+25)
``diff
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index 67328939ba420..70eda3bf40650 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -16,6 +16,7 @@ postfix_expression = primary_expression
| postfix_expression "->" id_expression ;
primary_expression = numeric_literal
+ | boolean_literal
| id_expression
| "(" expression ")" ;
@@ -35,6 +36,8 @@ integer_literal = ? Integer constant: hexademical, decimal,
octal, binary ? ;
numeric_literal = ? Integer constant: hexademical, decimal, octal, binary ?
| ? Floating constant ? ;
+boolean_literal = "true" | "false" ;
+
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 1d10755c46e39..0f05d753f1b56 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
enum class NodeKind {
eArraySubscriptNode,
eBitExtractionNode,
+ eBooleanLiteralNode,
eErrorNode,
eFloatLiteralNode,
eIdentifierNode,
@@ -226,6 +227,23 @@ class FloatLiteralNode : public ASTNode {
llvm::APFloat m_value;
};
+class BooleanLiteralNode : public ASTNode {
+public:
+ BooleanLiteralNode(uint32_t location, bool value)
+ : ASTNode(location, NodeKind::eBooleanLiteralNode), m_value(value) {}
+
+ llvm::Expected Accept(Visitor *v) const override;
+
+ bool GetValue() const & { return m_value; }
+
+ static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eBooleanLiteralNode;
+ }
+
+private:
+ bool m_value;
+};
+
/// 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
@@ -247,6 +265,8 @@ class Visitor {
Visit(const IntegerLiteralNode *node) = 0;
virtual llvm::Expected
Visit(const FloatLiteralNode *node) = 0;
+ virtual llvm::Expected
+ Visit(const BooleanLiteralNode *node) = 0;
};
} // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h
b/lldb/include/lldb/ValueObject/DILEval.h
index 5a48c2c989f4d..eab3218ff828f 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -58,6 +58,8 @@ class Interpreter : Visitor {
Visit(const IntegerLiteralNode *node) override;
llvm::Expected
Visit(const FloatLiteralNode *node) override;
+ llvm::Expected
+ Visit(const BooleanLiteralNode *node) override;
llvm::Expected
PickIntegerType(lldb::TypeSystemSP type_system,
diff --git a/lldb/include/lldb/ValueObject/DILLexer.h
b/lldb/include/lldb/ValueObject/DILLexer.h
index 4345e6ce7f26b..28b94a79c5902 100644
--- a/lldb/include/lldb/ValueObject/DILLexer.h
+++ b/lldb/include/lldb/ValueObject/DILLexer.h
@@ -31,6 +31,8 @@ class Token {
float_constant,
identifier,
integer_constant,
+kw_false,
+kw_true,
l_paren,
l_square,
minus,
diff --git a/lldb/include/lldb/ValueObject/DILParser.h
b/lldb/include/lldb/ValueObject/DILParser.h
index 90df109337dcf..d17ed66d9b3ee 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -99,11 +99,14 @@ class DILParser {
ASTNodeUP ParseNumericLiteral();
ASTNodeUP ParseIntegerLiteral();
ASTNodeUP ParseFloatingPointLiteral();
+ ASTNodeUP ParseBooleanLiteral();
void BailOut(const std::string &error, uint32_t loc, uint16_t err_len);
void Expect(Token::Kind kind);
+ void ExpectOneOf(std::vector kinds_vec);
+
void TentativeParsingRollback(uint32_t saved_idx) {
if (m_error)
llvm::consumeError(std::move(m_error));
diff --git a/lldb/source/ValueObject/DILAST.cpp
b/lldb/source/ValueObject/DILAST.cpp
index 70564663a62cd..7ed34db6e20df 100644
--- a/lldb/source/ValueObject/DILAST.cpp
+++ b/lldb/source/ValueObject/DILAST.cpp
@@ -46,4
[Lldb-commits] [lldb] [lldb][test] skip test `TestRerunAndExprDylib.py` on remote (PR #157916)
https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/157916 None >From de9206315b7692b33694eae0d58dc1278e4a1977 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 10 Sep 2025 19:02:22 +0100 Subject: [PATCH] [lldb][test] skip test `TestRerunAndExprDylib.py` on remote --- .../rerun_and_expr_dylib/TestRerunAndExprDylib.py| 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py b/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py index a8f98ef0f0182..19edaac964e62 100644 --- a/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py +++ b/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py @@ -28,6 +28,7 @@ def isUbuntu18_04(): class TestRerunExprDylib(TestBase): @skipTestIfFn(isUbuntu18_04, bugnumber="rdar://103831050") @skipIfWindows +@skipIfRemote def test(self): """ Tests whether re-launching a process without destroying ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ElfCore] Improve main executable detection in core files (PR #157170)
@@ -257,12 +257,21 @@ Status ProcessElfCore::DoLoadCore() {
// the main executable using data we found in the core file notes.
lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
if (!exe_module_sp) {
-// The first entry in the NT_FILE might be our executable
if (!m_nt_file_entries.empty()) {
+ // The first entry in the NT_FILE might be our executable
+ llvm::StringRef executable_path = m_nt_file_entries[0].path;
+ // Prefer the NT_FILE entry matching m_executable_name as main
executable.
+ for (const NT_FILE_Entry &file_entry : m_nt_file_entries)
+if (llvm::StringRef(file_entry.path)
+.ends_with("/" + m_executable_name)) {
+ executable_path = file_entry.path;
+ break;
+}
+
ModuleSpec exe_module_spec;
exe_module_spec.GetArchitecture() = arch;
- exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
- exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
+ exe_module_spec.GetUUID() = FindModuleUUID(executable_path);
GeorgeHuyubo wrote:
Actually FindModuleUUID is also used here:
https://github.com/llvm/llvm-project/blob/main/lldb/source/Core/DynamicLoader.cpp#L160
https://github.com/llvm/llvm-project/pull/157170
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Unwind through ARM Cortex-M exceptions automatically (PR #153922)
@@ -799,6 +799,23 @@ Status ProcessMachCore::DoGetMemoryRegionInfo(addr_t
load_addr,
region_info.SetMapped(MemoryRegionInfo::eNo);
}
return Status();
+ } else {
+// The corefile has no LC_SEGMENT at this virtual address,
+// but see if there is a binary whose Section has been
+// loaded at that address in the current Target.
jasonmolenda wrote:
This is the qMemoryRegionInfo style queries from the Unwinder where it is
trying to detect "is this pc/fp in actual memory, or have I gone off the
track". In my synthesized corefile, it may only have a couple hundred bytes of
stack memory and no code memory at all. This would halt the unwind algorithms.
We have a "file" (actually an ObjectFileJSON) which will declare there to be a
text section at a virtual address range, though, so when I can't find a
corefile memory range for a given address, I want to fall back to looking for a
Section that contains the address, and report that as a memory region.
https://github.com/llvm/llvm-project/pull/153922
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] acb38c8 - [lldb-dap] Add command line option `--connection-timeout` (#156803)
Author: Roy Shi
Date: 2025-09-10T08:21:12-07:00
New Revision: acb38c8be7152aa26e6958752499619ddd1c
URL:
https://github.com/llvm/llvm-project/commit/acb38c8be7152aa26e6958752499619ddd1c
DIFF:
https://github.com/llvm/llvm-project/commit/acb38c8be7152aa26e6958752499619ddd1c.diff
LOG: [lldb-dap] Add command line option `--connection-timeout` (#156803)
# Usage
This is an optional new command line option to use with `--connection`.
```
--connection-timeout When using --connection, the number of
seconds to
wait for new connections after the server has started and after all
clients
have disconnected. Each new connection will reset the timeout. When the
timeout is reached, the server will be closed and the process will exit.
Not specifying this argument or specifying non-positive values will
cause
the server to wait for new connections indefinitely.
```
A corresponding extension setting `Connection Timeout` is added to the
`lldb-dap` VS Code extension.
# Benefits
Automatic release of resources when lldb-dap is no longer being used
(e.g. release memory used by module cache).
# Test
See PR.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
lldb/tools/lldb-dap/Options.td
lldb/tools/lldb-dap/README.md
lldb/tools/lldb-dap/package.json
lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts
lldb/tools/lldb-dap/tool/lldb-dap.cpp
Removed:
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 66aa070a537e0..51debcf477a9d 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1533,6 +1533,7 @@ def launch(
env: Optional[dict[str, str]] = None,
log_file: Optional[TextIO] = None,
connection: Optional[str] = None,
+connection_timeout: Optional[int] = None,
additional_args: list[str] = [],
) -> tuple[subprocess.Popen, Optional[str]]:
adapter_env = os.environ.copy()
@@ -1550,6 +1551,10 @@ def launch(
args.append("--connection")
args.append(connection)
+if connection_timeout is not None:
+args.append("--connection-timeout")
+args.append(str(connection_timeout))
+
process = subprocess.Popen(
args,
stdin=subprocess.PIPE,
diff --git a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
index e01320c25b155..2ab6c7ed24710 100644
--- a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
+++ b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
@@ -5,6 +5,7 @@
import os
import signal
import tempfile
+import time
import dap_server
from lldbsuite.test.decorators import *
@@ -13,22 +14,28 @@
class TestDAP_server(lldbdap_testcase.DAPTestCaseBase):
-def start_server(self, connection):
+def start_server(
+self, connection, connection_timeout=None,
wait_seconds_for_termination=None
+):
log_file_path = self.getBuildArtifact("dap.txt")
(process, connection) = dap_server.DebugAdapterServer.launch(
executable=self.lldbDAPExec,
connection=connection,
+connection_timeout=connection_timeout,
log_file=log_file_path,
)
def cleanup():
-process.terminate()
+if wait_seconds_for_termination is not None:
+process.wait(wait_seconds_for_termination)
+else:
+process.terminate()
self.addTearDownHook(cleanup)
return (process, connection)
-def run_debug_session(self, connection, name):
+def run_debug_session(self, connection, name,
sleep_seconds_in_middle=None):
self.dap_server = dap_server.DebugAdapterServer(
connection=connection,
)
@@ -41,6 +48,8 @@ def run_debug_session(self, connection, name):
args=[name],
disconnectAutomatically=False,
)
+if sleep_seconds_in_middle is not None:
+time.sleep(sleep_seconds_in_middle)
self.set_source_breakpoints(source, [breakpoint_line])
self.continue_to_next_stop()
self.continue_to_exit()
@@ -108,3 +117,47 @@ def test_server_interrupt(self):
self.dap_server.exit_status,
"Process exited before interrupting lldb-dap server",
)
+
+@skipIfWindows
+def test_connection_timeout_at_server_start(self):
+"""
+Test launching lldb-dap in server mode with connection timeout and
waiting for it to terminate automati
[Lldb-commits] [lldb] [LLDB] Add boolean literals to DIL. (PR #157992)
kuilpd wrote: Can we add a couple of tests for these to `TestFrameVarDILLiterals.py`? https://github.com/llvm/llvm-project/pull/157992 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add `debugAdapterEnv` for `attach` requests & improve regex (PR #157980)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/157980 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
Michael137 wrote:
Ok so I looked at this with @da-viper offline. This is an existing issue with
formatting specifically `const std::unordered_map<..> *`. I added the test as
part of this issue: https://github.com/llvm/llvm-project/issues/146040. The
following is the discrepancy:
```
(lldb) frame var ptr -P 1
(std::unordered_map *) ptr = 0x00016fdff040 size=1 {
[0] = (first = 1, second = 2)
}
(lldb) frame var const_ptr -P 1
(const std::unordered_map *) const_ptr = 0x00016fdff040 size=1 {
[0] = {
__cc_ = (first = 1, second = 2)
}
}
```
The `__cc_` member on `hash_value_type` was actually removed altogether in a
[very recent version of
libc++](https://github.com/llvm/llvm-project/pull/143501). So, as I mentioned
in https://github.com/llvm/llvm-project/issues/146040#issuecomment-3027283454,
this works just fine on top-of-tree, because we no longer have the `__cc_`
wrapper in libc++. And I decided not to give that issue more attention because
we *try* to test the API-tests against the latest libc++ version, where the
test failure wouldn't reproduce. The issue that @da-viper is seeing when
running tests is explicitly when running a libc++ API test without a locally
built libc++. Then it falls back to the system libc++, which doesn't contain
the latest libc++ patch that makes this whole thing work.
So TL;DR, this is not a regression. This just didn't work prior to
https://github.com/llvm/llvm-project/pull/143501, but we never noticed cause
there was no test for it.
It would still be interesting to know why this fails when using older libc++. I
think @da-viper is investigating further why our unordered_map formatter breaks
on const pointers.
A separate question, should we allow running the libc++ API test category
without a locally built libc++?
https://github.com/llvm/llvm-project/pull/156033
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Test global variable support of dwim-print (NFC) (PR #157908)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/157908 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow division by floating point zero in Scalar (PR #158115)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Ilia Kuklin (kuilpd)
Changes
`Scalar` produced an invalid value when detecting any division by zero. This
should be only for integer division.
---
Full diff: https://github.com/llvm/llvm-project/pull/158115.diff
2 Files Affected:
- (modified) lldb/source/Utility/Scalar.cpp (+3-2)
- (modified) lldb/unittests/Utility/ScalarTest.cpp (+6)
``diff
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 7fbe46d46194f..c8766bdf2aee7 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -565,12 +565,13 @@ const Scalar lldb_private::operator-(Scalar lhs, Scalar
rhs) {
const Scalar lldb_private::operator/(Scalar lhs, Scalar rhs) {
Scalar result;
- if ((result.m_type = Scalar::PromoteToMaxType(lhs, rhs)) != Scalar::e_void &&
- !rhs.IsZero()) {
+ if ((result.m_type = Scalar::PromoteToMaxType(lhs, rhs)) != Scalar::e_void) {
switch (result.m_type) {
case Scalar::e_void:
break;
case Scalar::e_int:
+ if (rhs.IsZero())
+break;
result.m_integer = lhs.m_integer / rhs.m_integer;
return result;
case Scalar::e_float:
diff --git a/lldb/unittests/Utility/ScalarTest.cpp
b/lldb/unittests/Utility/ScalarTest.cpp
index 256d456783583..6d5caef42bee4 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -337,6 +337,12 @@ TEST(ScalarTest, Division) {
Scalar r = lhs / rhs;
EXPECT_TRUE(r.IsValid());
EXPECT_EQ(r, Scalar(2.5));
+
+ Scalar inf = Scalar(1) / Scalar(0.0f);
+ Scalar int0 = Scalar(1) / Scalar(0);
+ Scalar ref_inf = llvm::APFloat::getInf(llvm::APFloat::IEEEsingle());
+ EXPECT_EQ(inf, ref_inf);
+ EXPECT_FALSE(int0.IsValid());
}
TEST(ScalarTest, Promotion) {
``
https://github.com/llvm/llvm-project/pull/158115
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix undefined behavior (PR #158119)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Adrian Prantl (adrian-prantl)
Changes
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/2178/consoleText
```
[2025-09-11T13:10:53.352Z]
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp:14138:35:
runtime error: signed integer overflow: 2147483624 + 608 cannot be represented
in type 'int32_t' (aka 'int')
[2025-09-11T13:10:53.352Z] SUMMARY: UndefinedBehaviorSanitizer:
undefined-behavior
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp:14138:35
in
```
---
Full diff: https://github.com/llvm/llvm-project/pull/158119.diff
1 Files Affected:
- (modified) lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
(+7-1)
``diff
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 89da4d200699f..f5f077ffb0bfc 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -14135,7 +14135,13 @@ EmulateInstructionARM::AddWithCarry(uint32_t x,
uint32_t y, uint8_t carry_in) {
uint8_t overflow;
uint64_t unsigned_sum = x + y + carry_in;
- int64_t signed_sum = (int32_t)x + (int32_t)y + (int32_t)carry_in;
+ int64_t signed_sum = 0;
+ int32_t signed_sum32;
+ if (llvm::AddOverflow((int32_t)x, (int32_t)y, signed_sum32))
+signed_sum++;
+ signed_sum += signed_sum32;
+
+ signed_sum += (int32_t)carry_in;
result = UnsignedBits(unsigned_sum, 31, 0);
//carry_out = (result == unsigned_sum ? 0 : 1);
``
https://github.com/llvm/llvm-project/pull/158119
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e0117a5 - [lldb] Fix undefined behavior (#158119)
Author: Adrian Prantl
Date: 2025-09-11T11:07:38-07:00
New Revision: e0117a555d3c84a1c8e0101fc46fe3a34fa48ce5
URL:
https://github.com/llvm/llvm-project/commit/e0117a555d3c84a1c8e0101fc46fe3a34fa48ce5
DIFF:
https://github.com/llvm/llvm-project/commit/e0117a555d3c84a1c8e0101fc46fe3a34fa48ce5.diff
LOG: [lldb] Fix undefined behavior (#158119)
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/2178/consoleText
```
[2025-09-11T13:10:53.352Z]
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp:14138:35:
runtime error: signed integer overflow: 2147483624 + 608 cannot be represented
in type 'int32_t' (aka 'int')
[2025-09-11T13:10:53.352Z] SUMMARY: UndefinedBehaviorSanitizer:
undefined-behavior
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp:14138:35
in
```
Added:
Modified:
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
Removed:
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 89da4d200699f..f5f077ffb0bfc 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -14135,7 +14135,13 @@ EmulateInstructionARM::AddWithCarry(uint32_t x,
uint32_t y, uint8_t carry_in) {
uint8_t overflow;
uint64_t unsigned_sum = x + y + carry_in;
- int64_t signed_sum = (int32_t)x + (int32_t)y + (int32_t)carry_in;
+ int64_t signed_sum = 0;
+ int32_t signed_sum32;
+ if (llvm::AddOverflow((int32_t)x, (int32_t)y, signed_sum32))
+signed_sum++;
+ signed_sum += signed_sum32;
+
+ signed_sum += (int32_t)carry_in;
result = UnsignedBits(unsigned_sum, 31, 0);
//carry_out = (result == unsigned_sum ? 0 : 1);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: None (jimingham)
Changes
This patch adds the notion of "Facade" locations which can be reported from a
ScriptedResolver instead of the actual underlying breakpoint location for the
breakpoint. Also add a "was_hit" method to the scripted resolver that allows
the breakpoint to say which of these "Facade" locations was hit, and
"get_location_description" to provide a description for the facade locations.
I apologize in advance for the size of the patch. Almost all of what's here
was necessary to (a) make the feature testable and (b) not break any of the
current behavior.
The motivation for this feature is given in the "Providing Facade Locations"
section that I added to the python-reference.rst so I won't repeat it here.
rdar://152112327
---
Patch is 77.02 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/158128.diff
36 Files Affected:
- (modified) lldb/bindings/python/python-swigsafecast.swig (+4)
- (modified) lldb/bindings/python/python-wrapper.swig (+24)
- (modified) lldb/docs/use/python-reference.rst (+61)
- (modified) lldb/include/lldb/API/SBBreakpoint.h (+8-1)
- (modified) lldb/include/lldb/API/SBBreakpointLocation.h (+1)
- (modified) lldb/include/lldb/API/SBFrame.h (+2-1)
- (modified) lldb/include/lldb/Breakpoint/Breakpoint.h (+53-5)
- (modified) lldb/include/lldb/Breakpoint/BreakpointLocation.h (+60-8)
- (modified) lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h (+1-1)
- (modified) lldb/include/lldb/Breakpoint/BreakpointLocationList.h (+2-1)
- (modified) lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h (+6)
- (modified) lldb/include/lldb/Breakpoint/BreakpointSite.h (+2-1)
- (modified) lldb/include/lldb/Breakpoint/StopPointSiteList.h (-24)
- (modified) lldb/include/lldb/Breakpoint/StoppointSite.h (+4-1)
- (modified)
lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h (+10)
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+6)
- (modified) lldb/source/API/SBBreakpoint.cpp (+10)
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+74-14)
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+136-41)
- (modified) lldb/source/Breakpoint/BreakpointLocationCollection.cpp (+14-2)
- (modified) lldb/source/Breakpoint/BreakpointLocationList.cpp (+6-5)
- (modified) lldb/source/Breakpoint/BreakpointResolverScripted.cpp (+23-1)
- (modified) lldb/source/Breakpoint/BreakpointSite.cpp (+3-2)
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+13)
- (modified)
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp
(+26)
- (modified)
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h
(+6)
- (modified)
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
(+47)
- (modified)
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
(+27)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
(+3)
- (modified) lldb/source/Target/StopInfo.cpp (+47-25)
- (modified) lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
(-1)
- (added)
lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/Makefile (+4)
- (added)
lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py
(+85)
- (added)
lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py
(+45)
- (added) lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c
(+17)
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (+10)
``diff
diff --git a/lldb/bindings/python/python-swigsafecast.swig
b/lldb/bindings/python/python-swigsafecast.swig
index 4721dfdc17e6a..3ea24f1a31414 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -142,5 +142,9 @@ PythonObject SWIGBridge::ToSWIGWrapper(
return ToSWIGHelper(module_spec_sb.release(), SWIGTYPE_p_lldb__SBModuleSpec);
}
+PythonObject SWIGBridge::ToSWIGWrapper(lldb::DescriptionLevel level) {
+ return PythonInteger((int64_t) level);
+}
+
} // namespace python
} // namespace lldb_private
diff --git a/lldb/bindings/python/python-wrapper.swig
b/lldb/bindings/python/python-wrapper.swig
index 2c30d536a753d..64b7dc8381073 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -422,6 +422,30 @@ void
*lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *
return sb_ptr;
}
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrame(PyObject *
data) {
+ lldb::SBFrame *sb_ptr = nullptr;
+
+ int valid_cast =
+ SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBFrame, 0);
+
+ if (valid_cast == -1)
+return NULL;
+
+ return sb_ptr;
+}
+
+void
*lldb_private::python::LLDBSWIGPython_CastPyObje
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
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 origin/main...HEAD
lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/TestWasHit.py
lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/bkpt_resolver.py
lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from darker here.
``diff
--- was_hit/TestWasHit.py 2025-09-11 18:01:38.00 +
+++ was_hit/TestWasHit.py 2025-09-11 18:12:02.876650 +
@@ -31,55 +31,72 @@
command = "command script import " + script_name
self.runCmd(command)
def make_extra_args(self, sym_name, num_locs, loc_to_miss):
-return f' -k symbol -v {sym_name} -k num_locs -v {num_locs} -k
loc_to_miss -v {loc_to_miss} '
+return f" -k symbol -v {sym_name} -k num_locs -v {num_locs} -k
loc_to_miss -v {loc_to_miss} "
def do_test(self):
"""This reads in a python file and sets a breakpoint using it."""
target = self.make_target_and_import()
extra_args = self.make_extra_args("stop_symbol", 4, 2)
-bkpt_no = lldbutil.run_break_set_by_script(self,
"bkpt_resolver.FacadeExample", extra_args, 4)
+bkpt_no = lldbutil.run_break_set_by_script(
+self, "bkpt_resolver.FacadeExample", extra_args, 4
+)
# Make sure the help text shows up in the "break list" output:
self.expect(
"break list",
substrs=["I am a facade resolver - sym: stop_symbol - num_locs:
4"],
msg="Help is listed in break list",
)
bkpt = target.FindBreakpointByID(bkpt_no)
self.assertTrue(bkpt.IsValid(), "Found the right breakpoint")
-
+
# Now continue. We should hit locations 1, 3 and 4:
-(target, process, thread, bkpt) =
lldbutil.run_to_breakpoint_do_run(self, target, bkpt)
+(target, process, thread, bkpt) = lldbutil.run_to_breakpoint_do_run(
+self, target, bkpt
+)
# This location should be bkpt_no.1:
-self.assertEqual(thread.stop_reason_data[0], bkpt_no, "Hit the right
breakpoint")
+self.assertEqual(
+thread.stop_reason_data[0], bkpt_no, "Hit the right breakpoint"
+)
self.assertEqual(thread.stop_reason_data[1], 1, "First location hit is
1")
for loc in [3, 4]:
process.Continue()
-self.assertEqual(thread.stop_reason, lldb.eStopReasonBreakpoint,
"Hit breakpoint")
-self.assertEqual(thread.stop_reason_data[0], bkpt_no, "Hit the
right breakpoint")
-self.assertEqual(thread.stop_reason_data[1], loc, f"Hit the right
location: {loc}")
+self.assertEqual(
+thread.stop_reason, lldb.eStopReasonBreakpoint, "Hit
breakpoint"
+)
+self.assertEqual(
+thread.stop_reason_data[0], bkpt_no, "Hit the right breakpoint"
+)
+self.assertEqual(
+thread.stop_reason_data[1], loc, f"Hit the right location:
{loc}"
+)
# At this point we should have hit three of the four locations, and
not location 1.2.
# Check that that is true, and that the descriptions for the location
are the ones
# the resolver provided.
self.assertEqual(bkpt.hit_count, 3, "Hit three locations")
-for loc_id in range(1,4):
+for loc_id in range(1, 4):
bkpt_loc = bkpt.FindLocationByID(loc_id)
self.assertTrue(bkpt_loc.IsValid(), f"{loc_id} was invalid.")
if loc_id != 2:
-self.assertEqual(bkpt_loc.hit_count, 1, f"Loc {loc_id} hit
count was wrong")
+self.assertEqual(
+bkpt_loc.hit_count, 1, f"Loc {loc_id} hit count was wrong"
+)
else:
self.assertEqual(bkpt_loc.hit_count, 0, "We didn't skip loc 2")
stream = lldb.SBStream()
-self.assertTrue(bkpt_loc.GetDescription(stream,
lldb.eDescriptionLevelFull),
-f"Didn't get description for {loc_id}")
-self.assertIn(f"Location index: {loc_id}", stream.GetData(),
- f"Wrong desciption for {loc_id}")
-
-
+self.assertTrue(
+bkpt_loc.GetDescription(stream, lldb.eDescriptionLevelFull),
+f"Didn't get description for {loc_id}",
+)
+self.assertIn(
+f"Location index: {loc_id}",
+stream.G
[Lldb-commits] [lldb] [LLDB][NativePDB] Implement `AddSymbols` (PR #154121)
https://github.com/ZequanWu approved this pull request. https://github.com/llvm/llvm-project/pull/154121 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] AST: remove DependentTemplateSpecializationType (PR #158109)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/158109 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] AST: remove DependentTemplateSpecializationType (PR #158109)
@@ -222,7 +222,6 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(declRefExpr);
REGISTER_MATCHER(dependentNameType);
REGISTER_MATCHER(dependentScopeDeclRefExpr);
- REGISTER_MATCHER(dependentTemplateSpecializationType);
mizvekov wrote:
The matcher is highly incomplete because it doesn't allow matching on the
template name in any way. There is no support for template names in ast
matchers as far as I know.
So I highly doubt anyone depends on this.
https://github.com/llvm/llvm-project/pull/158109
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
@@ -0,0 +1,45 @@
+import lldb
+
+class FacadeExample:
+def __init__(self, bkpt, extra_args, dict):
+self.bkpt = bkpt
+self.extra_args = extra_args
+self.base_sym = None
+self.facade_locs = []
+self.facade_locs_desc = []
+self.cur_facade_loc = 1
+
+self.sym_name = extra_args.GetValueForKey("symbol").GetStringValue(100)
+self.num_locs =
extra_args.GetValueForKey("num_locs").GetIntegerValue(5)
medismailben wrote:
I believe you can do this with @kastiglione recent change.
```suggestion
self.sym_name = str(extra_args.GetValueForKey("symbol"))
self.num_locs = int(extra_args.GetValueForKey("num_locs"))
```
https://github.com/llvm/llvm-project/pull/158128
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix use after free on ModuleList::RemoveSharedModuleIfOrphaned (PR #155331)
JDevlieghere wrote: We discussed this offline today. I should've been less terse in explaining my idea, which is to use weak pointers all the way down, lock it just before we're going to remove it to create a critical section, account for the increase in refcount, and then release the pointer. Augusto seems on both and was going to give that a go. https://github.com/llvm/llvm-project/pull/155331 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
@@ -0,0 +1,45 @@
+import lldb
+
+class FacadeExample:
+def __init__(self, bkpt, extra_args, dict):
+self.bkpt = bkpt
+self.extra_args = extra_args
+self.base_sym = None
+self.facade_locs = []
+self.facade_locs_desc = []
+self.cur_facade_loc = 1
+
+self.sym_name = extra_args.GetValueForKey("symbol").GetStringValue(100)
+self.num_locs =
extra_args.GetValueForKey("num_locs").GetIntegerValue(5)
+self.loc_to_miss =
extra_args.GetValueForKey("loc_to_miss").GetIntegerValue(1)
+
+def __callback__(self, sym_ctx):
+self.base_sym = sym_ctx.module.FindSymbol(self.sym_name,
lldb.eSymbolTypeCode)
+if self.base_sym.IsValid():
+self.bkpt.AddLocation(self.base_sym.GetStartAddress())
+# Locations are 1 based, so to keep things simple, I'm making
+# the array holding locations 1 based as well:
+self.facade_locs_desc.append("This is the zero index, you
shouldn't see this")
+self.facade_locs.append(None)
+for i in range(1, self.num_locs + 1):
+self.facade_locs_desc.append(f"Location index: {i}")
+self.facade_locs.append(self.bkpt.AddFacadeLocation())
+
+def get_short_help(self):
+return f"I am a facade resolver - sym: {self.sym_name} - num_locs:
{self.num_locs} - locs_to_miss: {self.loc_to_miss}"
+
+def was_hit(self, frame, bp_loc):
+tmp_loc = self.cur_facade_loc
+
+self.cur_facade_loc = (self.cur_facade_loc + 1)
+if self.cur_facade_loc == 5:
+ self.cur_facade_loc = 1
medismailben wrote:
I guess you're doing this because you expect at most 4 locations, correct ?
https://github.com/llvm/llvm-project/pull/158128
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add boolean literals to DIL. (PR #157992)
https://github.com/cmtice updated
https://github.com/llvm/llvm-project/pull/157992
>From 097c19c6f7e76f055cbcc56ec14e5098dcee Mon Sep 17 00:00:00 2001
From: Caroline Tice
Date: Wed, 10 Sep 2025 21:58:07 -0700
Subject: [PATCH 1/2] [LLDB] Add boolean literals to DIL.
This adds the ability to recognize (and create ValueObjects for)
boolean literals ("true", "false") to DIL. This is a preliminary
step to adding type casting (and also for the ternary op).
---
lldb/docs/dil-expr-lang.ebnf | 3 +++
lldb/include/lldb/ValueObject/DILAST.h| 20 ++
lldb/include/lldb/ValueObject/DILEval.h | 2 ++
lldb/include/lldb/ValueObject/DILLexer.h | 2 ++
lldb/include/lldb/ValueObject/DILParser.h | 3 +++
lldb/source/ValueObject/DILAST.cpp| 5 +
lldb/source/ValueObject/DILEval.cpp | 6 ++
lldb/source/ValueObject/DILLexer.cpp | 15 +++---
lldb/source/ValueObject/DILParser.cpp | 25 +++
9 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index 67328939ba420..70eda3bf40650 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -16,6 +16,7 @@ postfix_expression = primary_expression
| postfix_expression "->" id_expression ;
primary_expression = numeric_literal
+ | boolean_literal
| id_expression
| "(" expression ")" ;
@@ -35,6 +36,8 @@ integer_literal = ? Integer constant: hexademical, decimal,
octal, binary ? ;
numeric_literal = ? Integer constant: hexademical, decimal, octal, binary ?
| ? Floating constant ? ;
+boolean_literal = "true" | "false" ;
+
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 1d10755c46e39..0f05d753f1b56 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
enum class NodeKind {
eArraySubscriptNode,
eBitExtractionNode,
+ eBooleanLiteralNode,
eErrorNode,
eFloatLiteralNode,
eIdentifierNode,
@@ -226,6 +227,23 @@ class FloatLiteralNode : public ASTNode {
llvm::APFloat m_value;
};
+class BooleanLiteralNode : public ASTNode {
+public:
+ BooleanLiteralNode(uint32_t location, bool value)
+ : ASTNode(location, NodeKind::eBooleanLiteralNode), m_value(value) {}
+
+ llvm::Expected Accept(Visitor *v) const override;
+
+ bool GetValue() const & { return m_value; }
+
+ static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eBooleanLiteralNode;
+ }
+
+private:
+ bool m_value;
+};
+
/// 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
@@ -247,6 +265,8 @@ class Visitor {
Visit(const IntegerLiteralNode *node) = 0;
virtual llvm::Expected
Visit(const FloatLiteralNode *node) = 0;
+ virtual llvm::Expected
+ Visit(const BooleanLiteralNode *node) = 0;
};
} // namespace lldb_private::dil
diff --git a/lldb/include/lldb/ValueObject/DILEval.h
b/lldb/include/lldb/ValueObject/DILEval.h
index 5a48c2c989f4d..eab3218ff828f 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -58,6 +58,8 @@ class Interpreter : Visitor {
Visit(const IntegerLiteralNode *node) override;
llvm::Expected
Visit(const FloatLiteralNode *node) override;
+ llvm::Expected
+ Visit(const BooleanLiteralNode *node) override;
llvm::Expected
PickIntegerType(lldb::TypeSystemSP type_system,
diff --git a/lldb/include/lldb/ValueObject/DILLexer.h
b/lldb/include/lldb/ValueObject/DILLexer.h
index 4345e6ce7f26b..28b94a79c5902 100644
--- a/lldb/include/lldb/ValueObject/DILLexer.h
+++ b/lldb/include/lldb/ValueObject/DILLexer.h
@@ -31,6 +31,8 @@ class Token {
float_constant,
identifier,
integer_constant,
+kw_false,
+kw_true,
l_paren,
l_square,
minus,
diff --git a/lldb/include/lldb/ValueObject/DILParser.h
b/lldb/include/lldb/ValueObject/DILParser.h
index 90df109337dcf..d17ed66d9b3ee 100644
--- a/lldb/include/lldb/ValueObject/DILParser.h
+++ b/lldb/include/lldb/ValueObject/DILParser.h
@@ -99,11 +99,14 @@ class DILParser {
ASTNodeUP ParseNumericLiteral();
ASTNodeUP ParseIntegerLiteral();
ASTNodeUP ParseFloatingPointLiteral();
+ ASTNodeUP ParseBooleanLiteral();
void BailOut(const std::string &error, uint32_t loc, uint16_t err_len);
void Expect(Token::Kind kind);
+ void ExpectOneOf(std::vector kinds_vec);
+
void TentativeParsingRollback(uint32_t saved_idx) {
if (m_error)
llvm::consumeError(std::move(m_error));
diff --git a/lldb/source/ValueObject/DILAST.cpp
b/lldb/source/ValueObject
[Lldb-commits] [lldb] [lldb][test] Enable non-address bit WritePointerToMemory test on Linux (PR #157435)
https://github.com/felipepiovezan approved this pull request. Argh, sorry for the delay, I missed the email for this PR. LGTM! I thought the test would need some more work because of the section's names in the json file. https://github.com/llvm/llvm-project/pull/157435 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
@@ -0,0 +1,45 @@ +import lldb + +class FacadeExample: +def __init__(self, bkpt, extra_args, dict): +self.bkpt = bkpt +self.extra_args = extra_args +self.base_sym = None +self.facade_locs = [] +self.facade_locs_desc = [] +self.cur_facade_loc = 1 jimingham wrote: Locations are 1 based, not 0 based. As I say around here somewhere, going from 1 based locations to 0 based list indices was driving me nuts, so I made all the arrays 1 based by virtue of filling the first element with placeholders... https://github.com/llvm/llvm-project/pull/158128 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add `debugAdapterEnv` for `attach` requests & improve regex (PR #157980)
https://github.com/royitaqi updated
https://github.com/llvm/llvm-project/pull/157980
>From 265efab57c62479bb296bd59e0673d9935e9767f Mon Sep 17 00:00:00 2001
From: Roy Shi
Date: Wed, 10 Sep 2025 17:38:53 -0700
Subject: [PATCH 1/3] [lldb-dap] Add missing `debugAdapterEnv` into `attach`
configuration
---
lldb/tools/lldb-dap/package.json | 23 +++
1 file changed, 23 insertions(+)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 9cc653cee405b..51b76536cfca5 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -672,6 +672,29 @@
},
"markdownDescription": "The list of additional arguments used
to launch the debug adapter executable. Overrides any user or workspace
settings."
},
+ "debugAdapterEnv": {
+"anyOf": [
+ {
+"type": "object",
+"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. E.g. `{ \"FOO\": \"1\" }`",
+"patternProperties": {
+ ".*": {
+"type": "string"
+ }
+},
+"default": {}
+ },
+ {
+"type": "array",
+"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. E.g. `[\"FOO=1\",
\"BAR\"]`",
+"items": {
+ "type": "string",
+ "pattern": "^((\\w+=.*)|^\\w+)$"
+},
+"default": []
+ }
+]
+ },
"program": {
"type": "string",
"description": "Path to the program to attach to."
>From 38ec521eccfdb91a6d43c068b15ec9e6886563ef Mon Sep 17 00:00:00 2001
From: Roy Shi
Date: Wed, 10 Sep 2025 17:58:11 -0700
Subject: [PATCH 2/3] Improve debugAdapterEnv's regex
---
lldb/tools/lldb-dap/package.json| 4 ++--
lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 51b76536cfca5..3d8b18bed0108 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -422,7 +422,7 @@
"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. E.g. `[\"FOO=1\",
\"BAR\"]`",
"items": {
"type": "string",
- "pattern": "^((\\w+=.*)|^\\w+)$"
+ "pattern": "^\\w+(=.*)?$"
},
"default": []
}
@@ -689,7 +689,7 @@
"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. E.g. `[\"FOO=1\",
\"BAR\"]`",
"items": {
"type": "string",
- "pattern": "^((\\w+=.*)|^\\w+)$"
+ "pattern": "^\\w+(=.*)?$"
},
"default": []
}
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index f7e92ee95ca32..7060638a94864 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -92,7 +92,7 @@ function validateDAPEnv(debugConfigEnv: any): boolean {
Array.isArray(debugConfigEnv) &&
debugConfigEnv.findIndex(
(entry) =>
-typeof entry !== "string" || !/^((\\w+=.*)|^\\w+)$/.test(entry),
+typeof entry !== "string" || !/^\w+(=.*)?$/.test(entry),
) !== -1
) {
return false;
>From eb85d54f76611f463f6d827bdb433db253bfd81c Mon Sep 17 00:00:00 2001
From: Roy Shi
Date: Thu, 11 Sep 2025 17:46:31 -0700
Subject: [PATCH 3/3] Use 'For example, ../..'
---
lldb/tools/lldb-dap/package.json | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 3d8b18bed0108..8141209fb6bb6 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -409,7 +409,7 @@
"anyOf": [
{
"type": "object",
-"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. E.g. `{ \"FOO\": \"1\" }`",
+"markdownDescription": "Additional environment variables
to set when launching the debug adapter executable. For example, `{ \"FOO\":
\"1\" }`",
"patternProperties": {
".*": {
[Lldb-commits] [lldb] 770cd43 - [lldb-dap] Add invalidated event (#157530)
Author: Druzhkov Sergei
Date: 2025-09-11T12:06:46-07:00
New Revision: 770cd432a692d9c35285fcbbd8e4fcca172ee7d7
URL:
https://github.com/llvm/llvm-project/commit/770cd432a692d9c35285fcbbd8e4fcca172ee7d7
DIFF:
https://github.com/llvm/llvm-project/commit/770cd432a692d9c35285fcbbd8e4fcca172ee7d7.diff
LOG: [lldb-dap] Add invalidated event (#157530)
This patch fixes the problem, when after a `setVariable` request
pointers and references to the variable are not updated. VSCode doesn't
send a `variables` request after a `setVariable` request, so we should
trigger it explicitly via`invalidated` event .Also, updated
`writeMemory` request in similar way.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
lldb/tools/lldb-dap/EventHelper.cpp
lldb/tools/lldb-dap/EventHelper.h
lldb/tools/lldb-dap/Handler/SetVariableRequestHandler.cpp
lldb/tools/lldb-dap/Handler/WriteMemoryRequestHandler.cpp
lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
lldb/tools/lldb-dap/Protocol/ProtocolEvents.h
lldb/unittests/DAP/ProtocolTypesTest.cpp
Removed:
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 51debcf477a9d..9fe8ca22e820b 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -215,6 +215,7 @@ def __init__(
self.terminated: bool = False
self.events: List[Event] = []
self.progress_events: List[Event] = []
+self.invalidated_event: Optional[Event] = None
self.reverse_requests: List[Request] = []
self.module_events: List[Dict] = []
self.sequence: int = 1
@@ -440,6 +441,8 @@ def _handle_event(self, packet: Event) -> None:
elif event == "capabilities" and body:
# Update the capabilities with new ones from the event.
self.capabilities.update(body["capabilities"])
+elif event == "invalidated":
+self.invalidated_event = packet
def _handle_reverse_request(self, request: Request) -> None:
if request in self.reverse_requests:
@@ -1014,6 +1017,7 @@ def request_initialize(self, sourceInitFile=False):
"supportsVariableType": True,
"supportsStartDebuggingRequest": True,
"supportsProgressReporting": True,
+"supportsInvalidatedEvent": True,
"$__lldb_sourceInitFile": sourceInitFile,
},
}
diff --git
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index fffd4c23d6fcd..a0a009ae6cc9a 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -241,6 +241,13 @@ def verify_commands(self, flavor: str, output: str,
commands: list[str]):
f"Command '{flavor}' - '{cmd}' not found in output: {output}",
)
+def verify_invalidated_event(self, expected_areas):
+event = self.dap_server.invalidated_event
+self.dap_server.invalidated_event = None
+self.assertIsNotNone(event)
+areas = event["body"].get("areas", [])
+self.assertEqual(set(expected_areas), set(areas))
+
def get_dict_value(self, d: dict, key_path: list[str]) -> Any:
"""Verify each key in the key_path array is in contained in each
dictionary within "d". Assert if any key isn't in the
@@ -352,13 +359,20 @@ def get_local_as_int(self, name, threadId=None):
else:
return int(value)
+def set_variable(self, varRef, name, value, id=None):
+"""Set a variable."""
+response = self.dap_server.request_setVariable(varRef, name,
str(value), id=id)
+if response["success"]:
+self.verify_invalidated_event(["variables"])
+return response
+
def set_local(self, name, value, id=None):
"""Set a top level local variable only."""
-return self.dap_server.request_setVariable(1, name, str(value), id=id)
+return self.set_variable(1, name, str(value), id=id)
def set_global(self, name, value, id=None):
"""Set a top level global variable only."""
-return self.dap_server.request_setVariable(2, name, str(value), id=id)
+return self.set_variable(2, name, str(value), id=id)
def stepIn(
self,
@@ -577,4 +591,6 @@ def writeMemory(self, memoryReference, data=None, offset=0,
allowPartial=False):
response =
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
Michael137 wrote: gentle ping https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
da-viper wrote: It was failing because the `typeName` checked by `isUnordered` is const qualified so it does not match the template name. https://github.com/llvm/llvm-project/pull/156033 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous struct in base classes (PR #158256)
https://github.com/imkiva edited https://github.com/llvm/llvm-project/pull/158256 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
@@ -113,7 +113,6 @@ def do_test_ptr(self): Test that pointers to std::unordered_map are formatted correctly. """ -self.build() Michael137 wrote: Can we do this in a separate PR? https://github.com/llvm/llvm-project/pull/156033 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
https://github.com/Michael137 approved this pull request. LGTM Could you update the PR description and title before merging? https://github.com/llvm/llvm-project/pull/156033 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)
https://github.com/da-viper updated
https://github.com/llvm/llvm-project/pull/156033
>From 09ad3b0137c3939a76e91409e8194215c1cd94a1 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike
Date: Fri, 29 Aug 2025 15:17:29 +0100
Subject: [PATCH] [lldb] fix std::unordered_map formatter for const types.
the type that is checked in isUnordered may be const qualified.
---
.../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 13 +++--
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index f88a5319068a2..ef49c4e6055a8 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -113,10 +113,11 @@ CompilerType
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
// wraps a std::pair. Peel away the internal wrapper type - whose structure
is
// of no value to users, to expose the std::pair. This matches the structure
// returned by the std::map synthetic provider.
- if (isUnorderedMap(m_backend.GetCompilerType()
- .GetNonReferenceType()
- .GetCanonicalType()
- .GetTypeName())) {
+ CompilerType backend_type = m_backend.GetCompilerType();
+ if (backend_type.IsPointerOrReferenceType())
+backend_type = backend_type.GetPointeeType();
+
+ if (isUnorderedMap(backend_type.GetCanonicalType().GetTypeName())) {
std::string name;
CompilerType field_type =
element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
@@ -165,9 +166,9 @@ lldb::ValueObjectSP lldb_private::formatters::
ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_");
if (!hash_sp || !value_sp) {
node_sp = m_next_element->Cast(m_node_type.GetPointerType())
- ->Dereference(error);
+->Dereference(error);
if (!node_sp || error.Fail())
- return nullptr;
+return nullptr;
hash_sp = node_sp->GetChildMemberWithName("__hash_");
if (!hash_sp)
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Require DIA SDK for testing the PDB plugin-selection setting (PR #158284)
https://github.com/Nerixyz created
https://github.com/llvm/llvm-project/pull/158284
If LLDB is built without the DIA SDK enabled, then the native plugin is used
regardless of `plugin.symbol-file.pdb.reader` or `LLDB_USE_NATIVE_PDB_READER`.
This made the test fail on Windows when the DIA SDK was disabled
(https://github.com/llvm/llvm-project/issues/114906#issuecomment-3241796062).
This PR changes the requirement for the test from `target-windows` to `diasdk`
(only used in this test).
>From 9990fae1d43641a1868e3df641f346873ce8f78e Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Fri, 12 Sep 2025 14:08:33 +0200
Subject: [PATCH] [LLDB] Require DIA SDK for testing the PDB plugin selection
setting
---
lldb/test/Shell/SymbolFile/PDB/native-setting.cpp | 2 +-
lldb/test/Shell/lit.cfg.py| 3 +++
lldb/test/Shell/lit.site.cfg.py.in| 3 +++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
index ce188e75553c7..edf7508b88f17 100644
--- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: target-windows
+// REQUIRES: diasdk
// Test plugin.symbol-file.pdb.reader setting
// RUN: %build -o %t.exe -- %s
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index 46e2117cdb8e7..505847fb763e0 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -170,6 +170,9 @@ def calculate_arch_features(arch_string):
)
)
+if config.have_dia_sdk:
+config.available_features.add("diasdk")
+
# NetBSD permits setting dbregs either if one is root
# or if user_set_dbregs is enabled
can_set_dbregs = True
diff --git a/lldb/test/Shell/lit.site.cfg.py.in
b/lldb/test/Shell/lit.site.cfg.py.in
index beaa41e6fd379..859a064d636ae 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -1,5 +1,7 @@
@LIT_SITE_CFG_IN_HEADER@
+import lit.util
+
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
@@ -34,6 +36,7 @@ config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
+config.have_dia_sdk = lit.util.pythonize_bool("@LLVM_ENABLE_DIA_SDK@")
# The shell tests use their own module caches.
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@",
"lldb-shell")
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@",
"lldb-shell")
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test. (PR #158286)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Ebuka Ezike (da-viper)
Changes
The build step is overidden so it uses `libstdc++` instead of `libc++` on linux
---
Full diff: https://github.com/llvm/llvm-project/pull/158286.diff
1 Files Affected:
- (modified)
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
(-1)
``diff
diff --git
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
index d2382373f4810..1e920faab6397 100644
---
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
+++
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
@@ -113,7 +113,6 @@ def do_test_ptr(self):
Test that pointers to std::unordered_map are formatted correctly.
"""
-self.build()
(self.target, process, thread, bkpt) =
lldbutil.run_to_source_breakpoint(
self, "Stop here", lldb.SBFileSpec("main.cpp", False)
)
``
https://github.com/llvm/llvm-project/pull/158286
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix unordered-map data formatter for const types (PR #156033)
https://github.com/da-viper edited https://github.com/llvm/llvm-project/pull/156033 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test. (PR #158286)
https://github.com/da-viper created
https://github.com/llvm/llvm-project/pull/158286
The build step is overidden so it uses `libstdc++` instead of `libc++` on linux
>From 1cd5ecd349d9b9d8054d409314862b2c0fbb694e Mon Sep 17 00:00:00 2001
From: Ebuka Ezike
Date: Fri, 12 Sep 2025 13:23:47 +0100
Subject: [PATCH] [lldb][test] Fix unordered-map test.
The build step is overidden so it uses `libstdc++` instead of `libc++`
---
.../unordered_map-iterator/TestDataFormatterStdUnorderedMap.py | 1 -
1 file changed, 1 deletion(-)
diff --git
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
index d2382373f4810..1e920faab6397 100644
---
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
+++
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
@@ -113,7 +113,6 @@ def do_test_ptr(self):
Test that pointers to std::unordered_map are formatted correctly.
"""
-self.build()
(self.target, process, thread, bkpt) =
lldbutil.run_to_source_breakpoint(
self, "Stop here", lldb.SBFileSpec("main.cpp", False)
)
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Require DIA SDK for testing the PDB plugin-selection setting (PR #158284)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/158284 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e8f6180 - [libcxx] adds size-based `__split_buffer` representation to unstable ABI (#139632)
Author: Christopher Di Bella
Date: 2025-09-12T06:33:10-07:00
New Revision: e8f61801c6237e56b3d69190af7a7acfdcede1e8
URL:
https://github.com/llvm/llvm-project/commit/e8f61801c6237e56b3d69190af7a7acfdcede1e8
DIFF:
https://github.com/llvm/llvm-project/commit/e8f61801c6237e56b3d69190af7a7acfdcede1e8.diff
LOG: [libcxx] adds size-based `__split_buffer` representation to unstable ABI
(#139632)
**tl;dr** We can significantly improve the runtime performance of
`std::vector` by changing its representation from three pointers to one
pointer and two integers. This document explains the details of this
change, along with the justifications for making it. See the [RFC] for
more information.
`vector` depends on `__split_buffer` for inserting elements. Changing
`__split_buffer` to match `vector`'s representation simplifies the
model, as it eliminates the need to convert between two different
representations of a contiguous buffer in the same configuration of
libc++.
[RFC]:
https://discourse.llvm.org/t/adding-a-size-based-vector-to-libc-s-unstable-abi/86306
-
Co-authored-by: Jorge Gorbe Moya
Added:
Modified:
libcxx/include/__split_buffer
libcxx/include/__vector/vector.h
libcxx/include/deque
libcxx/test/libcxx/type_traits/is_replaceable.compile.pass.cpp
libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp
lldb/examples/synthetic/libcxx.py
Removed:
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 21e58f4abc6b3..15368a3bc8955 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -13,10 +13,12 @@
#include <__algorithm/max.h>
#include <__algorithm/move.h>
#include <__algorithm/move_backward.h>
+#include <__assert>
#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
+#include <__memory/addressof.h>
#include <__memory/allocate_at_least.h>
#include <__memory/allocator.h>
#include <__memory/allocator_traits.h>
@@ -45,25 +47,434 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-// __split_buffer allocates a contiguous chunk of memory and stores objects in
the range [__begin_, __end_).
-// It has uninitialized memory in the ranges [__first_, __begin_) and
[__end_, __cap_). That allows
-// it to grow both in the front and back without having to move the data.
+template class
_Layout>
+class __split_buffer;
+
+template
+class __split_buffer_pointer_layout {
+protected:
+ using value_type = _Tp;
+ using allocator_type = _Allocator;
+ using __alloc_rr _LIBCPP_NODEBUG =
__libcpp_remove_reference_t;
+ using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>;
+ using reference = value_type&;
+ using const_reference = const value_type&;
+ using size_type = typename __alloc_traits::size_type;
+ using
diff erence_type = typename __alloc_traits::
diff erence_type;
+ using pointer = typename __alloc_traits::pointer;
+ using const_pointer = typename
__alloc_traits::const_pointer;
+ using iterator= pointer;
+ using const_iterator = const_pointer;
+ using __sentinel_type _LIBCPP_NODEBUG = pointer;
-template >
-struct __split_buffer {
public:
- using value_type = _Tp;
- using allocator_type = _Allocator;
- using __alloc_rr _LIBCPP_NODEBUG =
__libcpp_remove_reference_t;
- using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>;
- using reference = value_type&;
- using const_reference= const value_type&;
- using size_type = typename __alloc_traits::size_type;
- using
diff erence_type= typename __alloc_traits::
diff erence_type;
- using pointer= typename __alloc_traits::pointer;
- using const_pointer = typename
__alloc_traits::const_pointer;
- using iterator = pointer;
- using const_iterator = const_pointer;
+ // Can't be defaulted due to _LIBCPP_COMPRESSED_PAIR not being an aggregate
in C++03 and C++11.
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
__split_buffer_pointer_layout() : __back_cap_(nullptr) {}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20
+ _LIBCPP_HIDE_FROM_ABI explicit __split_buffer_pointer_layout(const
allocator_type& __alloc)
+ : __back_cap_(nullptr), __alloc_(__alloc) {}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __front_cap()
_NOEXCEPT { return __front_cap_; }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer
__front_cap() const _NOEXCEPT {
+return __front_cap_;
+ }
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_H
[Lldb-commits] [libcxx] [lldb] [libcxx] adds size-based `__split_buffer` representation to unstable ABI (PR #139632)
https://github.com/cjdb closed https://github.com/llvm/llvm-project/pull/139632 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous struct in base classes (PR #158256)
https://github.com/Michael137 commented: With each addition to this function my desire to move this into libClang grows stronger. Though I understand that the indexing is an LLDB-specific scheme, so might not be easy to move. https://github.com/llvm/llvm-project/pull/158256 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed UB in CPlusPlusLanguage plug-in (PR #158304)
slydiman wrote: Note tests failed because LLDB is broken since https://lab.llvm.org/buildbot/#/builders/195/builds/14502 ``` FAIL: lldb-api::TestVectorOfVectorsFromStdModule.py FAIL: lldb-api::TestDbgInfoContentVectorFromStdModule.py ``` https://github.com/llvm/llvm-project/pull/158304 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed UB in CPlusPlusLanguage plug-in (PR #158304)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/158304 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes This pages improve the LLDB website documentation readability and discoverability by breaking down the very long python-reference page into multiple subpages each explaining a specific topic. The long term goal is to have tutorials for every scripting extension. This also converts the pages into markdown, since it's easier to write. --- Patch is 167.69 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158331.diff 12 Files Affected: - (modified) lldb/docs/use/python-reference.rst (+18-1123) - (removed) lldb/docs/use/python.rst (-799) - (added) lldb/docs/use/tutorials/accessing-documentation.md (+59) - (added) lldb/docs/use/tutorials/breakpoint-triggered-scripts.md (+85) - (added) lldb/docs/use/tutorials/creating-custom-breakpoints.md (+128) - (added) lldb/docs/use/tutorials/custom-frame-recognizers.md (+52) - (added) lldb/docs/use/tutorials/custom-stepping-behavior.md (+42) - (added) lldb/docs/use/tutorials/python-embedded-interpreter.md (+66) - (added) lldb/docs/use/tutorials/python-standalone-scripts.md (+132) - (added) lldb/docs/use/tutorials/python-stop-hooks.md (+27) - (added) lldb/docs/use/tutorials/script-driven-debugging.md (+492) - (added) lldb/docs/use/tutorials/writing-custom-commands.md (+420) ``diff diff --git a/lldb/docs/use/python-reference.rst b/lldb/docs/use/python-reference.rst index 4292714c9c208..1d61cb29ef821 100644 --- a/lldb/docs/use/python-reference.rst +++ b/lldb/docs/use/python-reference.rst @@ -10,1126 +10,21 @@ command interpreter (we refer to this for brevity as the embedded interpreter). Of course, in this context it has full access to the LLDB API - with some additional conveniences we will call out in the FAQ. -Documentation --- - -The LLDB API is contained in a python module named lldb. A useful resource when -writing Python extensions is the lldb Python classes reference guide. - -The documentation is also accessible in an interactive debugger session with -the following command: - -:: - - (lldb) script help(lldb) - Help on package lldb: - - NAME - lldb - The lldb module contains the public APIs for Python binding. - - FILE - /System/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python/lldb/__init__.py - - DESCRIPTION - ... - -You can also get help using a module class name. The full API that is exposed -for that class will be displayed in a man page style window. Below we want to -get help on the lldb.SBFrame class: - -:: - - (lldb) script help(lldb.SBFrame) - Help on class SBFrame in module lldb: - - class SBFrame(__builtin__.object) - | Represents one of the stack frames associated with a thread. - | SBThread contains SBFrame(s). For example (from test/lldbutil.py), - | - | def print_stacktrace(thread, string_buffer = False): - | '''Prints a simple stack trace of this thread.''' - | - ... - -Or you can get help using any python object, here we use the lldb.process -object which is a global variable in the lldb module which represents the -currently selected process: - -:: - - (lldb) script help(lldb.process) - Help on SBProcess in module lldb object: - - class SBProcess(__builtin__.object) - | Represents the process associated with the target program. - | - | SBProcess supports thread iteration. For example (from test/lldbutil.py), - | - | # == - | # Utility functions related to Threads and Processes - | # == - | - ... - -Embedded Python Interpreter - -The embedded python interpreter can be accessed in a variety of ways from -within LLDB. The easiest way is to use the lldb command script with no -arguments at the lldb command prompt: - -:: - - (lldb) script - Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. - >>> 2+3 - 5 - >>> hex(12345) - '0x3039' - >>> - -This drops you into the embedded python interpreter. When running under the -script command, lldb sets some convenience variables that give you quick access -to the currently selected entities that characterize the program and debugger -state. In each case, if there is no currently selected entity of the -appropriate type, the variable's IsValid method will return false. These -variables are: - -+---+-+-+-+ -| Variable | Type| Equivalent | Description | -+---+-+---
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
@@ -0,0 +1,194 @@
+//===-- TestRiscvInstEmulation.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 "gtest/gtest.h"
+
+#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
+
+#include "lldb/Core/AddressRange.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/ArchSpec.h"
+
+#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
+#include "Plugins/Instruction/RISCV/EmulateInstructionRISCV.h"
+#include "Plugins/Process/Utility/lldb-riscv-register-enums.h"
+#include "llvm/Support/TargetSelect.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestRiscvInstEmulation : public testing::Test {
+public:
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+
+ // virtual void SetUp() override { }
+ // virtual void TearDown() override { }
+
+protected:
+};
+
+void TestRiscvInstEmulation::SetUpTestCase() {
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllDisassemblers();
+ DisassemblerLLVMC::Initialize();
+ EmulateInstructionRISCV::Initialize();
+}
+
+void TestRiscvInstEmulation::TearDownTestCase() {
+ DisassemblerLLVMC::Terminate();
+ EmulateInstructionRISCV::Terminate();
+}
+
+TEST_F(TestRiscvInstEmulation, TestSimpleRiscvFunction) {
+ ArchSpec arch("riscv64-unknown-linux-gnu");
+ // Enable compressed instruction support (RVC extension)
+ arch.SetFlags(ArchSpec::eRISCV_rvc);
+ std::unique_ptr engine(
+ static_cast(
+ UnwindAssemblyInstEmulation::CreateInstance(arch)));
+ ASSERT_NE(nullptr, engine);
+
+ const UnwindPlan::Row *row;
dmpots wrote:
Better to move these closer to where they are used/initialized. For example,
```
const UnwindPlan::Row * row = unwind_plan.GetRowForFunctionOffset(0);
...
UnwindPlan::Row::AbstractRegisterLocation regloc;
EXPECT_TRUE(row->GetRegisterInfo(gpr_fp_riscv, regloc));
```
https://github.com/llvm/llvm-project/pull/158161
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
@@ -0,0 +1,420 @@ +# Writing Custom Commands + +### Create a new command using a Python function + +Python functions can be used to create new LLDB command interpreter commands, +which will work like all the natively defined lldb commands. This provides a +very flexible and easy way to extend LLDB to meet your debugging requirements. + +To write a python function that implements a new LLDB command define the +function to take five arguments as follows: + +```python3 +def command_function(debugger, command, exe_ctx, result, internal_dict): +# Your code goes here +``` + +The meaning of the arguments is given in the table below. + +If you provide a Python docstring in your command function LLDB will use it +when providing "long help" for your command, as in: + +```python3 +def command_function(debugger, command, result, internal_dict): +"""This command takes a lot of options and does many fancy things""" +# Your code goes here +``` + +though providing help can also be done programmatically (see below). + +Prior to lldb 3.5.2 (April 2015), LLDB Python command definitions didn't take the SBExecutionContext +argument. So you may still see commands where the command definition is: + +```python3 +def command_function(debugger, command, result, internal_dict): +# Your code goes here +``` + +Using this form is strongly discouraged because it can only operate on the "currently selected" +target, process, thread, frame. The command will behave as expected when run +directly on the command line. But if the command is used in a stop-hook, breakpoint +callback, etc. where the response to the callback determines whether we will select +this or that particular process/frame/thread, the global "currently selected" +entity is not necessarily the one the callback is meant to handle. In that case, this +command definition form can't do the right thing. + +| Argument | Type | Description | +|--|--|-| +| `debugger` | `lldb.SBDebugger` | The current debugger object. | +| `command` | `python string` | A python string containing all arguments for your command. If you need to chop up the arguments try using the `shlex` module's `shlex.split(command)` to properly extract the arguments. | +| `exe_ctx` | `lldb.SBExecutionContext` | An execution context object carrying around information on the inferior process' context in which the command is expected to act *Optional since lldb 3.5.2, unavailable before* | +| `result` | `lldb.SBCommandReturnObject` | A return object which encapsulates success/failure information for the command and output text that needs to be printed as a result of the command. The plain Python "print" command also works but text won't go in the result by default (it is useful as a temporary logging facility). | +| `internal_dict` | `python dict object` | The dictionary for the current embedded script session which contains all variables and functions. | + +### Create a new command using a Python class + +Since lldb 3.7, Python commands can also be implemented by means of a class +which should implement the following interface: + +```python3 +class CommandObjectType: +def __init__(self, debugger, internal_dict): +# this call should initialize the command with respect to the command interpreter for the passed-in debugger + +def __call__(self, debugger, command, exe_ctx, result): +# this is the actual bulk of the command, akin to Python command functions + +def get_short_help(self): +# this call should return the short help text for this command[1] + +def get_long_help(self): +# this call should return the long help text for this command[1] + +def get_flags(self): +# this will be called when the command is added to the command interpreter, +# and should return a flag field made from or-ing together the appropriate +# elements of the lldb.CommandFlags enum to specify the requirements of this command. +# The CommandInterpreter will make sure all these requirements are met, and will +# return the standard lldb error if they are not.[1] + +def get_repeat_command(self, command): +# The auto-repeat command is what will get executed when the user types just +# a return at the next prompt after this command is run. Even if your command +# was run because it was specified as a repeat command, that invocation will still +# get asked for IT'S repeat command, so you can chain a series of repeats, for instance +# to implement a pager. + +# The command argument is the command that is about to be executed. + +# If this call returns None, then the ordinary repeat mechanism will be used +# If this call returns an empty string, then auto-repeat is disabled +# If this call returns any other string, that will be the repeat command [1] +``` + +[1] This method is optional. + +As a convenie
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
@@ -0,0 +1,420 @@ +# Writing Custom Commands + +### Create a new command using a Python function + +Python functions can be used to create new LLDB command interpreter commands, +which will work like all the natively defined lldb commands. This provides a +very flexible and easy way to extend LLDB to meet your debugging requirements. + +To write a python function that implements a new LLDB command define the +function to take five arguments as follows: + +```python3 +def command_function(debugger, command, exe_ctx, result, internal_dict): +# Your code goes here +``` + +The meaning of the arguments is given in the table below. + +If you provide a Python docstring in your command function LLDB will use it +when providing "long help" for your command, as in: + +```python3 +def command_function(debugger, command, result, internal_dict): +"""This command takes a lot of options and does many fancy things""" +# Your code goes here +``` + +though providing help can also be done programmatically (see below). + +Prior to lldb 3.5.2 (April 2015), LLDB Python command definitions didn't take the SBExecutionContext +argument. So you may still see commands where the command definition is: + +```python3 +def command_function(debugger, command, result, internal_dict): +# Your code goes here +``` + +Using this form is strongly discouraged because it can only operate on the "currently selected" +target, process, thread, frame. The command will behave as expected when run +directly on the command line. But if the command is used in a stop-hook, breakpoint +callback, etc. where the response to the callback determines whether we will select +this or that particular process/frame/thread, the global "currently selected" +entity is not necessarily the one the callback is meant to handle. In that case, this +command definition form can't do the right thing. + +| Argument | Type | Description | +|--|--|-| +| `debugger` | `lldb.SBDebugger` | The current debugger object. | +| `command` | `python string` | A python string containing all arguments for your command. If you need to chop up the arguments try using the `shlex` module's `shlex.split(command)` to properly extract the arguments. | +| `exe_ctx` | `lldb.SBExecutionContext` | An execution context object carrying around information on the inferior process' context in which the command is expected to act *Optional since lldb 3.5.2, unavailable before* | +| `result` | `lldb.SBCommandReturnObject` | A return object which encapsulates success/failure information for the command and output text that needs to be printed as a result of the command. The plain Python "print" command also works but text won't go in the result by default (it is useful as a temporary logging facility). | +| `internal_dict` | `python dict object` | The dictionary for the current embedded script session which contains all variables and functions. | + +### Create a new command using a Python class + +Since lldb 3.7, Python commands can also be implemented by means of a class +which should implement the following interface: + +```python3 +class CommandObjectType: +def __init__(self, debugger, internal_dict): +# this call should initialize the command with respect to the command interpreter for the passed-in debugger + +def __call__(self, debugger, command, exe_ctx, result): +# this is the actual bulk of the command, akin to Python command functions + +def get_short_help(self): +# this call should return the short help text for this command[1] + +def get_long_help(self): +# this call should return the long help text for this command[1] + +def get_flags(self): +# this will be called when the command is added to the command interpreter, +# and should return a flag field made from or-ing together the appropriate +# elements of the lldb.CommandFlags enum to specify the requirements of this command. +# The CommandInterpreter will make sure all these requirements are met, and will +# return the standard lldb error if they are not.[1] + +def get_repeat_command(self, command): +# The auto-repeat command is what will get executed when the user types just +# a return at the next prompt after this command is run. Even if your command +# was run because it was specified as a repeat command, that invocation will still +# get asked for IT'S repeat command, so you can chain a series of repeats, for instance +# to implement a pager. + +# The command argument is the command that is about to be executed. + +# If this call returns None, then the ordinary repeat mechanism will be used +# If this call returns an empty string, then auto-repeat is disabled +# If this call returns any other string, that will be the repeat command [1] +``` + +[1] This method is optional. + +As a convenie
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/barsolo2000 updated
https://github.com/llvm/llvm-project/pull/158161
>From 827f68dcc9b6e207ff324f1be353561ee10892d1 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik
Date: Thu, 11 Sep 2025 14:06:05 -0700
Subject: [PATCH 1/5] RISCV unwinding enable
---
lldb/include/lldb/Core/Opcode.h | 4 +-
.../RISCV/EmulateInstructionRISCV.cpp | 165 +--
.../RISCV/EmulateInstructionRISCV.h | 4 +
lldb/unittests/Instruction/CMakeLists.txt | 5 +
.../RISCV/TestRiscvInstEmulation.cpp | 194 ++
5 files changed, 359 insertions(+), 13 deletions(-)
create mode 100644 lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp
diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h
index 7bbd73d039f99..7e756d3f15d22 100644
--- a/lldb/include/lldb/Core/Opcode.h
+++ b/lldb/include/lldb/Core/Opcode.h
@@ -223,7 +223,9 @@ class Opcode {
int Dump(Stream *s, uint32_t min_byte_width) const;
const void *GetOpcodeBytes() const {
-return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
+return ((m_type == Opcode::eTypeBytes || m_type ==
Opcode::eType16_32Tuples)
+? m_data.inst.bytes
+: nullptr);
}
uint32_t GetByteSize() const {
diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 5e429a92613ce..7a56dcaa2f2db 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -230,10 +230,36 @@ Load(EmulateInstructionRISCV &emulator, I inst, uint64_t
(*extend)(E)) {
auto addr = LoadStoreAddr(emulator, inst);
if (!addr)
return false;
- return transformOptional(
- emulator.ReadMem(*addr),
- [&](T t) { return inst.rd.Write(emulator, extend(E(t))); })
- .value_or(false);
+
+ // Set up context for the load operation, similar to ARM64
+ EmulateInstructionRISCV::Context context;
+
+ // Get register info for base register
+ uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs);
+ std::optional reg_info_rs1 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb);
+
+ if (!reg_info_rs1)
+return false;
+
+ // Set context type based on whether this is a stack-based load
+ if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V
+context.type = EmulateInstruction::eContextPopRegisterOffStack;
+ } else {
+context.type = EmulateInstruction::eContextRegisterLoad;
+ }
+
+ // Set the context address information
+ context.SetAddress(*addr);
+
+ // Read from memory with context and write to register
+ bool success = false;
+ uint64_t value =
+ emulator.ReadMemoryUnsigned(context, *addr, sizeof(T), 0, &success);
+ if (!success)
+return false;
+
+ return inst.rd.Write(emulator, extend(E(T(value;
}
template
@@ -242,9 +268,38 @@ Store(EmulateInstructionRISCV &emulator, I inst) {
auto addr = LoadStoreAddr(emulator, inst);
if (!addr)
return false;
- return transformOptional(
- inst.rs2.Read(emulator),
- [&](uint64_t rs2) { return emulator.WriteMem(*addr, rs2); })
+
+ // Set up context for the store operation, similar to ARM64
+ EmulateInstructionRISCV::Context context;
+
+ // Get register info for source and base registers
+ uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs);
+ uint32_t rs2_lldb = GPREncodingToLLDB(inst.rs2.rs);
+ std::optional reg_info_rs1 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb);
+ std::optional reg_info_rs2 =
+ emulator.GetRegisterInfo(eRegisterKindLLDB, rs2_lldb);
+
+ if (!reg_info_rs1 || !reg_info_rs2)
+return false;
+
+ // Set context type based on whether this is a stack-based store
+ if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V
+context.type = EmulateInstruction::eContextPushRegisterOnStack;
+ } else {
+context.type = EmulateInstruction::eContextRegisterStore;
+ }
+
+ // Set the context to show which register is being stored to which base
+ // register + offset
+ context.SetRegisterToRegisterPlusOffset(*reg_info_rs2, *reg_info_rs1,
+ SignExt(inst.imm));
+
+ return transformOptional(inst.rs2.Read(emulator),
+ [&](uint64_t rs2) {
+ return emulator.WriteMemoryUnsigned(
+ context, *addr, rs2, sizeof(T));
+ })
.value_or(false);
}
@@ -737,11 +792,42 @@ class Executor {
bool operator()(SH inst) { return Store(m_emu, inst); }
bool operator()(SW inst) { return Store(m_emu, inst); }
bool operator()(ADDI inst) {
-return transformOptional(inst.rs1.ReadI64(m_emu),
- [&](int64_t rs1) {
- return inst.rd.Write(
- m_em
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
@@ -0,0 +1,420 @@ +# Writing Custom Commands + +### Create a new command using a Python function + +Python functions can be used to create new LLDB command interpreter commands, +which will work like all the natively defined lldb commands. This provides a +very flexible and easy way to extend LLDB to meet your debugging requirements. + +To write a python function that implements a new LLDB command define the +function to take five arguments as follows: + +```python3 +def command_function(debugger, command, exe_ctx, result, internal_dict): +# Your code goes here +``` + +The meaning of the arguments is given in the table below. + +If you provide a Python docstring in your command function LLDB will use it +when providing "long help" for your command, as in: + +```python3 +def command_function(debugger, command, result, internal_dict): +"""This command takes a lot of options and does many fancy things""" +# Your code goes here +``` + +though providing help can also be done programmatically (see below). + +Prior to lldb 3.5.2 (April 2015), LLDB Python command definitions didn't take the SBExecutionContext +argument. So you may still see commands where the command definition is: + +```python3 +def command_function(debugger, command, result, internal_dict): +# Your code goes here +``` + +Using this form is strongly discouraged because it can only operate on the "currently selected" +target, process, thread, frame. The command will behave as expected when run +directly on the command line. But if the command is used in a stop-hook, breakpoint +callback, etc. where the response to the callback determines whether we will select +this or that particular process/frame/thread, the global "currently selected" +entity is not necessarily the one the callback is meant to handle. In that case, this +command definition form can't do the right thing. + +| Argument | Type | Description | +|--|--|-| +| `debugger` | `lldb.SBDebugger` | The current debugger object. | +| `command` | `python string` | A python string containing all arguments for your command. If you need to chop up the arguments try using the `shlex` module's `shlex.split(command)` to properly extract the arguments. | +| `exe_ctx` | `lldb.SBExecutionContext` | An execution context object carrying around information on the inferior process' context in which the command is expected to act *Optional since lldb 3.5.2, unavailable before* | +| `result` | `lldb.SBCommandReturnObject` | A return object which encapsulates success/failure information for the command and output text that needs to be printed as a result of the command. The plain Python "print" command also works but text won't go in the result by default (it is useful as a temporary logging facility). | +| `internal_dict` | `python dict object` | The dictionary for the current embedded script session which contains all variables and functions. | + +### Create a new command using a Python class + +Since lldb 3.7, Python commands can also be implemented by means of a class +which should implement the following interface: + +```python3 +class CommandObjectType: +def __init__(self, debugger, internal_dict): +# this call should initialize the command with respect to the command interpreter for the passed-in debugger + +def __call__(self, debugger, command, exe_ctx, result): +# this is the actual bulk of the command, akin to Python command functions + +def get_short_help(self): +# this call should return the short help text for this command[1] + +def get_long_help(self): +# this call should return the long help text for this command[1] + +def get_flags(self): +# this will be called when the command is added to the command interpreter, +# and should return a flag field made from or-ing together the appropriate +# elements of the lldb.CommandFlags enum to specify the requirements of this command. +# The CommandInterpreter will make sure all these requirements are met, and will +# return the standard lldb error if they are not.[1] + +def get_repeat_command(self, command): +# The auto-repeat command is what will get executed when the user types just +# a return at the next prompt after this command is run. Even if your command +# was run because it was specified as a repeat command, that invocation will still +# get asked for IT'S repeat command, so you can chain a series of repeats, for instance +# to implement a pager. + +# The command argument is the command that is about to be executed. + +# If this call returns None, then the ordinary repeat mechanism will be used +# If this call returns an empty string, then auto-repeat is disabled +# If this call returns any other string, that will be the repeat command [1] +``` + +[1] This method is optional. + +As a convenie
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/158331 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NVIDIA] Add NVPTX architecture support (PR #158334)
https://github.com/agontarek created
https://github.com/llvm/llvm-project/pull/158334
- Introduced a new method `IsNVPTX()` in `ArchSpec` to check for NVPTX
architecture.
- Implemented the corresponding method in `ArchSpec.cpp` to utilize the
existing triple architecture checks.
>From 0751dd1fee9237590773d2f2f4e1e0fd8d88cab9 Mon Sep 17 00:00:00 2001
From: Andrew Gontarek
Date: Wed, 10 Sep 2025 12:40:28 -0500
Subject: [PATCH] [LLDB][NVIDIA] Add NVPTX architecture support
- Introduced a new method `IsNVPTX()` in `ArchSpec` to check for NVPTX
architecture.
- Implemented the corresponding method in `ArchSpec.cpp` to utilize the
existing triple architecture checks.
---
lldb/include/lldb/Utility/ArchSpec.h | 5 +
lldb/source/Utility/ArchSpec.cpp | 2 ++
2 files changed, 7 insertions(+)
diff --git a/lldb/include/lldb/Utility/ArchSpec.h
b/lldb/include/lldb/Utility/ArchSpec.h
index 96bd5e3597b68..361108fd8f0e7 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -327,6 +327,11 @@ class ArchSpec {
/// \return a boolean value.
bool IsMIPS() const;
+ /// If NVPTX architecture return true.
+ ///
+ /// \return a boolean value.
+ bool IsNVPTX() const;
+
/// Returns a string representing current architecture as a target CPU for
/// tools like compiler, disassembler etc.
///
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 1b8dae39735df..2a87cc6bf7de9 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -545,6 +545,8 @@ const char *ArchSpec::GetArchitectureName() const {
bool ArchSpec::IsMIPS() const { return GetTriple().isMIPS(); }
+bool ArchSpec::IsNVPTX() const { return GetTriple().isNVPTX(); }
+
std::string ArchSpec::GetTargetABI() const {
std::string abi;
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb-dap] Fix typo in invalidated event (PR #158338)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Druzhkov Sergei (DrSergei)
Changes
Fixed a typo in the `invalidated` event according to
[DAP](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Invalidated)
specification. While the field is `frameId` elsewhere, it must be
`stackFrameId` in this event.
---
Full diff: https://github.com/llvm/llvm-project/pull/158338.diff
3 Files Affected:
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp (+2-2)
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolEvents.h (+1-1)
- (modified) lldb/unittests/DAP/ProtocolTypesTest.cpp (+2-2)
``diff
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
index 9598c69878d66..062b9494ec10f 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
@@ -51,8 +51,8 @@ llvm::json::Value toJSON(const InvalidatedEventBody &IEB) {
json::Object Result{{"areas", IEB.areas}};
if (IEB.threadId)
Result.insert({"threadID", IEB.threadId});
- if (IEB.frameId)
-Result.insert({"frameId", IEB.frameId});
+ if (IEB.stackFrameId)
+Result.insert({"stackFrameId", IEB.stackFrameId});
return Result;
}
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h
b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h
index 138b622e01210..cb976d3395217 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h
@@ -83,7 +83,7 @@ struct InvalidatedEventBody {
/// If specified, the client only needs to refetch data related to this stack
/// frame (and the `threadId` is ignored).
- std::optional frameId;
+ std::optional stackFrameId;
};
llvm::json::Value toJSON(const InvalidatedEventBody::Area &);
llvm::json::Value toJSON(const InvalidatedEventBody &);
diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
index a964592495347..61d197a705e0e 100644
--- a/lldb/unittests/DAP/ProtocolTypesTest.cpp
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -1078,13 +1078,13 @@ TEST(ProtocolTypesTest, InvalidatedEventBody) {
InvalidatedEventBody body;
body.areas = {InvalidatedEventBody::eAreaStacks,
InvalidatedEventBody::eAreaThreads};
- body.frameId = 1;
+ body.stackFrameId = 1;
StringRef json = R"({
"areas": [
"stacks",
"threads"
],
- "frameId": 1
+ "stackFrameId": 1
})";
EXPECT_EQ(json, pp(body));
}
``
https://github.com/llvm/llvm-project/pull/158338
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
