[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138031 >From 63db109cdc1177b469ca695b504492623d268d13 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 14:15:39 -0700 Subject: [PATCH] [lldb][RPC] Upstream lldb-rpc-gen tool This commit upstreams the `lldb-rpc-gen` tool, a ClangTool that generates the LLDB RPC client and server interfaces. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- lldb/cmake/modules/LLDBConfig.cmake | 2 + lldb/test/CMakeLists.txt | 3 +- .../Tests/CheckRPCGenToolByproducts.test | 11 + lldb/test/Shell/RPC/Generator/lit.local.cfg | 3 + lldb/test/Shell/helper/toolchain.py | 8 + lldb/test/Shell/lit.site.cfg.py.in| 1 + lldb/tools/CMakeLists.txt | 3 + lldb/tools/lldb-rpc/CMakeLists.txt| 22 + lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake | 58 ++ lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake | 101 .../lldb-rpc/lldb-rpc-gen/CMakeLists.txt | 21 + .../tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp | 501 ++ lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h | 108 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp| 341 14 files changed, 1182 insertions(+), 1 deletion(-) create mode 100644 lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test create mode 100644 lldb/test/Shell/RPC/Generator/lit.local.cfg create mode 100644 lldb/tools/lldb-rpc/CMakeLists.txt create mode 100644 lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake create mode 100644 lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/CMakeLists.txt create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 37b823feb584b..069b5412d03f8 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -322,4 +322,6 @@ else() set(LLDB_CAN_USE_DEBUGSERVER OFF) endif() +set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "") + include(LLDBGenerateConfig) diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 6449ac5a9247f..45f68cf4aeb67 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -249,7 +249,8 @@ llvm_canonicalize_cmake_booleans( LLDB_TEST_SHELL_DISABLE_REMOTE LLDB_TOOL_LLDB_SERVER_BUILD LLDB_USE_SYSTEM_DEBUGSERVER - LLDB_IS_64_BITS) + LLDB_IS_64_BITS + LLDB_BUILD_LLDBRPC) # Configure the individual test suites. add_subdirectory(API) diff --git a/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test b/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test new file mode 100644 index 0..be3eefc69b20a --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test @@ -0,0 +1,11 @@ +# For this test, we're not checking any specific output from a generated file, +# but we do need a file to pass into lldb-rpc-gen so use SBAddress.h from source. +RUN: %lldb-rpc-gen --output-dir=%t %S/../../../../../include/lldb/API/SBAddress.h + +RUN: ls %t | FileCheck %s + +# We're just making sure that the tool emits the class names, +# methods and skipped methods file in the output directory. +CHECK: SBAPI.def +CHECK: SBClasses.def +CHECK: SkippedMethods.txt diff --git a/lldb/test/Shell/RPC/Generator/lit.local.cfg b/lldb/test/Shell/RPC/Generator/lit.local.cfg new file mode 100644 index 0..db9494781c00c --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/lit.local.cfg @@ -0,0 +1,3 @@ +# All tests for the tool need lldb-rpc-gen to be built. +if not config.lldb_has_lldbrpc: + config.unsupported = True diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index 42968128f2702..95437dba55b7d 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -156,6 +156,14 @@ def use_lldb_substitutions(config): extra_args=["platform"], unresolved="ignore", ), +ToolSubst( +"%lldb-rpc-gen", +command=FindTool("lldb-rpc-gen"), +extra_args=[ +'--extra-arg="-resource-dir=' + config.clang_resource_dir + '"' +], +unresolved="ignore", +), "lldb-test", "lldb-dap", ToolSubst( diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in index 5be5359217769..0e15c90237ccc 100644 --- a/lldb/test/Shell/lit.site.cfg.py.in +++ b/lldb/test/Shell/lit.site.cfg.py.in @@ -33,6 +33,7 @@ config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@" config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@ config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@ config.llvm_use_sanitizer
[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/146578 >From a689f4c68949b7be48562295e8f2105e880a5b30 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 1 Jul 2025 10:38:22 -0700 Subject: [PATCH] [lldb] Take a sledgehammer approach to resizing the statusline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. --- lldb/include/lldb/Core/Statusline.h | 4 +-- lldb/source/Core/Statusline.cpp | 46 - 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lldb/include/lldb/Core/Statusline.h b/lldb/include/lldb/Core/Statusline.h index 521b9f2526f6b..6bda153f822d2 100644 --- a/lldb/include/lldb/Core/Statusline.h +++ b/lldb/include/lldb/Core/Statusline.h @@ -36,12 +36,10 @@ class Statusline { /// Draw the statusline with the given text. void Draw(std::string msg); - /// Update terminal dimensions. - void UpdateTerminalProperties(); - enum ScrollWindowMode { EnableStatusline, DisableStatusline, +ResizeStatusline, }; /// Set the scroll window for the given mode. diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp index 8ec57c9fa5bac..32f69db5a48f3 100644 --- a/lldb/source/Core/Statusline.cpp +++ b/lldb/source/Core/Statusline.cpp @@ -24,6 +24,7 @@ #define ANSI_SAVE_CURSOR ESCAPE "7" #define ANSI_RESTORE_CURSOR ESCAPE "8" #define ANSI_CLEAR_BELOW ESCAPE "[J" +#define ANSI_CLEAR_SCREEN ESCAPE "[2J" #define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur" #define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f" #define ANSI_REVERSE_VIDEO ESCAPE "[7m" @@ -41,10 +42,12 @@ Statusline::Statusline(Debugger &debugger) Statusline::~Statusline() { Disable(); } void Statusline::TerminalSizeChanged() { - UpdateTerminalProperties(); + m_terminal_width = m_debugger.GetTerminalWidth(); + m_terminal_height = m_debugger.GetTerminalHeight(); - // This definitely isn't signal safe, but the best we can do, until we - // have proper signal-catching thread. + UpdateScrollWindow(ResizeStatusline); + + // Draw the old statusline. Redraw(/*update=*/false); } @@ -85,13 +88,6 @@ void Statusline::Draw(std::string str) { locked_stream << ANSI_RESTORE_CURSOR; } -void Statusline::UpdateTerminalProperties() { - UpdateScrollWindow(DisableStatusline); - m_terminal_width = m_debugger.GetTerminalWidth(); - m_terminal_height = m_debugger.GetTerminalHeight(); - UpdateScrollWindow(EnableStatusline); -} - void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { assert(m_terminal_width != 0 && m_terminal_height != 0); @@ -99,24 +95,32 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { if (!stream_sp) return; - const unsigned scroll_height = - (mode == DisableStatusline) ? m_terminal_height : m_terminal_height - 1; - + const unsigned reduced_scroll_window = m_terminal_height - 1; LockedStreamFile locked_stream = stream_sp->Lock(); - if (mode == EnableStatusline) { + switch (mode) { + case EnableStatusline: // Move everything on the screen up. locked_stream << '\n'; locked_stream.Printf(ANSI_UP_ROWS, 1); - } - - locked_stream << ANSI_SAVE_CURSOR; - locked_stream.Printf(ANSI_SET_SCROLL_ROWS, scroll_height); - locked_stream << ANSI_RESTORE_CURSOR; - - if (mode == DisableStatusline) { +// Reduce the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +locked_stream << ANSI_RESTORE_CURSOR; +break; + case DisableStatusline: +// Reset the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, 0); +locked_stream << ANSI_RESTORE_CURSOR; // Clear the screen below to hide the old statusline. locked_stream << ANSI_CLEAR_BELOW; +break; + case ResizeStatusline: +// Clear the screen and update the scroll window. +locked_stream << ANSI_CLEAR_SCREEN; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +break; } m_debugger.RefreshIOHandler(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/c
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
@@ -463,6 +463,27 @@ class Triple { const std::string &str() const { return Data; } + /// Return the triple string but only keep the first \p N components. + /// + /// The returned string will preserve the first \p N components exactly the + /// same as the original (including the leading "-" and the value, empty or + /// not). + /// + /// E.g. Triple("arm64-apple-ios").str(5) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(5) == "arm64-apple-ios--" + /// E.g. Triple("arm64-apple-ios--").str(4) == "arm64-apple-ios-" + /// E.g. Triple("arm64-apple-ios--").str(3) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(2) == "arm64-apple" + /// E.g. Triple("arm64-apple-ios--").str(1) == "arm64" + /// E.g. Triple("arm64-apple-ios--").str(0) == "" + /// + /// This method does not normalize any triple strings. Clients that need to + /// handle the non-canonical triples that users often specify should use the + /// normalize method. + /// + /// \returns the (shorterned) triple string. + StringRef str(size_t N) const; royitaqi wrote: > For the use cases in this PR we could do > triple.normalize(CanonicalForm::FOUR_IDENT) @clayborg / @jasonmolenda: Do you see a downside of what @dmpots suggested? @dmpots had a good point in offline discussion that these are for display in LLDB, so it maybe preferred that they are normalized. I agree with that, but I'm just not sure if that will change thing that you guys end up not like (similar to how I initially made the objfmt component to show up in the triple string). https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/146578 >From a57532d99ec1b46e76a388e1b2baa1f737838f62 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 1 Jul 2025 10:38:22 -0700 Subject: [PATCH] [lldb] Take a sledgehammer approach to resizing the statusline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. --- lldb/include/lldb/Core/Statusline.h | 4 +-- lldb/source/Core/Statusline.cpp | 46 +++- lldb/source/Host/common/Editline.cpp | 2 +- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lldb/include/lldb/Core/Statusline.h b/lldb/include/lldb/Core/Statusline.h index 521b9f2526f6b..6bda153f822d2 100644 --- a/lldb/include/lldb/Core/Statusline.h +++ b/lldb/include/lldb/Core/Statusline.h @@ -36,12 +36,10 @@ class Statusline { /// Draw the statusline with the given text. void Draw(std::string msg); - /// Update terminal dimensions. - void UpdateTerminalProperties(); - enum ScrollWindowMode { EnableStatusline, DisableStatusline, +ResizeStatusline, }; /// Set the scroll window for the given mode. diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp index 8ec57c9fa5bac..32f69db5a48f3 100644 --- a/lldb/source/Core/Statusline.cpp +++ b/lldb/source/Core/Statusline.cpp @@ -24,6 +24,7 @@ #define ANSI_SAVE_CURSOR ESCAPE "7" #define ANSI_RESTORE_CURSOR ESCAPE "8" #define ANSI_CLEAR_BELOW ESCAPE "[J" +#define ANSI_CLEAR_SCREEN ESCAPE "[2J" #define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur" #define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f" #define ANSI_REVERSE_VIDEO ESCAPE "[7m" @@ -41,10 +42,12 @@ Statusline::Statusline(Debugger &debugger) Statusline::~Statusline() { Disable(); } void Statusline::TerminalSizeChanged() { - UpdateTerminalProperties(); + m_terminal_width = m_debugger.GetTerminalWidth(); + m_terminal_height = m_debugger.GetTerminalHeight(); - // This definitely isn't signal safe, but the best we can do, until we - // have proper signal-catching thread. + UpdateScrollWindow(ResizeStatusline); + + // Draw the old statusline. Redraw(/*update=*/false); } @@ -85,13 +88,6 @@ void Statusline::Draw(std::string str) { locked_stream << ANSI_RESTORE_CURSOR; } -void Statusline::UpdateTerminalProperties() { - UpdateScrollWindow(DisableStatusline); - m_terminal_width = m_debugger.GetTerminalWidth(); - m_terminal_height = m_debugger.GetTerminalHeight(); - UpdateScrollWindow(EnableStatusline); -} - void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { assert(m_terminal_width != 0 && m_terminal_height != 0); @@ -99,24 +95,32 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { if (!stream_sp) return; - const unsigned scroll_height = - (mode == DisableStatusline) ? m_terminal_height : m_terminal_height - 1; - + const unsigned reduced_scroll_window = m_terminal_height - 1; LockedStreamFile locked_stream = stream_sp->Lock(); - if (mode == EnableStatusline) { + switch (mode) { + case EnableStatusline: // Move everything on the screen up. locked_stream << '\n'; locked_stream.Printf(ANSI_UP_ROWS, 1); - } - - locked_stream << ANSI_SAVE_CURSOR; - locked_stream.Printf(ANSI_SET_SCROLL_ROWS, scroll_height); - locked_stream << ANSI_RESTORE_CURSOR; - - if (mode == DisableStatusline) { +// Reduce the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +locked_stream << ANSI_RESTORE_CURSOR; +break; + case DisableStatusline: +// Reset the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, 0); +locked_stream << ANSI_RESTORE_CURSOR; // Clear the screen below to hide the old statusline. locked_stream << ANSI_CLEAR_BELOW; +break; + case ResizeStatusline: +// Clear the screen and update the scroll window. +locked_stream << ANSI_CLEAR_SCREEN; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +break; } m_debugger.RefreshIOHandler(); diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Edi
[Lldb-commits] [lldb] 3edae0d - [lldb] Use EL_REFRESH to refresh Editline
Author: Jonas Devlieghere Date: 2025-07-01T11:08:11-07:00 New Revision: 3edae0d5e5b69a4613a0dfce32ef56eb3ffec2fb URL: https://github.com/llvm/llvm-project/commit/3edae0d5e5b69a4613a0dfce32ef56eb3ffec2fb DIFF: https://github.com/llvm/llvm-project/commit/3edae0d5e5b69a4613a0dfce32ef56eb3ffec2fb.diff LOG: [lldb] Use EL_REFRESH to refresh Editline Letting Editline refresh itself is more robust and ensures that the current text is redraw if it was accidentally cleared. In that scenario MoveCursor would only fix up the cursor position. Added: Modified: lldb/source/Host/common/Editline.cpp lldb/test/API/functionalities/statusline/TestStatusline.py Removed: diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 4720d3b4c29ac..5ed30fbb231d8 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -1713,7 +1713,7 @@ void Editline::Refresh() { if (!m_editline || !m_output_stream_sp) return; LockedStreamFile locked_stream = m_output_stream_sp->Lock(); - MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingCursor); + el_set(m_editline, EL_REFRESH); } bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) { diff --git a/lldb/test/API/functionalities/statusline/TestStatusline.py b/lldb/test/API/functionalities/statusline/TestStatusline.py index e2c2ed548ed0e..ca2f10820d56d 100644 --- a/lldb/test/API/functionalities/statusline/TestStatusline.py +++ b/lldb/test/API/functionalities/statusline/TestStatusline.py @@ -114,8 +114,6 @@ def test_resize(self): self.resize() self.expect("set set show-statusline true", ["no target"]) self.resize(20, 60) -# Check for the newline followed by the escape code to move the cursor -# up one line. -self.child.expect(re.escape("\n\x1b[1A")) -# Check for the escape code to move the cursor back to column 8. -self.child.expect(re.escape("\x1b[8G")) +# Check for the escape code to resize the scroll window, followed by +# the prompt. +self.child.expect(re.escape("\x1b[1;19r\x1b8(lldb)")) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] When running OS Plugins from dSYM's, make sure start state is correct (PR #146441)
@@ -9,6 +9,7 @@ #ifndef LLDB_HOST_HOSTTHREAD_H #define LLDB_HOST_HOSTTHREAD_H +#include "lldb/Host/HostNativeThreadBase.h" #include "lldb/Host/HostNativeThreadForward.h" JDevlieghere wrote: Guess this one can go now? Or we implement `HasThread` out-of-line. https://github.com/llvm/llvm-project/pull/146441 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] When running OS Plugins from dSYM's, make sure start state is correct (PR #146441)
@@ -3144,16 +3144,17 @@ void Process::CompleteAttach() { } } - if (!m_os_up) { + if (!m_os_up) LoadOperatingSystemPlugin(false); -if (m_os_up) { - // Somebody might have gotten threads before now, but we need to force the - // update after we've loaded the OperatingSystem plugin or it won't get a - // chance to process the threads. - m_thread_list.Clear(); - UpdateThreadListIfNeeded(); -} + + if (m_os_up) { JDevlieghere wrote: My first instinct here was "should this be an else" before I realized that `LoadOperatingSystemPlugin` probably initializes `m_os_up`. Might be wroth a comment. https://github.com/llvm/llvm-project/pull/146441 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] When running OS Plugins from dSYM's, make sure start state is correct (PR #146441)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/146441 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -239,122 +240,24 @@ VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { bool lldb_private::formatters::LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = - valobj.IsPointerOrReferenceType() - ? valobj.GetPointerValue() - : valobj.GetAddressOf(scalar_is_load_addr); - if (addr_of_string != LLDB_INVALID_ADDRESS) { -switch (addr_type) { -case eAddressTypeLoad: { - ProcessSP process_sp(valobj.GetProcessSP()); - if (!process_sp) -return false; - - StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); - Status error; - lldb::addr_t addr_of_data = - process_sp->ReadPointerFromMemory(addr_of_string, error); - if (error.Fail() || addr_of_data == 0 || - addr_of_data == LLDB_INVALID_ADDRESS) -return false; - options.SetLocation(addr_of_data); - options.SetTargetSP(valobj.GetTargetSP()); - options.SetStream(&stream); - options.SetNeedsZeroTermination(false); - options.SetBinaryZeroIsTerminator(true); - lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory( - addr_of_string + process_sp->GetAddressByteSize(), error); - if (error.Fail()) -return false; - options.SetSourceSize(size_of_data); - options.SetHasSourceSize(true); - - if (!StringPrinter::ReadStringAndDumpToStream< - StringPrinter::StringElementType::UTF8>(options)) { -stream.Printf("Summary Unavailable"); -return true; - } else -return true; -} break; -case eAddressTypeHost: - break; -case eAddressTypeInvalid: -case eAddressTypeFile: - break; -} - } - return false; + ValueObjectSP ptr = valobj.GetChildAtNamePath({"_M_dataplus", "_M_p"}); + if (!ptr) +return false; + + stream << ptr->GetSummaryAsCString(); Nerixyz wrote: Opened https://github.com/llvm/llvm-project/pull/146562. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] When running OS Plugins from dSYM's, make sure start state is correct (PR #146441)
https://github.com/JDevlieghere approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/146441 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to make a breakpoint a hardware breakpoint (PR #146602)
jasonmolenda wrote: ah sure enough, ``` } else if (packet_cmd == 'z') { // remove switch (break_type) { case '0': // remove software breakpoint case '1': // remove hardware breakpoint if (DNBBreakpointClear(pid, addr)) { ``` there's no requirement to be correct about which packet you use to clear an existing breakpoint, with debugserver lldb-server passes whether a hardware or software breakpoint is being requested to be cleared, ``` if (want_breakpoint) { // Try to clear the breakpoint. const Status error = m_current_process->RemoveBreakpoint(addr, want_hardware); ``` and ``` Status NativeProcessLinux::RemoveBreakpoint(lldb::addr_t addr, bool hardware) { if (hardware) return RemoveHardwareBreakpoint(addr); else return NativeProcessProtocol::RemoveBreakpoint(addr); } ``` good chance this won't work on linux. https://github.com/llvm/llvm-project/pull/146602 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable (PR #146557)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/146557 >From 06ccadcfa44bbca9367eeff94a44aa6cfec2873a Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 1 Jul 2025 16:50:01 +0100 Subject: [PATCH 1/2] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable Follow-up to https://github.com/llvm/llvm-project/pull/145645#discussion_r2174948997 There's no need for this variable to be declared at the function-level. We reset it in all the cases where it's used anyway. --- .../SymbolFile/DWARF/DWARFFormValue.cpp | 24 +-- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 2e98e3c33acaf..6a657086608b8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -36,7 +36,6 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, bool indirect = false; bool is_block = false; m_value.data = nullptr; - uint8_t ref_addr_size; // Read the value for the form into value and follow and DW_FORM_indirect // instances we run into do { @@ -76,11 +75,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, break; case DW_FORM_strp: case DW_FORM_line_strp: -case DW_FORM_sec_offset: +case DW_FORM_sec_offset: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_addrx1: case DW_FORM_strx1: case DW_FORM_ref1: @@ -119,11 +118,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, case DW_FORM_GNU_addr_index: m_value.uval = data.GetULEB128(offset_ptr); break; -case DW_FORM_ref_addr: +case DW_FORM_ref_addr: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_indirect: m_form = static_cast(data.GetULEB128(offset_ptr)); indirect = true; @@ -208,7 +207,6 @@ bool DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, const DWARFUnit *unit) { - uint8_t ref_addr_size; switch (form) { // Blocks if inlined data that have a length field and the data bytes inlined // in the .debug_info @@ -244,12 +242,13 @@ bool DWARFFormValue::SkipValue(dw_form_t form, *offset_ptr += DWARFUnit::GetAddressByteSize(unit); return true; - case DW_FORM_ref_addr: + case DW_FORM_ref_addr: { assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will // get this wrong -ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); +uint8_t ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); *offset_ptr += ref_addr_size; return true; + } // 0 bytes values (implied from DW_FORM) case DW_FORM_flag_present: @@ -282,11 +281,12 @@ bool DWARFFormValue::SkipValue(dw_form_t form, // 32 bit for DWARF 32, 64 for DWARF 64 case DW_FORM_sec_offset: case DW_FORM_strp: -case DW_FORM_line_strp: +case DW_FORM_line_strp: { assert(unit); - ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); *offset_ptr += ref_addr_size; return true; +} // 4 byte values case DW_FORM_addrx4: >From 5c6307eacbe104f9294446c43022eb43647190eb Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 1 Jul 2025 16:53:04 +0100 Subject: [PATCH 2/2] fixup! no need for local variable at all --- .../SymbolFile/DWARF/DWARFFormValue.cpp | 28 --- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 6a657086608b8..767cda634f973 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -75,11 +75,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, break; case DW_FORM_strp: case DW_FORM_line_strp: -case DW_FORM_sec_offset: { +case DW_FORM_sec_offset: assert(m_unit); - uint8_t ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); - m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); -} break; + m_value.uval = data.GetMaxU64( + offset_p
[Lldb-commits] [lldb] 0c124be - [lldb][NFC] Inline ResolveSDKPathFromDebugInfo in one of its call site (#146062)
Author: Charles Zablit Date: 2025-07-01T16:23:23+01:00 New Revision: 0c124be33f8d2ed6ede41bcd3d8f0ca115921ef3 URL: https://github.com/llvm/llvm-project/commit/0c124be33f8d2ed6ede41bcd3d8f0ca115921ef3 DIFF: https://github.com/llvm/llvm-project/commit/0c124be33f8d2ed6ede41bcd3d8f0ca115921ef3.diff LOG: [lldb][NFC] Inline ResolveSDKPathFromDebugInfo in one of its call site (#146062) This patch is part of an effort to remove the `ResolveSDKPathFromDebugInfo` method, and more specifically the variant which takes a Module as argument. See the following PR for a follow up on what to do: - https://github.com/llvm/llvm-project/pull/144913. - Co-authored-by: Michael Buch Added: Modified: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Removed: diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 262a7dc731713..1db7bc78013d7 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1030,6 +1030,40 @@ PlatformDarwin::ExtractAppSpecificInfo(Process &process) { return dict_sp; } +static llvm::Expected +ResolveSDKPathFromDebugInfo(lldb_private::Target *target) { + + ModuleSP exe_module_sp = target->GetExecutableModule(); + if (!exe_module_sp) +return llvm::createStringError("Failed to get module from target"); + + SymbolFile *sym_file = exe_module_sp->GetSymbolFile(); + if (!sym_file) +return llvm::createStringError("Failed to get symbol file from module"); + + XcodeSDK merged_sdk; + for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) { +if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) { + auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp); + merged_sdk.Merge(cu_sdk); +} + } + + // TODO: The result of this loop is almost equivalent to deriving the SDK + // from the target triple, which would be a lot cheaper. + FileSpec sdk_path = merged_sdk.GetSysroot(); + if (FileSystem::Instance().Exists(sdk_path)) { +return sdk_path; + } + auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk}); + if (!path_or_err) +return llvm::createStringError( +llvm::formatv("Failed to resolve SDK path: {0}", + llvm::toString(path_or_err.takeError(; + + return FileSpec(*path_or_err); +} + void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( Target *target, std::vector &options, XcodeSDK::Type sdk_type) { const std::vector apple_arguments = { @@ -1129,15 +1163,13 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( FileSpec sysroot_spec; if (target) { -if (ModuleSP exe_module_sp = target->GetExecutableModule()) { - auto path_or_err = ResolveSDKPathFromDebugInfo(*exe_module_sp); - if (path_or_err) { -sysroot_spec = FileSpec(*path_or_err); - } else { -LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host), - path_or_err.takeError(), - "Failed to resolve SDK path: {0}"); - } +auto sysroot_spec_or_err = ::ResolveSDKPathFromDebugInfo(target); +if (!sysroot_spec_or_err) { + LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host), + sysroot_spec_or_err.takeError(), + "Failed to resolve sysroot: {0}"); +} else { + sysroot_spec = *sysroot_spec_or_err; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
@@ -276,7 +276,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), ashgti wrote: I'll fix that, I was thought that `file_t` was the more universal type to use for these handles. https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 98e6d5c - [lldb] Fix warnings
Author: Kazu Hirata Date: 2025-07-01T10:41:07-07:00 New Revision: 98e6d5cd47d4db020a1406032f96fd5cdfc56563 URL: https://github.com/llvm/llvm-project/commit/98e6d5cd47d4db020a1406032f96fd5cdfc56563 DIFF: https://github.com/llvm/llvm-project/commit/98e6d5cd47d4db020a1406032f96fd5cdfc56563.diff LOG: [lldb] Fix warnings This patch fixes: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:279:15: error: format specifies type 'unsigned long' but the argument has type 'file_t' (aka 'int') [-Werror,-Wformat] lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:383:15: error: format specifies type 'unsigned long' but the argument has type 'file_t' (aka 'int') [-Werror,-Wformat] Added: Modified: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp Removed: diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 4fda978c092b3..44a3ed2e59d5f 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -276,7 +276,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), static_cast(dst), static_cast(dst_len), static_cast(bytes_read), error.AsCString()); } @@ -380,7 +380,7 @@ size_t ConnectionFileDescriptor::Write(const void *src, size_t src_len, "%p ConnectionFileDescriptor::Write(fd = %" PRIu64 ", src = %p, src_len = %" PRIu64 ") => %" PRIu64 " (error = %s)", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), static_cast(src), static_cast(src_len), static_cast(bytes_sent), error.AsCString()); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Prevent using an implicit `step-in`. (PR #143644)
jimingham wrote: Cool. I wasn't so much commenting on this patch as noting in general that you can't know from an address where lldb's stepping machinery thinks the current frame is as that's history dependent. https://github.com/llvm/llvm-project/pull/143644 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)
@@ -0,0 +1,6 @@ +# All tests for the tool need lldb-rpc-gen to be built. +# As far as I can see, you need to check all possible ways to +# say "no" in a CMake option. +negation_options = ["OFF", "NO", 0] +if not config.lldb_has_lldbrpc or config.lldb_has_lldbrpc in negation_options: chelcassanova wrote: TIL, just updated the test to change this, thanks! https://github.com/llvm/llvm-project/pull/138031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -1372,6 +1373,37 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "${var.__y_} ${var.__m_} ${var.__wdl_}"))); } +static void RegisterStdStringSummaryProvider( +const lldb::TypeCategoryImplSP &category_sp, llvm::StringRef string_ty, +llvm::StringRef char_ty, lldb::TypeSummaryImplSP summary_sp) { + auto makeSpecifier = [](llvm::StringRef name) { +return std::make_shared( +name, eFormatterMatchExact); + }; + + category_sp->AddTypeSummary(makeSpecifier(string_ty), summary_sp); + + // std::basic_string + category_sp->AddTypeSummary( + makeSpecifier(llvm::formatv("std::basic_string<{}>", char_ty).str()), + summary_sp); + // std::basic_string,std::allocator > + category_sp->AddTypeSummary( + makeSpecifier(llvm::formatv("std::basic_string<{0},std::char_traits<{0}>," + "std::allocator<{0}> >", + char_ty) +.str()), + summary_sp); Michael137 wrote: I see. 13 years is a long enough support window for whatever it was used for and given it's untested I'm almost inclined to remove it tbh. But we can do it in a separate PR. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
@@ -463,6 +463,27 @@ class Triple { const std::string &str() const { return Data; } + /// Return the triple string but only keep the first \p N components. + /// + /// The returned string will preserve the first \p N components exactly the + /// same as the original (including the leading "-" and the value, empty or + /// not). + /// + /// E.g. Triple("arm64-apple-ios").str(5) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(5) == "arm64-apple-ios--" + /// E.g. Triple("arm64-apple-ios--").str(4) == "arm64-apple-ios-" + /// E.g. Triple("arm64-apple-ios--").str(3) == "arm64-apple-ios" + /// E.g. Triple("arm64-apple-ios--").str(2) == "arm64-apple" + /// E.g. Triple("arm64-apple-ios--").str(1) == "arm64" + /// E.g. Triple("arm64-apple-ios--").str(0) == "" + /// + /// This method does not normalize any triple strings. Clients that need to + /// handle the non-canonical triples that users often specify should use the + /// normalize method. + /// + /// \returns the (shorterned) triple string. + StringRef str(size_t N) const; royitaqi wrote: The difference between this new method `str(N)` and `normalize()` is that the former won't canonicalize the triple string and the latter will. >From method doc of `normalize()`: > In particular, it handles the common case in which otherwise valid components > are in the wrong order. So I think `str(N)` can be seen as an alternative to `normalize()` where the triple string isn't canonicalized. https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][framework] Copy framework files correctly (PR #146425)
bulbazord wrote: > > If framework-header-fix.py already puts the header in the framework, why > > might we want to wholesale copy it into the framework beforehand? > > I don't think the script and build infrastructure was actually putting > everything in the framework itself, just the staging area in the build dir. > Copying the files into the framework was a step in the original config for > this CMake module before I modified it to use the Python script so I think it > might have to be added back in here. My understanding was the `-o ${output_header}` here should place it in the framework when `${output_header}` is the right directory. ``` add_custom_command(TARGET liblldb POST_BUILD COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i ${input_header} -o ${output_header} -p ${unifdef_EXECUTABLE} USWIG COMMENT "LLDB.framework: Fix up and copy framework headers" ) ``` https://github.com/llvm/llvm-project/pull/146425 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [lldb] Fix object format in the Triple of Mach-O files (approach 4) (PR #145157)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/145157 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][NFC][MachO] Clean up LC_THREAD reading code, remove i386 corefile (PR #146480)
jasonmolenda wrote: > Sorry for going off-topic, but what does this say about the support for > `i386-apple-*` as a whole? I find the prospect of dropping that exciting, as > I believe that is the only target where eh_ and debug_frame register numbers > are different. I think we can remove i386-macos support, short of booting a seven year old OS on a machine at least that old, and who knows if everything in C++17 we use is even supported by the compilers back then. I know there are sometimes open source people trying to build & use a modern lldb on older configurations, but I think this would be a tough one to have working at this point. I wouldn't feel bad about any patches removing this support. I'll try to start removing these things as I have time/see an opportunity. Apple announced that the macOS version being released in a few months (macOS 26) would be the final version that supports Intel machines at all. We'll have a business requirement to keep the 64-bit Intel support for another release cycle or so after that. What open source contributors might be using the llvm.org sources on is a different question, but the entire target support is going to go away before much longer I think. https://github.com/llvm/llvm-project/pull/146480 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable (PR #146557)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/146557 Follow-up to https://github.com/llvm/llvm-project/pull/145645#discussion_r2174948997 There's no need for this variable to be declared at the function-level. We reset it in all the cases where it's used anyway. >From 06ccadcfa44bbca9367eeff94a44aa6cfec2873a Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 1 Jul 2025 16:50:01 +0100 Subject: [PATCH] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable Follow-up to https://github.com/llvm/llvm-project/pull/145645#discussion_r2174948997 There's no need for this variable to be declared at the function-level. We reset it in all the cases where it's used anyway. --- .../SymbolFile/DWARF/DWARFFormValue.cpp | 24 +-- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 2e98e3c33acaf..6a657086608b8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -36,7 +36,6 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, bool indirect = false; bool is_block = false; m_value.data = nullptr; - uint8_t ref_addr_size; // Read the value for the form into value and follow and DW_FORM_indirect // instances we run into do { @@ -76,11 +75,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, break; case DW_FORM_strp: case DW_FORM_line_strp: -case DW_FORM_sec_offset: +case DW_FORM_sec_offset: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_addrx1: case DW_FORM_strx1: case DW_FORM_ref1: @@ -119,11 +118,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, case DW_FORM_GNU_addr_index: m_value.uval = data.GetULEB128(offset_ptr); break; -case DW_FORM_ref_addr: +case DW_FORM_ref_addr: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_indirect: m_form = static_cast(data.GetULEB128(offset_ptr)); indirect = true; @@ -208,7 +207,6 @@ bool DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, const DWARFUnit *unit) { - uint8_t ref_addr_size; switch (form) { // Blocks if inlined data that have a length field and the data bytes inlined // in the .debug_info @@ -244,12 +242,13 @@ bool DWARFFormValue::SkipValue(dw_form_t form, *offset_ptr += DWARFUnit::GetAddressByteSize(unit); return true; - case DW_FORM_ref_addr: + case DW_FORM_ref_addr: { assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will // get this wrong -ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); +uint8_t ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); *offset_ptr += ref_addr_size; return true; + } // 0 bytes values (implied from DW_FORM) case DW_FORM_flag_present: @@ -282,11 +281,12 @@ bool DWARFFormValue::SkipValue(dw_form_t form, // 32 bit for DWARF 32, 64 for DWARF 64 case DW_FORM_sec_offset: case DW_FORM_strp: -case DW_FORM_line_strp: +case DW_FORM_line_strp: { assert(unit); - ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); *offset_ptr += ref_addr_size; return true; +} // 4 byte values case DW_FORM_addrx4: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. --- Full diff: https://github.com/llvm/llvm-project/pull/146578.diff 3 Files Affected: - (modified) lldb/include/lldb/Core/Statusline.h (+1-3) - (modified) lldb/source/Core/Statusline.cpp (+25-21) - (modified) lldb/source/Host/common/Editline.cpp (+2-2) ``diff diff --git a/lldb/include/lldb/Core/Statusline.h b/lldb/include/lldb/Core/Statusline.h index 521b9f2526f6b..6bda153f822d2 100644 --- a/lldb/include/lldb/Core/Statusline.h +++ b/lldb/include/lldb/Core/Statusline.h @@ -36,12 +36,10 @@ class Statusline { /// Draw the statusline with the given text. void Draw(std::string msg); - /// Update terminal dimensions. - void UpdateTerminalProperties(); - enum ScrollWindowMode { EnableStatusline, DisableStatusline, +ResizeStatusline, }; /// Set the scroll window for the given mode. diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp index 8ec57c9fa5bac..32f69db5a48f3 100644 --- a/lldb/source/Core/Statusline.cpp +++ b/lldb/source/Core/Statusline.cpp @@ -24,6 +24,7 @@ #define ANSI_SAVE_CURSOR ESCAPE "7" #define ANSI_RESTORE_CURSOR ESCAPE "8" #define ANSI_CLEAR_BELOW ESCAPE "[J" +#define ANSI_CLEAR_SCREEN ESCAPE "[2J" #define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur" #define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f" #define ANSI_REVERSE_VIDEO ESCAPE "[7m" @@ -41,10 +42,12 @@ Statusline::Statusline(Debugger &debugger) Statusline::~Statusline() { Disable(); } void Statusline::TerminalSizeChanged() { - UpdateTerminalProperties(); + m_terminal_width = m_debugger.GetTerminalWidth(); + m_terminal_height = m_debugger.GetTerminalHeight(); - // This definitely isn't signal safe, but the best we can do, until we - // have proper signal-catching thread. + UpdateScrollWindow(ResizeStatusline); + + // Draw the old statusline. Redraw(/*update=*/false); } @@ -85,13 +88,6 @@ void Statusline::Draw(std::string str) { locked_stream << ANSI_RESTORE_CURSOR; } -void Statusline::UpdateTerminalProperties() { - UpdateScrollWindow(DisableStatusline); - m_terminal_width = m_debugger.GetTerminalWidth(); - m_terminal_height = m_debugger.GetTerminalHeight(); - UpdateScrollWindow(EnableStatusline); -} - void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { assert(m_terminal_width != 0 && m_terminal_height != 0); @@ -99,24 +95,32 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { if (!stream_sp) return; - const unsigned scroll_height = - (mode == DisableStatusline) ? m_terminal_height : m_terminal_height - 1; - + const unsigned reduced_scroll_window = m_terminal_height - 1; LockedStreamFile locked_stream = stream_sp->Lock(); - if (mode == EnableStatusline) { + switch (mode) { + case EnableStatusline: // Move everything on the screen up. locked_stream << '\n'; locked_stream.Printf(ANSI_UP_ROWS, 1); - } - - locked_stream << ANSI_SAVE_CURSOR; - locked_stream.Printf(ANSI_SET_SCROLL_ROWS, scroll_height); - locked_stream << ANSI_RESTORE_CURSOR; - - if (mode == DisableStatusline) { +// Reduce the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +locked_stream << ANSI_RESTORE_CURSOR; +break; + case DisableStatusline: +// Reset the scroll window. +locked_stream << ANSI_SAVE_CURSOR; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, 0); +locked_stream << ANSI_RESTORE_CURSOR; // Clear the screen below to hide the old statusline. locked_stream << ANSI_CLEAR_BELOW; +break; + case ResizeStatusline: +// Clear the screen and update the scroll window. +locked_stream << ANSI_CLEAR_SCREEN; +locked_stream.Printf(ANSI_SET_SCROLL_ROWS, reduced_scroll_window); +break; } m_debugger.RefreshIOHandler(); diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 4720d3b4c29ac..a5bbdcd60ec26 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -1710,10 +1710,10 @@ void Editline::PrintAsync(lldb::LockableStreamFileSP stream_sp, const c
[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/146578 Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. >From 81c2ca0e953888bf2445ae2765e54a6f87b6d41b Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 1 Jul 2025 10:38:22 -0700 Subject: [PATCH] [lldb] Take a sledgehammer approach to resizing the statusline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. --- lldb/include/lldb/Core/Statusline.h | 4 +-- lldb/source/Core/Statusline.cpp | 46 +++- lldb/source/Host/common/Editline.cpp | 4 +-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lldb/include/lldb/Core/Statusline.h b/lldb/include/lldb/Core/Statusline.h index 521b9f2526f6b..6bda153f822d2 100644 --- a/lldb/include/lldb/Core/Statusline.h +++ b/lldb/include/lldb/Core/Statusline.h @@ -36,12 +36,10 @@ class Statusline { /// Draw the statusline with the given text. void Draw(std::string msg); - /// Update terminal dimensions. - void UpdateTerminalProperties(); - enum ScrollWindowMode { EnableStatusline, DisableStatusline, +ResizeStatusline, }; /// Set the scroll window for the given mode. diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp index 8ec57c9fa5bac..32f69db5a48f3 100644 --- a/lldb/source/Core/Statusline.cpp +++ b/lldb/source/Core/Statusline.cpp @@ -24,6 +24,7 @@ #define ANSI_SAVE_CURSOR ESCAPE "7" #define ANSI_RESTORE_CURSOR ESCAPE "8" #define ANSI_CLEAR_BELOW ESCAPE "[J" +#define ANSI_CLEAR_SCREEN ESCAPE "[2J" #define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur" #define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f" #define ANSI_REVERSE_VIDEO ESCAPE "[7m" @@ -41,10 +42,12 @@ Statusline::Statusline(Debugger &debugger) Statusline::~Statusline() { Disable(); } void Statusline::TerminalSizeChanged() { - UpdateTerminalProperties(); + m_terminal_width = m_debugger.GetTerminalWidth(); + m_terminal_height = m_debugger.GetTerminalHeight(); - // This definitely isn't signal safe, but the best we can do, until we - // have proper signal-catching thread. + UpdateScrollWindow(ResizeStatusline); + + // Draw the old statusline. Redraw(/*update=*/false); } @@ -85,13 +88,6 @@ void Statusline::Draw(std::string str) { locked_stream << ANSI_RESTORE_CURSOR; } -void Statusline::UpdateTerminalProperties() { - UpdateScrollWindow(DisableStatusline); - m_terminal_width = m_debugger.GetTerminalWidth(); - m_terminal_height = m_debugger.GetTerminalHeight(); - UpdateScrollWindow(EnableStatusline); -} - void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { assert(m_terminal_width != 0 && m_terminal_height != 0); @@ -99,24 +95,32 @@ void Statusline::UpdateScrollWindow(ScrollWindowMode mode) { if (!stream_sp) return; - const unsigned scroll_height = - (mode == DisableStatusline) ? m_terminal_height : m_terminal_height - 1; - + const unsigned reduced_scroll_window = m_terminal_height - 1; LockedStreamFile locked_stream = stream_sp->Lock(); - if (mode == EnableStatusline) { + switch (mode) { + case EnableStatusline: // Move everything on the screen up. locked_stream << '\n'; locked_stream.Printf(ANSI_UP_ROWS, 1); - } - - locked_stream << ANSI_SAVE_CURSOR; - locked_stream.Printf(ANSI_SET_SCROLL_ROWS, scroll_height); - locked_stream << ANSI_RESTORE_CURSOR; - - if (mode == DisableStatusline) { +// Reduce the scroll window. +locked_stream << ANSI_S
[Lldb-commits] [lldb] [lldb][framework] Copy framework files correctly (PR #146425)
chelcassanova wrote: > My understanding was the -o ${output_header} here should place it in the > framework when ${output_header} is the right directory. So did I, but when I actually tried a build with the framework enabled the headers weren't there. Looking at this again copying the files *might* be overkill as the original calculation for the output filepath is wrong. Originally I had put `set(output_header $/Headers/${input_header})` where `${input_header} is the complete path instead of just the basename. It might feasible to just use the basename to get the output header without copying everything from `FrameworkHeaders` into the framework itself. https://github.com/llvm/llvm-project/pull/146425 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Optimize statusline redrawing on terminal size change (PR #146435)
JDevlieghere wrote: Thanks for the report. I've reached the point where I'm skeptical that I'm able to get this right for every combination of OS/WM/Terminal so I think https://github.com/llvm/llvm-project/pull/146578 is the safest path forward. https://github.com/llvm/llvm-project/pull/146435 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Take a sledgehammer approach to resizing the statusline (PR #146578)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/146578 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
@@ -276,7 +276,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), ashgti wrote: Looks like this was already fixed by 98e6d5cd47d4db020a1406032f96fd5cdfc56563 https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Prevent using an implicit `step-in`. (PR #143644)
da-viper wrote: > The way I understand this, this patch isn't trying to fix the step over > problem (#144061). What it does is fix a different (but similar) problem in > lldb-dap where it would show the wrong source code for in cases where the > step operations ends up in a different file. And the fix is really to trust > the file information that lldb provides (its "virtual inline stack counter") > rather than trying to find the file by resolving the PC value. The extent > this deals with #144061 is that we need to work around that bug in order to > make a test for the lldb-dap bug. Yes this is the case. https://github.com/llvm/llvm-project/pull/143644 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable (PR #146557)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/146557 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138031 >From 1e10fc233cdf59299b3c1720838e89e6acfc07ad Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 14:15:39 -0700 Subject: [PATCH] [lldb][RPC] Upstream lldb-rpc-gen tool This commit upstreams the `lldb-rpc-gen` tool, a ClangTool that generates the LLDB RPC client and server interfaces. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- lldb/cmake/modules/LLDBConfig.cmake | 2 + lldb/test/CMakeLists.txt | 3 +- .../Tests/CheckRPCGenToolByproducts.test | 11 + lldb/test/Shell/RPC/Generator/lit.local.cfg | 3 + lldb/test/Shell/helper/toolchain.py | 8 + lldb/test/Shell/lit.site.cfg.py.in| 1 + lldb/tools/CMakeLists.txt | 3 + lldb/tools/lldb-rpc/CMakeLists.txt| 22 + lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake | 58 ++ lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake | 101 .../lldb-rpc/lldb-rpc-gen/CMakeLists.txt | 21 + .../tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp | 501 ++ lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h | 108 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp| 341 14 files changed, 1182 insertions(+), 1 deletion(-) create mode 100644 lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test create mode 100644 lldb/test/Shell/RPC/Generator/lit.local.cfg create mode 100644 lldb/tools/lldb-rpc/CMakeLists.txt create mode 100644 lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake create mode 100644 lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/CMakeLists.txt create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 37b823feb584b..069b5412d03f8 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -322,4 +322,6 @@ else() set(LLDB_CAN_USE_DEBUGSERVER OFF) endif() +set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "") + include(LLDBGenerateConfig) diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 6449ac5a9247f..45f68cf4aeb67 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -249,7 +249,8 @@ llvm_canonicalize_cmake_booleans( LLDB_TEST_SHELL_DISABLE_REMOTE LLDB_TOOL_LLDB_SERVER_BUILD LLDB_USE_SYSTEM_DEBUGSERVER - LLDB_IS_64_BITS) + LLDB_IS_64_BITS + LLDB_BUILD_LLDBRPC) # Configure the individual test suites. add_subdirectory(API) diff --git a/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test b/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test new file mode 100644 index 0..be3eefc69b20a --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test @@ -0,0 +1,11 @@ +# For this test, we're not checking any specific output from a generated file, +# but we do need a file to pass into lldb-rpc-gen so use SBAddress.h from source. +RUN: %lldb-rpc-gen --output-dir=%t %S/../../../../../include/lldb/API/SBAddress.h + +RUN: ls %t | FileCheck %s + +# We're just making sure that the tool emits the class names, +# methods and skipped methods file in the output directory. +CHECK: SBAPI.def +CHECK: SBClasses.def +CHECK: SkippedMethods.txt diff --git a/lldb/test/Shell/RPC/Generator/lit.local.cfg b/lldb/test/Shell/RPC/Generator/lit.local.cfg new file mode 100644 index 0..db9494781c00c --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/lit.local.cfg @@ -0,0 +1,3 @@ +# All tests for the tool need lldb-rpc-gen to be built. +if not config.lldb_has_lldbrpc: + config.unsupported = True diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index 42968128f2702..95437dba55b7d 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -156,6 +156,14 @@ def use_lldb_substitutions(config): extra_args=["platform"], unresolved="ignore", ), +ToolSubst( +"%lldb-rpc-gen", +command=FindTool("lldb-rpc-gen"), +extra_args=[ +'--extra-arg="-resource-dir=' + config.clang_resource_dir + '"' +], +unresolved="ignore", +), "lldb-test", "lldb-dap", ToolSubst( diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in index 5be5359217769..beaa41e6fd379 100644 --- a/lldb/test/Shell/lit.site.cfg.py.in +++ b/lldb/test/Shell/lit.site.cfg.py.in @@ -33,6 +33,7 @@ config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@" config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@ config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@ config.llvm_use_sanitizer
[Lldb-commits] [lldb] a79404e - [lldb] Correct an assertion name.
Author: John Harrison Date: 2025-07-01T10:26:32-07:00 New Revision: a79404e50cf5308bb76cc4eaf36cb8eaea9ab66a URL: https://github.com/llvm/llvm-project/commit/a79404e50cf5308bb76cc4eaf36cb8eaea9ab66a DIFF: https://github.com/llvm/llvm-project/commit/a79404e50cf5308bb76cc4eaf36cb8eaea9ab66a.diff LOG: [lldb] Correct an assertion name. Added: Modified: lldb/source/Host/windows/MainLoopWindows.cpp Removed: diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp index b4896dced0a48..abb4345b011e4 100644 --- a/lldb/source/Host/windows/MainLoopWindows.cpp +++ b/lldb/source/Host/windows/MainLoopWindows.cpp @@ -125,7 +125,7 @@ class SocketEvent : public MainLoopWindows::IOEvent { public: explicit SocketEvent(SOCKET socket) : IOEvent((IOObject::WaitableHandle)WSACreateEvent()), m_socket(socket) { -assert(event != WSA_INVALID_EVENT); +assert(m_event != WSA_INVALID_EVENT); } ~SocketEvent() override { WSACloseEvent((HANDLE)m_event); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
ashgti wrote: I was running my tests in `Release` mode, so I missed that one of the `assert` calls had an invalid variable name. Fixed in https://github.com/llvm/llvm-project/commit/a79404e50cf5308bb76cc4eaf36cb8eaea9ab66a https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
labath wrote: > I was running my tests in `Release` mode, so I missed that one of the > `assert` calls had an invalid variable name. Fixed in > [a79404e](https://github.com/llvm/llvm-project/commit/a79404e50cf5308bb76cc4eaf36cb8eaea9ab66a) I recommend `cmake -DLLVM_ENABLE_ASSERTIONS=On` :) https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][NFC][MachO] Clean up LC_THREAD reading code, remove i386 corefile (PR #146480)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/146480 >From e0e19746256fa8db4b94d3b3f747b22487589be7 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 1 Jul 2025 00:32:21 -0700 Subject: [PATCH 1/2] [lldb][NFC][MachO] Clean up LC_THREAD reading code, remove i386 corefile While fixing bugs in the x86_64 LC_THREAD parser in ObjectFileMachO, I noticed that the other LC_THREAD parsers are all less clear than they should be. To recap, a Mach-O LC_THREAD load command has a byte size for the entire payload. Within the payload, there will be one or more register sets provided. A register set starts with a UInt32 "flavor", the type of register set defined in the system headers, and a UInt32 "count", the number of UInt32 words of memory for this register set. After one register set, there may be additional sets. A parser can skip an unknown register set flavor by using the count field to get to the next register set. When the total byte size of the LC_THREAD load command has been parsed, it is completed. This patch fixes the riscv/arm/arm64 LC_THREAD parsers to use the total byte size as the exit condition, and to skip past unrecognized register sets, instead of stopping parsing. Instead of fixing the i386 corefile support, I removed it. The last macOS that supported 32-bit Intel code was macOS 10.14 in 2018. I also removed i386 KDP support, 32-bit intel kernel debugging hasn't been supported for even longer than that. It would be preferable to do these things separately, but I couldn't bring myself to update the i386 LC_THREAD parser, and it required very few changes to remove this support entirely. --- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 187 +--- .../Process/MacOSX-Kernel/CMakeLists.txt | 1 - .../MacOSX-Kernel/RegisterContextKDP_i386.cpp | 114 --- .../MacOSX-Kernel/RegisterContextKDP_i386.h | 38 - .../Process/MacOSX-Kernel/ThreadKDP.cpp | 5 - .../Plugins/Process/Utility/CMakeLists.txt| 2 - .../Utility/RegisterContextDarwin_i386.cpp| 958 -- .../Utility/RegisterContextDarwin_i386.h | 208 .../Utility/RegisterContextMach_i386.cpp | 60 -- .../Utility/RegisterContextMach_i386.h| 35 - .../source/Plugins/Process/Utility/BUILD.gn | 2 - 11 files changed, 12 insertions(+), 1598 deletions(-) delete mode 100644 lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp delete mode 100644 lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h delete mode 100644 lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp delete mode 100644 lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h delete mode 100644 lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp delete mode 100644 lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 70f954cd5413f..979123802435c 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -11,7 +11,6 @@ #include "Plugins/Process/Utility/RegisterContextDarwin_arm.h" #include "Plugins/Process/Utility/RegisterContextDarwin_arm64.h" -#include "Plugins/Process/Utility/RegisterContextDarwin_i386.h" #include "Plugins/Process/Utility/RegisterContextDarwin_riscv32.h" #include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h" #include "lldb/Core/Debugger.h" @@ -81,9 +80,6 @@ #ifdef CPU_TYPE_ARM64_32 #undef CPU_TYPE_ARM64_32 #endif -#ifdef CPU_TYPE_I386 -#undef CPU_TYPE_I386 -#endif #ifdef CPU_TYPE_X86_64 #undef CPU_TYPE_X86_64 #endif @@ -358,122 +354,6 @@ class RegisterContextDarwin_x86_64_Mach : public RegisterContextDarwin_x86_64 { } }; -class RegisterContextDarwin_i386_Mach : public RegisterContextDarwin_i386 { -public: - RegisterContextDarwin_i386_Mach(lldb_private::Thread &thread, - const DataExtractor &data) - : RegisterContextDarwin_i386(thread, 0) { -SetRegisterDataFrom_LC_THREAD(data); - } - - void InvalidateAllRegisters() override { -// Do nothing... registers are always valid... - } - - void SetRegisterDataFrom_LC_THREAD(const DataExtractor &data) { -lldb::offset_t offset = 0; -SetError(GPRRegSet, Read, -1); -SetError(FPURegSet, Read, -1); -SetError(EXCRegSet, Read, -1); -bool done = false; - -while (!done) { - int flavor = data.GetU32(&offset); - if (flavor == 0) -done = true; - else { -uint32_t i; -uint32_t count = data.GetU32(&offset); -switch (flavor) { -case GPRRegSet: - for (i = 0; i < count; ++i) -(&gpr.eax)[i] = data.GetU32(&offset); - SetError(GPRRegSet, Read, 0); - done = true; - - break; -case FPURegSet: - // TODO: fill in FPU r
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
@@ -276,7 +276,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), jyknight wrote: Why did you change these from uint64_t to file_t? It's now inconsistent with the format string above, which uses PRIu64. `lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:279:15: error: format specifies type 'unsigned long' but the argument has type 'file_t' (aka 'int') [-Werror,-Wformat]` https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] When running OS Plugins from dSYM's, make sure start state is correct (PR #146441)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/146441 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Inline ResolveSDKPathFromDebugInfo in one of its call site (PR #146062)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/146062 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1a7b7e2 - [lldb] Adding pipe support to lldb_private::MainLoopWindows. (#145621)
Author: John Harrison Date: 2025-07-01T08:59:27-07:00 New Revision: 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 URL: https://github.com/llvm/llvm-project/commit/1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 DIFF: https://github.com/llvm/llvm-project/commit/1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07.diff LOG: [lldb] Adding pipe support to lldb_private::MainLoopWindows. (#145621) This updates MainLoopWindows to support events for reading from a pipe (both anonymous and named pipes) as well as sockets. This unifies both handle types using `WSAWaitForMultipleEvents` which can listen to both sockets and handles for change events. This should allow us to unify how we handle watching pipes/sockets on Windows and Posix systems. We can extend this in the future if we want to support watching other types, like files or even other events like a process life time. - Co-authored-by: Pavel Labath Added: Modified: lldb/include/lldb/Host/windows/MainLoopWindows.h lldb/include/lldb/Utility/IOObject.h lldb/source/Host/common/File.cpp lldb/source/Host/common/JSONTransport.cpp lldb/source/Host/common/Socket.cpp lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/source/Host/windows/MainLoopWindows.cpp lldb/source/Utility/IOObject.cpp lldb/unittests/Host/FileTest.cpp lldb/unittests/Host/MainLoopTest.cpp Removed: diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 3937a24645d95..53df815255c3d 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -31,17 +31,30 @@ class MainLoopWindows : public MainLoopBase { Status Run() override; + class IOEvent { + public: +IOEvent(IOObject::WaitableHandle event) : m_event(event) {} +virtual ~IOEvent() {} +virtual void WillPoll() {} +virtual void DidPoll() {} +virtual void Disarm() {} +IOObject::WaitableHandle GetHandle() { return m_event; } + + protected: +IOObject::WaitableHandle m_event; + }; + using IOEventUP = std::unique_ptr; + protected: void UnregisterReadObject(IOObject::WaitableHandle handle) override; void Interrupt() override; private: - void ProcessReadObject(IOObject::WaitableHandle handle); llvm::Expected Poll(); struct FdInfo { -void *event; +IOEventUP event; Callback callback; }; llvm::DenseMap m_read_fds; diff --git a/lldb/include/lldb/Utility/IOObject.h b/lldb/include/lldb/Utility/IOObject.h index 8cf42992e7be5..de6532a637083 100644 --- a/lldb/include/lldb/Utility/IOObject.h +++ b/lldb/include/lldb/Utility/IOObject.h @@ -14,6 +14,7 @@ #include #include "lldb/lldb-private.h" +#include "lldb/lldb-types.h" namespace lldb_private { @@ -24,9 +25,9 @@ class IOObject { eFDTypeSocket, // Socket requiring send/recv }; - // TODO: On Windows this should be a HANDLE, and wait should use - // WaitForMultipleObjects - typedef int WaitableHandle; + // A handle for integrating with the host event loop model. + using WaitableHandle = lldb::file_t; + static const WaitableHandle kInvalidHandleValue; IOObject(FDType type) : m_fd_type(type) {} diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 9aa95ffda44cb..23b6dc9fe850d 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -274,7 +274,11 @@ int NativeFile::GetDescriptor() const { } IOObject::WaitableHandle NativeFile::GetWaitableHandle() { +#ifdef _WIN32 + return (HANDLE)_get_osfhandle(GetDescriptor()); +#else return GetDescriptor(); +#endif } FILE *NativeFile::GetStream() { diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index 1a0851d5c4365..bf269ffa45966 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,7 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); -sh.FDSetRead(descriptor.GetWaitableHandle()); +sh.FDSetRead((lldb::socket_t)descriptor.GetWaitableHandle()); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 802ff9a1b5d1d..3511cde8bb36f 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -313,8 +313,7 @@ Socket::DecodeHostAndPort(llvm::StringRef host_and_port) { } IOObject::WaitableHandle Socket::GetWaitableHandle() { - // TODO: On Windows, use WSAEventSelect - return m_socket; + return (IOObject::WaitableHandle)m_socket; } Status Socket::Read(void *buf, size_t &num_bytes) { diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPo
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
https://github.com/Michael137 approved this pull request. LGTM once https://github.com/llvm/llvm-project/pull/143177#discussion_r2177093572 is merged separately. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARF][NFC] Reduce scope of ref_addr_size variable (PR #146557)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Follow-up to https://github.com/llvm/llvm-project/pull/145645#discussion_r2174948997 There's no need for this variable to be declared at the function-level. We reset it in all the cases where it's used anyway. --- Full diff: https://github.com/llvm/llvm-project/pull/146557.diff 1 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (+12-12) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 2e98e3c33acaf..6a657086608b8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -36,7 +36,6 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, bool indirect = false; bool is_block = false; m_value.data = nullptr; - uint8_t ref_addr_size; // Read the value for the form into value and follow and DW_FORM_indirect // instances we run into do { @@ -76,11 +75,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, break; case DW_FORM_strp: case DW_FORM_line_strp: -case DW_FORM_sec_offset: +case DW_FORM_sec_offset: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getDwarfOffsetByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_addrx1: case DW_FORM_strx1: case DW_FORM_ref1: @@ -119,11 +118,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, case DW_FORM_GNU_addr_index: m_value.uval = data.GetULEB128(offset_ptr); break; -case DW_FORM_ref_addr: +case DW_FORM_ref_addr: { assert(m_unit); - ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); + uint8_t ref_addr_size = m_unit->GetFormParams().getRefAddrByteSize(); m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; +} break; case DW_FORM_indirect: m_form = static_cast(data.GetULEB128(offset_ptr)); indirect = true; @@ -208,7 +207,6 @@ bool DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, const DWARFUnit *unit) { - uint8_t ref_addr_size; switch (form) { // Blocks if inlined data that have a length field and the data bytes inlined // in the .debug_info @@ -244,12 +242,13 @@ bool DWARFFormValue::SkipValue(dw_form_t form, *offset_ptr += DWARFUnit::GetAddressByteSize(unit); return true; - case DW_FORM_ref_addr: + case DW_FORM_ref_addr: { assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will // get this wrong -ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); +uint8_t ref_addr_size = unit->GetFormParams().getRefAddrByteSize(); *offset_ptr += ref_addr_size; return true; + } // 0 bytes values (implied from DW_FORM) case DW_FORM_flag_present: @@ -282,11 +281,12 @@ bool DWARFFormValue::SkipValue(dw_form_t form, // 32 bit for DWARF 32, 64 for DWARF 64 case DW_FORM_sec_offset: case DW_FORM_strp: -case DW_FORM_line_strp: +case DW_FORM_line_strp: { assert(unit); - ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); + uint8_t ref_addr_size = unit->GetFormParams().getDwarfOffsetByteSize(); *offset_ptr += ref_addr_size; return true; +} // 4 byte values case DW_FORM_addrx4: `` https://github.com/llvm/llvm-project/pull/146557 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
https://github.com/xgupta created https://github.com/llvm/llvm-project/pull/146572 This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 >From 3be47f9a7f01b9549048722d8191ab1ff823e919 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Tue, 1 Jul 2025 19:42:48 +0530 Subject: [PATCH] [AArch64] Support TLS variables in debug info This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- lld/ELF/Arch/AArch64.cpp | 6 +++ .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 1 + .../AArch64/AArch64TargetObjectFile.cpp | 7 +++- .../Target/AArch64/AArch64TargetObjectFile.h | 3 ++ .../AArch64/AsmParser/AArch64AsmParser.cpp| 3 ++ .../MCTargetDesc/AArch64ELFObjectWriter.cpp | 5 +++ .../AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp | 2 + llvm/test/CodeGen/AArch64/tls-dtprel64.ll | 37 ++ .../test/DebugInfo/AArch64/tls-at-location.ll | 12 -- llvm/test/MC/AArch64/tls-dtprel64.s | 38 +++ 10 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/tls-dtprel64.ll create mode 100644 llvm/test/MC/AArch64/tls-dtprel64.s diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AA
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
llvmbot wrote: @llvm/pr-subscribers-debuginfo Author: Shivam Gupta (xgupta) Changes This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- Full diff: https://github.com/llvm/llvm-project/pull/146572.diff 10 Files Affected: - (modified) lld/ELF/Arch/AArch64.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+6-1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+3) - (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+3) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (+5) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (+2) - (added) llvm/test/CodeGen/AArch64/tls-dtprel64.ll (+37) - (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+9-3) - (added) llvm/test/MC/AArch64/tls-dtprel64.s (+38) ``diff diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AArch64::S_PREL_G1_NC) .Case("prel_g0", AArch64::S_PREL_G0) .Case("prel_g0_nc", AArch64::S_PREL_G0_NC) + .Case("dtprel", AArch64::S_DTPREL) .Case("dtprel_g2", AArch64::S_DTPREL_G2) .Case("
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
llvmbot wrote: @llvm/pr-subscribers-lld Author: Shivam Gupta (xgupta) Changes This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- Full diff: https://github.com/llvm/llvm-project/pull/146572.diff 10 Files Affected: - (modified) lld/ELF/Arch/AArch64.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+6-1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+3) - (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+3) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (+5) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (+2) - (added) llvm/test/CodeGen/AArch64/tls-dtprel64.ll (+37) - (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+9-3) - (added) llvm/test/MC/AArch64/tls-dtprel64.s (+38) ``diff diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AArch64::S_PREL_G1_NC) .Case("prel_g0", AArch64::S_PREL_G0) .Case("prel_g0_nc", AArch64::S_PREL_G0_NC) + .Case("dtprel", AArch64::S_DTPREL) .Case("dtprel_g2", AArch64::S_DTPREL_G2) .Case("dtprel
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: Shivam Gupta (xgupta) Changes This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- Full diff: https://github.com/llvm/llvm-project/pull/146572.diff 10 Files Affected: - (modified) lld/ELF/Arch/AArch64.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+6-1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+3) - (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+3) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (+5) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (+2) - (added) llvm/test/CodeGen/AArch64/tls-dtprel64.ll (+37) - (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+9-3) - (added) llvm/test/MC/AArch64/tls-dtprel64.s (+38) ``diff diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AArch64::S_PREL_G1_NC) .Case("prel_g0", AArch64::S_PREL_G0) .Case("prel_g0_nc", AArch64::S_PREL_G0_NC) + .Case("dtprel", AArch64::S_DTPREL) .Case("dtprel_g2", AArch64::S_DTPREL_G2) .
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Shivam Gupta (xgupta) Changes This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- Full diff: https://github.com/llvm/llvm-project/pull/146572.diff 10 Files Affected: - (modified) lld/ELF/Arch/AArch64.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+6-1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+3) - (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+3) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (+5) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (+2) - (added) llvm/test/CodeGen/AArch64/tls-dtprel64.ll (+37) - (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+9-3) - (added) llvm/test/MC/AArch64/tls-dtprel64.s (+38) ``diff diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AArch64::S_PREL_G1_NC) .Case("prel_g0", AArch64::S_PREL_G0) .Case("prel_g0_nc", AArch64::S_PREL_G0_NC) + .Case("dtprel", AArch64::S_DTPREL) .Case("dtprel_g2", AArch64::S_DTPREL_G2) .Case("dtpre
[Lldb-commits] [lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
llvmbot wrote: @llvm/pr-subscribers-mc @llvm/pr-subscribers-lld-elf Author: Shivam Gupta (xgupta) Changes This adds an implementation of getDebugThreadLocalSymbol for AArch64 by using AArch::S_DTPREL. Fixes #83466 --- Full diff: https://github.com/llvm/llvm-project/pull/146572.diff 10 Files Affected: - (modified) lld/ELF/Arch/AArch64.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+6-1) - (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+3) - (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+3) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (+5) - (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (+2) - (added) llvm/test/CodeGen/AArch64/tls-dtprel64.ll (+37) - (modified) llvm/test/DebugInfo/AArch64/tls-at-location.ll (+9-3) - (added) llvm/test/MC/AArch64/tls-dtprel64.s (+38) ``diff diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 1812f2af419d2..7576d904e3a60 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -156,6 +156,8 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, return R_ABS; case R_AARCH64_AUTH_ABS64: return RE_AARCH64_AUTH; + case R_AARCH64_TLS_DTPREL64: +return R_DTPREL; case R_AARCH64_TLSDESC_ADR_PAGE21: return RE_AARCH64_TLSDESC_PAGE; case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: @@ -542,6 +544,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel, if (isInt<32>(val)) write32(ctx, loc, val); break; + case R_AARCH64_TLS_DTPREL64: +checkInt(ctx, loc, val, 64, rel); +write64(ctx, loc, val); +break; case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_AUTH_GOT_ADD_LO12_NC: write32Imm12(loc, val); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index f69358de6a288..4593b7253a574 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2843,6 +2843,7 @@ unsigned ObjectFileELF::ApplyRelocations( case llvm::ELF::EM_AARCH64: switch (reloc_type(rel)) { case R_AARCH64_ABS64: +case R_AARCH64_TLS_DTPREL64: ApplyELF64ABS64Relocation(symtab, rel, debug_data, rel_section); break; case R_AARCH64_ABS32: diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index c218831ce0400..f76103733969a 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -30,7 +30,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx, // AARCH64 ELF ABI does not define static relocation type for TLS offset // within a module. Do not generate AT_location for TLS variables. - SupportDebugThreadLocalLocation = false; + SupportDebugThreadLocalLocation = true; // Make sure the implicitly created empty .text section has the // SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is @@ -186,3 +186,8 @@ MCSection *AArch64_ELFTargetObjectFile::SelectSectionForGlobal( return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); } + +const MCExpr *AArch64_ELFTargetObjectFile::getDebugThreadLocalSymbol( +const MCSymbol *Sym) const { + return MCSymbolRefExpr::create(Sym, AArch64::S_DTPREL, getContext()); +} diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h index 6b3381452c70b..78c0c22da8d1b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.h @@ -40,6 +40,9 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF { MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override; + + /// Describe a TLS variable address within debug info. + const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override; }; /// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin. diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index f16fc6cfefa42..35dc8e6e9902d 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4421,6 +4421,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("prel_g1_nc", AArch64::S_PREL_G1_NC) .Case("prel_g0", AArch64::S_PREL_G0) .Case("prel_g0_nc", AArch64::S_PREL_G0_NC) + .Case("dtprel", AArch64::S_DTPREL) .Case("dtprel_g2", AArch64::S_DTPREL_G2)
[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)
chelcassanova wrote: I'm still seeing the `no job control` error in the pre-commit CI. As far as I know this error is not supposed to be happening, RPC should be getting built which should mean that the `lldb-rpc-gen` tool is available for use in the shell test. I can't repro locally, I'm wondering if this is a Linux-specific issue. I'm also wondering if we should just set the bool to enable RPC to OFF by default, land this patch and then investigate after. https://github.com/llvm/llvm-project/pull/138031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -0,0 +1,120 @@ +# coding=utf8 +""" +Test std::*string summaries with MSVC's STL. +""" Michael137 wrote: Sounds good. Will give it a shot later this week https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Commands] image lookup: avoid double type lookup into current module (PR #146554)
@@ -0,0 +1,43 @@ +# REQUIRES: system-darwin Michael137 wrote: Wasn't sure how to create multiple modules which would work across all platforms. I'm sure there is a way, but was hoping someone to tell me :) https://github.com/llvm/llvm-project/pull/146554 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Commands] image lookup: avoid double type lookup into current module (PR #146554)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes The `current_module` pointer here was never set, but we check it when looping over the `target_modules` list. Presumably the intention was to avoid calling `LookupInModule` if we already found the type in the current module. This only affects `image lookup --all`. This patch sets `current_module` if we successfully completed a lookup into it. Before: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" 1 match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` After: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` --- Full diff: https://github.com/llvm/llvm-project/pull/146554.diff 2 Files Affected: - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+12-12) - (added) lldb/test/Shell/Commands/command-image-lookup-current-module.test (+43) ``diff diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index a4ced37649ea0..97ed2bab802c8 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3946,8 +3946,8 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { Options *GetOptions() override { return &m_options; } - bool LookupHere(CommandInterpreter &interpreter, CommandReturnObject &result, - bool &syntax_error) { + ModuleSP LookupHere(CommandInterpreter &interpreter, + CommandReturnObject &result, bool &syntax_error) { switch (m_options.m_type) { case eLookupTypeAddress: case eLookupTypeFileLine: @@ -3955,7 +3955,7 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { case eLookupTypeFunctionOrSymbol: case eLookupTypeSymbol: default: - return false; + return nullptr; case eLookupTypeType: break; } @@ -3963,29 +3963,29 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { StackFrameSP frame = m_exe_ctx.GetFrameSP(); if (!frame) - return false; + return nullptr; const SymbolContext &sym_ctx(frame->GetSymbolContext(eSymbolContextModule)); if (!sym_ctx.module_sp) - return false; + return nullptr; switch (m_options.m_type) { default: - return false; + return nullptr; case eLookupTypeType: if (!m_options.m_str.empty()) { if (LookupTypeHere(&GetTarget(), m_interpreter, result.GetOutputStream(), *sym_ctx.module_sp, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); - return true; + return sym_ctx.module_sp; } } break; } -return false; +return nullptr; } bool LookupInModule(CommandInterpreter &interpreter, Module *module, @@ -4086,12 +4086,12 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { // Dump all sections for all modules images if (command.GetArgumentCount() == 0) { - ModuleSP current_module; - // Where it is possible to look in the current symbol context first, // try that. If this search was successful and --all was not passed, // don't print anything else. - if (LookupHere(m_interpreter, result, syntax_error)) { + ModuleSP current_module_sp = + LookupHere(m_interpreter, result, syntax_error); + if (current_module_sp) { result.GetOutputStream().EOL(); num_successful_lookups++; if (!m_options.m_print_all) { @@ -4110,7 +4110,7 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { } for (ModuleSP module_sp : target_modules.ModulesNoLocking()) { -if (module_sp != current_module && +if (module_sp != current_module_sp && LookupInModule(m_interpreter, module_sp.get(), result, syntax_error)) { result.GetOutputStream().EOL(); diff --git a/lldb/test/Shell/Commands/command-image-lookup-current-module.test b/lldb/test/Shell/Commands/command-image-lookup-current-module.test new file mode 100644 index 0..52eec1c2b37f3 --- /dev/null +++ b/lldb/test/Shell/Commands/command-image-lookup-current-module.test @@ -0,0 +1,43 @@ +# REQUIRES: system-darwin + +# RUN: split-file %s %t +# RUN: %clang_host -g -gdwarf %t/lib1.cpp -shared -o %t-lib1.dylib +# RUN: %clang_host -g -gdwarf %t/lib2.cpp -shared -o %t-lib2.dylib +# RUN: %clang_hos
[Lldb-commits] [lldb] [LLDB] Simplify libstdc++ string summaries (PR #146562)
https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/146562 >From #143177. This combines the summaries for the pre- and post C++ 11 >`std::string` as well as `std::wstring`. In all cases, the data pointer is >reachable through `_M_dataplus._M_p`. It has the correct type (i.e. >`char*`/`wchar_t*`) and it's null terminated, so LLDB knows how to format it >as expected when using `GetSummaryAsCString`. >From 23ef0a092cac742df90127ec4c6e0f1932d6947a Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Tue, 1 Jul 2025 18:00:57 +0200 Subject: [PATCH] [LLDB] Simplify libstdc++ string summaries --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 29 ++--- .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 120 +- .../Plugins/Language/CPlusPlus/LibStdcpp.h| 6 +- 3 files changed, 17 insertions(+), 138 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 7ae2e141a63e0..f96fd0f0bcd30 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1344,38 +1344,31 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { .SetShowMembersOneLiner(false) .SetHideItemNames(false); - lldb::TypeSummaryImplSP std_string_summary_sp( - new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p}")); - - lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat( + lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat( stl_summary_flags, LibStdcppStringSummaryProvider, - "libstdc++ c++11 std::string summary provider")); - lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat( - stl_summary_flags, LibStdcppWStringSummaryProvider, - "libstdc++ c++11 std::wstring summary provider")); + "libstdc++ std::(w)string summary provider")); cpp_category_sp->AddTypeSummary("std::string", eFormatterMatchExact, - std_string_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary("std::basic_string", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary( "std::basic_string,std::allocator >", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary( "std::basic_string, std::allocator >", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::string", eFormatterMatchExact, - cxx11_string_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary( "std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, cxx11_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, - cxx11_string_summary_sp); + eFormatterMatchExact, string_summary_sp); // making sure we force-pick the summary for printing wstring (_M_p is a // wchar_t*) @@ -1395,11 +1388,11 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { eFormatterMatchExact, std_wstring_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::wstring", eFormatterMatchExact, - cxx11_wstring_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary( "std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, cxx11_wstring_summary_sp); + eFormatterMatchExact, string_summary_sp); SyntheticChildren::Flags stl_synth_flags; stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences( diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 77e0755607a06..28b7c01ab1b5b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -239,122 +239,12 @@ VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { bool lldb_private::formatters::LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = - valobj.IsPointerOrReferenceType() - ? valobj.GetPointerValue() - : valobj.GetA
[Lldb-commits] [lldb] [LLDB] Simplify libstdc++ string summaries (PR #146562)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) Changes >From #143177. This combines the summaries for the pre- and post C++ 11 >`std::string` as well as `std::wstring`. In all cases, the data pointer is >reachable through `_M_dataplus._M_p`. It has the correct type (i.e. >`char*`/`wchar_t*`) and it's null terminated, so LLDB knows how to format it >as expected when using `GetSummaryAsCString`. --- Full diff: https://github.com/llvm/llvm-project/pull/146562.diff 3 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+11-18) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp (+5-115) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h (+1-5) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 7ae2e141a63e0..f96fd0f0bcd30 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1344,38 +1344,31 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { .SetShowMembersOneLiner(false) .SetHideItemNames(false); - lldb::TypeSummaryImplSP std_string_summary_sp( - new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p}")); - - lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat( + lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat( stl_summary_flags, LibStdcppStringSummaryProvider, - "libstdc++ c++11 std::string summary provider")); - lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat( - stl_summary_flags, LibStdcppWStringSummaryProvider, - "libstdc++ c++11 std::wstring summary provider")); + "libstdc++ std::(w)string summary provider")); cpp_category_sp->AddTypeSummary("std::string", eFormatterMatchExact, - std_string_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary("std::basic_string", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary( "std::basic_string,std::allocator >", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary( "std::basic_string, std::allocator >", - eFormatterMatchExact, std_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::string", eFormatterMatchExact, - cxx11_string_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary( "std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, cxx11_string_summary_sp); + eFormatterMatchExact, string_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, - cxx11_string_summary_sp); + eFormatterMatchExact, string_summary_sp); // making sure we force-pick the summary for printing wstring (_M_p is a // wchar_t*) @@ -1395,11 +1388,11 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { eFormatterMatchExact, std_wstring_summary_sp); cpp_category_sp->AddTypeSummary("std::__cxx11::wstring", eFormatterMatchExact, - cxx11_wstring_summary_sp); + string_summary_sp); cpp_category_sp->AddTypeSummary( "std::__cxx11::basic_string, " "std::allocator >", - eFormatterMatchExact, cxx11_wstring_summary_sp); + eFormatterMatchExact, string_summary_sp); SyntheticChildren::Flags stl_synth_flags; stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences( diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 77e0755607a06..28b7c01ab1b5b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -239,122 +239,12 @@ VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { bool lldb_private::formatters::LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = - valobj.IsPointerOrReferenceType() - ? valobj.GetPointerValue() - : valobj.GetAddressOf(scalar_is_load_addr); - if (addr_of_string != LLDB_INVALID_ADDRESS) { -switch (ad
[Lldb-commits] [lldb] [lldb][Commands] image lookup: avoid double type lookup into current module (PR #146554)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/146554 The `current_module` pointer here was never set, but we check it when looping over the `target_modules` list. Presumably the intention was to avoid calling `LookupInModule` if we already found the type in the current module. This only affects `image lookup --all`. This patch sets `current_module` if we successfully completed a lookup into it. Before: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" 1 match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` After: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` >From fbc32ba76e51c75fd13ccfb63de77ca8977b5d46 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 1 Jul 2025 16:42:01 +0100 Subject: [PATCH] [lldb][Commands] image lookup: avoid double type lookup into current module The `current_module` pointer here was never set, but we check it when looping over the `target_modules` list. Presumably the intention was to avoid calling `LookupInModule` if we already found the type in the current module. This only affects `image lookup --all`. This patch sets `current_module` if we successfully completed a lookup into it. Before: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" 1 match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` After: ``` (lldb) im loo -vt Foo --all Best match found in /Users/jonas/Git/llvm-worktrees/llvm-project/a.out: id = {0x0037}, name = "Foo", byte-size = 1, decl = foo.cpp:1, compiler_type = "struct Foo { }" ``` --- lldb/source/Commands/CommandObjectTarget.cpp | 24 +-- .../command-image-lookup-current-module.test | 43 +++ 2 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 lldb/test/Shell/Commands/command-image-lookup-current-module.test diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index a4ced37649ea0..97ed2bab802c8 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3946,8 +3946,8 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { Options *GetOptions() override { return &m_options; } - bool LookupHere(CommandInterpreter &interpreter, CommandReturnObject &result, - bool &syntax_error) { + ModuleSP LookupHere(CommandInterpreter &interpreter, + CommandReturnObject &result, bool &syntax_error) { switch (m_options.m_type) { case eLookupTypeAddress: case eLookupTypeFileLine: @@ -3955,7 +3955,7 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { case eLookupTypeFunctionOrSymbol: case eLookupTypeSymbol: default: - return false; + return nullptr; case eLookupTypeType: break; } @@ -3963,29 +3963,29 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { StackFrameSP frame = m_exe_ctx.GetFrameSP(); if (!frame) - return false; + return nullptr; const SymbolContext &sym_ctx(frame->GetSymbolContext(eSymbolContextModule)); if (!sym_ctx.module_sp) - return false; + return nullptr; switch (m_options.m_type) { default: - return false; + return nullptr; case eLookupTypeType: if (!m_options.m_str.empty()) { if (LookupTypeHere(&GetTarget(), m_interpreter, result.GetOutputStream(), *sym_ctx.module_sp, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); - return true; + return sym_ctx.module_sp; } } break; } -return false; +return nullptr; } bool LookupInModule(CommandInterpreter &interpreter, Module *module, @@ -4086,12 +4086,12 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { // Dump all sections for all modules images if (command.GetArgumentCount() == 0) { - ModuleSP current_module; - // Where it is possible to look in the current symbol context first, // try that. If this search was successful and --all was not passed, // don't print anything else. - if (LookupHere(m_interpreter, result, synt
[Lldb-commits] [lldb] [lldb][Commands] image lookup: avoid double type lookup into current module (PR #146554)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/146554 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to make a breakpoint a hardware breakpoint (PR #146602)
jimingham wrote: I think SetIsHardware needs a return value. After all, you could have a software breakpoint set, and then make as many other hardware breakpoints as you have resources for, and THEN you go to change the software breakpoint to hardware. We need to tell the user that that didn't work. https://github.com/llvm/llvm-project/pull/146602 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SB API to make a breakpoint a hardware breakpoint (PR #146602)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/146602 >From 656beb2df5f39604454af0e3f4a9f4b1b7e9c5f8 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 1 Jul 2025 16:02:21 -0700 Subject: [PATCH 1/2] [lldb] Add SB API to make a breakpoint a hardware breakpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds SBBreakpoint::SetIsHardware, allowing clients to mark an existing breakpoint as a hardware breakpoint purely through the API. This is safe to do after creation, as the hardware/software distinction doesn't affect how breakpoint locations are selected. In some cases (e.g. when writing a trap instruction would alter program behavior), it's important to use hardware breakpoints. Ideally, we’d extend the various Create methods to support this, but given their number, this patch limits the scope to the post-creation API. As a workaround, users can also rely on target.require-hardware-breakpoint or use the breakpoint set command. rdar://153528045 --- lldb/include/lldb/API/SBBreakpoint.h | 2 + lldb/include/lldb/Breakpoint/Breakpoint.h | 1 + lldb/source/API/SBBreakpoint.cpp | 11 + lldb/source/Breakpoint/Breakpoint.cpp | 21 ++ .../simple_hw_breakpoints/Makefile| 7 .../TestSimpleHWBreakpoints.py| 40 +++ .../simple_hw_breakpoints/main.c | 7 7 files changed, 89 insertions(+) create mode 100644 lldb/test/API/functionalities/breakpoint/hardware_breakpoints/simple_hw_breakpoints/Makefile create mode 100644 lldb/test/API/functionalities/breakpoint/hardware_breakpoints/simple_hw_breakpoints/TestSimpleHWBreakpoints.py create mode 100644 lldb/test/API/functionalities/breakpoint/hardware_breakpoints/simple_hw_breakpoints/main.c diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h index e08df3b6d5ab0..307c9e13d7e39 100644 --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -148,6 +148,8 @@ class LLDB_API SBBreakpoint { bool IsHardware() const; + void SetIsHardware(bool is_hardware); + // Can only be called from a ScriptedBreakpointResolver... SBError AddLocation(SBAddress &address); diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h index f623a2e0c295b..8b1ab219832cc 100644 --- a/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -518,6 +518,7 @@ class Breakpoint : public std::enable_shared_from_this, lldb::break_id_t bp_loc_id); bool IsHardware() const { return m_hardware; } + void SetIsHardware(bool is_hardware); lldb::BreakpointResolverSP GetResolver() { return m_resolver_sp; } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 87fadbcec4f26..d790b3f4ca271 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -781,6 +781,17 @@ bool SBBreakpoint::IsHardware() const { return false; } +void SBBreakpoint::SetIsHardware(bool is_hardware) { + LLDB_INSTRUMENT_VA(this, is_hardware); + + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) { +std::lock_guard guard( +bkpt_sp->GetTarget().GetAPIMutex()); +bkpt_sp->SetIsHardware(is_hardware); + } +} + BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); } // This is simple collection of breakpoint id's and their target. diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 2ed0c9314e3e1..d5845ebeeb08a 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -251,6 +251,27 @@ const lldb::TargetSP Breakpoint::GetTargetSP() { bool Breakpoint::IsInternal() const { return LLDB_BREAK_ID_IS_INTERNAL(m_bid); } +void Breakpoint::SetIsHardware(bool is_hardware) { + if (is_hardware == m_hardware) +return; + + // Remember all the breakpoint locations we've disabled. + std::vector locations; + for (BreakpointLocationSP location : m_locations.BreakpointLocations()) { +if (location->IsEnabled()) { + locations.push_back(location); + location->SetEnabled(false); +} + } + + // Toggle the hardware mode. + m_hardware = is_hardware; + + // Re-enable the breakpoint locations. + for (BreakpointLocationSP location : locations) +location->SetEnabled(true); +} + BreakpointLocationSP Breakpoint::AddLocation(const Address &addr, bool *new_location) { return m_locations.AddLocation(addr, m_resolve_indirect_symbols, diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/simple_hw_breakpoints/Makefile b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/simple_hw_breakpoints/Makefile new file mode 100644 index 0..304633c2dca1f --- /dev/null
[Lldb-commits] [lldb] [llvm] [lldb] Enable support for DWARF64 format handling (PR #145645)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running on `hip-vega20-0` while building `lldb,llvm` at step 3 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/22423 Here is the relevant piece of the build log for the reference ``` Step 3 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure) ... [57/59] Linking CXX executable External/HIP/math_h-hip-6.3.0 [58/59] Building CXX object External/HIP/CMakeFiles/TheNextWeek-hip-6.3.0.dir/workload/ray-tracing/TheNextWeek/main.cc.o [59/59] Linking CXX executable External/HIP/TheNextWeek-hip-6.3.0 @@@BUILD_STEP Testing HIP test-suite@@@ + build_step 'Testing HIP test-suite' + echo '@@@BUILD_STEP Testing HIP test-suite@@@' + ninja check-hip-simple [0/1] cd /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP && /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/bin/llvm-lit -sv array-hip-6.3.0.test empty-hip-6.3.0.test with-fopenmp-hip-6.3.0.test saxpy-hip-6.3.0.test memmove-hip-6.3.0.test split-kernel-args-hip-6.3.0.test builtin-logb-scalbn-hip-6.3.0.test TheNextWeek-hip-6.3.0.test algorithm-hip-6.3.0.test cmath-hip-6.3.0.test complex-hip-6.3.0.test math_h-hip-6.3.0.test new-hip-6.3.0.test blender.test -- Testing: 14 tests, 14 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90 FAIL: test-suite :: External/HIP/blender.test (14 of 14) TEST 'test-suite :: External/HIP/blender.test' FAILED /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out --redirect-input /dev/null --summary /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.time /bin/bash test_blender.sh /bin/bash verify_blender.sh /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out Begin Blender test. TEST_SUITE_HIP_ROOT=/opt/botworker/llvm/External/hip Render /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45) Read blend: "/opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend" Could not open as Ogawa file from provided streams. Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc Could not open as Ogawa file from provided streams. Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc I0701 13:25:25.682497 3294208 devi
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -152,6 +152,20 @@ class StringPrinter { template static bool ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options); + + template + static constexpr uint64_t ElementByteSize() { Nerixyz wrote: Yes, done. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -239,122 +240,24 @@ VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { bool lldb_private::formatters::LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = - valobj.IsPointerOrReferenceType() - ? valobj.GetPointerValue() - : valobj.GetAddressOf(scalar_is_load_addr); - if (addr_of_string != LLDB_INVALID_ADDRESS) { -switch (addr_type) { -case eAddressTypeLoad: { - ProcessSP process_sp(valobj.GetProcessSP()); - if (!process_sp) -return false; - - StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); - Status error; - lldb::addr_t addr_of_data = - process_sp->ReadPointerFromMemory(addr_of_string, error); - if (error.Fail() || addr_of_data == 0 || - addr_of_data == LLDB_INVALID_ADDRESS) -return false; - options.SetLocation(addr_of_data); - options.SetTargetSP(valobj.GetTargetSP()); - options.SetStream(&stream); - options.SetNeedsZeroTermination(false); - options.SetBinaryZeroIsTerminator(true); - lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory( - addr_of_string + process_sp->GetAddressByteSize(), error); - if (error.Fail()) -return false; - options.SetSourceSize(size_of_data); - options.SetHasSourceSize(true); - - if (!StringPrinter::ReadStringAndDumpToStream< - StringPrinter::StringElementType::UTF8>(options)) { -stream.Printf("Summary Unavailable"); -return true; - } else -return true; -} break; -case eAddressTypeHost: - break; -case eAddressTypeInvalid: -case eAddressTypeFile: - break; -} - } - return false; + ValueObjectSP ptr = valobj.GetChildAtNamePath({"_M_dataplus", "_M_p"}); + if (!ptr) +return false; + + stream << ptr->GetSummaryAsCString(); + return true; } bool lldb_private::formatters::LibStdcppWStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = valobj.GetAddressOf(scalar_is_load_addr); - if (addr_of_string != LLDB_INVALID_ADDRESS) { -switch (addr_type) { -case eAddressTypeLoad: { - ProcessSP process_sp(valobj.GetProcessSP()); - if (!process_sp) -return false; - - CompilerType wchar_compiler_type = - valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); - - if (!wchar_compiler_type) -return false; - - // Safe to pass nullptr for exe_scope here. - std::optional size = - llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr)); - if (!size) -return false; - const uint32_t wchar_size = *size; - - StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); - Status error; - lldb::addr_t addr_of_data = - process_sp->ReadPointerFromMemory(addr_of_string, error); - if (error.Fail() || addr_of_data == 0 || - addr_of_data == LLDB_INVALID_ADDRESS) -return false; - options.SetLocation(addr_of_data); - options.SetTargetSP(valobj.GetTargetSP()); - options.SetStream(&stream); - options.SetNeedsZeroTermination(false); - options.SetBinaryZeroIsTerminator(false); - lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory( - addr_of_string + process_sp->GetAddressByteSize(), error); - if (error.Fail()) -return false; - options.SetSourceSize(size_of_data); - options.SetHasSourceSize(true); - options.SetPrefixToken("L"); - - switch (wchar_size) { - case 8: -return StringPrinter::ReadStringAndDumpToStream< -StringPrinter::StringElementType::UTF8>(options); - case 16: -return StringPrinter::ReadStringAndDumpToStream< -StringPrinter::StringElementType::UTF16>(options); - case 32: -return StringPrinter::ReadStringAndDumpToStream< -StringPrinter::StringElementType::UTF32>(options); - default: -stream.Printf("size for wchar_t is not valid"); -return true; - } - return true; -} break; -case eAddressTypeHost: - break; -case eAddressTypeInvalid: -case eAddressTypeFile: - break; -} - } - return false; + ValueObjectSP dataplus = valobj.GetChildMemberWithName("_M_dataplus"); Nerixyz wrote: Good point, this worked for me in MinGW, I'll see what the CI says. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -1629,6 +1630,80 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "^std::optional<.+>(( )?&)?$", stl_summary_flags, true); } +static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { Nerixyz wrote: Added "Load formatters that are formatting types from more than one STL". https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -239,122 +240,24 @@ VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { bool lldb_private::formatters::LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { - const bool scalar_is_load_addr = true; - auto [addr_of_string, addr_type] = - valobj.IsPointerOrReferenceType() - ? valobj.GetPointerValue() - : valobj.GetAddressOf(scalar_is_load_addr); - if (addr_of_string != LLDB_INVALID_ADDRESS) { -switch (addr_type) { -case eAddressTypeLoad: { - ProcessSP process_sp(valobj.GetProcessSP()); - if (!process_sp) -return false; - - StringPrinter::ReadStringAndDumpToStreamOptions options(valobj); - Status error; - lldb::addr_t addr_of_data = - process_sp->ReadPointerFromMemory(addr_of_string, error); - if (error.Fail() || addr_of_data == 0 || - addr_of_data == LLDB_INVALID_ADDRESS) -return false; - options.SetLocation(addr_of_data); - options.SetTargetSP(valobj.GetTargetSP()); - options.SetStream(&stream); - options.SetNeedsZeroTermination(false); - options.SetBinaryZeroIsTerminator(true); - lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory( - addr_of_string + process_sp->GetAddressByteSize(), error); - if (error.Fail()) -return false; - options.SetSourceSize(size_of_data); - options.SetHasSourceSize(true); - - if (!StringPrinter::ReadStringAndDumpToStream< - StringPrinter::StringElementType::UTF8>(options)) { -stream.Printf("Summary Unavailable"); -return true; - } else -return true; -} break; -case eAddressTypeHost: - break; -case eAddressTypeInvalid: -case eAddressTypeFile: - break; -} - } - return false; + ValueObjectSP ptr = valobj.GetChildAtNamePath({"_M_dataplus", "_M_p"}); + if (!ptr) +return false; + + stream << ptr->GetSummaryAsCString(); Nerixyz wrote: I'll do that as a separate PR. This initially came up when trying to port the format strings to C++ where I noticed that getting to the data pointer is the same in both pre- and post C++ 11 strings. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -1372,6 +1373,37 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "${var.__y_} ${var.__m_} ${var.__wdl_}"))); } +static void RegisterStdStringSummaryProvider( +const lldb::TypeCategoryImplSP &category_sp, llvm::StringRef string_ty, +llvm::StringRef char_ty, lldb::TypeSummaryImplSP summary_sp) { + auto makeSpecifier = [](llvm::StringRef name) { +return std::make_shared( +name, eFormatterMatchExact); + }; + + category_sp->AddTypeSummary(makeSpecifier(string_ty), summary_sp); + + // std::basic_string + category_sp->AddTypeSummary( + makeSpecifier(llvm::formatv("std::basic_string<{}>", char_ty).str()), + summary_sp); + // std::basic_string,std::allocator > + category_sp->AddTypeSummary( + makeSpecifier(llvm::formatv("std::basic_string<{0},std::char_traits<{0}>," + "std::allocator<{0}> >", + char_ty) +.str()), + summary_sp); Nerixyz wrote: This was initially added in https://github.com/llvm/llvm-project/commit/a6a60d0d87192d1cd99e46664c00e8e1d8d21da3, but I can't find why: > Finally, added a new class name to which the std::string summary should be > applied. https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use llvm::erase_if (NFC) (PR #146624)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/146624 Note that erase_if combines erase and remove_if. >From f284559ea2ba13678d65c6e68e3799e03e28a36a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 1 Jul 2025 11:18:31 -0700 Subject: [PATCH] [lldb] Use llvm::erase_if (NFC) Note that erase_if combines erase and remove_if. --- .../Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index c22d5bbdb6924..2adde02aca3a1 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -1891,11 +1891,8 @@ RISCVSingleStepBreakpointLocationsPredictor::HandleAtomicSequence( // Set breakpoints at the jump addresses of the forward branches that points // after the end of the atomic sequence. - bp_addrs.erase(llvm::remove_if(bp_addrs, - [exit_pc](lldb::addr_t bp_addr) { - return exit_pc >= bp_addr; - }), - bp_addrs.end()); + llvm::erase_if( + bp_addrs, [exit_pc](lldb::addr_t bp_addr) { return exit_pc >= bp_addr; }); // Set breakpoint at the end of atomic sequence. bp_addrs.push_back(exit_pc); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)
jasonmolenda wrote: > > Doesn't seem the ideal format given that we have a known size, today most > > often 16/32/64, and I guess 48 for funsies. > > Standard instructions are right now only 16/32, but custom instructions can > be any multiple of 16. This was the change to llvm-objdump to group bytes > like gnu objdump does: > [b27f86b](https://github.com/llvm/llvm-project/commit/b27f86b40b20942c0e809128214b43d6edde365a) > which was only a bit over a year ago. Thanks again for the helpful pointers and explanations. I'm surprised they gave up so many bits to help us distinguish opcodes! But we really should be using this in lldb as long as they're there. I don't think there's any good reason to print riscv instructions like we do with the intel variable length instructions in lldb's disassembler. Printing as a UInt16, UInt32, UInt16 + UInt16 + UInt16, or UInt32 + UInt32 etc seems like a good change to make to lldb's disassembler style for riscv + `-b`. I'm only skimming the patch to Opcode::Dump, but it looks like the existing code is relying on an enum when the Opcode object is constructed, ``` enum Type { eTypeInvalid, eType8, eType16, eType16_2, // a 32-bit Thumb instruction, made up of two words eType32, eType64, eTypeBytes }; ``` and the riscv instructions are constructed with the `Opcode(uint8_t *bytes, size_t length)` ctor so it gets `eTypeBytes` and it's printed that way. It looks like the `InstructionLLVMC::Decode()` function in DisassemblerLLVMC.cpp is creating these? I think changing the way we print the bytes for the riscv disassembler -b is a very reasonable change, instead of printing an array of UInt8's, and it doesn't seem like we should need to break this apart into a separate Opcode::DumpRISCV method? Adding `opcode_name = ""` i'm less immediately thrilled by, but I don't know what we'd print here that was useful as an alternative, maybe it's fine, would like to hear other opinions. https://github.com/llvm/llvm-project/pull/145793 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/146632 >From 3e0129934a74f9300a7d386797b63304a02b855f Mon Sep 17 00:00:00 2001 From: John Harrison Date: Tue, 1 Jul 2025 20:55:32 -0700 Subject: [PATCH] [lldb] Fixing warnings / win32 builds in MainLoop. Commit 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 introduced a few casting warnings and a build issue in Win32 platforms. Trying to correct the casts to c++ style casts instead of C style casts. --- .../lldb/Host/windows/MainLoopWindows.h | 8 ++-- lldb/include/lldb/lldb-types.h| 12 +++-- lldb/source/Host/common/JSONTransport.cpp | 3 +- .../posix/ConnectionFileDescriptorPosix.cpp | 10 ++-- lldb/source/Host/windows/MainLoopWindows.cpp | 48 +++ lldb/source/Utility/SelectHelper.cpp | 2 +- 6 files changed, 49 insertions(+), 34 deletions(-) diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 53df815255c3d..705e7e78ba48a 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -17,6 +17,8 @@ namespace lldb_private { +using handle_t = void *; + // Windows-specific implementation of the MainLoopBase class. It can monitor // socket descriptors for readability using WSAEventSelect. Non-socket file // descriptors are not supported. @@ -33,15 +35,15 @@ class MainLoopWindows : public MainLoopBase { class IOEvent { public: -IOEvent(IOObject::WaitableHandle event) : m_event(event) {} +IOEvent(handle_t event) : m_event(event) {} virtual ~IOEvent() {} virtual void WillPoll() {} virtual void DidPoll() {} virtual void Disarm() {} -IOObject::WaitableHandle GetHandle() { return m_event; } +handle_t GetHandle() { return m_event; } protected: -IOObject::WaitableHandle m_event; +handle_t m_event; }; using IOEventUP = std::unique_ptr; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 15781ad626efb..cef43892c8efa 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -42,12 +42,15 @@ typedef void *rwlock_t; typedef void *process_t; // Process type is HANDLE typedef void *thread_t; // Host thread type typedef void *file_t; // Host file type -typedef unsigned int __w64 socket_t; // Host socket type +typedef uintptr_t socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type typedef void *pipe_t; // Host pipe type is HANDLE +// printf macro for file_t +#define PRIuFT PRIuPTR + #else #include @@ -63,11 +66,14 @@ typedef void *thread_result_t; // Host thread result type typedef void *(*thread_func_t)(void *); // Host thread function type typedef int pipe_t; // Host pipe type +// printf macro for file_t +#define PRIuFT PRIi32 + #endif // _WIN32 -#define LLDB_INVALID_PROCESS ((lldb::process_t)-1) +#define LLDB_INVALID_PROCESS ((lldb::process_t) - 1) #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) -#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1) +#define LLDB_INVALID_PIPE ((lldb::pipe_t) - 1) #define LLDB_INVALID_CALLBACK_TOKEN ((lldb::callback_token_t) - 1) typedef void (*LogOutputCallback)(const char *, void *baton); diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index bf269ffa45966..546c12c8f7114 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,8 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); -sh.FDSetRead((lldb::socket_t)descriptor.GetWaitableHandle()); +sh.FDSetRead( +reinterpret_cast(descriptor.GetWaitableHandle())); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 44a3ed2e59d5f..83eb0c56853b3 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -273,10 +273,10 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, if (log) { LLDB_LOGF(log, - "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 + "%p ConnectionFileDescriptor::Read() fd = %" PRIuFT ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes Commit 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 introduced a few casting warnings and a build issue in Win32 platforms. Trying to correct the casts to c++ style casts instead of C style casts. --- Full diff: https://github.com/llvm/llvm-project/pull/146632.diff 6 Files Affected: - (modified) lldb/include/lldb/Host/windows/MainLoopWindows.h (+5-3) - (modified) lldb/include/lldb/lldb-types.h (+9-3) - (modified) lldb/source/Host/common/JSONTransport.cpp (+2-1) - (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+5-5) - (modified) lldb/source/Host/windows/MainLoopWindows.cpp (+27-21) - (modified) lldb/source/Utility/SelectHelper.cpp (+1-1) ``diff diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 53df815255c3d..705e7e78ba48a 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -17,6 +17,8 @@ namespace lldb_private { +using handle_t = void *; + // Windows-specific implementation of the MainLoopBase class. It can monitor // socket descriptors for readability using WSAEventSelect. Non-socket file // descriptors are not supported. @@ -33,15 +35,15 @@ class MainLoopWindows : public MainLoopBase { class IOEvent { public: -IOEvent(IOObject::WaitableHandle event) : m_event(event) {} +IOEvent(handle_t event) : m_event(event) {} virtual ~IOEvent() {} virtual void WillPoll() {} virtual void DidPoll() {} virtual void Disarm() {} -IOObject::WaitableHandle GetHandle() { return m_event; } +handle_t GetHandle() { return m_event; } protected: -IOObject::WaitableHandle m_event; +handle_t m_event; }; using IOEventUP = std::unique_ptr; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 15781ad626efb..cef43892c8efa 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -42,12 +42,15 @@ typedef void *rwlock_t; typedef void *process_t; // Process type is HANDLE typedef void *thread_t; // Host thread type typedef void *file_t; // Host file type -typedef unsigned int __w64 socket_t; // Host socket type +typedef uintptr_t socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type typedef void *pipe_t; // Host pipe type is HANDLE +// printf macro for file_t +#define PRIuFT PRIuPTR + #else #include @@ -63,11 +66,14 @@ typedef void *thread_result_t; // Host thread result type typedef void *(*thread_func_t)(void *); // Host thread function type typedef int pipe_t; // Host pipe type +// printf macro for file_t +#define PRIuFT PRIi32 + #endif // _WIN32 -#define LLDB_INVALID_PROCESS ((lldb::process_t)-1) +#define LLDB_INVALID_PROCESS ((lldb::process_t) - 1) #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) -#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1) +#define LLDB_INVALID_PIPE ((lldb::pipe_t) - 1) #define LLDB_INVALID_CALLBACK_TOKEN ((lldb::callback_token_t) - 1) typedef void (*LogOutputCallback)(const char *, void *baton); diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index bf269ffa45966..546c12c8f7114 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,8 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); -sh.FDSetRead((lldb::socket_t)descriptor.GetWaitableHandle()); +sh.FDSetRead( +reinterpret_cast(descriptor.GetWaitableHandle())); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 44a3ed2e59d5f..83eb0c56853b3 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -273,10 +273,10 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, if (log) { LLDB_LOGF(log, - "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 + "%p ConnectionFileDescriptor::Read() fd = %" PRIuFT ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()),
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
https://github.com/ashgti ready_for_review https://github.com/llvm/llvm-project/pull/146632 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the hardware breakpoint decorator (PR #146609)
https://github.com/jasonmolenda approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/146609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][framework] Copy framework files correctly (PR #146425)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/146425 >From e199f4ece908cfe9454e4b4b61f04133a615f8d2 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Mon, 30 Jun 2025 14:51:43 -0700 Subject: [PATCH] [lldb][framework] Copy framework files correctly A build step needs to copy headers from the framework staging area to the framework itself. This commit modifies the LLDB framework CMake module to do this. --- lldb/cmake/modules/LLDBFramework.cmake | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/cmake/modules/LLDBFramework.cmake b/lldb/cmake/modules/LLDBFramework.cmake index 70010ffbf738c..ccebf437a9814 100644 --- a/lldb/cmake/modules/LLDBFramework.cmake +++ b/lldb/cmake/modules/LLDBFramework.cmake @@ -109,10 +109,14 @@ add_dependencies(liblldb liblldb-resource-headers) # Then write them to the output directory. # Also, run unifdef to remove any specified guards from the header files. file(GLOB lldb_framework_header_staging_list ${lldb_framework_header_staging}/*) +add_custom_command(TARGET liblldb POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_framework_header_staging} $/Headers +) foreach(header ${lldb_framework_header_staging_list}) set(input_header ${header}) - set(output_header $/Headers/${input_header}) + get_filename_component(output_header_basename ${input_header} NAME) + set(output_header $/Headers/${output_header_basename}) add_custom_command(TARGET liblldb POST_BUILD COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i ${input_header} -o ${output_header} -p ${unifdef_EXECUTABLE} USWIG ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)
lenary wrote: > Doesn't seem the ideal format given that we have a known size, today most > often 16/32/64, and I guess 48 for funsies. Standard instructions are right now only 16/32, but custom instructions can be any multiple of 16. This was the change to llvm-objdump to group bytes like gnu objdump does: https://github.com/llvm/llvm-project/commit/b27f86b40b20942c0e809128214b43d6edde365a which was only a bit over a year ago. https://github.com/llvm/llvm-project/pull/145793 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)
lenary wrote: > I didn't realize that the riscv instructions had a scheme for indicating > their lengths, very convenient. It "doesn't". LLVM objdump implements the scheme described in the spec, but for >32-bit instructions, that scheme is not ratified so it could change in the future (the note about this is there but easy to miss). That said, Qualcomm's custom instructions have adopted the unratified scheme for 48-bit instructions. > ... is this something that could be formatted from the SBInstructions in > `fdis`? ... > I haven't looked at the contents of the SBInstruction to see if this is > straightforward or if there are things like the comment field that are > missing, but it's my first thought for accomplishing this. IIRC, there's nothing to that provides the raw encoding bytes to pass off to another disassembler. Maybe I missed it, or it's not documented? That said, it would be great not to have to re-implement all of the disassemble command's argument handling, which looks fairly complex to me. https://github.com/llvm/llvm-project/pull/145793 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the hardware breakpoint decorator (PR #146609)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/146609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a87b27f - [lldb] Fix the hardware breakpoint decorator (#146609)
Author: Jonas Devlieghere Date: 2025-07-01T18:01:19-07:00 New Revision: a87b27fd5161ec43527fc3356852046a321ea82c URL: https://github.com/llvm/llvm-project/commit/a87b27fd5161ec43527fc3356852046a321ea82c DIFF: https://github.com/llvm/llvm-project/commit/a87b27fd5161ec43527fc3356852046a321ea82c.diff LOG: [lldb] Fix the hardware breakpoint decorator (#146609) A decorator to skip or XFAIL a test takes effect when the function that's passed in returns a reason string. The wrappers around hw_breakpoints_supported were doing that incorrectly by inverting (calling `not`) on the result, turning it into a boolean, which means the test is always skipped. Added: Modified: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py Removed: diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py index 0ab5dd0f910f2..0ad903befc65e 100644 --- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py +++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py @@ -14,5 +14,15 @@ def supports_hw_breakpoints(self): self.runCmd("breakpoint set -b main --hardware") self.runCmd("run") if "stopped" in self.res.GetOutput(): +return True +return False + +def hw_breakpoints_supported(self): +if self.supports_hw_breakpoints(): return "Hardware breakpoints are supported" return None + +def hw_breakpoints_unsupported(self): +if not self.supports_hw_breakpoints(): +return "Hardware breakpoints are unsupported" +return None diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py index 1a0515aa04c07..4632c3bed1899 100644 --- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py +++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py @@ -12,16 +12,13 @@ class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase): -def does_not_support_hw_breakpoints(self): -return not super().supports_hw_breakpoints() - -@skipTestIfFn(does_not_support_hw_breakpoints) +@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported) def test_hw_break_set_delete_multi_thread_macos(self): self.build() self.setTearDownCleanup() self.break_multi_thread("delete") -@skipTestIfFn(does_not_support_hw_breakpoints) +@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_unsupported) def test_hw_break_set_disable_multi_thread_macos(self): self.build() self.setTearDownCleanup() diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py index 89d57683a8007..a8c9cdeea9362 100644 --- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py +++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py @@ -26,7 +26,7 @@ def test_breakpoint(self): breakpoint = target.BreakpointCreateByLocation("main.c", 1) self.assertTrue(breakpoint.IsHardware()) -@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints) +@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported) def test_step_range(self): """Test stepping when hardware breakpoints are required.""" self.build() @@ -49,7 +49,7 @@ def test_step_range(self): "Could not create hardware breakpoint for thread plan", error.GetCString() ) -@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints) +@skipTestIfFn(HardwareBreakpointTestBase.hw_breakpoints_supported) def test_step_out(self): """Test stepping out when hardware breakpoints are required.""" self.build() @@ -71,7 +71,7 @@ def test_step_out(self): "Could not create hardware breakpoint for thread plan", error.GetCString()
[Lldb-commits] [lldb] [lldb] Use llvm::erase_if (NFC) (PR #146624)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) Changes Note that erase_if combines erase and remove_if. --- Full diff: https://github.com/llvm/llvm-project/pull/146624.diff 1 Files Affected: - (modified) lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp (+2-5) ``diff diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index c22d5bbdb6924..2adde02aca3a1 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -1891,11 +1891,8 @@ RISCVSingleStepBreakpointLocationsPredictor::HandleAtomicSequence( // Set breakpoints at the jump addresses of the forward branches that points // after the end of the atomic sequence. - bp_addrs.erase(llvm::remove_if(bp_addrs, - [exit_pc](lldb::addr_t bp_addr) { - return exit_pc >= bp_addr; - }), - bp_addrs.end()); + llvm::erase_if( + bp_addrs, [exit_pc](lldb::addr_t bp_addr) { return exit_pc >= bp_addr; }); // Set breakpoint at the end of atomic sequence. bp_addrs.push_back(exit_pc); `` https://github.com/llvm/llvm-project/pull/146624 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/146632 Commit 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 introduced a few casting warnings and a build issue in Win32 platforms. Trying to correct the casts to c++ style casts instead of C style casts. >From 7740b5aab057f4515525c60ccf7c26b4528499f5 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Tue, 1 Jul 2025 20:55:32 -0700 Subject: [PATCH] [lldb] Fixing warnings / win32 builds in MainLoop. Commit 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 introduced a few casting warnings and a build issue in Win32 platforms. Trying to correct the casts to c++ style casts instead of C style casts. --- .../lldb/Host/windows/MainLoopWindows.h | 8 ++-- lldb/include/lldb/lldb-types.h| 6 ++- lldb/source/Host/common/JSONTransport.cpp | 2 +- .../posix/ConnectionFileDescriptorPosix.cpp | 10 ++-- lldb/source/Host/windows/MainLoopWindows.cpp | 48 +++ lldb/source/Utility/SelectHelper.cpp | 2 +- 6 files changed, 44 insertions(+), 32 deletions(-) diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 53df815255c3d..98b429a8fc712 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -17,6 +17,8 @@ namespace lldb_private { +using handle_t = void*; + // Windows-specific implementation of the MainLoopBase class. It can monitor // socket descriptors for readability using WSAEventSelect. Non-socket file // descriptors are not supported. @@ -33,15 +35,15 @@ class MainLoopWindows : public MainLoopBase { class IOEvent { public: -IOEvent(IOObject::WaitableHandle event) : m_event(event) {} +IOEvent(handle_t event) : m_event(event) {} virtual ~IOEvent() {} virtual void WillPoll() {} virtual void DidPoll() {} virtual void Disarm() {} -IOObject::WaitableHandle GetHandle() { return m_event; } +handle_t GetHandle() { return m_event; } protected: -IOObject::WaitableHandle m_event; +handle_t m_event; }; using IOEventUP = std::unique_ptr; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 15781ad626efb..90b58e3729c8a 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -42,12 +42,14 @@ typedef void *rwlock_t; typedef void *process_t; // Process type is HANDLE typedef void *thread_t; // Host thread type typedef void *file_t; // Host file type -typedef unsigned int __w64 socket_t; // Host socket type +typedef uintptr_t socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type typedef void *pipe_t; // Host pipe type is HANDLE +#define PRIuFT PRIuPTR + #else #include @@ -63,6 +65,8 @@ typedef void *thread_result_t; // Host thread result type typedef void *(*thread_func_t)(void *); // Host thread function type typedef int pipe_t; // Host pipe type +#define PRIuFT PRIu64 + #endif // _WIN32 #define LLDB_INVALID_PROCESS ((lldb::process_t)-1) diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index bf269ffa45966..444d3b091e58c 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,7 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); -sh.FDSetRead((lldb::socket_t)descriptor.GetWaitableHandle()); + sh.FDSetRead(reinterpret_cast(descriptor.GetWaitableHandle())); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 44a3ed2e59d5f..83eb0c56853b3 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -273,10 +273,10 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, if (log) { LLDB_LOGF(log, - "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 + "%p ConnectionFileDescriptor::Read() fd = %" PRIuFT ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static_cast(m_io_sp->GetWaitableHandle()), + static_cast(m_io_sp->GetWaitableHandle()), static_cast(dst), static_cast(dst_len), static_cast(bytes_read), error.AsCString())
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- lldb/include/lldb/Host/windows/MainLoopWindows.h lldb/include/lldb/lldb-types.h lldb/source/Host/common/JSONTransport.cpp lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/source/Host/windows/MainLoopWindows.cpp lldb/source/Utility/SelectHelper.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 98b429a8f..705e7e78b 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -17,7 +17,7 @@ namespace lldb_private { -using handle_t = void*; +using handle_t = void *; // Windows-specific implementation of the MainLoopBase class. It can monitor // socket descriptors for readability using WSAEventSelect. Non-socket file diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 90b58e372..5d53b656e 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -42,7 +42,7 @@ typedef void *rwlock_t; typedef void *process_t; // Process type is HANDLE typedef void *thread_t; // Host thread type typedef void *file_t; // Host file type -typedef uintptr_t socket_t; // Host socket type +typedef uintptr_t socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index 444d3b091..546c12c8f 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,8 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); - sh.FDSetRead(reinterpret_cast(descriptor.GetWaitableHandle())); +sh.FDSetRead( +reinterpret_cast(descriptor.GetWaitableHandle())); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. `` https://github.com/llvm/llvm-project/pull/146632 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixing warnings / win32 builds in MainLoop. (PR #146632)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/146632 >From 14960a86f9d2f01b4ec175fe6539f8d359beaba7 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Tue, 1 Jul 2025 20:55:32 -0700 Subject: [PATCH] [lldb] Fixing warnings / win32 builds in MainLoop. Commit 1a7b7e24bcc1041ae0fb90abcfb73d36d76f4a07 introduced a few casting warnings and a build issue in Win32 platforms. Trying to correct the casts to c++ style casts instead of C style casts. --- .../lldb/Host/windows/MainLoopWindows.h | 8 ++-- lldb/include/lldb/lldb-types.h| 12 +++-- lldb/source/Host/common/JSONTransport.cpp | 3 +- .../posix/ConnectionFileDescriptorPosix.cpp | 10 ++-- lldb/source/Host/windows/MainLoopWindows.cpp | 48 +++ lldb/source/Utility/SelectHelper.cpp | 2 +- 6 files changed, 49 insertions(+), 34 deletions(-) diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h b/lldb/include/lldb/Host/windows/MainLoopWindows.h index 53df815255c3d..705e7e78ba48a 100644 --- a/lldb/include/lldb/Host/windows/MainLoopWindows.h +++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h @@ -17,6 +17,8 @@ namespace lldb_private { +using handle_t = void *; + // Windows-specific implementation of the MainLoopBase class. It can monitor // socket descriptors for readability using WSAEventSelect. Non-socket file // descriptors are not supported. @@ -33,15 +35,15 @@ class MainLoopWindows : public MainLoopBase { class IOEvent { public: -IOEvent(IOObject::WaitableHandle event) : m_event(event) {} +IOEvent(handle_t event) : m_event(event) {} virtual ~IOEvent() {} virtual void WillPoll() {} virtual void DidPoll() {} virtual void Disarm() {} -IOObject::WaitableHandle GetHandle() { return m_event; } +handle_t GetHandle() { return m_event; } protected: -IOObject::WaitableHandle m_event; +handle_t m_event; }; using IOEventUP = std::unique_ptr; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 15781ad626efb..d5db4a5dbc26b 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -42,12 +42,15 @@ typedef void *rwlock_t; typedef void *process_t; // Process type is HANDLE typedef void *thread_t; // Host thread type typedef void *file_t; // Host file type -typedef unsigned int __w64 socket_t; // Host socket type +typedef uintptr_t socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type typedef void *pipe_t; // Host pipe type is HANDLE +// printf macro for file_t +#define PRIuFT PRIuPTR + #else #include @@ -63,11 +66,14 @@ typedef void *thread_result_t; // Host thread result type typedef void *(*thread_func_t)(void *); // Host thread function type typedef int pipe_t; // Host pipe type +// printf macro for file_t +#define PRIuFT PRIu64 + #endif // _WIN32 -#define LLDB_INVALID_PROCESS ((lldb::process_t)-1) +#define LLDB_INVALID_PROCESS ((lldb::process_t) - 1) #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) -#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1) +#define LLDB_INVALID_PIPE ((lldb::pipe_t) - 1) #define LLDB_INVALID_CALLBACK_TOKEN ((lldb::callback_token_t) - 1) typedef void (*LogOutputCallback)(const char *, void *baton); diff --git a/lldb/source/Host/common/JSONTransport.cpp b/lldb/source/Host/common/JSONTransport.cpp index bf269ffa45966..546c12c8f7114 100644 --- a/lldb/source/Host/common/JSONTransport.cpp +++ b/lldb/source/Host/common/JSONTransport.cpp @@ -42,7 +42,8 @@ ReadFull(IOObject &descriptor, size_t length, if (timeout && timeout_supported) { SelectHelper sh; sh.SetTimeout(*timeout); -sh.FDSetRead((lldb::socket_t)descriptor.GetWaitableHandle()); +sh.FDSetRead( +reinterpret_cast(descriptor.GetWaitableHandle())); Status status = sh.Select(); if (status.Fail()) { // Convert timeouts into a specific error. diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 44a3ed2e59d5f..83eb0c56853b3 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -273,10 +273,10 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, if (log) { LLDB_LOGF(log, - "%p ConnectionFileDescriptor::Read() fd = %" PRIu64 + "%p ConnectionFileDescriptor::Read() fd = %" PRIuFT ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s", static_cast(this), - static
[Lldb-commits] [lldb] [lldb] Add SB API to make a breakpoint a hardware breakpoint (PR #146602)
https://github.com/JDevlieghere converted_to_draft https://github.com/llvm/llvm-project/pull/146602 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -152,6 +152,20 @@ class StringPrinter { template static bool ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options); + + template + static constexpr uint64_t ElementByteSize() { Michael137 wrote: Can we just make this a static in `MsvcStl.cpp`? https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add linux test for the three-arg version of getProcFile (PR #146500)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/146500 Also conditionalize the header includes. Not strictly necessary, but it's weird to include an aix header on non-aix builds, it makes clang-tidy complain, and breaks build systems which require you to declare all headers belonging to a library (aka bazel). >From 2b30e53ff0c1d03e3acfd10c06863463a99dec60 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 1 Jul 2025 12:06:23 +0200 Subject: [PATCH] [lldb] Add linux test for the three-arg version of getProcFile Also conditionalize the header includes. Not strictly necessary, but it's weird to include an aix header on non-aix builds, it makes clang-tidy complain, and breaks build systems which require you to declare all headers belonging to a library (aka bazel). --- lldb/unittests/Host/posix/SupportTest.cpp | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lldb/unittests/Host/posix/SupportTest.cpp b/lldb/unittests/Host/posix/SupportTest.cpp index e4d7ba89fece6..6999128e43e36 100644 --- a/lldb/unittests/Host/posix/SupportTest.cpp +++ b/lldb/unittests/Host/posix/SupportTest.cpp @@ -7,10 +7,15 @@ //===--===// #include "lldb/Host/posix/Support.h" -#include "lldb/Host/aix/Support.h" #include "llvm/Support/Threading.h" #include "gtest/gtest.h" +#if defined(_AIX) +#include "lldb/Host/aix/Support.h" +#elif defined(__linux__) +#include "lldb/Host/linux/Support.h" +#endif + using namespace lldb_private; #ifndef __APPLE__ @@ -21,9 +26,15 @@ TEST(Support, getProcFile_Pid) { } #endif // #ifndef __APPLE__ -#if defined(_AIX) && defined(LLVM_ENABLE_THREADING) +#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING) TEST(Support, getProcFile_Tid) { - auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "lwpstatus"); + auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), +#ifdef _AIX + "lwpstatus" +#else + "status" +#endif + ); ASSERT_TRUE(BufferOrError); ASSERT_TRUE(*BufferOrError); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)
https://github.com/HemangGadhavi updated https://github.com/llvm/llvm-project/pull/145645 >From a85d648ce62b69b870dda306dbdc2d412ed89d33 Mon Sep 17 00:00:00 2001 From: HemangGadhavi Date: Wed, 25 Jun 2025 02:06:05 -0400 Subject: [PATCH 1/6] [lldb][DWARF64] Enable support for DWARF64 format handling --- .../SymbolFile/DWARF/DWARFFormValue.cpp | 47 --- .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 15 +- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 1 + 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index fd3d45cef4c5e..d0cc5edc6678a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -77,7 +77,10 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, case DW_FORM_strp: case DW_FORM_line_strp: case DW_FORM_sec_offset: - m_value.uval = data.GetMaxU64(offset_ptr, 4); + if (m_unit->GetFormat() == DwarfFormat::DWARF32) +m_value.uval = data.GetMaxU64(offset_ptr, 4); + else if (m_unit->GetFormat() == DwarfFormat::DWARF64) +m_value.uval = data.GetMaxU64(offset_ptr, 8); break; case DW_FORM_addrx1: case DW_FORM_strx1: @@ -121,8 +124,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, assert(m_unit); if (m_unit->GetVersion() <= 2) ref_addr_size = m_unit->GetAddressByteSize(); - else -ref_addr_size = 4; + else { +if (m_unit->GetFormat() == DwarfFormat::DWARF32) + ref_addr_size = 4; +else if (m_unit->GetFormat() == DwarfFormat::DWARF64) + ref_addr_size = 8; + } m_value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); break; case DW_FORM_indirect: @@ -165,17 +172,18 @@ static FormSize g_form_sizes[] = { {1, 1}, // 0x0b DW_FORM_data1 {1, 1}, // 0x0c DW_FORM_flag {0, 0}, // 0x0d DW_FORM_sdata -{1, 4}, // 0x0e DW_FORM_strp +{0, 0}, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64) {0, 0}, // 0x0f DW_FORM_udata {0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later -{1, 1}, // 0x11 DW_FORM_ref1 -{1, 2}, // 0x12 DW_FORM_ref2 -{1, 4}, // 0x13 DW_FORM_ref4 -{1, 8}, // 0x14 DW_FORM_ref8 -{0, 0}, // 0x15 DW_FORM_ref_udata -{0, 0}, // 0x16 DW_FORM_indirect -{1, 4}, // 0x17 DW_FORM_sec_offset +{1, 1}, // 0x11 DW_FORM_ref1 +{1, 2}, // 0x12 DW_FORM_ref2 +{1, 4}, // 0x13 DW_FORM_ref4 +{1, 8}, // 0x14 DW_FORM_ref8 +{0, 0}, // 0x15 DW_FORM_ref_udata +{0, 0}, // 0x16 DW_FORM_indirect +{0, + 0}, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32, 8 bytes for DWARF64) {0, 0}, // 0x18 DW_FORM_exprloc {1, 0}, // 0x19 DW_FORM_flag_present {0, 0}, // 0x1a DW_FORM_strx (ULEB128) @@ -183,8 +191,8 @@ static FormSize g_form_sizes[] = { {1, 4}, // 0x1c DW_FORM_ref_sup4 {0, 0}, // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64) {1, 16}, // 0x1e DW_FORM_data16 -{1, 4}, // 0x1f DW_FORM_line_strp -{1, 8}, // 0x20 DW_FORM_ref_sig8 +{0, 0}, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for DWARF64) +{1, 8}, // 0x20 DW_FORM_ref_sig8 }; std::optional DWARFFormValue::GetFixedSize(dw_form_t form, @@ -251,8 +259,12 @@ bool DWARFFormValue::SkipValue(dw_form_t form, // get this wrong if (unit->GetVersion() <= 2) ref_addr_size = unit->GetAddressByteSize(); -else - ref_addr_size = 4; +else { + if (unit->GetFormat() == DwarfFormat::DWARF32) +ref_addr_size = 4; + else if (unit->GetFormat() == DwarfFormat::DWARF64) +ref_addr_size = 8; +} *offset_ptr += ref_addr_size; return true; @@ -288,7 +300,10 @@ bool DWARFFormValue::SkipValue(dw_form_t form, case DW_FORM_sec_offset: case DW_FORM_strp: case DW_FORM_line_strp: - *offset_ptr += 4; + if (unit->GetFormat() == DwarfFormat::DWARF32) +*offset_ptr += 4; + else if (unit->GetFormat() == DwarfFormat::DWARF64) +*offset_ptr += 8; return true; // 4 byte values diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index ffd6f1dd52aff..f216ab13e8936 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -1073,20 +1073,7 @@ const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const { : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData(); } -uint32_t DWARFUnit::GetHeaderByteSize() const { - switch (m_header.getUnitType()) { - case llvm::dwarf::DW_UT_compile: - case llvm::dwarf::DW_UT_partial: -ret
[Lldb-commits] [lldb] [lldb][AArch64] Add HWCAP3 to register field detection (PR #145029)
DavidSpickett wrote: ping! https://github.com/llvm/llvm-project/pull/145029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)
@@ -299,6 +299,7 @@ Changes to LLDB stop reason = SIGSEGV: sent by tkill system call (sender pid=649752, uid=2667987) ``` * ELF Cores can now have their siginfo structures inspected using `thread siginfo`. +* LLDB now supports `DWARF64` debugging information format. HemangGadhavi wrote: Thanks! Updated https://github.com/llvm/llvm-project/pull/145645 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add linux test for the three-arg version of getProcFile (PR #146500)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes Also conditionalize the header includes. Not strictly necessary, but it's weird to include an aix header on non-aix builds, it makes clang-tidy complain, and breaks build systems which require you to declare all headers belonging to a library (aka bazel). --- Full diff: https://github.com/llvm/llvm-project/pull/146500.diff 1 Files Affected: - (modified) lldb/unittests/Host/posix/SupportTest.cpp (+14-3) ``diff diff --git a/lldb/unittests/Host/posix/SupportTest.cpp b/lldb/unittests/Host/posix/SupportTest.cpp index e4d7ba89fece6..6999128e43e36 100644 --- a/lldb/unittests/Host/posix/SupportTest.cpp +++ b/lldb/unittests/Host/posix/SupportTest.cpp @@ -7,10 +7,15 @@ //===--===// #include "lldb/Host/posix/Support.h" -#include "lldb/Host/aix/Support.h" #include "llvm/Support/Threading.h" #include "gtest/gtest.h" +#if defined(_AIX) +#include "lldb/Host/aix/Support.h" +#elif defined(__linux__) +#include "lldb/Host/linux/Support.h" +#endif + using namespace lldb_private; #ifndef __APPLE__ @@ -21,9 +26,15 @@ TEST(Support, getProcFile_Pid) { } #endif // #ifndef __APPLE__ -#if defined(_AIX) && defined(LLVM_ENABLE_THREADING) +#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING) TEST(Support, getProcFile_Tid) { - auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "lwpstatus"); + auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), +#ifdef _AIX + "lwpstatus" +#else + "status" +#endif + ); ASSERT_TRUE(BufferOrError); ASSERT_TRUE(*BufferOrError); } `` https://github.com/llvm/llvm-project/pull/146500 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)
@@ -299,6 +299,7 @@ Changes to LLDB stop reason = SIGSEGV: sent by tkill system call (sender pid=649752, uid=2667987) ``` * ELF Cores can now have their siginfo structures inspected using `thread siginfo`. +* LLDB now supports `DWARF64` debugging information format. DavidSpickett wrote: I would say "the `DWARF64`". https://github.com/llvm/llvm-project/pull/145645 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add linux test for the three-arg version of getProcFile (PR #146500)
@@ -21,9 +26,15 @@ TEST(Support, getProcFile_Pid) { } #endif // #ifndef __APPLE__ -#if defined(_AIX) && defined(LLVM_ENABLE_THREADING) +#if (defined(_AIX) || defined(__linux__)) && defined(LLVM_ENABLE_THREADING) DavidSpickett wrote: Why do we care about threading here, are we starting a new process using llvm's APIs then asking for the proc files of that process? https://github.com/llvm/llvm-project/pull/146500 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -0,0 +1,143 @@ +//===-- MsvcStl.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "MsvcStl.h" + +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FormatEntity.h" +#include "lldb/DataFormatters/StringPrinter.h" +#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/ValueObject/ValueObject.h" + +#include "Plugins/Language/CPlusPlus/CxxStringTypes.h" + +#include "lldb/lldb-forward.h" +#include +#include + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::formatters; + +using StringElementType = StringPrinter::StringElementType; + +static ValueObjectSP ExtractMsvcStlStringData(ValueObject &valobj) { + return valobj.GetChildAtNamePath({"_Mypair", "_Myval2"}); +} + +/// Determine the size in bytes of \p valobj (a MSVC STL std::string object) and +/// extract its data payload. Return the size + payload pair. +static std::optional> +ExtractMsvcStlStringInfo(ValueObject &valobj, uint64_t element_size) { + ValueObjectSP valobj_pair_sp = ExtractMsvcStlStringData(valobj); + if (!valobj_pair_sp || !valobj_pair_sp->GetError().Success()) +return {}; + + ValueObjectSP size_sp = valobj_pair_sp->GetChildMemberWithName("_Mysize"); + ValueObjectSP capacity_sp = valobj_pair_sp->GetChildMemberWithName("_Myres"); + ValueObjectSP bx_sp = valobj_pair_sp->GetChildMemberWithName("_Bx"); + if (!size_sp || !capacity_sp || !bx_sp) +return {}; + + bool success = false; + uint64_t size = size_sp->GetValueAsUnsigned(0, &success); + if (!success) +return {}; + uint64_t capacity = capacity_sp->GetValueAsUnsigned(0, &success); + if (!success) +return {}; + + size_t bufSize = std::max(16 / element_size, 1); + bool isShortString = capacity < bufSize; + + if (isShortString) { +ValueObjectSP buf_sp = bx_sp->GetChildMemberWithName("_Buf"); +if (buf_sp) + return std::make_pair(size, buf_sp); +return {}; + } + ValueObjectSP ptr_sp = bx_sp->GetChildMemberWithName("_Ptr"); + if (ptr_sp) +return std::make_pair(size, ptr_sp); + return {}; +} + +template +static bool +MsvcStlStringSummaryProviderImpl(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options, + std::string prefix_token) { + auto string_info = ExtractMsvcStlStringInfo( + valobj, StringPrinter::ElementByteSize()); + if (!string_info) +return false; + uint64_t size; + ValueObjectSP location_sp; + std::tie(size, location_sp) = *string_info; Michael137 wrote: ```suggestion auto [size, location_sp] = *string_info; ``` https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)
https://github.com/DavidSpickett approved this pull request. https://github.com/llvm/llvm-project/pull/145645 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)
DavidSpickett wrote: This has approvals already and looks good to me, do you need someone to merge it? https://github.com/llvm/llvm-project/pull/145645 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -18,11 +18,11 @@ namespace lldb_private { namespace formatters { bool LibStdcppStringSummaryProvider( ValueObject &valobj, Stream &stream, -const TypeSummaryOptions &options); // libcstdc++ c++11 std::string +const TypeSummaryOptions &options); // libcstdc++ std::string Michael137 wrote: ```suggestion const TypeSummaryOptions &options); // libstdc++ std::string ``` https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
https://github.com/Michael137 commented: LGTM, with some minor nits https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
@@ -0,0 +1,120 @@ +# coding=utf8 +""" +Test std::*string summaries with MSVC's STL. +""" Michael137 wrote: I might've missed some discussion on this: Not a blocker for this PR but why do we have separate API test directories for the various STLs? The only difference in them being `USE_LIBCPP` vs. `USE_LIBSTCPP` in the Makefiles. And now a third one with no apparent difference in the Makefile. We should probably consolidate them all into the `data-formatter/data-formatter-stl` and just pass the necessary makefile flags from within the python tests (via `self.build`)? @labath @DavidSpickett anything stopping us from doing that? https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/143177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits