[Lldb-commits] [lldb] [LLDB][ProcessWindows] Set exit status on instance rather than going through all targets (PR #159308)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) Changes When quitting LLDB on Windows while a process was still running, LLDB would take unusually long to exit. This was due to a temporary deadlock: The main thread was destroying the processes. In doing so, it iterated over the target list: https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Core/Debugger.cpp#L1095-L1098 This locks the list for the whole iteration. Finalizing the process would eventually lead to `DebuggerThread::StopDebugging`, which terminates the process and waits for it to exit: https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp#L196 The debugger loop (on a separate thread) would see that the process exited and call [`ProcessWindows::OnExitProcess`](https://github.com/llvm/llvm-project/blob/88c64f76ed2ca226da99b99f60d316b1519fc7d8/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp#L656-L673). This calls the static function [`Process::SetProcessExitStatus`](https://github.com/llvm/llvm-project/blob/0a7a7d56fc882653335beba0d1f8ea9f26089c22/lldb/source/Target/Process.cpp#L1098-L1126). This tries to find the process by its ID from the debugger's target list. Doing so requires locking the list, so the debugger thread would then be stuck on https://github.com/llvm/llvm-project/blob/0a7a7d56fc882653335beba0d1f8ea9f26089c22/lldb/source/Target/TargetList.cpp#L403 After 5s, the main thread would give up waiting. So every exit where the process was still running would be delayed by about 5s. Since `ProcessWindows` would find itself when calling `SetProcessExitStatus`, we can call `SetExitStatus` directly. This can also make some tests run faster. For example, the DIA PDB tests previously took 15s to run on my PC (24 jobs) and now take 5s. For all shell tests, the difference isn't that big (only about 3s), because most don't run into this and the tests run in parallel. --- Full diff: https://github.com/llvm/llvm-project/pull/159308.diff 1 Files Affected: - (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (+1-1) ``diff diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index 27530f032ce51..0fecefe23b88e 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -666,7 +666,7 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) { target->ModulesDidUnload(unloaded_modules, true); } - SetProcessExitStatus(GetID(), true, 0, exit_code); + SetExitStatus(exit_code, /*exit_string=*/""); SetPrivateState(eStateExited); ProcessDebugger::OnExitProcess(exit_code); `` https://github.com/llvm/llvm-project/pull/159308 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
walter-erquinigo wrote: I see. Thanks! I'll think more about this next week https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
https://github.com/DrSergei created https://github.com/llvm/llvm-project/pull/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. >From 35117bc744bb67834fbea112ae7e316128db779b Mon Sep 17 00:00:00 2001 From: Druzhkov Sergei Date: Mon, 8 Sep 2025 21:14:21 +0300 Subject: [PATCH] [lldb-dap] Add invalidated event --- .../test/tools/lldb-dap/dap_server.py | 3 ++ .../test/tools/lldb-dap/lldbdap_testcase.py | 20 +-- .../tools/lldb-dap/memory/TestDAP_memory.py | 4 +-- .../lldb-dap/variables/TestDAP_variables.py | 34 ++- lldb/tools/lldb-dap/EventHelper.cpp | 22 lldb/tools/lldb-dap/EventHelper.h | 10 ++ .../Handler/SetVariableRequestHandler.cpp | 4 +++ .../Handler/WriteMemoryRequestHandler.cpp | 6 8 files changed, 74 insertions(+), 29 deletions(-) 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") sel
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
@@ -50,17 +56,88 @@ class TransportUnhandledContentsError std::string m_unhandled_contents; }; +class InvalidParams : public llvm::ErrorInfo { +public: + static char ID; + + explicit InvalidParams(std::string method, std::string context) + : m_method(std::move(method)), m_context(std::move(context)) {} + + void log(llvm::raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + +private: + std::string m_method; + std::string m_context; +}; + +// Value for tracking functions that have a void param or result. +using VoidT = std::monostate; + +template using Callback = llvm::unique_function; ashgti wrote: I refactored this section a bit to remove the `VoidT` type, we shouldn't need that anymore. I moved this whole file into `lldb_private::transport`. https://github.com/llvm/llvm-project/pull/159160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Disable a procfile test when threading is not enabled (PR #159559)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/159559 As is done for other procfile tests. >From 959edbe1add44159d473602d4151cf533cac4050 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 18 Sep 2025 12:51:55 +0100 Subject: [PATCH] [lldb][test] Disable a procfile test when threading is not enabled As is done for other procfile tests. --- lldb/unittests/Host/posix/SupportTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/unittests/Host/posix/SupportTest.cpp b/lldb/unittests/Host/posix/SupportTest.cpp index 5393ad83ad8ac..1b11f0caa0981 100644 --- a/lldb/unittests/Host/posix/SupportTest.cpp +++ b/lldb/unittests/Host/posix/SupportTest.cpp @@ -26,7 +26,7 @@ TEST(Support, getProcFile_Pid) { } #endif // #ifndef __APPLE__ -#if defined(_AIX) || defined(__linux__) +#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING) TEST(Support, getProcFile_Tid) { auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), #ifdef _AIX @@ -38,4 +38,4 @@ TEST(Support, getProcFile_Tid) { ASSERT_TRUE(BufferOrError); ASSERT_TRUE(*BufferOrError); } -#endif // #if defined(_AIX) || defined(__linux__) +#endif // #if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/159117 Recognize an MTE tag fault Mach exception. A tag fault is an error reported by Arm's Memory Tagging Extension (MTE) when a memory access attempts to use a pointer with a tag that doesn't match the tag stored with the memory. LLDB will print the tag and address to make the issue easier to diagnose. This was hand tested by debugging an MTE enabled binary on an iPhone 17 running iOS 26. rdar://113575216 >From 03a63175357f3b941d120ec3bbab57bf2c3e5997 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 16 Sep 2025 08:58:41 -0700 Subject: [PATCH] [lldb] Recognize MTE fault Mach exceptions Recognize an MTE tag fault Mach exception. A tag fault is an error reported by Arm's Memory Tagging Extension (MTE) when a memory access attempts to use a pointer with a tag that doesn't match the tag stored with the memory. LLDB will print the tag and address to make the issue easier to diagnose. This was tested by debugging an MTE enabled binary running on an iPhone 17 running iOS 26. --- .../Process/Utility/StopInfoMachException.cpp | 31 +++ .../Process/Utility/StopInfoMachException.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 29a64a2a03bf0..6853121f3e01c 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -77,6 +77,35 @@ static void DescribeAddressBriefly(Stream &strm, const Address &addr, strm.Printf(".\n"); } +static constexpr uint8_t g_mte_tag_shift = 64 - 8; +static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift; + +bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) { + const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS + const bool IsMTETagFault = (m_exc_code == 0x106); // EXC_ARM_MTE_TAG_FAULT + if (!IsBadAccess || !IsMTETagFault) +return false; + + if (m_exc_data_count < 2) +return false; + + const uint64_t bad_address = m_exc_subcode; + + StreamString strm; + strm.Printf("EXC_ARM_MTE_TAG_FAULT (code=%" PRIu64 ", address=0x%" PRIx64 + ")\n", + m_exc_code, bad_address); + + const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift; + const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask; + strm.Printf( + "Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64, + tag, canonical_addr); + m_description = std::string(strm.GetString()); + + return true; +} + bool StopInfoMachException::DeterminePtrauthFailure(ExecutionContext &exe_ctx) { bool IsBreakpoint = m_value == 6; // EXC_BREAKPOINT bool IsBadAccess = m_value == 1; // EXC_BAD_ACCESS @@ -266,6 +295,8 @@ const char *StopInfoMachException::GetDescription() { case llvm::Triple::aarch64: if (DeterminePtrauthFailure(exe_ctx)) return m_description.c_str(); + if (DetermineTagMismatch(exe_ctx)) +return m_description.c_str(); break; default: diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h index c612ac400b4c4..c02389e5b3642 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h @@ -27,6 +27,8 @@ class StopInfoMachException : public StopInfo { /// is auth-related failure, and returns false otherwise. bool DeterminePtrauthFailure(ExecutionContext &exe_ctx); + bool DetermineTagMismatch(ExecutionContext &exe_ctx); + public: // Constructors and Destructors StopInfoMachException(Thread &thread, uint32_t exc_type, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary plus and minus to DIL (PR #155617)
kuilpd 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? We can do this, because the arithmetic itself is not typed. Math is implemented through `Scalar` class, which only operates on numbers itself (integer, IEEE float, IEEE double, etc). So we can retrieve the scalars from `c_integer` and `rust_integer` and add them together as scalars, then pick whatever compiler type we want the result to be. In this case, `Int` from Swift. I will show more of this logic once we get to binary operands. > 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. Basically, the promotion rules of DIL math are from `Scalar` class. The language specific promotion rules I'm implementing now are for picking the resulting type, and it doesn't really influence the math itself. It's so that the result can be a value `ValueObject` with a compiler type, which can be used wherever DIL was called from. By implementing the promotion rules in the respective type system we get the result closer to an actual language. It's just right now the type system for the result is taken from the current execution context, but that can be changed once we start implementing assignment operators. > 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. For the reason above, I don't think we have to sacrifice the correctness of result types to achieve the main goal of DIL. Every language will have to implement something in their type system anyway for DIL to work with it. If it doesn't matter to the language, it can just return a default type, like `Int` for Swift. > OTOH, type systems deal with a lot more than integral types, so I can also > imagine not doing that, and either having the DIL return something other than > a ValueObject (for the cases where the result of evaluation is not a program > value) or by teaching value objects to not require a type system. I would really like DIL to be just compatible with the rest of LLDB as is. I don't see much of a problem with picking a type for the result. Other than primitive types, we have to have a type anyway for the result to be usable. https://github.com/llvm/llvm-project/pull/155617 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] refactor watchpoint functionality (PR #159807)
JDevlieghere wrote: Thank you for breaking this change up into smaller patches, that's always a good idea and will certainly help with reviewing. Given that this is a significant new feature, could you please start an RFC on [Discourse](https://discourse.llvm.org/c/subprojects/lldb/8)? We had a good amount of discussion in the original PR that would be good to capture in the RFC. https://github.com/llvm/llvm-project/pull/159807 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/158701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Re-enable `TestRerunAndExprDylib.py` (PR #157872)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) Changes the `skipTestIfFn` requires a function that return a string to skip or None to run the test. The `isUbuntu18_04` function returns a bool and the test is skipped on all platforms. https://github.com/llvm/llvm-project/blob/25ebdfe0ab202a6cb30232d84bc5838439fd67d5/lldb/packages/Python/lldbsuite/test/decorators.py#L145-L157 --- Full diff: https://github.com/llvm/llvm-project/pull/157872.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py (+2-2) ``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 74e7c895c0fab..a8f98ef0f0182 100644 --- a/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py +++ b/lldb/test/API/functionalities/rerun_and_expr_dylib/TestRerunAndExprDylib.py @@ -20,9 +20,9 @@ def isUbuntu18_04(): with open(path) as f: contents = f.read() if "Ubuntu 18.04" in contents: -return True +return "Ubuntu 18.04 is not supported." -return False +return None class TestRerunExprDylib(TestBase): `` https://github.com/llvm/llvm-project/pull/157872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Mark blocks as parsed after parsing (PR #157493)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/157493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 693146d - [lldb][yaml2macho-core] Address bug when run on Windows
Author: Jason Molenda Date: 2025-09-08T10:37:16-07:00 New Revision: 693146dcc0a1d653827cc88993acf52428af1a94 URL: https://github.com/llvm/llvm-project/commit/693146dcc0a1d653827cc88993acf52428af1a94 DIFF: https://github.com/llvm/llvm-project/commit/693146dcc0a1d653827cc88993acf52428af1a94.diff LOG: [lldb][yaml2macho-core] Address bug when run on Windows The two API tests I converted to use yaml2macho-core were failing on windows. I was writing the output corefile with fopen(filename, "w"), and it turns out there was some newline conversion happening on Windows if a linefeed character was present. Charles Zablit helped to identify the issue and confirm the fix. Re-enabling the two tests on all platforms. https://github.com/llvm/llvm-project/pull/153911 Added: Modified: lldb/test/API/macosx/arm-corefile-regctx/TestArmMachoCorefileRegctx.py lldb/test/API/macosx/riscv32-corefile/TestRV32MachOCorefile.py lldb/tools/yaml2macho-core/yaml2macho.cpp Removed: diff --git a/lldb/test/API/macosx/arm-corefile-regctx/TestArmMachoCorefileRegctx.py b/lldb/test/API/macosx/arm-corefile-regctx/TestArmMachoCorefileRegctx.py index acb6956ec478b..a2890cdfeaa44 100644 --- a/lldb/test/API/macosx/arm-corefile-regctx/TestArmMachoCorefileRegctx.py +++ b/lldb/test/API/macosx/arm-corefile-regctx/TestArmMachoCorefileRegctx.py @@ -13,7 +13,6 @@ class TestArmMachoCorefileRegctx(TestBase): NO_DEBUG_INFO_TESTCASE = True -@skipUnlessDarwin # CI fail on Windows, lr has value 0x0F00? def test_armv7_corefile(self): ### Create corefile corefile = self.getBuildArtifact("core") diff --git a/lldb/test/API/macosx/riscv32-corefile/TestRV32MachOCorefile.py b/lldb/test/API/macosx/riscv32-corefile/TestRV32MachOCorefile.py index f791c01313fb1..449da70fb08ca 100644 --- a/lldb/test/API/macosx/riscv32-corefile/TestRV32MachOCorefile.py +++ b/lldb/test/API/macosx/riscv32-corefile/TestRV32MachOCorefile.py @@ -13,7 +13,6 @@ class TestRV32MachOCorefile(TestBase): NO_DEBUG_INFO_TESTCASE = True -@skipUnlessDarwin # windows CI failure, says only 1 thread in corefile @no_debug_info_test def test_riscv32_gpr_corefile_registers(self): corefile = self.getBuildArtifact("core") diff --git a/lldb/tools/yaml2macho-core/yaml2macho.cpp b/lldb/tools/yaml2macho-core/yaml2macho.cpp index b01f61d491079..85979a37d1676 100644 --- a/lldb/tools/yaml2macho-core/yaml2macho.cpp +++ b/lldb/tools/yaml2macho-core/yaml2macho.cpp @@ -198,7 +198,7 @@ int main(int argc, char **argv) { if (lc_note_payload_bytes.size() > 0) payload_fileoff = (payload_fileoff + 4096 - 1) & ~(4096 - 1); - FILE *f = fopen(OutputFilename.c_str(), "w"); + FILE *f = fopen(OutputFilename.c_str(), "wb"); if (f == nullptr) { fprintf(stderr, "Unable to open file %s for writing\n", OutputFilename.c_str()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
walter-erquinigo wrote: @jhuber6 , something I care about for LLDB is being able to use different disassemblers for ptx and sass. The unique situation here is that sass is not part of LLVM code generation, and it seems that's why LLVM is unaware of sass. LLVM can only generate ptx and folks rely on an nvidia proprietary compiler to go from ptx to sass. But at runtime, LLDB sees both sass and nvptx. I guess that a simpler patch that would exist only within LLDB is to add two flavors to the nvptx architecture, one for nvptx and for sass in the ArchSpec class in LLDB. I for sure can do that without doing major architectural changes like this. https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 created https://github.com/llvm/llvm-project/pull/158256 Fixes https://github.com/llvm/llvm-project/issues/158131 Similar to https://github.com/llvm/llvm-project/pull/138487 but also search for child indices in the base classes. >From 8e00d31ce15eb3255c7bafe924754752dd563fd3 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 16:14:23 +0800 Subject: [PATCH 1/3] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous structs in base classes Fixes #158131 Similar to #138487 but also search for child indexes in the base classes --- .../TypeSystem/Clang/TypeSystemClang.cpp| 17 + 1 file changed, 17 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 39aacdb58e694..1cf73dab2e724 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6786,6 +6786,23 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( } if (cxx_record_decl) { + for (const clang::CXXBaseSpecifier &base_spec : cxx_record_decl->bases()) { +uint32_t base_slot = +GetIndexForRecordBase(record_decl, &base_spec, omit_empty_base_classes); +if (base_slot == UINT32_MAX) + continue; + +std::vector save = child_indexes; +child_indexes.push_back(base_slot); +CompilerType base_type = GetType(base_spec.getType()); +if (GetIndexOfChildMemberWithName(base_type.GetOpaqueQualType(), + name, omit_empty_base_classes, + child_indexes)) { + return child_indexes.size(); +} +child_indexes = std::move(save); + } + const clang::RecordDecl *parent_record_decl = cxx_record_decl; // Didn't find things easily, lets let clang do its thang... >From 3c8ce49a705f4fd1dfc304e76704a9294beb4158 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 17:12:37 +0800 Subject: [PATCH 2/3] [LLDB] Add tests --- .../cpp/type_lookup_anon_base_member/Makefile | 3 ++ .../TestCppTypeLookupAnonBaseMember.py| 37 +++ .../cpp/type_lookup_anon_base_member/main.cpp | 18 + 3 files changed, 58 insertions(+) create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py new file mode 100644 index 0..8f38403acfc34 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py @@ -0,0 +1,37 @@ +""" +Test that we properly print anonymous members in a base class. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators + + +class TestTypeLookupAnonBaseMember(TestBase): +def test_lookup_anon_base_member(self): +self.build() +(target, process, thread, bp1) = lldbutil.run_to_source_breakpoint( +self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp") +) + +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame = thread.GetFrameAtIndex(0) + +d = frame.FindVariable("d") +self.assertTrue(d.IsValid()) + +# b from Base +b = d.GetChildMemberWithName("b") +self.assertTrue(b.IsValid()) +self.assertEqual(b.GetValueAsSigned(), 1) + +# x from anonymous struct (inside Base) +x = d.GetChildMemberWithName("x") +self.assertTrue(x.IsValid()) +self.assertEqual(x.GetValueAsSigned(), 2) + +# d from Derived +a = d.GetChildMemberWithName("a") +self.assertTrue(a.IsValid()) +self.assertEqual(a.GetValueAsSigned(), 3) diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp new file mode 100644 index 0..f27cf4ce163f9 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp @@ -0,0 +1,18 @@ +struct Base { + int b; + struct { +int x; + }; +}; + +struct Derived : publ
[Lldb-commits] [lldb] [lldb] Fix unordered-map data formatter for const types (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 1/2] [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) >From f0181ef6fa9c2771514a05f0ff41459e196a876f Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 12 Sep 2025 12:01:34 +0100 Subject: [PATCH 2/2] [lldb] fix std::unordered_map formatter for const types. the type that is checked in isUnordered may be const qualified. --- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index ef49c4e6055a8..4b183a8d62e53 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -166,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 lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -959,6 +959,9 @@ CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize( if (type_name == "long double" && QualTypeMatchesBitSize(bit_size, ast, ast.LongDoubleTy)) return GetType(ast.LongDoubleTy); +if (type_name == "__bf16" && tgs-sc wrote: This is a new created PR: https://github.com/llvm/llvm-project/pull/157674 https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Re-enable import-std-module tests on Linux (PR #157649)
gulfemsavrun wrote: I've tested this PR on our LLDB builders and confirmed that the segmentation fault from issue [#137046](https://github.com/llvm/llvm-project/issues/137046) is no longer present. See the builder results here: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci.shadow/lldb-linux-x64/b8704184328175965969/overview The PR test run resulted in two new test failures, but the failures appear to be unrelated to the original issue. ``` Failed Tests (2): lldb-api :: lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py lldb-shell :: Recognizer/ubsan_add_overflow.test ``` https://github.com/llvm/llvm-project/pull/157649 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3e57a0d - [lldb][MachO] Local structs for larger VA offsets (#159849)
Author: Jason Molenda Date: 2025-09-19T19:53:26-07:00 New Revision: 3e57a0d01c90c09b1e40d8edfe48f8e5a63e2de6 URL: https://github.com/llvm/llvm-project/commit/3e57a0d01c90c09b1e40d8edfe48f8e5a63e2de6 DIFF: https://github.com/llvm/llvm-project/commit/3e57a0d01c90c09b1e40d8edfe48f8e5a63e2de6.diff LOG: [lldb][MachO] Local structs for larger VA offsets (#159849) The Mach-O file format has several load commands which specify the location of data in the file in UInt32 offsets. lldb uses these same structures to track the offsets of the binary in virtual address space when it is running. Normally a binary is loaded in memory contiguously, so this is fine, but on Darwin systems there is a "system shared cache" where all system libraries are combined into one region of memory and pre-linked. The shared cache has the TEXT segments for every binary loaded contiguously, then the DATA segments, and finally a shared common LINKEDIT segment for all binaries. The virtual address offset from the TEXT segment for a libray to the LINKEDIT may exceed 4GB of virtual address space depending on the structure of the shared cache, so this use of a UInt32 offset will not work. There was an initial instance of this issue that I fixed last November in https://github.com/llvm/llvm-project/pull/117832 where I fixed this issue for the LC_SYMTAB / `symtab_command` structure. But we have the same issue now with three additional structures; `linkedit_data_command`, `dyld_info_command`, and `dysymtab_command`. For all of these we can see the pattern of `dyld_info.export_off += linkedit_slide` applied to the offset fields in ObjectFileMachO. This defines local structures that mirror the Mach-O structures, except that it uses UInt64 offset fields so we can reuse the same field for a large virtual address offset at runtime. I defined ctor's from the genuine structures, as well as operator= methods so the structures can be read from the Mach-O binary into the standard object, then copied into our local expanded versions of them. These structures are ABI in Mach-O and cannot change their layout. The alternative is to create local variables alongside these Mach-O load command objects for the offsets that we care about, adjust those by the correct VA offsets, and only use those local variables instead of the fields in the objects. I took the approach of the local enhanced structure in November and I think it is the cleaner approach. rdar://160384968 Added: Modified: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Removed: diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 924e34053d411..fada1fda2b4bc 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2156,10 +2156,10 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { LLDB_LOG(log, "Parsing symbol table for {0}", file_name); Progress progress("Parsing symbol table", file_name); - llvm::MachO::linkedit_data_command function_starts_load_command = {0, 0, 0, 0}; - llvm::MachO::linkedit_data_command exports_trie_load_command = {0, 0, 0, 0}; - llvm::MachO::dyld_info_command dyld_info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - llvm::MachO::dysymtab_command dysymtab = m_dysymtab; + LinkeditDataCommandLargeOffsets function_starts_load_command; + LinkeditDataCommandLargeOffsets exports_trie_load_command; + DyldInfoCommandLargeOffsets dyld_info; + DysymtabCommandLargeOffsets dysymtab(m_dysymtab); SymtabCommandLargeOffsets symtab_load_command; // The data element of type bool indicates that this entry is thumb // code. @@ -2196,32 +2196,24 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { break; // Watch for the symbol table load command switch (lc.cmd) { -case LC_SYMTAB: - // struct symtab_command { - // uint32_tcmd;/* LC_SYMTAB */ - // uint32_tcmdsize;/* sizeof(struct symtab_command) */ - // uint32_tsymoff; /* symbol table offset */ - // uint32_tnsyms; /* number of symbol table entries */ - // uint32_tstroff; /* string table offset */ - // uint32_tstrsize;/* string table size in bytes */ - // }; - symtab_load_command.cmd = lc.cmd; - symtab_load_command.cmdsize = lc.cmdsize; - symtab_load_command.symoff = m_data.GetU32(&offset); - symtab_load_command.nsyms = m_data.GetU32(&offset); - symtab_load_command.stroff = m_data.GetU32(&offset); - symtab_load_command.strsize = m_data.GetU32(&offset); - break; +case LC_SYMTAB: { + llvm::MachO::symtab_command lc_obj; + if (m_data.GetU32(&offset, &lc_obj.symoff, 4)) {
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
tgs-sc wrote: @Michael137, probably we should return finding and adding specialization in DWARFASTParserClang.cpp? https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 updated https://github.com/llvm/llvm-project/pull/158256 >From 8e00d31ce15eb3255c7bafe924754752dd563fd3 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 16:14:23 +0800 Subject: [PATCH 1/5] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous structs in base classes Fixes #158131 Similar to #138487 but also search for child indexes in the base classes --- .../TypeSystem/Clang/TypeSystemClang.cpp| 17 + 1 file changed, 17 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 39aacdb58e694..1cf73dab2e724 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6786,6 +6786,23 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( } if (cxx_record_decl) { + for (const clang::CXXBaseSpecifier &base_spec : cxx_record_decl->bases()) { +uint32_t base_slot = +GetIndexForRecordBase(record_decl, &base_spec, omit_empty_base_classes); +if (base_slot == UINT32_MAX) + continue; + +std::vector save = child_indexes; +child_indexes.push_back(base_slot); +CompilerType base_type = GetType(base_spec.getType()); +if (GetIndexOfChildMemberWithName(base_type.GetOpaqueQualType(), + name, omit_empty_base_classes, + child_indexes)) { + return child_indexes.size(); +} +child_indexes = std::move(save); + } + const clang::RecordDecl *parent_record_decl = cxx_record_decl; // Didn't find things easily, lets let clang do its thang... >From 3c8ce49a705f4fd1dfc304e76704a9294beb4158 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 17:12:37 +0800 Subject: [PATCH 2/5] [LLDB] Add tests --- .../cpp/type_lookup_anon_base_member/Makefile | 3 ++ .../TestCppTypeLookupAnonBaseMember.py| 37 +++ .../cpp/type_lookup_anon_base_member/main.cpp | 18 + 3 files changed, 58 insertions(+) create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py new file mode 100644 index 0..8f38403acfc34 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py @@ -0,0 +1,37 @@ +""" +Test that we properly print anonymous members in a base class. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators + + +class TestTypeLookupAnonBaseMember(TestBase): +def test_lookup_anon_base_member(self): +self.build() +(target, process, thread, bp1) = lldbutil.run_to_source_breakpoint( +self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp") +) + +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame = thread.GetFrameAtIndex(0) + +d = frame.FindVariable("d") +self.assertTrue(d.IsValid()) + +# b from Base +b = d.GetChildMemberWithName("b") +self.assertTrue(b.IsValid()) +self.assertEqual(b.GetValueAsSigned(), 1) + +# x from anonymous struct (inside Base) +x = d.GetChildMemberWithName("x") +self.assertTrue(x.IsValid()) +self.assertEqual(x.GetValueAsSigned(), 2) + +# d from Derived +a = d.GetChildMemberWithName("a") +self.assertTrue(a.IsValid()) +self.assertEqual(a.GetValueAsSigned(), 3) diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp new file mode 100644 index 0..f27cf4ce163f9 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp @@ -0,0 +1,18 @@ +struct Base { + int b; + struct { +int x; + }; +}; + +struct Derived : public Base { + int a; +}; + +int main() { + Derived d; + d.b = 1; + d.x = 2; + d.a = 3; + return 0; // Set breakpoint here +} >From cb332933cd6ec6d0bae0ad8a01216a07587e9c1
[Lldb-commits] [lldb] [vscode-lldb] Improve logging in Server Mode (PR #159672)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/159672 >From 79ea55789a7f01b05009a9bb6c28fa6e4ebe7fdb Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Thu, 18 Sep 2025 15:52:45 -0700 Subject: [PATCH 1/3] [vscode-lldb] Improve logging in server mode --- lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts b/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts index 774be50053a17..280a11d807f6a 100644 --- a/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts +++ b/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts @@ -167,9 +167,12 @@ Restarting the server will interrupt any existing debug sessions and start a new return [ path, ...args, - ...Object.entries(env ?? {}).map( -(entry) => String(entry[0]) + "=" + String(entry[1]), - ), + ...Object.entries(env ?? {}) +// Filter and sort to avoid restarting the server just because the +// order of env changed or the log path changed. +.filter((entry) => String(entry[0]) !== "LLDBDAP_LOG") +.sort() +.map((entry) => String(entry[0]) + "=" + String(entry[1])), ]; } } >From 0abc316fdf19feec035399b2895d4e3a5b62f7e6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Thu, 18 Sep 2025 16:00:14 -0700 Subject: [PATCH 2/3] Add username to log filename --- lldb/tools/lldb-dap/src-ts/logging.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/tools/lldb-dap/src-ts/logging.ts b/lldb/tools/lldb-dap/src-ts/logging.ts index 3b1c3c37ce1ce..e3b6c56291cec 100644 --- a/lldb/tools/lldb-dap/src-ts/logging.ts +++ b/lldb/tools/lldb-dap/src-ts/logging.ts @@ -1,3 +1,4 @@ +import * as os from 'os'; import * as path from "path"; import * as vscode from "vscode"; @@ -44,7 +45,7 @@ export class LogFilePathProvider { const logFolder = this.logFolder || this.context.logUri.fsPath; switch(type) { case LogType.DEBUG_SESSION: -return path.join(logFolder, `lldb-dap-session-${formatDate(new Date())}.log`); +return path.join(logFolder, `lldb-dap-session-${os.userInfo().username}-${formatDate(new Date())}.log`); break; } } >From b50a42118c47713dbee74cbf45a84b5b8f3b79b8 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Fri, 19 Sep 2025 13:35:41 -0700 Subject: [PATCH 3/3] Use vscode session ID instead --- lldb/tools/lldb-dap/src-ts/logging.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/tools/lldb-dap/src-ts/logging.ts b/lldb/tools/lldb-dap/src-ts/logging.ts index e3b6c56291cec..e48dde74d4a4d 100644 --- a/lldb/tools/lldb-dap/src-ts/logging.ts +++ b/lldb/tools/lldb-dap/src-ts/logging.ts @@ -1,4 +1,3 @@ -import * as os from 'os'; import * as path from "path"; import * as vscode from "vscode"; @@ -45,7 +44,7 @@ export class LogFilePathProvider { const logFolder = this.logFolder || this.context.logUri.fsPath; switch(type) { case LogType.DEBUG_SESSION: -return path.join(logFolder, `lldb-dap-session-${os.userInfo().username}-${formatDate(new Date())}.log`); +return path.join(logFolder, `lldb-dap-session-${formatDate(new Date())}-vscode-${vscode.env.sessionId}.log`); break; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/docs] Breakdown python reference into multiple files (PR #158331)
medismailben wrote: > Any reason we can't use the existing > [.htaccess](https://github.com/llvm/llvm-project/blob/main/lldb/docs/.htaccess) > for that? Sure, we can also do that https://github.com/llvm/llvm-project/pull/158331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add some vector operations to the IRInterpreter (PR #155000)
DavidSpickett wrote: s390x is the other big endian target, I have no idea what its vectors do. https://github.com/llvm/llvm-project/pull/155000 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary plus and minus to DIL (PR #155617)
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/155617 >From 4d14bbb31d0411c45b95778d1659ccc416165be1 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Aug 2025 19:11:55 +0500 Subject: [PATCH 1/8] [LLDB] Add unary plus and minus to DIL --- lldb/include/lldb/ValueObject/DILAST.h| 2 + lldb/source/ValueObject/DILEval.cpp | 155 -- lldb/source/ValueObject/DILLexer.cpp | 1 - lldb/source/ValueObject/DILParser.cpp | 10 +- .../frame/var-dil/expr/Arithmetic/Makefile| 3 + .../Arithmetic/TestFrameVarDILArithmetic.py | 40 + .../frame/var-dil/expr/Arithmetic/main.cpp| 9 + 7 files changed, 203 insertions(+), 17 deletions(-) create mode 100644 lldb/test/API/commands/frame/var-dil/expr/Arithmetic/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/expr/Arithmetic/TestFrameVarDILArithmetic.py create mode 100644 lldb/test/API/commands/frame/var-dil/expr/Arithmetic/main.cpp diff --git a/lldb/include/lldb/ValueObject/DILAST.h b/lldb/include/lldb/ValueObject/DILAST.h index 1d10755c46e39..900eb8a792a1e 100644 --- a/lldb/include/lldb/ValueObject/DILAST.h +++ b/lldb/include/lldb/ValueObject/DILAST.h @@ -32,6 +32,8 @@ enum class NodeKind { enum class UnaryOpKind { AddrOf, // "&" Deref, // "*" + Minus, // "-" + Plus, // "+" }; /// Forward declaration, for use in DIL AST nodes. Definition is at the very diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index c6cf41ee9e9ee..595c25085bfed 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -21,6 +21,73 @@ namespace lldb_private::dil { +static CompilerType GetBasicTypeFromCU(std::shared_ptr ctx, + lldb::BasicType basic_type) { + SymbolContext symbol_context = + ctx->GetSymbolContext(lldb::eSymbolContextCompUnit); + auto language = symbol_context.comp_unit->GetLanguage(); + + symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextModule); + auto type_system = + symbol_context.module_sp->GetTypeSystemForLanguage(language); + + if (type_system) +if (auto compiler_type = type_system.get()->GetBasicTypeFromAST(basic_type)) + return compiler_type; + + return CompilerType(); +} + +static CompilerType GetIntCompilerTypeForSize(uint32_t size, bool is_signed, + lldb::TypeSystemSP type_system, + std::shared_ptr ctx) { + lldb::BasicType promote_types[] = { + // lldb::eBasicTypeChar, lldb::eBasicTypeUnsignedChar, + // lldb::eBasicTypeShort,lldb::eBasicTypeUnsignedShort, + lldb::eBasicTypeInt, lldb::eBasicTypeUnsignedInt, + lldb::eBasicTypeLong, lldb::eBasicTypeUnsignedLong, + lldb::eBasicTypeLongLong, lldb::eBasicTypeUnsignedLongLong, + }; + for (auto &basic_type : promote_types) { +uint64_t byte_size = 0; +CompilerType type = GetBasicType(type_system, basic_type); +if (auto temp = type.GetByteSize(ctx.get())) + byte_size = *temp; +if (size < byte_size || +(size == byte_size && + is_signed == (bool)(type.GetTypeInfo() & lldb::eTypeIsSigned))) { + return type; +} + } + + llvm_unreachable("size could not fit into long long"); + return CompilerType(); +} + +static llvm::Expected +GetScalarFromValueObject(lldb::ValueObjectSP valobj, + std::shared_ptr ctx) { + auto type = valobj->GetCompilerType(); + Scalar scalar; + bool resolved = valobj->ResolveValue(scalar); + if (resolved) { +if (scalar.GetType() == scalar.e_int) { + auto apsint = scalar.GetAPSInt(); + auto type_bitsize = type.GetBitSize(ctx.get()); + if (type_bitsize) { +llvm::APSInt adjusted; +if (type.IsSigned()) + adjusted = apsint.sextOrTrunc(*type_bitsize); +else + adjusted = apsint.zextOrTrunc(*type_bitsize); +return Scalar(adjusted); + } +} else + return scalar; + } + return Scalar(); +} + static lldb::VariableSP DILFindVariable(ConstString name, VariableList &variable_list) { lldb::VariableSP exact_match; @@ -175,21 +242,21 @@ Interpreter::Visit(const IdentifierNode *node) { llvm::Expected Interpreter::Visit(const UnaryOpNode *node) { Status error; - auto rhs_or_err = Evaluate(node->GetOperand()); - if (!rhs_or_err) -return rhs_or_err; + auto op_or_err = Evaluate(node->GetOperand()); + if (!op_or_err) +return op_or_err; - lldb::ValueObjectSP rhs = *rhs_or_err; + lldb::ValueObjectSP operand = *op_or_err; switch (node->GetKind()) { case UnaryOpKind::Deref: { -lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_use_dynamic); -if (dynamic_rhs) - rhs = dynamic_rhs; +lldb::ValueObjectSP dynamic_op = operand->GetDynamicValue(m_use_dynamic); +if (dyna
[Lldb-commits] [lldb] Fixing makefile issue to include riscv emulation test only when RISCV is present. (PR #159842)
https://github.com/barsolo2000 created https://github.com/llvm/llvm-project/pull/159842 None >From af1a938bb9f5b83c9b6caed82e0a68bdebab7550 Mon Sep 17 00:00:00 2001 From: Bar Soloveychik Date: Fri, 19 Sep 2025 13:02:57 -0700 Subject: [PATCH 1/2] Reapply "RISCV unwinding enable" (#159790) This reverts commit 19bc0d6543aedc1d9151e1b2435fc4b998a72d4e. --- lldb/include/lldb/Core/Opcode.h | 4 +- .../RISCV/EmulateInstructionRISCV.cpp | 176 ++-- .../RISCV/EmulateInstructionRISCV.h | 4 + lldb/unittests/Instruction/CMakeLists.txt | 5 + .../RISCV/TestRiscvInstEmulation.cpp | 188 ++ 5 files changed, 364 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..20661290ca4c6 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -33,6 +33,10 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, InstructionRISCV) namespace lldb_private { +// RISC-V General Purpose Register numbers +static constexpr uint32_t RISCV_GPR_SP = 2; // x2 is the stack pointer +static constexpr uint32_t RISCV_GPR_FP = 8; // x8 is the frame pointer + /// Returns all values wrapped in Optional, or std::nullopt if any of the values /// is std::nullopt. template @@ -108,6 +112,16 @@ static uint32_t FPREncodingToLLDB(uint32_t reg_encode) { return LLDB_INVALID_REGNUM; } +// Helper function to get register info from GPR encoding +static std::optional +GPREncodingToRegisterInfo(EmulateInstructionRISCV &emulator, + uint32_t reg_encode) { + uint32_t lldb_reg = GPREncodingToLLDB(reg_encode); + if (lldb_reg == LLDB_INVALID_REGNUM) +return std::nullopt; + return emulator.GetRegisterInfo(eRegisterKindLLDB, lldb_reg); +} + bool Rd::Write(EmulateInstructionRISCV &emulator, uint64_t value) { uint32_t lldb_reg = GPREncodingToLLDB(rd); EmulateInstruction::Context ctx; @@ -230,10 +244,34 @@ 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 + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + + if (!reg_info_rs1) +return false; + + // Set context type based on whether this is a stack-based load. + if (inst.rs1.rs == RISCV_GPR_SP) +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 +280,35 @@ 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. + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + std::optional reg_info_rs2 = + GPREncodingToRegisterInfo(emulator, inst.rs2.rs); + + 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 == RISCV_GPR_SP) +context.type = EmulateInstruction::eContextPushRegisterOnStack; + else +context.type = EmulateInstruction::eContextRegisterStore; + + // Set
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -1676,6 +1676,14 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl( class_template_specialization_decl->setInstantiationOf(class_template_decl); class_template_specialization_decl->setTemplateArgs( TemplateArgumentList::CreateCopy(ast, args)); + void *InsertPos = nullptr; + if (!class_template_decl->findSpecialization(args, InsertPos)) { +// Add this specialization to the class template. +class_template_decl->AddSpecialization(class_template_specialization_decl, + InsertPos); + } else +// Specialization exists, so return nullptr. +return nullptr; Michael137 wrote: ```suggestion if (class_template_decl->findSpecialization(args, InsertPos)) return nullptr; class_template_decl->AddSpecialization(class_template_specialization_decl, InsertPos); ``` https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Enable non-address bit WritePointerToMemory test on Linux (PR #157435)
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/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.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 --- TestArmPointerMetadataStripping.py 2025-09-08 12:05:55.00 + +++ TestArmPointerMetadataStripping.py 2025-09-08 12:10:08.113837 + @@ -2,10 +2,11 @@ import json import os from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + # On AArch64 systems, unused top bits of pointers can be used for other things. @skipIf(archs=no_match(["aarch64", "arm64", "arm64e"])) # Only run this test on systems where Top Byte Ignore is known to be enabled # and widely available (FreeBSD has support but only since recently). `` https://github.com/llvm/llvm-project/pull/157435 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (PR #159444)
DavidSpickett wrote: The tests are stable on 32-bit Arm with this applied. https://github.com/llvm/llvm-project/pull/159444 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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/Michael137 approved this pull request. LGTM (module remaining comments) https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 134d45f372d7ac528f14899b0041add13269774d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 29 Aug 2025 15:17:29 +0100 Subject: [PATCH 1/2] [lldb][test] Fix unordered-map test. test was failing because there is an extra struct on the stored pair in map --- .../Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 6 -- .../TestDataFormatterStdUnorderedMap.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index f88a5319068a2..a10056fcd74d0 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -113,8 +113,10 @@ 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() + CompilerType backend_type = m_backend.GetCompilerType(); + if (backend_type.IsPointerOrReferenceType()) +backend_type = backend_type.GetPointeeType(); + if (isUnorderedMap(backend_type .GetCanonicalType() .GetTypeName())) { std::string name; 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) ) >From 12c872a5e8249209889a3474232c2f56b2678029 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 12 Sep 2025 11:06:21 +0100 Subject: [PATCH 2/2] [lldb][test] Fix unordered-map test. test was failing because there is an extra struct on the stored pair in map --- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index a10056fcd74d0..6b5c430f5a487 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -116,9 +116,7 @@ CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: CompilerType backend_type = m_backend.GetCompilerType(); if (backend_type.IsPointerOrReferenceType()) backend_type = backend_type.GetPointeeType(); - if (isUnorderedMap(backend_type - .GetCanonicalType() - .GetTypeName())) { + if (isUnorderedMap(backend_type.GetCanonicalType().GetTypeName())) { std::string name; CompilerType field_type = element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "RISCV unwinding enable" (PR #159790)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/159790 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 edited https://github.com/llvm/llvm-project/pull/156803 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection (PR #158609)
@@ -237,6 +237,7 @@ contain the following key/value pairs: | **stopOnEntry** | boolean | | Whether to stop program immediately after launching. | **runInTerminal** (deprecated)| boolean | | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs. | **console** | string | | Specify where to launch the program: internal console (`internalConsole`), integrated terminal (`integratedTerminal`) or external terminal (`externalTerminal`). Supported from lldb-dap 21.0 version. +| **stdio** | [string]| | Destination for program stdio streams (0 - stdin, 1 - stdout, 2 - stderr, ...). Using `null` value means no redirection. Supported from lldb-dap 22.0 version. walter-erquinigo wrote: Could you pretty much include all the contents from here ``` The stdio property is a list of redirection targets for each of the debuggee's stdio streams: null value will cause redirect to the default debug session terminal (as specified by the terminal launch property), "/some/path" will cause the stream to be redirected to the specified file, pipe or a TTY device*, if you provide less than 3 values, the list will be padded to 3 entries using the last provided value, you may specify more than three values, in which case additional file descriptors will be created (4, 5, etc.) Examples: "stdio": [null, "log.txt", null] - connect stdin and stderr to the default terminal, while sending stdout to "log.txt", "stdio": ["input.txt", "log.txt"] - connect stdin to "input.txt", while sending both stdout and stderr to "log.txt", "stdio": null - connect all three streams to the default terminal. ``` ? That will be very clear https://github.com/llvm/llvm-project/pull/158609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
@@ -230,10 +242,34 @@ 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 + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + + if (!reg_info_rs1) +return false; + + // Set context type based on whether this is a stack-based load + if (inst.rs1.rs == RISCV_GPR_SP) // x2 is the stack pointer in RISC-V clayborg wrote: We probably don't need this comment now that we are using `RISCV_GPR_SP`? https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 updated https://github.com/llvm/llvm-project/pull/157503 >From ec45d323014b15ce7a960fc519ef3782820a44d2 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Mon, 8 Sep 2025 09:05:15 -0700 Subject: [PATCH 1/2] [lldb-mcp] Auto connect to the first running lldb mcp instance. This improves the flow by automatically connecting to an exisitng lldb instance, if one is found. Future improvements include: * Launching a binary if an instance isn't detected. * Multiplexing if multiple instances are detected. --- lldb/include/lldb/Protocol/MCP/Server.h | 5 + lldb/source/Protocol/MCP/Server.cpp | 78 +-- lldb/tools/lldb-mcp/CMakeLists.txt | 1 + lldb/tools/lldb-mcp/lldb-mcp.cpp| 125 4 files changed, 184 insertions(+), 25 deletions(-) diff --git a/lldb/include/lldb/Protocol/MCP/Server.h b/lldb/include/lldb/Protocol/MCP/Server.h index 254b7d9680cd8..a65c310828daf 100644 --- a/lldb/include/lldb/Protocol/MCP/Server.h +++ b/lldb/include/lldb/Protocol/MCP/Server.h @@ -30,6 +30,11 @@ namespace lldb_protocol::mcp { struct ServerInfo { std::string connection_uri; lldb::pid_t pid; + + /// Writes the server info into a unique file in `~/.lldb`. + static llvm::Error Write(const ServerInfo &); + /// Loads any server info saved in `~/.lldb`. + static llvm::Expected> Load(); }; llvm::json::Value toJSON(const ServerInfo &); bool fromJSON(const llvm::json::Value &, ServerInfo &, llvm::json::Path); diff --git a/lldb/source/Protocol/MCP/Server.cpp b/lldb/source/Protocol/MCP/Server.cpp index 0381b7f745e98..3c2c246218774 100644 --- a/lldb/source/Protocol/MCP/Server.cpp +++ b/lldb/source/Protocol/MCP/Server.cpp @@ -7,25 +7,89 @@ //===--===// #include "lldb/Protocol/MCP/Server.h" +#include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Host/JSONTransport.h" #include "lldb/Protocol/MCP/MCPError.h" #include "lldb/Protocol/MCP/Protocol.h" #include "llvm/Support/JSON.h" -using namespace lldb_protocol::mcp; using namespace llvm; +using namespace lldb_private; +using namespace lldb_protocol::mcp; -llvm::json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) { - return llvm::json::Object{{"connection_uri", SM.connection_uri}, -{"pid", SM.pid}}; +json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) { + return json::Object{{"connection_uri", SM.connection_uri}, {"pid", SM.pid}}; } -bool lldb_protocol::mcp::fromJSON(const llvm::json::Value &V, ServerInfo &SM, - llvm::json::Path P) { - llvm::json::ObjectMapper O(V, P); +bool lldb_protocol::mcp::fromJSON(const json::Value &V, ServerInfo &SM, + json::Path P) { + json::ObjectMapper O(V, P); return O && O.map("connection_uri", SM.connection_uri) && O.map("pid", SM.pid); } +llvm::Error ServerInfo::Write(const ServerInfo &info) { + std::string buf = formatv("{0}", toJSON(info)).str(); + size_t num_bytes = buf.size(); + + FileSpec user_lldb_dir = HostInfo::GetUserLLDBDir(); + + Status error(llvm::sys::fs::create_directory(user_lldb_dir.GetPath())); + if (error.Fail()) +return error.takeError(); + + FileSpec mcp_registry_entry_path = user_lldb_dir.CopyByAppendingPathComponent( + formatv("lldb-mcp-{0}.json", getpid()).str()); + + const File::OpenOptions flags = File::eOpenOptionWriteOnly | + File::eOpenOptionCanCreate | + File::eOpenOptionTruncate; + llvm::Expected file = FileSystem::Instance().Open( + mcp_registry_entry_path, flags, lldb::eFilePermissionsFileDefault, false); + if (!file) +return file.takeError(); + if (llvm::Error error = (*file)->Write(buf.data(), num_bytes).takeError()) +return error; + return llvm::Error::success(); +} + +llvm::Expected> ServerInfo::Load() { + FileSpec user_lldb_dir = HostInfo::GetUserLLDBDir(); + namespace path = llvm::sys::path; + FileSystem &fs = FileSystem::Instance(); + std::error_code EC; + llvm::vfs::directory_iterator it = fs.DirBegin(user_lldb_dir, EC); + llvm::vfs::directory_iterator end; + std::vector infos; + for (; it != end && !EC; it.increment(EC)) { +auto &entry = *it; +auto name = path::filename(entry.path()); +if (!name.starts_with("lldb-mcp-") || !name.ends_with(".json")) { + continue; +} + +llvm::Expected> file = +fs.Open(FileSpec(entry.path()), File::eOpenOptionReadOnly); +if (!file) + return file.takeError(); + +char buf[1024] = {0}; +size_t bytes_read = sizeof(buf); +if (llvm::Error error = (*file)->Read(buf, bytes_read).takeError()) + return std::move(error); + +auto info = json::parse(StringRef(buf, bytes_read)); +if (!info) + return info.takeError(); + +infos.emplace_back(std::move(*info)); +
[Lldb-commits] [lldb] [lldb][test] Enable non-address bit WritePointerToMemory test on Linux (PR #157435)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/157435 First added in #153585 for Darwin only. All Linux AArch64 systems also have Top Byte Ignore enabled in userspace so the test "just works" there. FreeBSD has very recently gained Top Byte Ignore support: https://github.com/freebsd/freebsd-src/commit/4c6c27d3fb4ad15931aae2eaf8e624aed99a3fd9 However it's so recent, I don't want to assume it'll be available on any random FreeBSD system out there. There isn't really a good place to put this test, so I put it in the top level of API, next to the other non-address bit test that didn't have a good home either. >From 528fbe2b518b586283ffa6ce93674dbf346687d7 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Mon, 8 Sep 2025 12:03:58 + Subject: [PATCH] [lldb][test] Enable non-address bit WritePointerToMemory test on Linux First added in #153585 for Darwin only. All Linux AArch64 systems also have Top Byte Ignore enabled in userspace so the test "just works" there. FreeBSD has very recently gained Top Byte Ignore support: https://github.com/freebsd/freebsd-src/commit/4c6c27d3fb4ad15931aae2eaf8e624aed99a3fd9 However it's so recent, I don't want to assume it'll be available on any random FreeBSD system out there. There isn't really a good place to put this test, so I put it in the top level of API, next to the other non-address bit test that didn't have a good home either. --- .../Makefile | 0 .../TestArmPointerMetadataStripping.py| 8 +--- .../extra_symbols.json| 0 .../main.c| 0 4 files changed, 5 insertions(+), 3 deletions(-) rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => pointer-nonaddressable-bits}/Makefile (100%) rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => pointer-nonaddressable-bits}/TestArmPointerMetadataStripping.py (82%) rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => pointer-nonaddressable-bits}/extra_symbols.json (100%) rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => pointer-nonaddressable-bits}/main.c (100%) diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/Makefile b/lldb/test/API/pointer-nonaddressable-bits/Makefile similarity index 100% rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/Makefile rename to lldb/test/API/pointer-nonaddressable-bits/Makefile diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py similarity index 82% rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py rename to lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py index f61945b3eb4c9..21caf7195412a 100644 --- a/lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py +++ b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py @@ -5,9 +5,11 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - -@skipUnlessDarwin -@skipIf(archs=no_match(["arm64", "arm64e"])) +# On AArch64 systems, unused top bits of pointers can be used for other things. +@skipIf(archs=no_match(["aarch64", "arm64", "arm64e"])) +# Only run this test on systems where Top Byte Ignore is known to be enabled +# and widely available (FreeBSD has support but only since recently). +@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples()) class TestArmPointerMetadataStripping(TestBase): # Use extra_symbols.json as a template to add a new symbol whose address # contains non-zero high order bits set. diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/extra_symbols.json b/lldb/test/API/pointer-nonaddressable-bits/extra_symbols.json similarity index 100% rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/extra_symbols.json rename to lldb/test/API/pointer-nonaddressable-bits/extra_symbols.json diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c b/lldb/test/API/pointer-nonaddressable-bits/main.c similarity index 100% rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c rename to lldb/test/API/pointer-nonaddressable-bits/main.c ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -0,0 +1,675 @@ +# struct Type {}; +# +# template struct _Optional_payload; +# +# template struct _Optional_payload<_Tp, true, false, false> {}; +# +# template +# struct _Optional_payload<_Tp, false, _Copy, _Move> +# : _Optional_payload<_Tp, true, false, false> {}; +# +# int main() { +# _Optional_payload X; +# } +# +# YAML generated on Linux using obj2yaml on the above program +# compiled with G++. tgs-sc wrote: Addressed https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
jhuber6 wrote: > Interesting. Thanks for the feedback and thanks for reverting this change. If you can make a PR for just the lldb stuff I can review it. I appreciate NVIDIA trying to upstream more support, so I'm not trying to dissuade you. https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
walter-erquinigo wrote: Interesting. Thanks for the feedback. I'll revert this change. https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Turn LineEntry into a class and make AddressRange member optional (PR #158811)
JDevlieghere wrote: Can we break this up into an NFC patch that makes `LineEntry` a class and a separate PR for the functional change that makes `AddressRange` optional? https://github.com/llvm/llvm-project/pull/158811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Re-enable import-std-module tests on Linux (PR #157649)
dwblaikie wrote: Seeing some repeated test failures in tests modified by this change on the linux premerge testing: https://github.com/llvm/llvm-project/actions/runs/17683541354?pr=158343 - perhaps someone here knows what that's about? https://github.com/llvm/llvm-project/pull/157649 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/157432 >From c0f08a5823327e83f17e921e65d6234ce98fce6b Mon Sep 17 00:00:00 2001 From: David Spickett Date: Mon, 8 Sep 2025 11:41:33 + Subject: [PATCH 1/2] [lldb][test] Prevent TestqOffsets.py picking up host binaries Due to a fallback in GDBRemoteCommunicationClient.cpp, on Linux we will assume a PID of 1 if the remote does not respond in some way that tells us the real PID. So if PID 1 happened to be a process that the current user could read, we would try to debug that instead. On my current machine, PID 1 was sshd run by root so we would ignore it. If I changed the fallback to some process ID run by my user, the test would fail. To prevent this, return something to LLDB that tells it there is no remote PID, preventing the host lookup. Fixes #155895 --- .../API/functionalities/gdb_remote_client/TestqOffsets.py| 5 + 1 file changed, 5 insertions(+) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py index a1adc20e864ba..e069f10b19e1e 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py @@ -10,6 +10,11 @@ class Responder(MockGDBServerResponder): def qOffsets(self): return "Text=47;Data=47" +def qfThreadInfo(self): +# Prevent LLDB defaulting to PID of 1 and looking up some other +# process when on an AArch64 host. +return "m-1" + def test(self): self.server.responder = TestqOffsets.Responder() target = self.createTarget("qOffsets.yaml") >From 040fcd7a26fabce2291a4cff8103c55df444ba79 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Mon, 8 Sep 2025 14:07:48 + Subject: [PATCH 2/2] platform select instead --- .../API/functionalities/gdb_remote_client/TestqOffsets.py | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py index e069f10b19e1e..629361c6ae5b8 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py @@ -10,13 +10,10 @@ class Responder(MockGDBServerResponder): def qOffsets(self): return "Text=47;Data=47" -def qfThreadInfo(self): -# Prevent LLDB defaulting to PID of 1 and looking up some other -# process when on an AArch64 host. -return "m-1" - def test(self): self.server.responder = TestqOffsets.Responder() +# This ensures that we do not pick up any binaries on the host. +self.runCmd("platform select remote-linux") target = self.createTarget("qOffsets.yaml") text = target.modules[0].FindSection(".text") self.assertEqual(text.GetLoadAddress(target), lldb.LLDB_INVALID_ADDRESS) ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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)
medismailben wrote: I like how you give a conceptual explanation of the feature here but I think it would be great we could add a little tutorial to show what workflow this feature enables. I'd just take your test example and run the user through it. I also think we have to add a `ScriptedBreakpointResolver` base class to the lldb python module and document it like we do for [other Scripted Extensions](https://lldb.llvm.org/python_extensions.html), that way you could just link to the auto-generated extension page so it always stay up-to-date. Lastly, I think we should break down the python-reference page into subpages targeting specific topics. I think that'd improve discoverability and readability. I can take of that part :) https://github.com/llvm/llvm-project/pull/158128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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)
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 h,cpp -- lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.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/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 43d956a2e..414349a91 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6714,14 +6714,14 @@ bool TypeSystemClang::FindInAnonRecordFields(const clang::RecordDecl *rd, uint32_t local_idx = 0; // We need the visible base count to compute the child index offset - const clang::CXXRecordDecl *crd = - llvm::dyn_cast(rd); + const clang::CXXRecordDecl *crd = llvm::dyn_cast(rd); const uint32_t bases = TypeSystemClang::GetNumBaseClasses(crd, omit_empty_base_classes); - // We only treat anonymous record fields as transparent containers for further lookup. - for (auto it = rd->field_begin(), ie = rd->field_end(); - it != ie; ++it, ++local_idx) { + // We only treat anonymous record fields as transparent containers for further + // lookup. + for (auto it = rd->field_begin(), ie = rd->field_end(); it != ie; + ++it, ++local_idx) { llvm::StringRef fname = it->getName(); const bool is_anon = it->isAnonymousStructOrUnion() || fname.empty(); @@ -6739,7 +6739,8 @@ bool TypeSystemClang::FindInAnonRecordFields(const clang::RecordDecl *rd, continue; const auto *inner_rt = it->getType()->castAs(); -const clang::RecordDecl *inner_rd = inner_rt->getOriginalDecl()->getDefinitionOrSelf(); +const clang::RecordDecl *inner_rd = +inner_rt->getOriginalDecl()->getDefinitionOrSelf(); if (!inner_rd) continue; @@ -6822,8 +6823,10 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( std::vector save_indices = child_indexes; child_indexes.push_back(this_slot); const auto *rt = field->getType()->castAs(); - const clang::RecordDecl *rd = rt->getOriginalDecl()->getDefinitionOrSelf(); - if (rd && FindInAnonRecordFields(rd, child_indexes, name, omit_empty_base_classes)) + const clang::RecordDecl *rd = + rt->getOriginalDecl()->getDefinitionOrSelf(); + if (rd && FindInAnonRecordFields(rd, child_indexes, name, + omit_empty_base_classes)) return child_indexes.size(); child_indexes = std::move(save_indices); } @@ -6837,9 +6840,10 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( } if (cxx_record_decl) { - for (const clang::CXXBaseSpecifier &base_spec : cxx_record_decl->bases()) { -uint32_t base_slot = -GetIndexForRecordBase(record_decl, &base_spec, omit_empty_base_classes); + for (const clang::CXXBaseSpecifier &base_spec : + cxx_record_decl->bases()) { +uint32_t base_slot = GetIndexForRecordBase(record_decl, &base_spec, + omit_empty_base_classes); if (base_slot == UINT32_MAX) continue; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 62e6d8314..8a6b36426 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -321,8 +321,7 @@ public: bool omit_empty_base_classes); bool FindInAnonRecordFields(const clang::RecordDecl *rd, - std::vector &path, - llvm::StringRef name, + std::vector &path, llvm::StringRef name, bool omit_empty_base_classes); /// Synthesize a clang::Module and return its ID or a default-constructed ID. `` https://github.com/llvm/llvm-project/pull/158256 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
DavidSpickett wrote: Also you'd probably save a bunch of time by doing one giant test that checks all the little MTE additions in one go, maybe that is in fact your plan. https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/149827 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Mark blocks as parsed after parsing (PR #157493)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) Changes After parsing blocks in a function, the blocks should be marked as parsed for them to be dumped (see [Function::Dump](https://github.com/llvm/llvm-project/blob/e6aefbec782dbb57f72eb0ae399ed944fe49db2e/lldb/source/Symbol/Function.cpp#L446-L447)). As explained in https://github.com/llvm/llvm-project/issues/114906#issuecomment-3255016266, this happens (accidentally?) in the DIA plugin when parsing variables, because it calls `function.GetBlock(can_create=true)` which marks blocks as parsed. In the native plugin, this was never called, so blocks and variables were never included in the `lldb-test symbols` output. The `variables.test` for the DIA plugin tests this. One difference between the plugins is how they specify the location of local variables. This causes the output of the native plugin to be two lines per variable, whereas the DIA plugin has one line: ``` (native): 02C4B7593020: Variable{0x1c81}, name = "var_arg1", type = {0744} 0x02C4B6CA7900 (int), scope = parameter, location = 0x: [0x00014000102c, 0x00014000103e): DW_OP_breg7 RSP+8 ``` ``` (DIA): 02778C827EE0: Variable{0x001b}, name = "var_arg1", type = {0005} 0x02778C1FBAB0 (int), scope = parameter, decl = VariablesTest.cpp:32, location = DW_OP_breg7 RSP+8 ``` In the test, I filtered lines starting with spaces followed by `[0x`, so we can still use `CHECK-NEXT`. --- Another difference between the plugins is that DIA marks the `this` pointer as artificial (equivalent to DWARF). This is done if a variable's object kind is `ObjectPtr` ([source](https://github.com/llvm/llvm-project/blob/ab898f32c60689d1d47d0b6de66c30d3476994bb/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp#L1050)). As far as I know, there isn't anything in the debug info that says "this variable is the `this` pointer" other than the name/type of a variable and the type of the function. --- Full diff: https://github.com/llvm/llvm-project/pull/157493.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (+2) - (modified) lldb/test/Shell/SymbolFile/PDB/variables.test (+22-12) ``diff diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 112eb06e462fc..81b2818fa07bd 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1624,6 +1624,8 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) { for (uint64_t uid : remove_uids) { m_inline_sites.erase(uid); } + + func.GetBlock(false).SetBlockInfoHasBeenParsed(true, true); return count; } diff --git a/lldb/test/Shell/SymbolFile/PDB/variables.test b/lldb/test/Shell/SymbolFile/PDB/variables.test index 9ee10f75c7e38..970d714c29c3b 100644 --- a/lldb/test/Shell/SymbolFile/PDB/variables.test +++ b/lldb/test/Shell/SymbolFile/PDB/variables.test @@ -2,15 +2,27 @@ REQUIRES: system-windows, msvc RUN: mkdir -p %t.dir RUN: %build --compiler=clang-cl --mode=compile --arch=64 --nodefaultlib --output=%t.dir/VariablesTest.cpp.obj %S/Inputs/VariablesTest.cpp RUN: %build --compiler=msvc --mode=link --arch=64 --nodefaultlib --output=%t.dir/VariablesTest.cpp.exe %t.dir/VariablesTest.cpp.obj -RUN: lldb-test symbols %t.dir/VariablesTest.cpp.exe > %t.dir/VariablesTest.out -RUN: FileCheck --check-prefix=GLOBALS --input-file=%t.dir/VariablesTest.out %s -RUN: FileCheck --check-prefix=FUNC-F --input-file=%t.dir/VariablesTest.out %s -RUN: FileCheck --check-prefix=FUNC-MAIN --input-file=%t.dir/VariablesTest.out %s -RUN: FileCheck --check-prefix=FUNC-CONSTRUCTOR --input-file=%t.dir/VariablesTest.out %s -RUN: FileCheck --check-prefix=FUNC-MEMBER --input-file=%t.dir/VariablesTest.out %s +# Note: The native plugin creates a location list for variables that's only valid for the function. +# The DIA plugin creates a location expression that's always valid. This causes DIA to output +# one line per variable where the native plugin would output two (the second would contain the +# location information). This removes the second line from the output of the native plugin. +# It's done in both cases, because LLDB might not be compiled with the DIA SDK in which case +# the native plugin is always used. +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols %t.dir/VariablesTest.cpp.exe | sed '/^ \+\[0x/d' > %t.dir/VariablesTest.DIA.out +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols %t.dir/VariablesTest.cpp.exe | sed '/^ \+\[0x/d' > %t.dir/VariablesTest.Native.out +RUN: FileCheck --check-prefix=GLOBALS --input-file=%t.dir/VariablesTest.DIA.out %s +RUN: FileCheck --check-prefix=GLOBALS --input-file=%t.dir/VariablesTest.Native.out %s +RUN: FileCheck --ch
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -599,6 +599,39 @@ TEST_F(DWARFASTParserClangTests, TestDefaultTemplateParamParsing) { } } +TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) { + // Tests checking error if ClassTemplateSpecializationDecl already exists. Michael137 wrote: ```suggestion // Tests that parsing a ClassTemplateSpecializationDecl that already exists // is handled gracefully. ``` https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Recognize an MTE tag fault Mach exception. A tag fault is an error reported by Arm's Memory Tagging Extension (MTE) when a memory access attempts to use a pointer with a tag that doesn't match the tag stored with the memory. LLDB will print the tag and address to make the issue easier to diagnose. This was hand tested by debugging an MTE enabled binary on an iPhone 17 running iOS 26. rdar://113575216 --- Full diff: https://github.com/llvm/llvm-project/pull/159117.diff 2 Files Affected: - (modified) lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp (+31) - (modified) lldb/source/Plugins/Process/Utility/StopInfoMachException.h (+2) ``diff diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 29a64a2a03bf0..6853121f3e01c 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -77,6 +77,35 @@ static void DescribeAddressBriefly(Stream &strm, const Address &addr, strm.Printf(".\n"); } +static constexpr uint8_t g_mte_tag_shift = 64 - 8; +static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift; + +bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) { + const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS + const bool IsMTETagFault = (m_exc_code == 0x106); // EXC_ARM_MTE_TAG_FAULT + if (!IsBadAccess || !IsMTETagFault) +return false; + + if (m_exc_data_count < 2) +return false; + + const uint64_t bad_address = m_exc_subcode; + + StreamString strm; + strm.Printf("EXC_ARM_MTE_TAG_FAULT (code=%" PRIu64 ", address=0x%" PRIx64 + ")\n", + m_exc_code, bad_address); + + const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift; + const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask; + strm.Printf( + "Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64, + tag, canonical_addr); + m_description = std::string(strm.GetString()); + + return true; +} + bool StopInfoMachException::DeterminePtrauthFailure(ExecutionContext &exe_ctx) { bool IsBreakpoint = m_value == 6; // EXC_BREAKPOINT bool IsBadAccess = m_value == 1; // EXC_BAD_ACCESS @@ -266,6 +295,8 @@ const char *StopInfoMachException::GetDescription() { case llvm::Triple::aarch64: if (DeterminePtrauthFailure(exe_ctx)) return m_description.c_str(); + if (DetermineTagMismatch(exe_ctx)) +return m_description.c_str(); break; default: diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h index c612ac400b4c4..c02389e5b3642 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h @@ -27,6 +27,8 @@ class StopInfoMachException : public StopInfo { /// is auth-related failure, and returns false otherwise. bool DeterminePtrauthFailure(ExecutionContext &exe_ctx); + bool DetermineTagMismatch(ExecutionContext &exe_ctx); + public: // Constructors and Destructors StopInfoMachException(Thread &thread, uint32_t exc_type, `` https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix 64 bit support for CIE and FDE handling in DWARFCallFrameInfo (PR #158350)
https://github.com/agontarek updated https://github.com/llvm/llvm-project/pull/158350 >From a5db208cd21b45ba0c2dc7816fcab6b85bc9cc41 Mon Sep 17 00:00:00 2001 From: Andrew Gontarek Date: Wed, 10 Sep 2025 12:53:21 -0500 Subject: [PATCH 1/2] [LLDB] Refactor CIE and FDE handling in DWARFCallFrameInfo - Introduced a new helper function `IsCIEMarker` to determine if a given `cie_id` indicates a CIE (Common Information Entry) or FDE (Frame Description Entry). - New helper function can now correctly identify both 32-bit and 64-bit CIE based on the DWARF specifications. - Updated the `ParseCIE` and `GetFDEIndex` methods to utilize the new helper function for improved clarity and correctness in identifying CIE and FDE entries. - Replaced direct comparisons with `UINT32_MAX` and `UINT64_MAX` with `std::numeric_limits` for better readability. --- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 44 +-- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index 2f8f9e9182fb2..6ba5c6660140b 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -20,7 +20,9 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Timer.h" +#include #include +#include #include #include @@ -147,6 +149,27 @@ GetGNUEHPointer(const DataExtractor &DE, lldb::offset_t *offset_ptr, return baseAddress + addressValue; } +// Check if the given cie_id value indicates a CIE (Common Information Entry) +// as opposed to an FDE (Frame Description Entry). +// +// For eh_frame sections: CIE is marked with cie_id == 0 +// For debug_frame sections: +// - DWARF32: CIE is marked with cie_id == +// std::numeric_limits::max() +// - DWARF64: CIE is marked with cie_id == +// std::numeric_limits::max() +static bool IsCIEMarker(uint64_t cie_id, bool is_64bit, +DWARFCallFrameInfo::Type type) { + if (type == DWARFCallFrameInfo::EH) +return cie_id == 0; + + // DWARF type + if (is_64bit) +return cie_id == std::numeric_limits::max(); + + return cie_id == std::numeric_limits::max(); +} + DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile &objfile, SectionSP §ion_sp, Type type) : m_objfile(objfile), m_section_sp(section_sp), m_type(type) {} @@ -283,7 +306,7 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { GetCFIData(); uint32_t length = m_cfi_data.GetU32(&offset); dw_offset_t cie_id, end_offset; - bool is_64bit = (length == UINT32_MAX); + bool is_64bit = (length == std::numeric_limits::max()); if (is_64bit) { length = m_cfi_data.GetU64(&offset); cie_id = m_cfi_data.GetU64(&offset); @@ -292,8 +315,9 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { cie_id = m_cfi_data.GetU32(&offset); end_offset = cie_offset + length + 4; } - if (length > 0 && ((m_type == DWARF && cie_id == UINT32_MAX) || - (m_type == EH && cie_id == 0ul))) { + + // Check if this is a CIE or FDE based on the CIE ID marker + if (length > 0 && IsCIEMarker(cie_id, is_64bit, m_type)) { size_t i; //cie.offset = cie_offset; //cie.length = length; @@ -470,7 +494,7 @@ void DWARFCallFrameInfo::GetFDEIndex() { const dw_offset_t current_entry = offset; dw_offset_t cie_id, next_entry, cie_offset; uint32_t len = m_cfi_data.GetU32(&offset); -bool is_64bit = (len == UINT32_MAX); +bool is_64bit = (len == std::numeric_limits::max()); if (is_64bit) { len = m_cfi_data.GetU64(&offset); cie_id = m_cfi_data.GetU64(&offset); @@ -493,11 +517,8 @@ void DWARFCallFrameInfo::GetFDEIndex() { return; } -// An FDE entry contains CIE_pointer in debug_frame in same place as cie_id -// in eh_frame. CIE_pointer is an offset into the .debug_frame section. So, -// variable cie_offset should be equal to cie_id for debug_frame. -// FDE entries with cie_id == 0 shouldn't be ignored for it. -if ((cie_id == 0 && m_type == EH) || cie_id == UINT32_MAX || len == 0) { +// Check if this is a CIE or FDE based on the CIE ID marker +if (IsCIEMarker(cie_id, is_64bit, m_type) || len == 0) { auto cie_sp = ParseCIE(current_entry); if (!cie_sp) { // Cannot parse, the reason is already logged @@ -568,7 +589,7 @@ DWARFCallFrameInfo::ParseFDE(dw_offset_t dwarf_offset, uint32_t length = m_cfi_data.GetU32(&offset); dw_offset_t cie_offset; - bool is_64bit = (length == UINT32_MAX); + bool is_64bit = (length == std::numeric_limits::max()); if (is_64bit) { length = m_cfi_data.GetU64(&offset); cie_offset = m_cfi_data.GetU64(&offset); @@ -577,7 +598,8 @@ DWARFCallFrameInfo::ParseFDE(dw_offset_t dwarf_offset, } // FDE entries with zeroth cie_offset may occur for debug_frame. - assert(!(m_type == EH && 0 == cie_o
[Lldb-commits] [lldb] [llvm] Revert "[ELF][LLDB] Add an nvsass triple (#159459)" (PR #159879)
https://github.com/jhuber6 closed https://github.com/llvm/llvm-project/pull/159879 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add invalidated event (PR #157530)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/157530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NVIDIA] Add NVPTX architecture support (PR #158334)
agontarek wrote: @clayborg @walter-erquinigo Please review. https://github.com/llvm/llvm-project/pull/158334 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/147990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Revert "[ELF][LLDB] Add an nvsass triple (#159459)" (PR #159879)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` running on `sanitizer-buildbot8` while building `lldb,llvm` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/23838 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) (timed out) ... [181/186] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64.o [182/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o [183/186] Generating Msan-aarch64-with-call-Test [184/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o [185/186] Generating Msan-aarch64-Test [185/186] Running compiler_rt regression tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:74: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds. -- Testing: 5972 tests, 72 workers -- command timed out: 1200 seconds without output running [b'python', b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'], attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=1902.785146 Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Step 9 (test compiler-rt symbolizer) failure: test compiler-rt symbolizer (failure) ... -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/typeindex.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/typeinfo.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/unordered_map.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/unordered_set.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/utility.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/valarray.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/variant.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/vector.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std/version.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cassert.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cctype.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cerrno.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cfenv.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cfloat.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/cinttypes.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/climits.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_aarch64/share/libc++/v1/std.compat/clocale.inc -- Installing: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/ru
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/122265 >From a9e13ad8d2a7a95d431dddcced611bea1e83b99a Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 9 Jan 2025 10:01:31 + Subject: [PATCH 01/14] [clang][DebugInfo] Expand detection of structured bindings to account for std::get free function When we generate the debug-info for a `VarDecl` we try to determine whether it was introduced as part of a structure binding (aka a "holding var"). If it was, we don't mark it as `artificial`. The heuristic to determine a holding var uses `IgnoreUnlessSpelledInSource` to unwrap the `VarDecl` initializer until we hit a `DeclRefExpr` that refers to a `Decomposition`. For "tuple-like decompositions", Clang will generate a call to a `template Foo get(Bar)` function that retrieves the `Ith` element from the tuple-like structure. If that function is a member function, we get an AST that looks as follows: ``` VarDecl implicit used z1 'std::tuple_element<0, B>::type &&' cinit `-ExprWithCleanups 'int' xvalue `-MaterializeTemporaryExpr 'int' xvalue extended by Var 0x11d110cf8 'z1' 'std::tuple_element<0, B>::type &&' `-CXXMemberCallExpr 'int' `-MemberExpr '' .get 0x11d104390 `-ImplicitCastExpr 'B' xvalue `-DeclRefExpr 'B' lvalue Decomposition 0x11d1100a8 '' 'B' ``` `IgnoreUnlessSpelledInSource` happily unwraps this down to the `DeclRefExpr`. However, when the `get` helper is a free function (which it is for `std::pair` in libc++ for example), then the AST is: ``` VarDecl col:16 implicit used k 'std::tuple_element<0, const std::tuple>::type &' cinit `-CallExpr 'const typename tuple_element<0UL, tuple>::type':'const int' lvalue adl |-ImplicitCastExpr 'const typename tuple_element<0UL, tuple>::type &(*)(const tuple &) noexcept' | `-DeclRefExpr 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' lvalue Function 0x1210262d8 'get' 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' (FunctionTemplate 0x11d068088 'get') `-DeclRefExpr 'const std::tuple' lvalue Decomposition 0x121021518 '' 'const std::tuple &' ``` `IgnoreUnlessSpelledInSource` doesn't unwrap this `CallExpr`, so we incorrectly mark the binding as `artificial` in debug-info. This patch adjusts our heuristic to account for `CallExpr` nodes. Fixes https://github.com/llvm/llvm-project/issues/122028 --- clang/lib/CodeGen/CGDebugInfo.cpp | 28 ++- .../test/DebugInfo/CXX/structured-binding.cpp | 27 +++ .../TestStructuredBinding.py | 11 +++ .../API/lang/cpp/structured-binding/main.cpp | 81 +-- 4 files changed, 140 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0385dbdac869b..4b0f2bce457df 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -87,12 +87,38 @@ static bool IsDecomposedVarDecl(VarDecl const *VD) { if (!Init) return false; + Init = Init->IgnoreUnlessSpelledInSource(); + if (!Init) +return false; + + // For tuple-like decompositions, if the `get` function + // is not a member of the decomposed type, but instead a + // free function (e.g., how std::get is specialized for + // std::pair), then the initializer is a `CallExpr` and + // we need to dig into the argument before unwrapping it + // with IgnoreUnlessSpelledInSource. + if (auto const *CE = llvm::dyn_cast(Init)) { +if (CE->getNumArgs() == 0) + return false; + +// The first argument will be the type we're decomposing. +// Technically the getter could have more than 1 argument +// (e.g., if they're defaulted arguments), but we don't care +// about them because we just need to check whether the +// first argument is a DecompositionDecl. +auto const *Arg = CE->getArg(0); +if (!Arg) + return false; + +Init = Arg; + } + auto const *RefExpr = llvm::dyn_cast_or_null(Init->IgnoreUnlessSpelledInSource()); if (!RefExpr) return false; - return llvm::dyn_cast_or_null(RefExpr->getDecl()); + return llvm::isa_and_nonnull(RefExpr->getDecl()); } /// Returns true if \ref VD is a compiler-generated variable diff --git a/clang/test/DebugInfo/CXX/structured-binding.cpp b/clang/test/DebugInfo/CXX/structured-binding.cpp index 8032ce85c9e25..7d4919ad52bc7 100644 --- a/clang/test/DebugInfo/CXX/structured-binding.cpp +++ b/clang/test/DebugInfo/CXX/structured-binding.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg.declare" +// CHECK: define noundef i32 @_Z1fv // CHECK: #dbg_declare(ptr %{{[a-z]+}}, ![[VAR_0:[0-9]+]], !DIExpression(), // CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_1:[0-9]+]], !DIExpression(), // CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_2:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 4), @@ -1
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
Michael137 wrote: > Just as few nits (sorry for the delay and thanks for the pings!) No worries! Thanks for the review https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
jhuber6 wrote: I'm assuming the `lldb` changes are fine but should probably just use `nvptx64`. We could probably entirely remove `nvptx32` since NVIDIA's removed it AFAIK. https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/122265 >From a9e13ad8d2a7a95d431dddcced611bea1e83b99a Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 9 Jan 2025 10:01:31 + Subject: [PATCH 01/14] [clang][DebugInfo] Expand detection of structured bindings to account for std::get free function When we generate the debug-info for a `VarDecl` we try to determine whether it was introduced as part of a structure binding (aka a "holding var"). If it was, we don't mark it as `artificial`. The heuristic to determine a holding var uses `IgnoreUnlessSpelledInSource` to unwrap the `VarDecl` initializer until we hit a `DeclRefExpr` that refers to a `Decomposition`. For "tuple-like decompositions", Clang will generate a call to a `template Foo get(Bar)` function that retrieves the `Ith` element from the tuple-like structure. If that function is a member function, we get an AST that looks as follows: ``` VarDecl implicit used z1 'std::tuple_element<0, B>::type &&' cinit `-ExprWithCleanups 'int' xvalue `-MaterializeTemporaryExpr 'int' xvalue extended by Var 0x11d110cf8 'z1' 'std::tuple_element<0, B>::type &&' `-CXXMemberCallExpr 'int' `-MemberExpr '' .get 0x11d104390 `-ImplicitCastExpr 'B' xvalue `-DeclRefExpr 'B' lvalue Decomposition 0x11d1100a8 '' 'B' ``` `IgnoreUnlessSpelledInSource` happily unwraps this down to the `DeclRefExpr`. However, when the `get` helper is a free function (which it is for `std::pair` in libc++ for example), then the AST is: ``` VarDecl col:16 implicit used k 'std::tuple_element<0, const std::tuple>::type &' cinit `-CallExpr 'const typename tuple_element<0UL, tuple>::type':'const int' lvalue adl |-ImplicitCastExpr 'const typename tuple_element<0UL, tuple>::type &(*)(const tuple &) noexcept' | `-DeclRefExpr 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' lvalue Function 0x1210262d8 'get' 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' (FunctionTemplate 0x11d068088 'get') `-DeclRefExpr 'const std::tuple' lvalue Decomposition 0x121021518 '' 'const std::tuple &' ``` `IgnoreUnlessSpelledInSource` doesn't unwrap this `CallExpr`, so we incorrectly mark the binding as `artificial` in debug-info. This patch adjusts our heuristic to account for `CallExpr` nodes. Fixes https://github.com/llvm/llvm-project/issues/122028 --- clang/lib/CodeGen/CGDebugInfo.cpp | 28 ++- .../test/DebugInfo/CXX/structured-binding.cpp | 27 +++ .../TestStructuredBinding.py | 11 +++ .../API/lang/cpp/structured-binding/main.cpp | 81 +-- 4 files changed, 140 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0385dbdac869b..4b0f2bce457df 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -87,12 +87,38 @@ static bool IsDecomposedVarDecl(VarDecl const *VD) { if (!Init) return false; + Init = Init->IgnoreUnlessSpelledInSource(); + if (!Init) +return false; + + // For tuple-like decompositions, if the `get` function + // is not a member of the decomposed type, but instead a + // free function (e.g., how std::get is specialized for + // std::pair), then the initializer is a `CallExpr` and + // we need to dig into the argument before unwrapping it + // with IgnoreUnlessSpelledInSource. + if (auto const *CE = llvm::dyn_cast(Init)) { +if (CE->getNumArgs() == 0) + return false; + +// The first argument will be the type we're decomposing. +// Technically the getter could have more than 1 argument +// (e.g., if they're defaulted arguments), but we don't care +// about them because we just need to check whether the +// first argument is a DecompositionDecl. +auto const *Arg = CE->getArg(0); +if (!Arg) + return false; + +Init = Arg; + } + auto const *RefExpr = llvm::dyn_cast_or_null(Init->IgnoreUnlessSpelledInSource()); if (!RefExpr) return false; - return llvm::dyn_cast_or_null(RefExpr->getDecl()); + return llvm::isa_and_nonnull(RefExpr->getDecl()); } /// Returns true if \ref VD is a compiler-generated variable diff --git a/clang/test/DebugInfo/CXX/structured-binding.cpp b/clang/test/DebugInfo/CXX/structured-binding.cpp index 8032ce85c9e25..7d4919ad52bc7 100644 --- a/clang/test/DebugInfo/CXX/structured-binding.cpp +++ b/clang/test/DebugInfo/CXX/structured-binding.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s --implicit-check-not="call void @llvm.dbg.declare" +// CHECK: define noundef i32 @_Z1fv // CHECK: #dbg_declare(ptr %{{[a-z]+}}, ![[VAR_0:[0-9]+]], !DIExpression(), // CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_1:[0-9]+]], !DIExpression(), // CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_2:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 4), @@ -1
[Lldb-commits] [lldb] [llvm] Revert "[ELF][LLDB] Add an nvsass triple (#159459)" (PR #159879)
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/159879 Summary: This patch has broken the `libc` build bot. I could work around that but the changes seem unnecessary. This reverts commit 9ba844eb3a21d461c3adc7add7691a076c6992fc. >From f0829fd54d9b9b90a73a4229fbca77d17443d4a2 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Fri, 19 Sep 2025 18:44:31 -0500 Subject: [PATCH] Revert "[ELF][LLDB] Add an nvsass triple (#159459)" Summary: This patch has broken the `libc` build bot. I could work around that but the changes seem unnecessary. This reverts commit 9ba844eb3a21d461c3adc7add7691a076c6992fc. --- lldb/include/lldb/Utility/ArchSpec.h| 6 +- lldb/source/Utility/ArchSpec.cpp| 4 llvm/include/llvm/Object/ELFObjectFile.h| 6 -- llvm/include/llvm/TargetParser/Triple.h | 7 +-- llvm/lib/Object/ELFObjectFile.cpp | 4 ++-- llvm/lib/Object/ObjectFile.cpp | 2 +- llvm/lib/TargetParser/TargetDataLayout.cpp | 1 - llvm/lib/TargetParser/Triple.cpp| 15 --- llvm/unittests/Object/ELFObjectFileTest.cpp | 2 +- 9 files changed, 10 insertions(+), 37 deletions(-) diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index 8415eca96ea69..361108fd8f0e7 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -236,8 +236,6 @@ class ArchSpec { eCore_wasm32, -eCore_nvsass, - kNumCores, kCore_invalid, @@ -284,10 +282,8 @@ class ArchSpec { kCore_mips64el_last = eCore_mips64r6el, kCore_mips_first = eCore_mips32, -kCore_mips_last = eCore_mips64r6el, +kCore_mips_last = eCore_mips64r6el -kCore_nvsass_first = eCore_nvsass, -kCore_nvsass_last = eCore_nvsass, }; /// Default constructor. diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 062e74af7d7aa..dfe4351f0c45b 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -248,9 +248,6 @@ static constexpr const CoreDefinition g_core_definitions[] = { {eByteOrderLittle, 4, 1, 4, llvm::Triple::wasm32, ArchSpec::eCore_wasm32, "wasm32"}, - -{eByteOrderLittle, 8, 4, 4, llvm::Triple::nvsass, ArchSpec::eCore_nvsass, - "nvsass"}, }; // Ensure that we have an entry in the g_core_definitions for each core. If you @@ -415,7 +412,6 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { {ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV, ArchSpec::eRISCVSubType_riscv64}, // riscv64 {ArchSpec::eCore_loongarch32, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch32}, // loongarch32 {ArchSpec::eCore_loongarch64, llvm::ELF::EM_LOONGARCH, ArchSpec::eLoongArchSubType_loongarch64}, // loongarch64 -{ArchSpec::eCore_nvsass, llvm::ELF::EM_CUDA, }, // nvsass }; // clang-format on diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index 7f8f4a2a01fe4..ced1afdd4cc6a 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -69,7 +69,7 @@ class LLVM_ABI ELFObjectFileBase : public ObjectFile { SubtargetFeatures getLoongArchFeatures() const; StringRef getAMDGPUCPUName() const; - StringRef getCUDACPUName() const; + StringRef getNVPTXCPUName() const; protected: ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source); @@ -1431,7 +1431,9 @@ template Triple::ArchType ELFObjectFile::getArch() const { } case ELF::EM_CUDA: { -return Triple::nvsass; +if (EF.getHeader().e_ident[ELF::EI_CLASS] == ELF::ELFCLASS32) + return Triple::nvptx; +return Triple::nvptx64; } case ELF::EM_BPF: diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 3b9f55ef9f6ea..ed2e01ccb1e26 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -110,7 +110,6 @@ class Triple { renderscript32, // 32-bit RenderScript renderscript64, // 64-bit RenderScript ve, // NEC SX-Aurora Vector Engine -nvsass, // NVIDIA SASS LastArchType = ve }; enum SubArchType { @@ -906,8 +905,6 @@ class Triple { bool isAMDGPU() const { return getArch() == Triple::r600 || isAMDGCN(); } - bool isNVSASS() const { return getArch() == Triple::nvsass; } - /// Tests whether the target is Thumb (little and big endian). bool isThumb() const { return getArch() == Triple::thumb || getArch() == Triple::thumbeb; @@ -1276,9 +1273,7 @@ class Triple { LLVM_ABI bool isCompatibleWith(const Triple &Other) const; /// Test whether the target triple is for a GPU. - bool isGPU() const { -return isSPIRV() || isNVPTX() || isAMDGPU() || isNVSASS(); - } + bool isGPU() const { return isSPIRV() || isNVPTX() || isAMDGPU(); } /// Merge target triple
[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -foverflow-behavior-types -std=c++11 -ast-print %s -o - | FileCheck %s + +extern int __attribute__((overflow_behavior(no_wrap))) a; +extern int __attribute__((overflow_behavior(wrap))) b; + +// CHECK: extern __no_wrap int a; +// CHECK: extern __wrap int b; mizvekov wrote: So yeah, please just fix the type printer so it prints using the attribute spelling, if we are going with that, and make sure the ast-print test also does the round-tripping. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
@@ -2544,6 +2544,19 @@ Stmt *BlockExpr::getBody() { //===--===// // Generic Expression Routines //===--===// +namespace { +/// Helper to determine wether \c E is a CXXConstructExpr constructing +/// a DecompositionDecl. Used to skip Clang-generated calls to std::get +/// for structured bindings. +bool IsDecompositionDeclRefExpr(const Expr *E) { + const Expr *Unrwapped = E->IgnoreUnlessSpelledInSource(); + const DeclRefExpr *Ref = llvm::dyn_cast_or_null(Unrwapped); cor3ntin wrote: I don't think E can be null, so Unwrapped probably cannot be null either, it should just be `dyn_cast` https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when the lldb-dap binary's modification time has changed (PR #159481)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159481 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table (PR #158551)
DavidSpickett wrote: I assume this is fallout from https://discourse.llvm.org/t/rfc-should-we-omit-local-symbols-in-elf-files-from-the-lldb-symbol-table/87384. Which I have no context for but I'll add some of those folks on review. https://github.com/llvm/llvm-project/pull/158551 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
joker-eph wrote: > I don't buy that argument at all. "Sound" has plenty of uses. It does not > imply "sound of mind". The argument, I believe, is that **when you can replace "sanity" with 'sound'**, then sound is used a "sound of mind", and in other context you shouldn't use sound at it does not match the intent behind the original use of "sanity" (this last point as been mentioned in the RFC). https://github.com/llvm/llvm-project/pull/156995 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fixing makefile issue to include riscv emulation test only when RISCV is present. (PR #159842)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-lldb Author: None (barsolo2000) Changes Initial PR was reverted due failing test since the buildbots don't include RISCV. --- Full diff: https://github.com/llvm/llvm-project/pull/159842.diff 5 Files Affected: - (modified) lldb/include/lldb/Core/Opcode.h (+3-1) - (modified) lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp (+164-12) - (modified) lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h (+4) - (modified) lldb/unittests/Instruction/CMakeLists.txt (+21-1) - (added) lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp (+188) ``diff 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..20661290ca4c6 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -33,6 +33,10 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, InstructionRISCV) namespace lldb_private { +// RISC-V General Purpose Register numbers +static constexpr uint32_t RISCV_GPR_SP = 2; // x2 is the stack pointer +static constexpr uint32_t RISCV_GPR_FP = 8; // x8 is the frame pointer + /// Returns all values wrapped in Optional, or std::nullopt if any of the values /// is std::nullopt. template @@ -108,6 +112,16 @@ static uint32_t FPREncodingToLLDB(uint32_t reg_encode) { return LLDB_INVALID_REGNUM; } +// Helper function to get register info from GPR encoding +static std::optional +GPREncodingToRegisterInfo(EmulateInstructionRISCV &emulator, + uint32_t reg_encode) { + uint32_t lldb_reg = GPREncodingToLLDB(reg_encode); + if (lldb_reg == LLDB_INVALID_REGNUM) +return std::nullopt; + return emulator.GetRegisterInfo(eRegisterKindLLDB, lldb_reg); +} + bool Rd::Write(EmulateInstructionRISCV &emulator, uint64_t value) { uint32_t lldb_reg = GPREncodingToLLDB(rd); EmulateInstruction::Context ctx; @@ -230,10 +244,34 @@ 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 + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + + if (!reg_info_rs1) +return false; + + // Set context type based on whether this is a stack-based load. + if (inst.rs1.rs == RISCV_GPR_SP) +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 +280,35 @@ 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. + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + std::optional reg_info_rs2 = + GPREncodingToRegisterInfo(emulator, inst.rs2.rs); + + 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 == RISCV_GPR_SP) +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.SetRegisterToRegis
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 757bb36 - [lldb][test] Disable a test from TestDAP_cancel.py on Windows
Author: David Spickett Date: 2025-09-15T08:48:04Z New Revision: 757bb36a58c7d7151a28c6a5fc7caa2e1f44de87 URL: https://github.com/llvm/llvm-project/commit/757bb36a58c7d7151a28c6a5fc7caa2e1f44de87 DIFF: https://github.com/llvm/llvm-project/commit/757bb36a58c7d7151a28c6a5fc7caa2e1f44de87.diff LOG: [lldb][test] Disable a test from TestDAP_cancel.py on Windows Flakey on our Windows on Arm bot: https://lab.llvm.org/buildbot/#/builders/141/builds/11516 See https://github.com/llvm/llvm-project/issues/137660 Added: Modified: lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py index 109f34ff10a5d..9dea325694f00 100644 --- a/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py +++ b/lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py @@ -70,6 +70,7 @@ def test_pending_request(self): self.assertEqual(cancel_resp["success"], True) self.continue_to_exit() +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_inflight_request(self): """ Tests cancelling an inflight request. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NVIDIA] Add NVPTX architecture support (PR #158334)
https://github.com/walter-erquinigo closed https://github.com/llvm/llvm-project/pull/158334 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change directory creation logic in framework-header-fix (PR #158355)
JDevlieghere wrote: Why don't we ensure the build system creates the directory instead? https://github.com/llvm/llvm-project/pull/158355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fixing makefile issue to include riscv emulation test only when RISCV is present. (PR #159842)
https://github.com/barsolo2000 edited https://github.com/llvm/llvm-project/pull/159842 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` running on `sanitizer-buildbot8` while building `clang,lldb` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/23865 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... [182/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o [183/186] Generating Msan-aarch64-with-call-Test [184/186] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o [185/186] Generating Msan-aarch64-Test [185/186] Running compiler_rt regression tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:74: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds. -- Testing: 5972 tests, 72 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90. FAIL: libFuzzer-aarch64-libcxx-Linux :: reduce_inputs.test (5747 of 5972) TEST 'libFuzzer-aarch64-libcxx-Linux :: reduce_inputs.test' FAILED Exit Code: 1 Command Output (stderr): -- rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C # RUN: at line 3 + rm -rf /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C mkdir -p /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C # RUN: at line 4 + mkdir -p /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest # RUN: at line 5 + /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64LibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowTest # RUN: at line 6 + /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/run
[Lldb-commits] [lldb] [lldb] Unwind through ARM Cortex-M exceptions automatically (PR #153922)
@@ -293,6 +293,9 @@ void RegisterContextUnwind::InitializeZerothFrame() { return; } + // Give the Architecture a chance to replace the UnwindPlan. + AdoptArchitectureUnwindPlan(); DavidSpickett wrote: Thanks for explaining. https://github.com/llvm/llvm-project/pull/153922 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)
Michael137 wrote: /cherry-pick 39572f5e9168b1b44c2f9078494616fed8752086 879f40ab041b31fa73b9b25e4ec9e06e810bc767 bdf645bb9b509b60bdb6a71d865b4f8999187977 5326b3b176e82191b18ffc368118b36e0103af3d https://github.com/llvm/llvm-project/pull/133079 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/133079 >From 8f3f629b3913a5402a87786c4e1387d880d83f11 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 26 Mar 2025 12:54:36 + Subject: [PATCH] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries --- .../Target/InstrumentationRuntimeStopInfo.h | 3 ++ .../Target/InstrumentationRuntimeStopInfo.cpp | 42 +++ .../functionalities/asan/TestMemoryHistory.py | 8 .../functionalities/asan/TestReportData.py| 4 ++ .../ubsan/basic/TestUbsanBasic.py | 4 +- 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h index 5345160850914..dafa41c11327a 100644 --- a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -24,6 +24,9 @@ class InstrumentationRuntimeStopInfo : public StopInfo { return lldb::eStopReasonInstrumentation; } + std::optional + GetSuggestedStackFrameIndex(bool inlined_stack) override; + const char *GetDescription() override; bool DoShouldNotify(Event *event_ptr) override { return true; } diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp index 7f82581cc601e..aef895def7939 100644 --- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp +++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp @@ -8,13 +8,20 @@ #include "lldb/Target/InstrumentationRuntimeStopInfo.h" +#include "lldb/Core/Module.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Process.h" +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; +static bool IsStoppedInDarwinSanitizer(Thread &thread, Module &module) { + return module.GetFileSpec().GetFilename().GetStringRef().starts_with( + "libclang_rt."); +} + InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo( Thread &thread, std::string description, StructuredData::ObjectSP additional_data) @@ -34,3 +41,38 @@ InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData( return StopInfoSP( new InstrumentationRuntimeStopInfo(thread, description, additionalData)); } + +std::optional +InstrumentationRuntimeStopInfo::GetSuggestedStackFrameIndex( +bool inlined_stack) { + ThreadSP thread_sp = GetThread(); + if (!thread_sp) +return std::nullopt; + + // Defensive upper-bound of when we stop walking up the frames in + // case we somehow ended up looking at an infinite recursion. + constexpr size_t max_stack_depth = 128; + + // Start at parent frame. + size_t stack_idx = 1; + StackFrameSP most_relevant_frame_sp = + thread_sp->GetStackFrameAtIndex(stack_idx); + + while (most_relevant_frame_sp && stack_idx <= max_stack_depth) { +auto const &sc = +most_relevant_frame_sp->GetSymbolContext(lldb::eSymbolContextModule); + +if (!sc.module_sp) + return std::nullopt; + +// Found a frame outside of the sanitizer runtime libraries. +// That's the one we want to display. +if (!IsStoppedInDarwinSanitizer(*thread_sp, *sc.module_sp)) + return stack_idx; + +++stack_idx; +most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(stack_idx); + } + + return stack_idx; +} diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py b/lldb/test/API/functionalities/asan/TestMemoryHistory.py index 66f6e3e7502c1..a8f400de8ab08 100644 --- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py +++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py @@ -94,6 +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") + # do the same using SB API process = self.dbg.GetSelectedTarget().process val = ( @@ -218,6 +222,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") + # make sure the 'memory history' command still works even when we're # generating a report now self.expect( diff --git a/lldb/test/API/functionalities/asan/TestReportData.py b/lldb/test/API/functionalities/asan/TestReportData.py index dd6834a01b80c..ccc1b846d1607 100644 --- a/lldb/test/API/functionalities/asan/TestReportData.py +++ b/lldb/test/API/functionalities/asan/TestReportData.py @@ -67,6 +67,10 @@ def asan_tests(self, libsanitizers=False): lldb.eStopReasonInstrumentation,
[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)
https://github.com/medismailben deleted https://github.com/llvm/llvm-project/pull/158128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -959,6 +959,9 @@ CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize( if (type_name == "long double" && QualTypeMatchesBitSize(bit_size, ast, ast.LongDoubleTy)) return GetType(ast.LongDoubleTy); +if (type_name == "__bf16" && Michael137 wrote: This needs to be a separate PR https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 edited https://github.com/llvm/llvm-project/pull/156803 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 012680f - [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (#122265)
Author: Michael Buch Date: 2025-09-20T18:30:18+01:00 New Revision: 012680faf4c63a9bd432aa92fa0da97981793ac3 URL: https://github.com/llvm/llvm-project/commit/012680faf4c63a9bd432aa92fa0da97981793ac3 DIFF: https://github.com/llvm/llvm-project/commit/012680faf4c63a9bd432aa92fa0da97981793ac3.diff LOG: [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (#122265) When we generate the debug-info for a `VarDecl` we try to determine whether it was introduced as part of a structure binding (aka a "holding var"). If it was then we don't mark it as `artificial`. The heuristic to determine a holding var uses `IgnoreUnlessSpelledInSource` to unwrap the `VarDecl` initializer until we hit a `DeclRefExpr` that refers to a `Decomposition`. For "tuple-like decompositions", Clang will generate a call to a `template Foo get(Bar)` function that retrieves the `Ith` element from the tuple-like structure. If that function is a member function, we get an AST that looks as follows: ``` VarDecl implicit used z1 'std::tuple_element<0, B>::type &&' cinit `-ExprWithCleanups 'int' xvalue `-MaterializeTemporaryExpr 'int' xvalue extended by Var 0x11d110cf8 'z1' 'std::tuple_element<0, B>::type &&' `-CXXMemberCallExpr 'int' `-MemberExpr '' .get 0x11d104390 `-ImplicitCastExpr 'B' xvalue `-DeclRefExpr 'B' lvalue Decomposition 0x11d1100a8 '' 'B' ``` `IgnoreUnlessSpelledInSource` happily unwraps this down to the `DeclRefExpr`. However, when the `get` helper is a free function (which it is for `std::pair` in libc++ for example), then the AST is: ``` VarDecl col:16 implicit used k 'std::tuple_element<0, const std::tuple>::type &' cinit `-CallExpr 'const typename tuple_element<0UL, tuple>::type':'const int' lvalue adl |-ImplicitCastExpr 'const typename tuple_element<0UL, tuple>::type &(*)(const tuple &) noexcept' | `-DeclRefExpr 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' lvalue Function 0x1210262d8 'get' 'const typename tuple_element<0UL, tuple>::type &(const tuple &) noexcept' (FunctionTemplate 0x11d068088 'get') `-DeclRefExpr 'const std::tuple' lvalue Decomposition 0x121021518 '' 'const std::tuple &' ``` `IgnoreUnlessSpelledInSource` doesn't unwrap this `CallExpr`, so we incorrectly mark the binding as `artificial` in debug-info. This patch adjusts `IgnoreUnlessSpelledInSource` so it unwraps implicit `CallExpr`s. It's almost identical to how we treat implicit constructor calls (unfortunately the code can't quite be re-used because a `CXXConstructExpr` is-not a `CallExpr`, and we check `isElidable`, which doesn't exist for regular function calls. So I added a new `IgnoreImplicitCallSingleStep`). Fixes https://github.com/llvm/llvm-project/issues/122028 Added: Modified: clang/lib/AST/Expr.cpp clang/test/DebugInfo/CXX/structured-binding.cpp clang/unittests/AST/ASTTraverserTest.cpp lldb/test/API/lang/cpp/structured-binding/TestStructuredBinding.py lldb/test/API/lang/cpp/structured-binding/main.cpp Removed: diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index cdff160067fed..6ef7e54ec00b9 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2545,6 +2545,18 @@ Stmt *BlockExpr::getBody() { // Generic Expression Routines //===--===// +/// Helper to determine wether \c E is a CXXConstructExpr constructing +/// a DecompositionDecl. Used to skip Clang-generated calls to std::get +/// for structured bindings. +static bool IsDecompositionDeclRefExpr(const Expr *E) { + const auto *Unwrapped = E->IgnoreUnlessSpelledInSource(); + const auto *Ref = dyn_cast(Unwrapped); + if (!Ref) +return false; + + return isa_and_nonnull(Ref->getDecl()); +} + bool Expr::isReadIfDiscardedInCPlusPlus11() const { // In C++11, discarded-value expressions of a certain form are special, // according to [expr]p10: @@ -3159,10 +3171,39 @@ Expr *Expr::IgnoreUnlessSpelledInSource() { } return E; }; + + // Used when Clang generates calls to std::get for decomposing + // structured bindings. + auto IgnoreImplicitCallSingleStep = [](Expr *E) { +auto *C = dyn_cast(E); +if (!C) + return E; + +// Looking for calls to a std::get, which usually just takes +// 1 argument (i.e., the structure being decomposed). If it has +// more than 1 argument, the others need to be defaulted. +unsigned NumArgs = C->getNumArgs(); +if (NumArgs == 0 || (NumArgs > 1 && !isa(C->getArg(1 + return E; + +Expr *A = C->getArg(0); + +// This was spelled out in source. Don't ignore. +if (A->getSourceRange() != E->getSourceRange()) + return E; + +// If the argument refers to a DecompositionDecl construction, +// ignore it. +if (IsDecompositionDeclRefExpr(A)) + return
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)
@@ -1676,6 +1676,13 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl( class_template_specialization_decl->setInstantiationOf(class_template_decl); class_template_specialization_decl->setTemplateArgs( TemplateArgumentList::CreateCopy(ast, args)); + // Specialization exists, so return nullptr. + void *InsertPos = nullptr; + if (class_template_decl->findSpecialization(args, InsertPos)) +return nullptr; + // Add this specialization to the class template. tgs-sc wrote: Addressed https://github.com/llvm/llvm-project/pull/154123 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (PR #159542)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/159542 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [ELF][LLDB] Add an nvsass triple (PR #159459)
jhuber6 wrote: > @jhuber6 , something I care about for LLDB is being able to use different > disassemblers for ptx and sass. The unique situation here is that sass is not > part of LLVM code generation, and it seems that's why LLVM is unaware of > sass. LLVM can only generate ptx and folks rely on an nvidia proprietary > compiler to go from ptx to sass. But at runtime, LLDB sees both sass and > nvptx. > > I guess that a simpler patch that would exist only within LLDB is to add two > flavors to the nvptx architecture, one for nvptx and for sass in the ArchSpec > class in LLDB. I for sure can do that without doing major architectural > changes like this. LLVM's backend can only emit PTX, but as a toolchain we simply export that handling to `ptxas` as our assembler. The toolchain handles the binaries as the `nvptx64` triple because they correspond to ELF files created with `--target=nvptx64-nvidia-cuda`. You can generate SASS yourself with something similar to https://godbolt.org/z/ofWE6baPT. This is as far as I understand it at least, because as far as I'm aware, if a file has ELF magic and the `EM_CUDA` machine, it is SASS. https://github.com/llvm/llvm-project/pull/159459 ___ lldb-commits mailing list lldb-commits@lists.llvm.org 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 1/2] [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) >From f0181ef6fa9c2771514a05f0ff41459e196a876f Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 12 Sep 2025 12:01:34 +0100 Subject: [PATCH 2/2] [lldb] fix std::unordered_map formatter for const types. the type that is checked in isUnordered may be const qualified. --- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index ef49c4e6055a8..4b183a8d62e53 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -166,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 lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -foverflow-behavior-types -std=c++11 -ast-print %s -o - | FileCheck %s + +extern int __attribute__((overflow_behavior(no_wrap))) a; +extern int __attribute__((overflow_behavior(wrap))) b; + +// CHECK: extern __no_wrap int a; +// CHECK: extern __wrap int b; JustinStitt wrote: @mizvekov Let me know what you think about https://github.com/llvm/llvm-project/pull/148914/commits/0042195b7c9f06b70ffb24c8d76d1aaed6ee3dee. I use the full attribute spelling for AST type printer and I use a shorthand in diagnostics. I had to make a method `TryConvertOverflowBehaviorTypeToDiagnosticString()` to drop into `ConvertTypeToDiagnosticString()` which sort of matches how `ext_vector` types are handled to be pretty printed. round-trip test is all good. Im happy to iterate further too. let me know what you think. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Introduce Process::FixAnyAddressPreservingAuthentication (PR #159785)
felipepiovezan wrote: > I forgot all about #157435 so I just merged it and you'll have conflicts from > that. All good, I was just waiting for the PR bots to give me basic signal before tagging reviewers, but you beat me to it! :) > > You don't have to make the test work on Linux, `if Darwin` is fine and extend > it later. So I'm hoping this PR is a no-op for all other targets, as the only ABI plugin that implements this new method is the Darwin one. All other plugins just forward to the existing FixAnyAddress method, and preserve existing behavior. > In an ideal world, we would know that the target has memory tagging enabled > and only then leave the tag in. Though given that MTE implies TBI and we have > TBI everywhere we care about, we won't fault leaving in the tag bits on a > system without MTE. > > So what you've got is fine, assuming you have at least TBI on all systems > you're gonna use this with. > > I do wonder if this is gonna work for any AArch64 target, because there can > be targets where you need to remove PAC codes but you don't have top byte > ignore. Anyway I'll think about that. Right, I think this is where each plugin will need to some querying of process properties in order to know what the right thing to do is. A very reasonable thing to do here is to query the process on whether it was launched with memory tagging here. I've chosen not to do that in the apple plugin, mostly because I think we're missing some debugserver support atm for this kind of query. And because we use TBI everywhere AFAICT. In a very ideal world, I would love if we could not strip anything, ever. But this places some burden on codegen of the expression evaluator, for all languages and all ABIs. I don't think it's doable right now. > > FixAnyAddressPreservingAuthentication > > Authentication is an awkward word choice considering that it removes Pointer > Authentication Codes. > A more generic term might be "significant" bits, significant to what is what > people will wonder but at least it covers the bits significant to address > resolution, plus anything required to use the pointer in code. > "PreservingAccess" - though not every bit will be about access, > "PreservingPermissions" - these aren't really permissions as such, this is > not CHERI after all. Yeah, I'm not happy with the method name either. Let's see if others come up with something, but maybe "Significant" is ok. We could also just say "FixAddressForExpressionEvaluation", given how that's the only use case I know of today. https://github.com/llvm/llvm-project/pull/159785 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] refactor watchpoint functionality (PR #159807)
@@ -1093,22 +1097,30 @@ class CommandObjectWatchpointSetExpression : public CommandObjectRaw { } Status error; -WatchpointSP watch_sp = -target.CreateWatchpoint(addr, size, &compiler_type, watch_type, error); -if (watch_sp) { - watch_sp->SetWatchSpec(std::string(expr)); - Stream &output_stream = result.GetOutputStream(); - output_stream.Printf("Watchpoint created: "); - watch_sp->GetDescription(&output_stream, lldb::eDescriptionLevelFull); - output_stream.EOL(); - result.SetStatus(eReturnStatusSuccessFinishResult); -} else { - result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 - ", size=%" PRIu64 ").\n", - addr, (uint64_t)size); - if (error.AsCString(nullptr)) -result.AppendError(error.AsCString()); +WatchpointSP watch_sp; +watch_sp = dlav-sc wrote: If you are asking about `WatchpointSP watch_sp;`, then I myself don't know why this line is placed separately :) It seems I changed this lines several times. Fixed it. https://github.com/llvm/llvm-project/pull/159807 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] refactor watchpoint functionality (PR #159807)
dlav-sc wrote: > Could you explain in broad strokes the theme of the refactoring here? This is > a big PR to go in without a summary of what to expect. **I StopInfo.cpp/Watchpoint.cpp ==** Prior to this patch, all logic for evaluating a watchpoint hit on the host side was implemented in the `StopInfoWatchpoint::PerformAction` function. Specifically, checks for the watchpoint condition https://github.com/llvm/llvm-project/pull/159807/files#diff-08d3a818bf87a1dc1d1558dec9570f8b4f27fb0a1bd0a8d37c74b29d43a8b92aL979-L1026, its ignore count https://github.com/llvm/llvm-project/pull/159807/files#diff-08d3a818bf87a1dc1d1558dec9570f8b4f27fb0a1bd0a8d37c74b29d43a8b92aL1056-L1058, and an additional check for watchpoints of the modify type https://github.com/llvm/llvm-project/pull/159807/files#diff-08d3a818bf87a1dc1d1558dec9570f8b4f27fb0a1bd0a8d37c74b29d43a8b92aL1056-L1058 were implemented within this function. These checks are also necessary for software watchpoints. However, these checks are not performed within the `StopInfoWatchpoint::PerformAction` function but are instead handled by a special `ThreadPlan`, which is not part of this patch. The reason is the difference in how hardware and software watchpoints are handled. In the case of a hardware watchpoint, we enter `StopInfoWatchpoint::PerformAction` after the LLDB client sets the `WatchpointStopReason`, which itself happens after the `lldb-server` reports a watchpoint hit. In contrast, for a software watchpoint, all the logic is implemented on the client side; the `lldb-server` knows nothing about them. A special `ThreadPlan` is responsible for software watchpoints checks. When this `ThreadPlan` detects a hit, it sets the `WatchpointStopReason`, and only after that do we enter the `StopInfoWatchpoint::PerformAction` function. Furthermore, there were software design issues. For example, the `Watchpoint` class had `StopInfoWatchpoint` as a `friend` https://github.com/llvm/llvm-project/pull/159807/files#diff-19e75401810e5613449c129f4525becae9b6ea148f9487bf8f68aa657b6277aeL194 because `StopInfoWatchpoint::PerformAction` needed to modify the private `m_hit_counter` field of the `Watchpoint` class. These reasons led me to the idea that the watchpoint evaluation checks on the client side should be implemented directly within the `Watchpoint` class. Please note the `Watchpoint::WatchedValueReportable` function, into which a large part of the logic from `StopInfoWatchpoint::PerformAction` was moved. This includes the watchpoint condition check (which was refactored into a separate function `CheckWatchpointCondition` https://github.com/llvm/llvm-project/pull/159807/files#diff-5496aa2a96cec82fa4af70a90383248937efbf2cea6d19f768ecf8163b1f45c8R268 ), the ignore count check https://github.com/llvm/llvm-project/pull/159807/files#diff-5496aa2a96cec82fa4af70a90383248937efbf2cea6d19f768ecf8163b1f45c8R268, the software watchpoint check https://github.com/llvm/llvm-project/pull/159807/files#diff-5496aa2a96cec82fa4af70a90383248937efbf2cea6d19f768ecf8163b1f45c8R332-R340, and an additional check for hardware modify watchpoints https://github.com/llvm/llvm-project/pull/159807/files#diff-5496aa2a96cec82fa4af70a90383248937efbf2cea6d19f768ecf8163b1f45c8R332-R340. This allowed me to eliminate the need for `StopInfoWatchpoint` to be a `friend` and to reuse the logic for checking software watchpoints in the corresponding `ThreadPlan`. Note: I simply moved the `WatchpointSentry` https://github.com/llvm/llvm-project/pull/159807/files#diff-5496aa2a96cec82fa4af70a90383248937efbf2cea6d19f768ecf8163b1f45c8R332-R340 class entirely from `StopInfo.cpp` to `Watchpoint.h`, as I also need this class for software watchpoint checks. **P.S.** Furthermore, I believe that checking the condition of a hardware watchpoint and its ignore count within `StopInfoWatchpoint::PerformAction` is, in general, a bad idea. Conceptually, setting the `WatchpointStopReason` should occur **after** all checks have been completed, specifically the checks for the watchpoint condition and its ignore count. I don't remember all the intricacies anymore, but I encountered some very rare and exceptional bugs where a watchpoint with an ignore count would break the operation of `step/next`, leading to a situation where the debugger wouldn't regain control after the `step/next` command. These are very subtle issues; the stars really have to align to catch something like that. https://github.com/llvm/llvm-project/pull/159807 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when lldb-dap binary has changed (PR #159797)
@@ -83,6 +88,18 @@ export class LLDBDapServer implements vscode.Disposable { }); this.serverProcess = process; this.serverSpawnInfo = this.getSpawnInfo(dapPath, dapArgs, options?.env); + this.serverFileChanged = false; walter-erquinigo wrote: try using https://www.npmjs.com/package/chokidar https://github.com/llvm/llvm-project/pull/159797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (PR #122265)
@@ -2544,6 +2544,19 @@ Stmt *BlockExpr::getBody() { //===--===// // Generic Expression Routines //===--===// +namespace { +/// Helper to determine wether \c E is a CXXConstructExpr constructing +/// a DecompositionDecl. Used to skip Clang-generated calls to std::get +/// for structured bindings. +bool IsDecompositionDeclRefExpr(const Expr *E) { + const Expr *Unrwapped = E->IgnoreUnlessSpelledInSource(); cor3ntin wrote: ```suggestion const Expr *Unwrapped = E->IgnoreUnlessSpelledInSource(); ``` https://github.com/llvm/llvm-project/pull/122265 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits