[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)
https://github.com/kusmour updated https://github.com/llvm/llvm-project/pull/134339 >From 2f8dc76a640368d958068bf1d0ea0bbdfaba117f Mon Sep 17 00:00:00 2001 From: Wanyi Ye Date: Thu, 3 Apr 2025 22:29:13 -0700 Subject: [PATCH 1/2] [lldb] Make SBProcess thread related actions listen to StopLocker --- lldb/source/API/SBProcess.cpp | 20 ++- .../tools/lldb-dap/attach/TestDAP_attach.py | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 23ea449b30cca..ba77b2beed5ea 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -193,10 +193,11 @@ uint32_t SBProcess::GetNumThreads() { if (process_sp) { Process::StopLocker stop_locker; -const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); -std::lock_guard guard( -process_sp->GetTarget().GetAPIMutex()); -num_threads = process_sp->GetThreadList().GetSize(can_update); +if (stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard guard( + process_sp->GetTarget().GetAPIMutex()); + num_threads = process_sp->GetThreadList().GetSize(); +} } return num_threads; @@ -393,11 +394,12 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) { ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; -const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); -std::lock_guard guard( -process_sp->GetTarget().GetAPIMutex()); -thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); -sb_thread.SetThread(thread_sp); +if (stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard guard( + process_sp->GetTarget().GetAPIMutex()); + thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, false); + sb_thread.SetThread(thread_sp); +} } return sb_thread; diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index 9df44cc454d5d..b9fbf2c8d14f9 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -1,5 +1,5 @@ """ -Test lldb-dap setBreakpoints request +Test lldb-dap attach request """ >From 9618197664f934988f4affc407a1d21fe4e6eb53 Mon Sep 17 00:00:00 2001 From: Wanyi Ye Date: Tue, 8 Apr 2025 22:52:19 -0700 Subject: [PATCH 2/2] [lldb-dap] Client expects initial threads request not empty --- .../test/tools/lldb-dap/dap_server.py | 6 +- lldb/tools/lldb-dap/DAP.h | 3 +++ .../ConfigurationDoneRequestHandler.cpp | 20 ++- .../Handler/ThreadsRequestHandler.cpp | 20 ++- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 45403e9df8525..6dbfc9dd84afa 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -649,13 +649,17 @@ def request_configurationDone(self): response = self.send_recv(command_dict) if response: self.configuration_done_sent = True +# Client requests the baseline of currently existing threads after +# a successful launch or attach. +# Kick off the threads request that follows +self.request_threads() return response def _process_stopped(self): self.threads = None self.frame_scopes = {} -def request_continue(self, threadId=None): +def request_continue(self, threadId=None): if self.exit_status is not None: raise ValueError("request_continue called after process exited") # If we have launched or attached, then the first continue is done by diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..feeb040546c76 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -207,6 +207,9 @@ struct DAP { /// The set of features supported by the connected client. llvm::DenseSet clientFeatures; + /// The initial thread list upon attaching + std::optional initial_thread_list; + /// Creates a new DAP sessions. /// /// \param[in] log diff --git a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp index cd120e1fdfaba..f908c640da2d8 100644 --- a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp @@ -44,6 +44,18 @@ namespace lldb_dap { // just an acknowledgement, so no body field is required." // }] // }, + +llvm::json::Array CacheInitialThre
[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r HEAD~1...HEAD lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py `` View the diff from darker here. ``diff --- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2025-04-10 01:45:08.00 + +++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2025-04-10 01:47:56.113884 + @@ -657,11 +657,11 @@ def _process_stopped(self): self.threads = None self.frame_scopes = {} -def request_continue(self, threadId=None): +def request_continue(self, threadId=None): if self.exit_status is not None: raise ValueError("request_continue called after process exited") # If we have launched or attached, then the first continue is done by # sending the 'configurationDone' request if not self.configuration_done_sent: `` https://github.com/llvm/llvm-project/pull/134339 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
slydiman wrote: Note `Language::ForEach()` gives the following list: ``` cplusplus(eLanguageTypeC_plus_plus) objc(eLanguageTypeObjC) objcplusplus(eLanguageTypeObjC_plus_plus) cplusplus(eLanguageTypeC_plus_plus_03) cplusplus(eLanguageTypeC_plus_plus_11) cplusplus(eLanguageTypeC_plus_plus_14) cplusplus(eLanguageTypeC_plus_plus_17) cplusplus(eLanguageTypeC_plus_plus_20) ``` so cplusplus plug-in was called many times. The order of language plug-ins in CMakeLists.txt does not matter. I have optimized `Module::LookupInfo()` a lot. Note if name_type_mask = eFunctionNameTypeAuto it is very important to call all plugins and cplusplus->GetFunctionNameInfo(). gives `eFunctionNameTypeMethod | eFunctionNameTypeBase` flags to ObjC names. The TestExternCSymbols.py test failed because of missing logic ``` // Still try and get a basename in case someone specifies a name type mask // of eFunctionNameTypeFull and a name like "A::func" ``` It must be fixed now. https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into helper functions and use LLVM style (PR #135031)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/135031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][debugserver] Fix an off-by-one error in watchpoint identification (PR #134314)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running on `linaro-lldb-arm-ubuntu` while building `lldb` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/14116 Here is the relevant piece of the build log for the reference ``` Step 6 (test) failure: build (failure) ... UNSUPPORTED: lldb-api :: functionalities/unwind/ehframe/TestEhFrameUnwind.py (690 of 2951) UNSUPPORTED: lldb-api :: functionalities/unwind/noreturn/TestNoreturnUnwind.py (691 of 2951) PASS: lldb-api :: functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py (692 of 2951) PASS: lldb-api :: functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py (693 of 2951) UNSUPPORTED: lldb-api :: functionalities/unwind/sigtramp/TestSigtrampUnwind.py (694 of 2951) PASS: lldb-api :: functionalities/unwind/zeroth_frame/TestZerothFrame.py (695 of 2951) PASS: lldb-api :: functionalities/value_md5_crash/TestValueMD5Crash.py (696 of 2951) PASS: lldb-api :: functionalities/valobj_errors/TestValueObjectErrors.py (697 of 2951) PASS: lldb-api :: functionalities/var_path/TestVarPath.py (698 of 2951) UNSUPPORTED: lldb-api :: functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py (699 of 2951) FAIL: lldb-api :: functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py (700 of 2951) TEST 'lldb-api :: functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py' FAILED Script: -- /usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch armv8l --build-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints -p TestConsecutiveWatchpoints.py -- Exit Code: 1 Command Output (stdout): -- lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 21d912121c9f41385b165a736be787527f5bd7c2) clang revision 21d912121c9f41385b165a736be787527f5bd7c2 llvm revision 21d912121c9f41385b165a736be787527f5bd7c2 Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc'] -- Command Output (stderr): -- FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_large_watchpoint (TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase) == FAIL: test_large_watchpoint (TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase) Test watchpoint that covers a large region of memory. -- Traceback (most recent call last): File "/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py", line 58, in test_large_watchpoint self.assertTrue(field4_wp.IsValid()) AssertionError: False is not true Config=arm-/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang -- Ran 1 test in 0.560s FAILED (failures=1) -- UNSUPPORTED: lldb-api :: functionalities/watchpoint/unaligned-large-watchpoint/TestUnalignedLargeWatchpoint.py (701 of 2951) PASS: lldb-api :: functionalities/watchpoint/modify-watchpoints/TestModifyWatchpoint.py (702 of 2951) UNSUPPORTED: lldb-api :: functionalities/watchpoint/unaligned-spanning-two-dwords/TestUnalignedSpanningDwords.py (703 of 2951) ``` https://github.com/llvm/llvm-project/pull/134314 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)
@@ -391,8 +392,13 @@ bool Debugger::SetTerminalWidth(uint64_t term_width) { if (auto handler_sp = m_io_handler_stack.Top()) handler_sp->TerminalSizeChanged(); - if (m_statusline) -m_statusline->TerminalSizeChanged(); + + { +// This might get called from a signal handler. +std::unique_lock lock(m_statusline_mutex, std::try_to_lock); +if (m_statusline) JDevlieghere wrote: Correct, the purpose of this lock is to protect other threads when this is **not** called from a signal handler. You're right that for this method/thread, this is no better than not locking at all. Handling the signal is definitely more important than risking a relatively benign race, which is why this doesn't check if the lock succeeded. In the future, if we have a signal handler thread as @labath suggested in an earlier review, we should call a different method (or pass a flag) so we know when we're called from a signal handler. Today, that's not possible because there's now way to know if we were called for a signal at the SB API level, which that would need to be threaded through. https://github.com/llvm/llvm-project/pull/134759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)
da-viper wrote: I think it should be. Most distributions are still on llvm 19 as llvm 20.1 was released last month. Maybe that's why there haven't been any reports. This only affects the 20 and 21 branches. https://github.com/llvm/llvm-project/pull/134626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo reopened https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/134956 >From 390942ce3a1cf6c51f95e8e2893f88807a48e745 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 8 Apr 2025 17:33:41 -0700 Subject: [PATCH] [lldb] Handle signals in a separate thread in the driver Handle signals in a separate thread in the driver so that we can stop worrying about signal safety of functions in libLLDB that may get called from a signal handler. --- lldb/tools/driver/CMakeLists.txt | 2 + lldb/tools/driver/Driver.cpp | 96 +--- 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt index 89884ecd0601b..8b4aa92f96f0d 100644 --- a/lldb/tools/driver/CMakeLists.txt +++ b/lldb/tools/driver/CMakeLists.txt @@ -22,6 +22,8 @@ add_lldb_tool(lldb LINK_LIBS liblldb +lldbHost +lldbUtility LINK_COMPONENTS Option diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 15cb0134fec8e..fb051f198381f 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -19,7 +19,9 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/Host/Config.h" - +#include "lldb/Host/MainLoop.h" +#include "lldb/Host/MainLoopBase.h" +#include "lldb/Utility/Status.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" #include "llvm/Support/InitLLVM.h" @@ -50,6 +52,9 @@ using namespace lldb; using namespace llvm; +using lldb_private::MainLoop; +using lldb_private::MainLoopBase; +using lldb_private::Status; namespace { using namespace llvm::opt; @@ -636,15 +641,12 @@ void Driver::UpdateWindowSize() { } } -void sigwinch_handler(int signo) { - if (g_driver != nullptr) -g_driver->UpdateWindowSize(); -} - void sigint_handler(int signo) { -#ifdef _WIN32 // Restore handler as it is not persistent on Windows +#ifdef _WIN32 + // Restore handler as it is not persistent on Windows. signal(SIGINT, sigint_handler); #endif + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver != nullptr) { if (!g_interrupt_sent.test_and_set()) { @@ -657,31 +659,6 @@ void sigint_handler(int signo) { _exit(signo); } -#ifndef _WIN32 -static void sigtstp_handler(int signo) { - if (g_driver != nullptr) -g_driver->GetDebugger().SaveInputTerminalState(); - - // Unblock the signal and remove our handler. - sigset_t set; - sigemptyset(&set); - sigaddset(&set, signo); - pthread_sigmask(SIG_UNBLOCK, &set, nullptr); - signal(signo, SIG_DFL); - - // Now re-raise the signal. We will immediately suspend... - raise(signo); - // ... and resume after a SIGCONT. - - // Now undo the modifications. - pthread_sigmask(SIG_BLOCK, &set, nullptr); - signal(signo, sigtstp_handler); - - if (g_driver != nullptr) -g_driver->GetDebugger().RestoreInputTerminalState(); -} -#endif - static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) { std::string usage_str = tool_name.str() + " [options]"; table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB", false); @@ -787,11 +764,56 @@ int main(int argc, char const *argv[]) { // Setup LLDB signal handlers once the debugger has been initialized. SBDebugger::PrintDiagnosticsOnError(); + // FIXME: Migrate the SIGINT handler to be handled by the signal loop below. signal(SIGINT, sigint_handler); #if !defined(_WIN32) signal(SIGPIPE, SIG_IGN); - signal(SIGWINCH, sigwinch_handler); - signal(SIGTSTP, sigtstp_handler); + + // Handle signals in a MainLoop running on a separate thread. + MainLoop signal_loop; + Status signal_status; + + auto sigwinch_handler = signal_loop.RegisterSignal( + SIGWINCH, + [&](MainLoopBase &) { +if (g_driver) + g_driver->UpdateWindowSize(); + }, + signal_status); + assert(sigwinch_handler && signal_status.Success()); + + auto sigtstp_handler = signal_loop.RegisterSignal( + SIGTSTP, + [&](MainLoopBase &) { +if (g_driver) + g_driver->GetDebugger().SaveInputTerminalState(); + +struct sigaction old_action; +struct sigaction new_action; + +memset(&new_action, 0, sizeof(new_action)); +new_action.sa_handler = SIG_DFL; +new_action.sa_flags = SA_SIGINFO; +sigemptyset(&new_action.sa_mask); +sigaddset(&new_action.sa_mask, SIGTSTP); + +int ret = sigaction(SIGTSTP, &new_action, &old_action); +UNUSED_IF_ASSERT_DISABLED(ret); +assert(ret == 0 && "sigaction failed"); + +raise(SIGTSTP); + +ret = sigaction(SIGTSTP, &old_action, nullptr); +UNUSED_IF_ASSERT_DISABLED(ret); +assert(ret == 0 && "sigaction failed"); + +if (g_driver) + g_driver->GetDebugger().RestoreInputTerminalState(); + }, + signal_status); + assert(sigtstp_handler && signal_status.Success()); + + std::thread signal_thread(
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -355,6 +355,8 @@ class SymbolFile : public PluginInterface { virtual const ObjectFile *GetObjectFile() const = 0; virtual ObjectFile *GetMainObjectFile() = 0; + virtual std::vector GetAllObjectFiles(); + clayborg wrote: This call should be in `lldb_private::Module` as that is the class that can be represented by one or more objects files: 1 for the executaable and optionally another one for the symbol file. https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/134563 >From 85bee8e66fcbc7b2001e2c06499b3458a197be25 Mon Sep 17 00:00:00 2001 From: George Hu Date: Tue, 8 Apr 2025 18:12:29 -0700 Subject: [PATCH 1/2] Add locate time for each module in statistics --- lldb/include/lldb/Symbol/ObjectFile.h | 4 lldb/include/lldb/Symbol/SymbolFile.h | 5 + lldb/include/lldb/Target/Statistics.h | 1 + lldb/source/Core/ModuleList.cpp| 11 --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 13 + .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 3 +++ .../SymbolVendor/ELF/SymbolVendorELF.cpp | 18 ++ lldb/source/Target/Statistics.cpp | 8 8 files changed, 56 insertions(+), 7 deletions(-) diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index cfcca04a76de8..0a782f28dc947 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -13,6 +13,7 @@ #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/Symtab.h" #include "lldb/Symbol/UnwindTable.h" +#include "lldb/Target/Statistics.h" #include "lldb/Utility/AddressableBits.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" @@ -589,6 +590,8 @@ class ObjectFile : public std::enable_shared_from_this, /// this routine to set eTypeDebugInfo when loading debug link files. virtual void SetType(Type type) { m_type = type; } + virtual StatsDuration &GetLocateTime() { return m_locate_time; } + /// The object file should be able to calculate the strata of the object /// file. /// @@ -752,6 +755,7 @@ class ObjectFile : public std::enable_shared_from_this, protected: // Member variables. + StatsDuration m_locate_time; ///< Time to locate the object file FileSpec m_file; Type m_type; Strata m_strata; diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index f35d3ee9f22ae..6bea7c3e90a77 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -422,6 +422,11 @@ class SymbolFile : public PluginInterface { /// hasn't been indexed yet, or a valid duration if it has. virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; } + /// Return the time it took to locate any extra symbol files. + /// + /// \returns 0.0 if no extra symbol files need to be located + virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; } + /// Reset the statistics for the symbol file. virtual void ResetStatistics() {} diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index ee365357fcf31..1fbd3c57efaa6 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -122,6 +122,7 @@ struct ModuleStats { double symtab_index_time = 0.0; double debug_parse_time = 0.0; double debug_index_time = 0.0; + double symbol_locate_time = 0.0; uint64_t debug_info_size = 0; bool symtab_loaded_from_cache = false; bool symtab_saved_to_cache = false; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 2b8ccab2406c6..45dbaf4c014c9 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -917,9 +917,13 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, // Fixup the incoming path in case the path points to a valid file, yet the // arch or UUID (if one was passed in) don't match. - ModuleSpec located_binary_modulespec = - PluginManager::LocateExecutableObjectFile(module_spec); - + ModuleSpec located_binary_modulespec; + StatsDuration locate_duration; + { +ElapsedTime elapsed(locate_duration); +located_binary_modulespec = +PluginManager::LocateExecutableObjectFile(module_spec); + } // Don't look for the file if it appears to be the same one we already // checked for above... if (located_binary_modulespec.GetFileSpec() != module_file_spec) { @@ -992,6 +996,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, // By getting the object file we can guarantee that the architecture // matches if (module_sp && module_sp->GetObjectFile()) { +module_sp->GetObjectFile()->GetLocateTime() += locate_duration; if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { module_sp.reset(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index b95159d882bc7..a3c809945d9ce 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4250,11 +4250,13 @@ const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() { ModuleSpec module_spec;
[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)
@@ -391,8 +392,13 @@ bool Debugger::SetTerminalWidth(uint64_t term_width) { if (auto handler_sp = m_io_handler_stack.Top()) handler_sp->TerminalSizeChanged(); - if (m_statusline) -m_statusline->TerminalSizeChanged(); + + { +// This might get called from a signal handler. +std::unique_lock lock(m_statusline_mutex, std::try_to_lock); +if (m_statusline) labath wrote: The reason I want to do it in the driver is because it's more flexible (and it matches status quo). As a library, you can't really know whether a SIGWINCH was "meant" for you, or if you're embedded in some larger terminal application. So, to do it the right way, it would have to be somehow configurable, and I'd like to avoid getting into the business of providing a general signal catching API. https://github.com/llvm/llvm-project/pull/134759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [dsymutil] Avoid copying binary swiftmodules built from textual (PR #134719)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `amdgpu-offload-rhel-9-cmake-build-only` running on `rocm-docker-rhel-9` while building `lldb,llvm` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/5802 Here is the relevant piece of the build log for the reference ``` Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py --jobs=32' (failure) ... [7693/7733] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/MachOUtils.cpp.o [7694/7733] Linking CXX shared library lib/libflangPasses.so.21.0git [7695/7733] Creating library symlink lib/libflangPasses.so [7696/7733] Linking CXX executable bin/fir-opt [7697/7733] Linking CXX shared library lib/libclang-cpp.so.21.0git [7698/7733] Creating library symlink lib/libclang-cpp.so [7699/7733] Linking CXX executable bin/tco [7700/7733] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil.cpp.o [7701/7733] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/DwarfLinkerForBinary.cpp.o [7702/7733] Linking CXX executable bin/dsymutil FAILED: bin/dsymutil : && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/./lib -Wl,--gc-sections tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/BinaryHolder.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/DwarfLinkerForBinary.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/MachODebugMapParser.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/MachOUtils.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/Reproducer.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/RelocationMap.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil-driver.cpp.o -o bin/dsymutil -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib:" lib/libLLVMAMDGPUCodeGen.so.21.0git lib/libLLVMSPIRVCodeGen.so.21.0git lib/libLLVMX86CodeGen.so.21.0git lib/libLLVMAMDGPUDesc.so.21.0git lib/libLLVMSPIRVDesc.so.21.0git lib/libLLVMX86Desc.so.21.0git lib/libLLVMAMDGPUInfo.so.21.0git lib/libLLVMSPIRVInfo.so.21.0git lib/libLLVMX86Info.so.21.0git lib/libLLVMDWARFLinkerClassic.so.21.0git lib/libLLVMDWARFLinkerParallel.so.21.0git lib/libLLVMOption.so.21.0git lib/libLLVMAsmPrinter.so.21.0git lib/libLLVMDWARFLinker.so.21.0git lib/libLLVMCodeGen.so.21.0git lib/libLLVMCodeGenTypes.so.21.0git lib/libLLVMTarget.so.21.0git lib/libLLVMDebugInfoDWARF.so.21.0git lib/libLLVMObject.so.21.0git lib/libLLVMMC.so.21.0git lib/libLLVMRemarks.so.21.0git lib/libLLVMTargetParser.so.21.0git lib/libLLVMSupport.so.21.0git -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib && : /usr/bin/ld: tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o: undefined reference to symbol '_ZN4llvm15BitstreamCursor10readRecordEjRNS_15SmallVectorImplImEEPNS_9StringRefE' /usr/bin/ld: /home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/./lib/libLLVMBitstreamReader.so.21.0git: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status [7703/7733] Linking CXX shared library lib/libFortranLower.so.21.0git ninja: build stopped: subcommand failed. ['ninja'] exited with return code 1. The build step threw an exception... Traceback (most recent call last): File "/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py", line 50, in step yield File "/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py", line 41, in main run_command(["ninja"]) File "/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py", line 63, in run_command util.report_run_cmd(cmd, cwd=directory) File "/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd subprocess.check_call(cmd, shell=shell, *args, **kwargs) File "/usr/lib64/python3.9/subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subpr
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
JDevlieghere wrote: @labath I originally used the MainLoop to handle `SIGINT` on non-Windows platforms and that didn't caused two test failures. I was able to reproduce the weird behavior by hand. With the current SIGINT handler: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> ``` I send a CTRL-C and a KeyboardInterrupt shows up immediately on screen: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> KeyboardInterrupt ``` With the [MainLoop SIGINT handler](https://github.com/llvm/llvm-project/commit/3943112f5182065eed43d72e2960ed166737b237): ``` ❯ lldb (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> ``` I send a CTRL-C and nothing happens. The `KeyboardInterrupt` only shows up after I hit enter: ``` (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> >>> KeyboardInterrupt ``` Like you said, that doesn't work on Windows and we don't need that for the statusline so it's not on the critical path of this PR, but I'm curious if you can think of a reason this behaves oddly with the MainLoop implementation. https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)
@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef &format_str, return parent; } +/// Parses a single highlighting format specifier. +/// +/// Example syntax for such specifier: +/// \code +/// ${function.name-with-args:%highlight_basename(ansi.fg.green)} Michael137 wrote: @adrian-prantl pointed out that another hurdle with this would be how to handle non-C++ languages with these fine-grained variables. We could make these variables C++ specific? (e.g., call them `${function.cxx-basename}`. Then language plugins themselves would handle them (like we do `FunctionNameWithArgs` already). We'll also need a mechanism to say "fall back to `${function.name-with-args}` if one of these variables can't be handled by the language" (which I don't think is possible at the moment). https://github.com/llvm/llvm-project/pull/131836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/134956 >From 3943112f5182065eed43d72e2960ed166737b237 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 8 Apr 2025 17:33:41 -0700 Subject: [PATCH] [lldb] Handle signals in a separate thread in the driver Handle signals in a separate thread in the driver so that we can stop worrying about signal safety of functions in libLLDB that may get called from a signal handler. --- lldb/tools/driver/CMakeLists.txt | 2 + lldb/tools/driver/Driver.cpp | 117 ++- 2 files changed, 84 insertions(+), 35 deletions(-) diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt index 89884ecd0601b..8b4aa92f96f0d 100644 --- a/lldb/tools/driver/CMakeLists.txt +++ b/lldb/tools/driver/CMakeLists.txt @@ -22,6 +22,8 @@ add_lldb_tool(lldb LINK_LIBS liblldb +lldbHost +lldbUtility LINK_COMPONENTS Option diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 15cb0134fec8e..2557c08c0e396 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -19,7 +19,9 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/Host/Config.h" - +#include "lldb/Host/MainLoop.h" +#include "lldb/Host/MainLoopBase.h" +#include "lldb/Utility/Status.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" #include "llvm/Support/InitLLVM.h" @@ -50,6 +52,9 @@ using namespace lldb; using namespace llvm; +using lldb_private::MainLoop; +using lldb_private::MainLoopBase; +using lldb_private::Status; namespace { using namespace llvm::opt; @@ -636,15 +641,11 @@ void Driver::UpdateWindowSize() { } } -void sigwinch_handler(int signo) { - if (g_driver != nullptr) -g_driver->UpdateWindowSize(); -} - +#ifdef _WIN32 void sigint_handler(int signo) { -#ifdef _WIN32 // Restore handler as it is not persistent on Windows + // Restore handler as it is not persistent on Windows. signal(SIGINT, sigint_handler); -#endif + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver != nullptr) { if (!g_interrupt_sent.test_and_set()) { @@ -656,30 +657,6 @@ void sigint_handler(int signo) { _exit(signo); } - -#ifndef _WIN32 -static void sigtstp_handler(int signo) { - if (g_driver != nullptr) -g_driver->GetDebugger().SaveInputTerminalState(); - - // Unblock the signal and remove our handler. - sigset_t set; - sigemptyset(&set); - sigaddset(&set, signo); - pthread_sigmask(SIG_UNBLOCK, &set, nullptr); - signal(signo, SIG_DFL); - - // Now re-raise the signal. We will immediately suspend... - raise(signo); - // ... and resume after a SIGCONT. - - // Now undo the modifications. - pthread_sigmask(SIG_BLOCK, &set, nullptr); - signal(signo, sigtstp_handler); - - if (g_driver != nullptr) -g_driver->GetDebugger().RestoreInputTerminalState(); -} #endif static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) { @@ -787,11 +764,75 @@ int main(int argc, char const *argv[]) { // Setup LLDB signal handlers once the debugger has been initialized. SBDebugger::PrintDiagnosticsOnError(); +#if defined(_WIN32) + // FIXME: Support signals in MainLoopWindows and handle SIGINT in the signal + // loop below. signal(SIGINT, sigint_handler); -#if !defined(_WIN32) +#else signal(SIGPIPE, SIG_IGN); - signal(SIGWINCH, sigwinch_handler); - signal(SIGTSTP, sigtstp_handler); + + // Handle signals in a MainLoop running on a separate thread. + MainLoop signal_loop; + Status signal_status; + + auto sigint_handler = signal_loop.RegisterSignal( + SIGINT, + [&](MainLoopBase &loop) { +static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; +if (g_driver) { + if (!g_interrupt_sent.test_and_set()) { +g_driver->GetDebugger().DispatchInputInterrupt(); +g_interrupt_sent.clear(); +return; + } +} +loop.RequestTermination(); +_exit(SIGINT); + }, + signal_status); + assert(sigint_handler && signal_status.Success()); + + auto sigwinch_handler = signal_loop.RegisterSignal( + SIGWINCH, + [&](MainLoopBase &) { +if (g_driver) + g_driver->UpdateWindowSize(); + }, + signal_status); + assert(sigwinch_handler && signal_status.Success()); + + auto sigtstp_handler = signal_loop.RegisterSignal( + SIGTSTP, + [&](MainLoopBase &) { +if (g_driver) + g_driver->GetDebugger().SaveInputTerminalState(); + +struct sigaction old_action; +struct sigaction new_action; + +memset(&new_action, 0, sizeof(new_action)); +new_action.sa_handler = SIG_DFL; +new_action.sa_flags = SA_SIGINFO; +sigemptyset(&new_action.sa_mask); +sigaddset(&new_action.sa_mask, SIGTSTP); + +int ret = sigaction(SIGTSTP, &new_action, &old_action); +
[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/134626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)
JDevlieghere wrote: > I was also wondering if this should be backported as it also affects llvm > 20.x branch Given its low risk I'm okay back porting this, if you think it's important. That said, I haven't seen any other reports so I'm guessing this crash isn't particularly widespread. https://github.com/llvm/llvm-project/pull/134626 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
slydiman wrote: It seems the sorting of language plug-ins in CMakeLists.txt is not enough. I tested #132274 locally and it passed, but failed on the buildbot [lldb-aarch64-windows](https://lab.llvm.org/buildbot/#/builders/141). I have updated LookupInfo::LookupInfo() close to the current code as much as possible. I have hardcoded the list of language plug-ins in used in LookupInfo::LookupInfo(). Note `CPlusPlusLanguage::ExtractContextAndIdentifier()` currently is used for all languages including ObjC and I don't know the default behavior. It seems I need help with testing this patch on MacOS. Thanks in advance. https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)
@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef &format_str, return parent; } +/// Parses a single highlighting format specifier. +/// +/// Example syntax for such specifier: +/// \code +/// ${function.name-with-args:%highlight_basename(ansi.fg.green)} labath wrote: Just parachuting here to say I like the idea of separate variables for parts of the function name. I like how it lets you completely omit (and not just avoid highlighting) a part of the name. The funny C return types are indeed a problem but maybe we could solve that by having two variables for the return type (the part that comes after the name and the part that comes before it). https://github.com/llvm/llvm-project/pull/131836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/134563 >From 85bee8e66fcbc7b2001e2c06499b3458a197be25 Mon Sep 17 00:00:00 2001 From: George Hu Date: Tue, 8 Apr 2025 18:12:29 -0700 Subject: [PATCH 1/2] Add locate time for each module in statistics --- lldb/include/lldb/Symbol/ObjectFile.h | 4 lldb/include/lldb/Symbol/SymbolFile.h | 5 + lldb/include/lldb/Target/Statistics.h | 1 + lldb/source/Core/ModuleList.cpp| 11 --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 13 + .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 3 +++ .../SymbolVendor/ELF/SymbolVendorELF.cpp | 18 ++ lldb/source/Target/Statistics.cpp | 8 8 files changed, 56 insertions(+), 7 deletions(-) diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index cfcca04a76de8..0a782f28dc947 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -13,6 +13,7 @@ #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/Symtab.h" #include "lldb/Symbol/UnwindTable.h" +#include "lldb/Target/Statistics.h" #include "lldb/Utility/AddressableBits.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" @@ -589,6 +590,8 @@ class ObjectFile : public std::enable_shared_from_this, /// this routine to set eTypeDebugInfo when loading debug link files. virtual void SetType(Type type) { m_type = type; } + virtual StatsDuration &GetLocateTime() { return m_locate_time; } + /// The object file should be able to calculate the strata of the object /// file. /// @@ -752,6 +755,7 @@ class ObjectFile : public std::enable_shared_from_this, protected: // Member variables. + StatsDuration m_locate_time; ///< Time to locate the object file FileSpec m_file; Type m_type; Strata m_strata; diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index f35d3ee9f22ae..6bea7c3e90a77 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -422,6 +422,11 @@ class SymbolFile : public PluginInterface { /// hasn't been indexed yet, or a valid duration if it has. virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; } + /// Return the time it took to locate any extra symbol files. + /// + /// \returns 0.0 if no extra symbol files need to be located + virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; } + /// Reset the statistics for the symbol file. virtual void ResetStatistics() {} diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index ee365357fcf31..1fbd3c57efaa6 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -122,6 +122,7 @@ struct ModuleStats { double symtab_index_time = 0.0; double debug_parse_time = 0.0; double debug_index_time = 0.0; + double symbol_locate_time = 0.0; uint64_t debug_info_size = 0; bool symtab_loaded_from_cache = false; bool symtab_saved_to_cache = false; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 2b8ccab2406c6..45dbaf4c014c9 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -917,9 +917,13 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, // Fixup the incoming path in case the path points to a valid file, yet the // arch or UUID (if one was passed in) don't match. - ModuleSpec located_binary_modulespec = - PluginManager::LocateExecutableObjectFile(module_spec); - + ModuleSpec located_binary_modulespec; + StatsDuration locate_duration; + { +ElapsedTime elapsed(locate_duration); +located_binary_modulespec = +PluginManager::LocateExecutableObjectFile(module_spec); + } // Don't look for the file if it appears to be the same one we already // checked for above... if (located_binary_modulespec.GetFileSpec() != module_file_spec) { @@ -992,6 +996,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, // By getting the object file we can guarantee that the architecture // matches if (module_sp && module_sp->GetObjectFile()) { +module_sp->GetObjectFile()->GetLocateTime() += locate_duration; if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { module_sp.reset(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index b95159d882bc7..a3c809945d9ce 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4250,11 +4250,13 @@ const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() { ModuleSpec module_spec;
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -4267,6 +4269,8 @@ const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() { // find the correct DWP file, as the Debuginfod plugin uses *only* this // data to correctly match the DWP file with the binary. module_spec.GetUUID() = m_objfile_sp->GetUUID(); + duration.reset(); clayborg wrote: You shouldn't reset this right? If we download the .dwp file above and that takes some time, we still want to know the total time it took to locate the file right? What if the first debuginfod locate method takes 500ms to make a failed http request, and then we look again, all of that time should be logged. So don't reset this. To get accurate measurement, use an extra scope above https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -111,7 +111,7 @@ struct ModuleStats { std::string uuid; std::string triple; // Path separate debug info file, or empty if none. - std::string symfile_path; + std::vector symfile_path; clayborg wrote: This shouldn't be a vector. The `lldb_private::Module` will have a `lldb_private::ObjectFile`. The module always have a `lldb_private::SymbolFile` and that symbol file might use a different `lldb_private::ObjectFile`, or it might use the same `lldb_private::ObjectFile` as the `lldb_private::Module`. So the stats are ok here, no need for a list. I presume we are not trying to list the .dwo files here, it will just be the main executable and the separate debug info file. https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -4250,11 +4250,13 @@ const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() { ModuleSpec module_spec; module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec(); FileSpec dwp_filespec; +StatsDuration duration; for (const auto &symfile : symfiles.files()) { module_spec.GetSymbolFileSpec() = FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle()); LLDB_LOG(log, "Searching for DWP using: \"{0}\"", module_spec.GetSymbolFileSpec()); + ElapsedTime elapsed(duration); dwp_filespec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); clayborg wrote: ``` { ElapsedTime elapsed(duration); dwp_filespec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); } ``` https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -4267,6 +4269,8 @@ const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() { // find the correct DWP file, as the Debuginfod plugin uses *only* this // data to correctly match the DWP file with the binary. module_spec.GetUUID() = m_objfile_sp->GetUUID(); + duration.reset(); + ElapsedTime elapsed(duration); dwp_filespec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); clayborg wrote: ``` { ElapsedTime elapsed(duration); dwp_filespec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); } ``` https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo edited https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
@@ -3,7 +3,12 @@ (* This is currently a subset of the final DIL Language, matching the current DIL implementation. *) -expression = primary_expression ; +expression = unary_expression ; + +unary_expression = unary_operator expression kuilpd wrote: We have a final grammar ready, but it will have to be adjusted every patch anyway. For now, this allows to write multiple unary operators in a row, like `&*foo`. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
@@ -232,4 +263,105 @@ Interpreter::Visit(const IdentifierNode *node) { return identifier; } -} // namespace lldb_private::dil +llvm::Expected +Interpreter::Visit(const UnaryOpNode *node) { + FlowAnalysis rhs_flow( + /* address_of_is_pending */ node->kind() == UnaryOpKind::AddrOf); + + Status error; + auto rhs_or_err = EvaluateNode(node->rhs(), &rhs_flow); + if (!rhs_or_err) { +return rhs_or_err; + } + lldb::ValueObjectSP rhs = *rhs_or_err; + + CompilerType rhs_type = rhs->GetCompilerType(); + switch (node->kind()) { + case UnaryOpKind::Deref: { +if (rhs_type.IsArrayType()) + rhs = ArrayToPointerConversion(rhs, m_exe_ctx_scope); + +lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_default_dynamic); +if (dynamic_rhs) + rhs = dynamic_rhs; + +if (rhs->GetCompilerType().IsPointerType()) { + if (rhs->GetCompilerType().IsPointerToVoid()) { +return llvm::make_error( +m_expr, "indirection not permitted on operand of type 'void *'", +node->GetLocation(), 1); + } + return EvaluateDereference(rhs); +} +lldb::ValueObjectSP child_sp = rhs->Dereference(error); +if (error.Success()) + rhs = child_sp; + +return rhs; + } + case UnaryOpKind::AddrOf: { +if (node->rhs()->is_rvalue()) { + std::string errMsg = + llvm::formatv("cannot take the address of an rvalue of type {0}", +rhs_type.TypeDescription()); + return llvm::make_error(m_expr, errMsg, + node->GetLocation()); +} +if (rhs->IsBitfield()) { + return llvm::make_error( + m_expr, "address of bit-field requested", node->GetLocation()); +} +// If the address-of operation wasn't cancelled during the evaluation of +// RHS (e.g. because of the address-of-a-dereference elision), apply it +// here. +if (rhs_flow.AddressOfIsPending()) { + Status error; + lldb::ValueObjectSP value = rhs->AddressOf(error); + if (error.Fail()) { +return llvm::make_error(m_expr, error.AsCString(), +node->GetLocation()); + } + return value; +} +return rhs; + } + } + + // Unsupported/invalid operation. + return llvm::make_error( + m_expr, "invalid ast: unexpected binary operator", node->GetLocation(), + 1); +} + +lldb::ValueObjectSP Interpreter::EvaluateDereference(lldb::ValueObjectSP rhs) { + // If rhs is a reference, dereference it first. + Status error; + if (rhs->GetCompilerType().IsReferenceType()) +rhs = rhs->Dereference(error); + + assert(rhs->GetCompilerType().IsPointerType() && + "invalid ast: must be a pointer type"); + + if (rhs->GetDerefValobj()) kuilpd wrote: This checks if the value has already been dereferenced. The same check is also done in the beginning of `Dereference()`, but if we want to skip `CreateValueObjectFromAddress` as well, this is done separately beforehand. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
kuilpd wrote: > I'm also not very convinced by this "FlowAnalysis" thingy. Is it supposed to > be a performance optimization (collapsing *&foo to foo) or does it do > something more? FlowAnalysis is also used in subscript operator, to short-circuit getting an address of an element: `&arr[1]`, which could be a much more common use case. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -111,7 +111,7 @@ struct ModuleStats { std::string uuid; std::string triple; // Path separate debug info file, or empty if none. - std::string symfile_path; + std::vector symfile_path; GeorgeHuyubo wrote: Since debuginfod could also provide dwp files, I wanted to list the separate debuginfo and potentially the dwp here. But anyway I will go with the map of locate time solution https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo reopened https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
@@ -422,6 +424,11 @@ class SymbolFile : public PluginInterface { /// hasn't been indexed yet, or a valid duration if it has. virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; } + /// Return the time it took to locate any extra symbol files. + /// + /// \returns 0.0 if no extra symbol files need to be located + virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; } + clayborg wrote: move to `lldb_private::Module` https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)
https://github.com/GeorgeHuyubo edited https://github.com/llvm/llvm-project/pull/134563 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
@@ -232,4 +263,105 @@ Interpreter::Visit(const IdentifierNode *node) { return identifier; } -} // namespace lldb_private::dil +llvm::Expected +Interpreter::Visit(const UnaryOpNode *node) { + FlowAnalysis rhs_flow( + /* address_of_is_pending */ node->kind() == UnaryOpKind::AddrOf); + + Status error; + auto rhs_or_err = EvaluateNode(node->rhs(), &rhs_flow); + if (!rhs_or_err) { +return rhs_or_err; + } + lldb::ValueObjectSP rhs = *rhs_or_err; + + CompilerType rhs_type = rhs->GetCompilerType(); + switch (node->kind()) { + case UnaryOpKind::Deref: { +if (rhs_type.IsArrayType()) + rhs = ArrayToPointerConversion(rhs, m_exe_ctx_scope); + +lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_default_dynamic); +if (dynamic_rhs) + rhs = dynamic_rhs; + +if (rhs->GetCompilerType().IsPointerType()) { + if (rhs->GetCompilerType().IsPointerToVoid()) { +return llvm::make_error( +m_expr, "indirection not permitted on operand of type 'void *'", +node->GetLocation(), 1); + } + return EvaluateDereference(rhs); +} +lldb::ValueObjectSP child_sp = rhs->Dereference(error); +if (error.Success()) + rhs = child_sp; + +return rhs; + } + case UnaryOpKind::AddrOf: { +if (node->rhs()->is_rvalue()) { + std::string errMsg = + llvm::formatv("cannot take the address of an rvalue of type {0}", +rhs_type.TypeDescription()); + return llvm::make_error(m_expr, errMsg, + node->GetLocation()); +} +if (rhs->IsBitfield()) { + return llvm::make_error( + m_expr, "address of bit-field requested", node->GetLocation()); +} kuilpd wrote: `ValueObject::GetAddressOf` returns `LLDB_INVALID_ADDRESS` for a bitfield without an error, so this check is to provide a meaningful error message. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
@@ -232,4 +263,105 @@ Interpreter::Visit(const IdentifierNode *node) { return identifier; } -} // namespace lldb_private::dil +llvm::Expected +Interpreter::Visit(const UnaryOpNode *node) { + FlowAnalysis rhs_flow( + /* address_of_is_pending */ node->kind() == UnaryOpKind::AddrOf); + + Status error; + auto rhs_or_err = EvaluateNode(node->rhs(), &rhs_flow); + if (!rhs_or_err) { +return rhs_or_err; + } + lldb::ValueObjectSP rhs = *rhs_or_err; + + CompilerType rhs_type = rhs->GetCompilerType(); + switch (node->kind()) { + case UnaryOpKind::Deref: { +if (rhs_type.IsArrayType()) + rhs = ArrayToPointerConversion(rhs, m_exe_ctx_scope); + +lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_default_dynamic); +if (dynamic_rhs) + rhs = dynamic_rhs; + +if (rhs->GetCompilerType().IsPointerType()) { + if (rhs->GetCompilerType().IsPointerToVoid()) { +return llvm::make_error( +m_expr, "indirection not permitted on operand of type 'void *'", +node->GetLocation(), 1); + } + return EvaluateDereference(rhs); +} +lldb::ValueObjectSP child_sp = rhs->Dereference(error); +if (error.Success()) + rhs = child_sp; + +return rhs; + } + case UnaryOpKind::AddrOf: { +if (node->rhs()->is_rvalue()) { kuilpd wrote: >From what I could gather, the first one is `ValueObject::AddressOf` that >creates a `ValueObjectConstResult` and fills in its address. The second one >calls `ValueObjectConstResultImpl::AddressOf` that also creates >`ValueObjectConstResult` but with no address this time (which makes sense for >a const value), so the third one fails. I'm guessing that the first `ValueObjectConstResult` is pretty much an implementation of a reference, so it has to have an address behind it so it can be dereferenced normally. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
@@ -18,6 +18,22 @@ namespace lldb_private::dil { +static lldb::ValueObjectSP +ArrayToPointerConversion(lldb::ValueObjectSP valobj, + std::shared_ptr ctx) { + assert(valobj->IsArrayType() && + "an argument to array-to-pointer conversion must be an array"); + + uint64_t addr = valobj->GetLoadAddress(); + llvm::StringRef name = "result"; + ExecutionContext exe_ctx; + ctx->CalculateExecutionContext(exe_ctx); + return ValueObject::CreateValueObjectFromAddress( + name, addr, exe_ctx, + valobj->GetCompilerType().GetArrayElementType(ctx.get()).GetPointerType(), + /* do_deref */ false); +} + jimingham wrote: Yes, I concur. As a general rule, we want the evaluator to know as little as possible about how any operation is performed and delegate as much as possible to ValueObject methods. The evaluator can't know anything about the language of the values it is operating on or it will either only work for C-backed ValueObjects or end up cluttered with "if C/C++/swift/go/future_language" code, which we really want to avoid. However, ValueObjects always know what type system their type comes from, and so they can naturally do the right thing for their language. So we should defer to them whenever we're doing any non-trivial operations. https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
JDevlieghere wrote: With eh current path, `TestObjCBreakpoints.py` is still failing on macOS: ``` FAIL: test_break_dwarf (TestObjCBreakpoints.TestObjCBreakpoints) Test setting Objective-C specific breakpoints (DWARF in .o files). -- Traceback (most recent call last): File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1804, in test_method return attrvalue(self) File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py", line 21, in test_break self.check_objc_breakpoints(False) File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py", line 100, in check_objc_breakpoints self.assertGreaterEqual( AssertionError: 10 not greater than or equal to 124 : Make sure we get at least the same amount of breakpoints if not more when setting by name "count" ``` I'll try to find some time tomorrow to debug this. https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman ready_for_review https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NFC]Also includes the error in log msg. (PR #134922)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/134922 >From ab50c89574613178ba2bf79455eaa8aba0f2205d Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 8 Apr 2025 15:58:10 -0400 Subject: [PATCH 1/2] [LLDB][NFC]Also includes the error in log msg. --- lldb/include/lldb/Core/Telemetry.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 28897f283dc55..022f40b1d2f2f 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -272,7 +272,8 @@ template struct ScopedDispatcher { // And then we dispatch. if (llvm::Error er = manager->dispatch(&info)) { LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er), - "Failed to dispatch entry of type: {0}", info.getKind()); + "{0} Failed to dispatch entry of type: {1}", + info.getKind()); } } >From 8cbc51eed7cd54240ffcff65d19e4246b01c73de Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Wed, 9 Apr 2025 10:14:06 -0400 Subject: [PATCH 2/2] Update lldb/include/lldb/Core/Telemetry.h Co-authored-by: Jonas Devlieghere --- lldb/include/lldb/Core/Telemetry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 022f40b1d2f2f..fa01e2e4af90f 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -272,7 +272,7 @@ template struct ScopedDispatcher { // And then we dispatch. if (llvm::Error er = manager->dispatch(&info)) { LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er), - "{0} Failed to dispatch entry of type: {1}", + "Failed to dispatch entry of type {1}: {0}", info.getKind()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
@@ -794,6 +800,10 @@ int main(int argc, char const *argv[]) { signal(SIGTSTP, sigtstp_handler); #endif + // Run the signal handling MainLoop on a separate thread. + std::thread signal_thread([] { g_signal_loop.Run(); }); + signal_thread.detach(); labath wrote: I'd like to avoid a detached thread running around causing havoc during process destruction. Why not just join the thread right after the RequestTermination call? https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)
DavidSpickett wrote: The above failure is legit, this is the relevant bit of the log: ``` FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf) -- Traceback (most recent call last): File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1804, in test_method return attrvalue(self) ^^^ File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbinline.py", line 122, in _test self.do_test() File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbinline.py", line 152, in do_test parser.handle_breakpoint(self, bp_id) File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbinline.py", line 82, in handle_breakpoint test.execute_user_command(breakpoint["command"]) File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbinline.py", line 125, in execute_user_command exec(__command, globals(), locals()) File "", line 1, in File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 2406, in expect self.runCmd( File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1005, in runCmd self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Command 'expression -- foo()' did not return successfully Error output: error: Couldn't look up symbols: int foo(void) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ``` No idea why at the moment, I have some other issues to deal with before I can look into it. https://github.com/llvm/llvm-project/pull/132274 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/135033 The original PR is #132274. >From 08b6d2b832d3f40ed56f05e7e7da26d6f3f0a8cc Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 9 Apr 2025 17:06:49 +0400 Subject: [PATCH] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies The original PR is #132274. --- lldb/include/lldb/Core/Mangled.h | 2 + lldb/include/lldb/Core/RichManglingContext.h | 16 +- lldb/include/lldb/Target/Language.h | 98 +++ lldb/source/Core/CMakeLists.txt | 5 +- lldb/source/Core/Mangled.cpp | 10 +- lldb/source/Core/Module.cpp | 152 -- lldb/source/Core/RichManglingContext.cpp | 22 ++- .../Clang/ClangExpressionDeclMap.cpp | 11 +- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 128 ++- .../Language/CPlusPlus/CPlusPlusLanguage.h| 58 ++- .../Plugins/Language/ObjC/ObjCLanguage.cpp| 12 ++ .../Plugins/Language/ObjC/ObjCLanguage.h | 3 + .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +- lldb/unittests/Core/CMakeLists.txt| 1 + .../Core/RichManglingContextTest.cpp | 7 + .../CPlusPlus/CPlusPlusLanguageTest.cpp | 22 +-- 16 files changed, 285 insertions(+), 266 deletions(-) diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 5988d919a89b8..7db63eeeb6ee0 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,6 +246,8 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); + static bool IsMangledName(llvm::StringRef name); + /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 3b79924e88a9a..50ec2ae361098 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,6 +12,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -67,11 +68,7 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - /// Members for PluginCxxLanguage - /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The - /// respective header is in Plugins and including it from here causes cyclic - /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. - llvm::Any m_cxx_method_parser; + std::unique_ptr m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -81,15 +78,6 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); - - /// Cast the given parser to the given type. Ideally we would have a type - /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we - /// can't access CPlusPlusLanguage::MethodName from within the header. - template static ParserT *get(llvm::Any parser) { -assert(parser.has_value()); -assert(llvm::any_cast(&parser)); -return *llvm::any_cast(&parser); - } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index b699a90aff8e4..d46969cb3b4e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,6 +214,104 @@ class Language : public PluginInterface { return std::vector(); }; + class MethodName { + public: +MethodName() {} + +MethodName(ConstString full) +: m_full(full), m_basename(), m_context(), m_arguments(), + m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), + m_parse_error(false) {} + +virtual ~MethodName() {}; + +void Clear() { + m_full.Clear(); + m_basename = llvm::StringRef(); + m_context = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + m_return_type = llvm::StringRef(); + m_scope_qualified.clear(); + m_parsed = false; + m_parse_error = false; +} + +bool IsValid() { + if (!m_parsed) +Parse(); + if (m_parse_error) +return false; + return (bool)m_full; +} + +ConstString GetFullName() const { return m_full; } + +llvm::StringRef GetBasename() { + if (!m_parsed) +Parse(); + return m_basename; +} + +llvm::StringRef GetContext() { + if (!m_parsed) +Parse(); + return m_context; +} + +llvm::StringRef GetArguments() { + if (!m_parsed) +Parse(); + r
[Lldb-commits] [lldb] [llvm] [dsymutil] Avoid copying binary swiftmodules built from textual (PR #134719)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on `as-worker-93` while building `lldb,llvm` at step 7 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2673 Here is the relevant piece of the build log for the reference ``` Step 7 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM-Unit :: Support/./SupportTests.exe/82/95' FAILED Script(shard): -- GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-17880-82-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=82 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe -- Script: -- C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath -- C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values: 0 RC Which is: -2 C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success. error number: 13 error message: permission denied C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160 Expected equality of these values: 0 RC Which is: -2 C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163 fs::remove(Twine(LongPath)): did not return errc::success. error number: 13 error message: permission denied ``` https://github.com/llvm/llvm-project/pull/134719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) Changes The original PR is #132274. --- Patch is 38.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/135033.diff 16 Files Affected: - (modified) lldb/include/lldb/Core/Mangled.h (+2) - (modified) lldb/include/lldb/Core/RichManglingContext.h (+2-14) - (modified) lldb/include/lldb/Target/Language.h (+98) - (modified) lldb/source/Core/CMakeLists.txt (+1-4) - (modified) lldb/source/Core/Mangled.cpp (+5-5) - (modified) lldb/source/Core/Module.cpp (+65-87) - (modified) lldb/source/Core/RichManglingContext.cpp (+9-13) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+6-5) - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+52-76) - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h (+9-49) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp (+12) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.h (+3) - (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+2-2) - (modified) lldb/unittests/Core/CMakeLists.txt (+1) - (modified) lldb/unittests/Core/RichManglingContextTest.cpp (+7) - (modified) lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (+11-11) ``diff diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 5988d919a89b8..7db63eeeb6ee0 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,6 +246,8 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); + static bool IsMangledName(llvm::StringRef name); + /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 3b79924e88a9a..50ec2ae361098 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,6 +12,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -67,11 +68,7 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - /// Members for PluginCxxLanguage - /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The - /// respective header is in Plugins and including it from here causes cyclic - /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. - llvm::Any m_cxx_method_parser; + std::unique_ptr m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -81,15 +78,6 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); - - /// Cast the given parser to the given type. Ideally we would have a type - /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we - /// can't access CPlusPlusLanguage::MethodName from within the header. - template static ParserT *get(llvm::Any parser) { -assert(parser.has_value()); -assert(llvm::any_cast(&parser)); -return *llvm::any_cast(&parser); - } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index b699a90aff8e4..d46969cb3b4e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,6 +214,104 @@ class Language : public PluginInterface { return std::vector(); }; + class MethodName { + public: +MethodName() {} + +MethodName(ConstString full) +: m_full(full), m_basename(), m_context(), m_arguments(), + m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), + m_parse_error(false) {} + +virtual ~MethodName() {}; + +void Clear() { + m_full.Clear(); + m_basename = llvm::StringRef(); + m_context = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + m_return_type = llvm::StringRef(); + m_scope_qualified.clear(); + m_parsed = false; + m_parse_error = false; +} + +bool IsValid() { + if (!m_parsed) +Parse(); + if (m_parse_error) +return false; + return (bool)m_full; +} + +ConstString GetFullName() const { return m_full; } + +llvm::StringRef GetBasename() { + if (!m_parsed) +Parse(); + return m_basename; +} + +llvm::StringRef GetContext() { + if (!m_parsed) +Parse(); + return m_context; +} + +llvm::StringRef GetArguments() { + if (!m_parsed) +Parse(); + return m_arguments; +} + +
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
JDevlieghere wrote: > You need to actually let the main loop handle the signals > (MainLoopPosix::RegisterSignal), as it knows how to do that safely. The > function is not available on windows, so you'd need to `#ifdef` it, but that > should be fine because the current code is conditionalized anyway. That makes a lot of sense. I was looking at the interface for MainLoopBase. Cool, I'll rework the PR with your input. https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
@@ -824,5 +834,11 @@ int main(int argc, char const *argv[]) { future.wait(); } + // Stop the signal handler thread. Do this after calling SBDebugger::Terminate + // so that impatient users can send a SIGSTOP if they don't want to wait for JDevlieghere wrote: I meant `SIGINT` (i.e. CTRl-C). https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/135033 >From 75c47b9b6ff38150ee7ddd47c9b0be05681bc499 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 9 Apr 2025 17:06:49 +0400 Subject: [PATCH] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies The original PR is #132274. --- lldb/include/lldb/Core/Mangled.h | 2 + lldb/include/lldb/Core/RichManglingContext.h | 16 +- lldb/include/lldb/Target/Language.h | 98 +++ lldb/source/Core/CMakeLists.txt | 5 +- lldb/source/Core/Mangled.cpp | 10 +- lldb/source/Core/Module.cpp | 153 -- lldb/source/Core/RichManglingContext.cpp | 22 ++- .../Clang/ClangExpressionDeclMap.cpp | 11 +- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 128 ++- .../Language/CPlusPlus/CPlusPlusLanguage.h| 58 ++- .../Plugins/Language/ObjC/ObjCLanguage.cpp| 12 ++ .../Plugins/Language/ObjC/ObjCLanguage.h | 3 + .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +- lldb/unittests/Core/CMakeLists.txt| 1 + .../Core/RichManglingContextTest.cpp | 7 + .../CPlusPlus/CPlusPlusLanguageTest.cpp | 22 +-- 16 files changed, 286 insertions(+), 266 deletions(-) diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 5988d919a89b8..7db63eeeb6ee0 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,6 +246,8 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); + static bool IsMangledName(llvm::StringRef name); + /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 3b79924e88a9a..50ec2ae361098 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,6 +12,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -67,11 +68,7 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - /// Members for PluginCxxLanguage - /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The - /// respective header is in Plugins and including it from here causes cyclic - /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. - llvm::Any m_cxx_method_parser; + std::unique_ptr m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -81,15 +78,6 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); - - /// Cast the given parser to the given type. Ideally we would have a type - /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we - /// can't access CPlusPlusLanguage::MethodName from within the header. - template static ParserT *get(llvm::Any parser) { -assert(parser.has_value()); -assert(llvm::any_cast(&parser)); -return *llvm::any_cast(&parser); - } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index b699a90aff8e4..d46969cb3b4e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,6 +214,104 @@ class Language : public PluginInterface { return std::vector(); }; + class MethodName { + public: +MethodName() {} + +MethodName(ConstString full) +: m_full(full), m_basename(), m_context(), m_arguments(), + m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), + m_parse_error(false) {} + +virtual ~MethodName() {}; + +void Clear() { + m_full.Clear(); + m_basename = llvm::StringRef(); + m_context = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + m_return_type = llvm::StringRef(); + m_scope_qualified.clear(); + m_parsed = false; + m_parse_error = false; +} + +bool IsValid() { + if (!m_parsed) +Parse(); + if (m_parse_error) +return false; + return (bool)m_full; +} + +ConstString GetFullName() const { return m_full; } + +llvm::StringRef GetBasename() { + if (!m_parsed) +Parse(); + return m_basename; +} + +llvm::StringRef GetContext() { + if (!m_parsed) +Parse(); + return m_context; +} + +llvm::StringRef GetArguments() { + if (!m_parsed) +Parse(); + return m_arguments; +} + +
[Lldb-commits] [lldb] [NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (PR #134961)
https://github.com/zhyty approved this pull request. LGTM, though the comment in `AddData` seemed useful, even though it had a couple of typos. Why remove it? https://github.com/llvm/llvm-project/pull/134961 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (PR #134961)
Jlalond wrote: > LGTM, though the comment in `AddData` seemed useful, even though it had a > couple of typos. Why remove it? I recently landed changes that did add chunking of the data so the comment was no longer accurate. Now we'll only ever get chunks up to the `MAX_CHUNK_SIZE` https://github.com/llvm/llvm-project/pull/134961 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e98d138 - [NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (#134961)
Author: Jacob Lalonde Date: 2025-04-09T10:55:30-07:00 New Revision: e98d1380a0e7282ef23d1f583f0a4e02d608eb1d URL: https://github.com/llvm/llvm-project/commit/e98d1380a0e7282ef23d1f583f0a4e02d608eb1d DIFF: https://github.com/llvm/llvm-project/commit/e98d1380a0e7282ef23d1f583f0a4e02d608eb1d.diff LOG: [NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (#134961) I've recently been working on Minidump File Builder again, and some of the comments are out of date, and many of the includes are no longer used. This patch removes unneeded includes and rephrases some comments to better fit with the current state after the read write chunks pr. Added: Modified: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp Removed: diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 6ed184273572b..38806dfc8e5b5 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -41,14 +41,9 @@ #include #include -#include #include #include -#include -#include -#include #include -#include using namespace lldb; using namespace lldb_private; @@ -879,8 +874,8 @@ Status MinidumpFileBuilder::AddMemoryList() { // We apply a generous padding here so that the Directory, MemoryList and // Memory64List sections all begin in 32b addressable space. // Then anything overflow extends into 64b addressable space. - // All core memeroy ranges will either container nothing on stacks only - // or all the memory ranges including stacks + // all_core_memory_vec will either contain all stack regions at this point, + // or be empty if it's a stack only minidump. if (!all_core_memory_vec.empty()) total_size += 256 + (all_core_memory_vec.size() * sizeof(llvm::minidump::MemoryDescriptor_64)); @@ -924,9 +919,9 @@ Status MinidumpFileBuilder::DumpHeader() const { header.StreamDirectoryRVA = static_cast(HEADER_SIZE); header.Checksum = static_cast( - 0u), // not used in most of the writers - header.TimeDateStamp = - static_cast(std::time(nullptr)); + 0u); // not used in most of the writers + header.TimeDateStamp = + static_cast(std::time(nullptr)); header.Flags = static_cast(0u); // minidump normal flag @@ -987,10 +982,10 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks( current_addr, bytes_read, error.AsCString()); // If we failed in a memory read, we would normally want to skip - // this entire region, if we had already written to the minidump + // this entire region. If we had already written to the minidump // file, we can't easily rewind that state. // - // So if we do encounter an error while reading, we just return + // So if we do encounter an error while reading, we return // immediately, any prior bytes read will still be included but // any bytes partially read before the error are ignored. return lldb_private::IterationAction::Stop; @@ -1069,7 +1064,7 @@ MinidumpFileBuilder::AddMemoryList_32(std::vector &ranges, return error; // If we completely failed to read this range -// we can just omit any of the book keeping. +// we can drop the memory range if (bytes_read == 0) continue; @@ -1209,12 +1204,7 @@ MinidumpFileBuilder::AddMemoryList_64(std::vector &ranges, } Status MinidumpFileBuilder::AddData(const void *data, uint64_t size) { - // This should also get chunked, because worst case we copy over a big - // object / memory range, say 5gb. In that case, we'd have to allocate 10gb - // 5 gb for the buffer we're copying from, and then 5gb for the buffer we're - // copying to. Which will be short lived and immedaitely go to disk, the goal - // here is to limit the number of bytes we need to host in memory at any given - // time. + // Append the data to the buffer, if the buffer spills over, flush it to disk m_data.AppendData(data, size); if (m_data.GetByteSize() > MAX_WRITE_CHUNK_SIZE) return FlushBufferToDisk(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][LLDB] Clean up comments/some code in MinidumpFileBuilder (PR #134961)
https://github.com/Jlalond closed https://github.com/llvm/llvm-project/pull/134961 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/135033 >From 5e365a86734b33f4ce31eb9199b88a4a772b5342 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 9 Apr 2025 17:06:49 +0400 Subject: [PATCH] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies The original PR is #132274. Co-authored-by: @bulbazord Alex Langford --- lldb/include/lldb/Core/Mangled.h | 2 + lldb/include/lldb/Core/RichManglingContext.h | 16 +- lldb/include/lldb/Target/Language.h | 98 lldb/source/Core/CMakeLists.txt | 5 +- lldb/source/Core/Mangled.cpp | 12 +- lldb/source/Core/Module.cpp | 151 +++--- lldb/source/Core/RichManglingContext.cpp | 22 ++- .../Clang/ClangExpressionDeclMap.cpp | 11 +- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 131 +++ .../Language/CPlusPlus/CPlusPlusLanguage.h| 62 ++- .../Plugins/Language/ObjC/ObjCLanguage.cpp| 33 ++-- .../Plugins/Language/ObjC/ObjCLanguage.h | 15 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 16 +- .../SymbolFile/DWARF/DWARFASTParserClang.h| 2 +- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 4 +- .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +- lldb/unittests/Core/CMakeLists.txt| 1 + .../Core/RichManglingContextTest.cpp | 7 + .../CPlusPlus/CPlusPlusLanguageTest.cpp | 22 +-- .../Language/ObjC/ObjCLanguageTest.cpp| 24 +-- 20 files changed, 328 insertions(+), 310 deletions(-) diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 5988d919a89b8..7db63eeeb6ee0 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,6 +246,8 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); + static bool IsMangledName(llvm::StringRef name); + /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 3b79924e88a9a..50ec2ae361098 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,6 +12,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -67,11 +68,7 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - /// Members for PluginCxxLanguage - /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The - /// respective header is in Plugins and including it from here causes cyclic - /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. - llvm::Any m_cxx_method_parser; + std::unique_ptr m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -81,15 +78,6 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); - - /// Cast the given parser to the given type. Ideally we would have a type - /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we - /// can't access CPlusPlusLanguage::MethodName from within the header. - template static ParserT *get(llvm::Any parser) { -assert(parser.has_value()); -assert(llvm::any_cast(&parser)); -return *llvm::any_cast(&parser); - } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index b699a90aff8e4..b96a6ab3d8b45 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,6 +214,104 @@ class Language : public PluginInterface { return std::vector(); }; + class MethodName { + public: +MethodName() {} + +MethodName(ConstString full) +: m_full(full), m_basename(), m_context(), m_arguments(), + m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), + m_parse_error(false) {} + +virtual ~MethodName() {}; + +void Clear() { + m_full.Clear(); + m_basename = llvm::StringRef(); + m_context = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + m_return_type = llvm::StringRef(); + m_scope_qualified.clear(); + m_parsed = false; + m_parse_error = false; +} + +bool IsValid() { + if (!m_parsed) +Parse(); + if (m_parse_error) +return false; + return (bool)m_full; +} + +ConstString GetFullName() const { return m_full; } + +llvm::StringRef GetBasename() { + if (!m_parsed) +
[Lldb-commits] [lldb] Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (PR #134995)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/134995 Reverts llvm/llvm-project#132274 Broke a test on LLDB Widows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/7726 ``` FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf) <...> self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Command 'expression -- foo()' did not return successfully Error output: error: Couldn't look up symbols: int foo(void) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ``` >From 0451084e2e64fc5262f480eae8150c9a191eb7dc Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 9 Apr 2025 13:15:33 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"[LLDB]=20Refactored=20CPlusPlusLangua?= =?UTF-8?q?ge::MethodName=20to=20break=20lldb-server=20=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fbc6241d3af45d74ac8e8d3728a57435aab1d5ec. --- lldb/include/lldb/Core/Mangled.h | 2 - lldb/include/lldb/Core/RichManglingContext.h | 16 +- lldb/include/lldb/Target/Language.h | 98 lldb/source/Core/CMakeLists.txt | 5 +- lldb/source/Core/Mangled.cpp | 10 +- lldb/source/Core/Module.cpp | 151 ++ lldb/source/Core/RichManglingContext.cpp | 22 +-- .../Clang/ClangExpressionDeclMap.cpp | 11 +- lldb/source/Plugins/Language/CMakeLists.txt | 2 - .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 128 +-- .../Language/CPlusPlus/CPlusPlusLanguage.h| 58 +-- .../Plugins/Language/ObjC/ObjCLanguage.cpp| 13 -- .../Plugins/Language/ObjC/ObjCLanguage.h | 3 - .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +- lldb/unittests/Core/CMakeLists.txt| 1 - .../Core/RichManglingContextTest.cpp | 7 - .../CPlusPlus/CPlusPlusLanguageTest.cpp | 22 +-- 17 files changed, 267 insertions(+), 286 deletions(-) diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 7db63eeeb6ee0..5988d919a89b8 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,8 +246,6 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); - static bool IsMangledName(llvm::StringRef name); - /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 50ec2ae361098..3b79924e88a9a 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,7 +12,6 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" -#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -68,7 +67,11 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - std::unique_ptr m_cxx_method_parser; + /// Members for PluginCxxLanguage + /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The + /// respective header is in Plugins and including it from here causes cyclic + /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. + llvm::Any m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -78,6 +81,15 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); + + /// Cast the given parser to the given type. Ideally we would have a type + /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we + /// can't access CPlusPlusLanguage::MethodName from within the header. + template static ParserT *get(llvm::Any parser) { +assert(parser.has_value()); +assert(llvm::any_cast(&parser)); +return *llvm::any_cast(&parser); + } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index d46969cb3b4e4..b699a90aff8e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,104 +214,6 @@ class Language : public PluginInterface { return std::vector(); }; - class MethodName { - public: -MethodName() {} - -MethodName(ConstString full) -: m_full(full), m_basename(), m_context(), m_arguments(), - m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), - m_parse_error(false) {} - -virtual ~MethodName() {}; - -void Clear() { - m_full.Clear(); - m_basename = llvm::StringRef(); - m_co
[Lldb-commits] [lldb] a29be9f - Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (#134995)
Author: David Spickett Date: 2025-04-09T13:16:23+01:00 New Revision: a29be9f28e8e0d4ca7a8a3cfdffe616ac780c754 URL: https://github.com/llvm/llvm-project/commit/a29be9f28e8e0d4ca7a8a3cfdffe616ac780c754 DIFF: https://github.com/llvm/llvm-project/commit/a29be9f28e8e0d4ca7a8a3cfdffe616ac780c754.diff LOG: Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (#134995) Reverts llvm/llvm-project#132274 Broke a test on LLDB Widows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/7726 ``` FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf) <...> self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Command 'expression -- foo()' did not return successfully Error output: error: Couldn't look up symbols: int foo(void) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ``` Added: Modified: lldb/include/lldb/Core/Mangled.h lldb/include/lldb/Core/RichManglingContext.h lldb/include/lldb/Target/Language.h lldb/source/Core/CMakeLists.txt lldb/source/Core/Mangled.cpp lldb/source/Core/Module.cpp lldb/source/Core/RichManglingContext.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/Language/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/unittests/Core/CMakeLists.txt lldb/unittests/Core/RichManglingContextTest.cpp lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp Removed: diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 7db63eeeb6ee0..5988d919a89b8 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,8 +246,6 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); - static bool IsMangledName(llvm::StringRef name); - /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 50ec2ae361098..3b79924e88a9a 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,7 +12,6 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" -#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -68,7 +67,11 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - std::unique_ptr m_cxx_method_parser; + /// Members for PluginCxxLanguage + /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The + /// respective header is in Plugins and including it from here causes cyclic + /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. + llvm::Any m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -78,6 +81,15 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); + + /// Cast the given parser to the given type. Ideally we would have a type + /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we + /// can't access CPlusPlusLanguage::MethodName from within the header. + template static ParserT *get(llvm::Any parser) { +assert(parser.has_value()); +assert(llvm::any_cast(&parser)); +return *llvm::any_cast(&parser); + } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index d46969cb3b4e4..b699a90aff8e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,104 +214,6 @@ class Language : public PluginInterface { return std::vector(); }; - class MethodName { - public: -MethodName() {} - -MethodName(ConstString full) -: m_full(full), m_basename(), m_context(), m_arguments(), - m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), - m_parse_error(false) {} - -virtual ~MethodName() {}; - -void Clear() { - m_full.Clear(); - m_basename = llvm::StringRef(); - m_context = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - m_return_type = llvm::StringRef(); - m_scope_qualified.clear(); - m_p
[Lldb-commits] [lldb] [lldb][lldb-dap] fix repeating commands in repl mode (PR #135008)
https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/135008 Fixes #131589 Add a new option to the RunCommands functions to control the echoing of commands >From 296019edb5edba4a21e040feb154b1ef83f1e64d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 9 Apr 2025 14:35:09 +0100 Subject: [PATCH] [lldb][lldb-dap] fix repeating commands in repl mode Fixes #131589 Add a new option to the RunCommands* functions to control the echoing of commands --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 2 +- .../tools/lldb-dap/launch/TestDAP_launch.py | 4 +-- .../repl-mode/TestDAP_repl_mode_detection.py | 11 +++--- lldb/tools/lldb-dap/DAP.cpp | 6 ++-- lldb/tools/lldb-dap/DAP.h | 3 +- .../Handler/EvaluateRequestHandler.cpp| 3 +- lldb/tools/lldb-dap/LLDBUtils.cpp | 35 ++- lldb/tools/lldb-dap/LLDBUtils.h | 19 +++--- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 251d77d79d080..e2f843bd337a6 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -101,7 +101,7 @@ def run_test_evaluate_expressions( if context == "repl": # In the repl context expressions may be interpreted as lldb # commands since no variables have the same name as the command. -self.assertEvaluate("list", r"\(lldb\) list\n.*") +self.assertEvaluate("list", r".*") else: self.assertEvaluateFailure("list") # local variable of a_function diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 64c99019a1c9b..eceba2f8a13cb 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -522,11 +522,9 @@ def test_version(self): ) version_eval_output = version_eval_response["body"]["result"] -# The first line is the prompt line like "(lldb) version", so we skip it. -version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:] version_string = self.dap_server.get_initialize_value("$__lldb_version") self.assertEqual( -version_eval_output_without_prompt_line, +version_eval_output.splitlines(), version_string.splitlines(), "version string does not match", ) diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py index 7c77fc8541b93..09ca725ee8883 100644 --- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py +++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py @@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. +self.assertEvaluate("`command regex user_command s/^$/platform/", r"^$") +self.assertEvaluate("`command alias alias_command platform", r"^$") self.assertEvaluate( "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", -r"\(lldb\) command alias", +r"^$", ) self.continue_to_next_stop() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 9361ba968e9c2..03b9dc7135ef7 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression, } bool DAP::RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands) { + llvm::ArrayRef commands, + bool echo_commands) { bool required_command_failed = false; std::string output = - ::RunLLDBCommands(debugger, prefix, commands, required_command_failed); + ::RunLLDBCommands(debugger, prefix, commands, required_command_failed, +/*parse_command_directives*/ true, echo_commands); SendOutput(OutputType::Console, output); return !required_command_failed; } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..cb3431cc87fd1 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -290,7 +290,8 @@ struct DAP { /// \b false if a fatal error was found while executing t
[Lldb-commits] [lldb] [lldb][lldb-dap] fix repeating commands in repl mode (PR #135008)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) Changes Fixes #131589 Add a new option to the RunCommands functions to control the echoing of commands --- Full diff: https://github.com/llvm/llvm-project/pull/135008.diff 8 Files Affected: - (modified) lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py (+1-1) - (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+1-3) - (modified) lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py (+4-7) - (modified) lldb/tools/lldb-dap/DAP.cpp (+4-2) - (modified) lldb/tools/lldb-dap/DAP.h (+2-1) - (modified) lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp (+2-1) - (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+26-9) - (modified) lldb/tools/lldb-dap/LLDBUtils.h (+14-5) ``diff diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 251d77d79d080..e2f843bd337a6 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -101,7 +101,7 @@ def run_test_evaluate_expressions( if context == "repl": # In the repl context expressions may be interpreted as lldb # commands since no variables have the same name as the command. -self.assertEvaluate("list", r"\(lldb\) list\n.*") +self.assertEvaluate("list", r".*") else: self.assertEvaluateFailure("list") # local variable of a_function diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 64c99019a1c9b..eceba2f8a13cb 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -522,11 +522,9 @@ def test_version(self): ) version_eval_output = version_eval_response["body"]["result"] -# The first line is the prompt line like "(lldb) version", so we skip it. -version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:] version_string = self.dap_server.get_initialize_value("$__lldb_version") self.assertEqual( -version_eval_output_without_prompt_line, +version_eval_output.splitlines(), version_string.splitlines(), "version string does not match", ) diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py index 7c77fc8541b93..09ca725ee8883 100644 --- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py +++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py @@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. +self.assertEvaluate("`command regex user_command s/^$/platform/", r"^$") +self.assertEvaluate("`command alias alias_command platform", r"^$") self.assertEvaluate( "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", -r"\(lldb\) command alias", +r"^$", ) self.continue_to_next_stop() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 9361ba968e9c2..03b9dc7135ef7 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression, } bool DAP::RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands) { + llvm::ArrayRef commands, + bool echo_commands) { bool required_command_failed = false; std::string output = - ::RunLLDBCommands(debugger, prefix, commands, required_command_failed); + ::RunLLDBCommands(debugger, prefix, commands, required_command_failed, +/*parse_command_directives*/ true, echo_commands); SendOutput(OutputType::Console, output); return !required_command_failed; } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..cb3431cc87fd1 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -290,7 +290,8 @@ struct DAP { /// \b false if a fatal error was found while executing these commands, /// according to the rules of \a LLDBUtils::RunLLDBCommands. bool RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands); +
[Lldb-commits] [lldb] Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (PR #134995)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/134995 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)
@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef &format_str, return parent; } +/// Parses a single highlighting format specifier. +/// +/// Example syntax for such specifier: +/// \code +/// ${function.name-with-args:%highlight_basename(ansi.fg.green)} Michael137 wrote: Yea i think we can make that work. I got something working with the following: ``` settings set frame-format "${function.return-left}${function.scope}${function.basename}${function.template-arguments}${function.arguments}${function.return-right}${function.qualifiers}\n" ``` The concept of "left" vs. "right" parts of the return type already exists in the demangler when printing the name. So I borrowed that terminology. If people are happy with this syntax I'll update this PR https://github.com/llvm/llvm-project/pull/131836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NFC]Also includes the error in log msg. (PR #134922)
https://github.com/oontvoo closed https://github.com/llvm/llvm-project/pull/134922 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e3f5a1b - [LLDB][NFC]Also includes the error in log msg. (#134922)
Author: Vy Nguyen Date: 2025-04-09T10:23:48-04:00 New Revision: e3f5a1bfc58b5c8db8ff8ac8390e790c7a396d4a URL: https://github.com/llvm/llvm-project/commit/e3f5a1bfc58b5c8db8ff8ac8390e790c7a396d4a DIFF: https://github.com/llvm/llvm-project/commit/e3f5a1bfc58b5c8db8ff8ac8390e790c7a396d4a.diff LOG: [LLDB][NFC]Also includes the error in log msg. (#134922) Co-authored-by: Jonas Devlieghere Added: Modified: lldb/include/lldb/Core/Telemetry.h Removed: diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index 28897f283dc55..fa01e2e4af90f 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -272,7 +272,8 @@ template struct ScopedDispatcher { // And then we dispatch. if (llvm::Error er = manager->dispatch(&info)) { LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er), - "Failed to dispatch entry of type: {0}", info.getKind()); + "Failed to dispatch entry of type {1}: {0}", + info.getKind()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into helper functions and use LLVM style (PR #135031)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes I've always found this hard to read. Some upcoming changes make similar computations, so I thought it's a good time to factor out this logic into re-usable helpers and clean it up using LLVM's preferred early-return style. --- Full diff: https://github.com/llvm/llvm-project/pull/135031.diff 1 Files Affected: - (modified) lldb/source/Core/FormatEntity.cpp (+69-49) ``diff diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 04dea7efde54d..a9370595c11e7 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1160,6 +1160,64 @@ static void FormatInlinedBlock(Stream &out_stream, Block *block) { } } +static VariableListSP GetFunctionVariableList(const SymbolContext &sc) { + assert(sc.function); + + if (sc.block) +if (Block *inline_block = sc.block->GetContainingInlinedBlock()) + return inline_block->GetBlockVariableList(true); + + return sc.function->GetBlock(true).GetBlockVariableList(true); +} + +static char const *GetInlinedFunctionName(const SymbolContext &sc) { + if (!sc.block) +return nullptr; + + const Block *inline_block = sc.block->GetContainingInlinedBlock(); + if (!inline_block) +return nullptr; + + const InlineFunctionInfo *inline_info = + inline_block->GetInlinedFunctionInfo(); + if (!inline_info) +return nullptr; + + return inline_info->GetName().AsCString(nullptr); +} + +static bool PrintFunctionNameWithArgs(Stream &s, + const ExecutionContext *exe_ctx, + const SymbolContext &sc) { + assert(sc.function); + + ExecutionContextScope *exe_scope = + exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; + + const char *cstr = sc.function->GetName().AsCString(nullptr); + if (!cstr) +return false; + + if (const char *inlined_name = GetInlinedFunctionName(sc)) { +s.PutCString(cstr); +s.PutCString(" [inlined] "); +cstr = inlined_name; + } + + VariableList args; + if (auto variable_list_sp = GetFunctionVariableList(sc)) +variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, + args); + + if (args.GetSize() > 0) { +PrettyPrintFunctionNameWithArgs(s, cstr, exe_scope, args); + } else { +s.PutCString(cstr); + } + + return true; +} + bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, @@ -1736,59 +1794,21 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (language_plugin_handled) { s << ss.GetString(); return true; -} else { - // Print the function name with arguments in it - if (sc->function) { -ExecutionContextScope *exe_scope = -exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; -const char *cstr = sc->function->GetName().AsCString(nullptr); -if (cstr) { - const InlineFunctionInfo *inline_info = nullptr; - VariableListSP variable_list_sp; - bool get_function_vars = true; - if (sc->block) { -Block *inline_block = sc->block->GetContainingInlinedBlock(); - -if (inline_block) { - get_function_vars = false; - inline_info = inline_block->GetInlinedFunctionInfo(); - if (inline_info) -variable_list_sp = inline_block->GetBlockVariableList(true); -} - } +} - if (get_function_vars) { -variable_list_sp = -sc->function->GetBlock(true).GetBlockVariableList(true); - } +if (sc->function) + return PrintFunctionNameWithArgs(s, exe_ctx, *sc); - if (inline_info) { -s.PutCString(cstr); -s.PutCString(" [inlined] "); -cstr = inline_info->GetName().GetCString(); - } +if (!sc->symbol) + return false; - VariableList args; - if (variable_list_sp) -variable_list_sp->AppendVariablesWithScope( -eValueTypeVariableArgument, args); - if (args.GetSize() > 0) { -PrettyPrintFunctionNameWithArgs(s, cstr, exe_scope, args); - } else { -s.PutCString(cstr); - } - return true; -} - } else if (sc->symbol) { -const char *cstr = sc->symbol->GetName().AsCString(nullptr); -if (cstr) { - s.PutCString(cstr); - return true; -} - } -} +const char *cstr = sc->symbol->GetName().AsCString(nullptr); +if (!cstr) + return false; + +s.PutCString(cstr); +return true; } -return false; case Entry::Type::FunctionMangledName: { if (!sc) `` https
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/135033 >From d89b0242152002161b90d29e275a68e0e3f51dfe Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Wed, 9 Apr 2025 17:06:49 +0400 Subject: [PATCH] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies The original PR is #132274. Co-authored-by: @bulbazord Alex Langford --- lldb/include/lldb/Core/Mangled.h | 2 + lldb/include/lldb/Core/RichManglingContext.h | 16 +- lldb/include/lldb/Target/Language.h | 98 lldb/source/Core/CMakeLists.txt | 5 +- lldb/source/Core/Mangled.cpp | 10 +- lldb/source/Core/Module.cpp | 151 -- lldb/source/Core/RichManglingContext.cpp | 22 ++- .../Clang/ClangExpressionDeclMap.cpp | 11 +- lldb/source/Plugins/Language/CMakeLists.txt | 4 +- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 128 ++- .../Language/CPlusPlus/CPlusPlusLanguage.h| 58 ++- .../Plugins/Language/ObjC/ObjCLanguage.cpp| 13 ++ .../Plugins/Language/ObjC/ObjCLanguage.h | 3 + .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 4 +- lldb/unittests/Core/CMakeLists.txt| 1 + .../Core/RichManglingContextTest.cpp | 7 + .../CPlusPlus/CPlusPlusLanguageTest.cpp | 22 +-- 17 files changed, 287 insertions(+), 268 deletions(-) diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 5988d919a89b8..7db63eeeb6ee0 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,6 +246,8 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); + static bool IsMangledName(llvm::StringRef name); + /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 3b79924e88a9a..50ec2ae361098 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,6 +12,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -67,11 +68,7 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - /// Members for PluginCxxLanguage - /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The - /// respective header is in Plugins and including it from here causes cyclic - /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. - llvm::Any m_cxx_method_parser; + std::unique_ptr m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -81,15 +78,6 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); - - /// Cast the given parser to the given type. Ideally we would have a type - /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we - /// can't access CPlusPlusLanguage::MethodName from within the header. - template static ParserT *get(llvm::Any parser) { -assert(parser.has_value()); -assert(llvm::any_cast(&parser)); -return *llvm::any_cast(&parser); - } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index b699a90aff8e4..d46969cb3b4e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,6 +214,104 @@ class Language : public PluginInterface { return std::vector(); }; + class MethodName { + public: +MethodName() {} + +MethodName(ConstString full) +: m_full(full), m_basename(), m_context(), m_arguments(), + m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), + m_parse_error(false) {} + +virtual ~MethodName() {}; + +void Clear() { + m_full.Clear(); + m_basename = llvm::StringRef(); + m_context = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + m_return_type = llvm::StringRef(); + m_scope_qualified.clear(); + m_parsed = false; + m_parse_error = false; +} + +bool IsValid() { + if (!m_parsed) +Parse(); + if (m_parse_error) +return false; + return (bool)m_full; +} + +ConstString GetFullName() const { return m_full; } + +llvm::StringRef GetBasename() { + if (!m_parsed) +Parse(); + return m_basename; +} + +llvm::StringRef GetContext() { + if (!m_parsed) +Parse(); + return m_context; +} + +llvm::Strin
[Lldb-commits] [lldb] Revert "[LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies" (PR #134995)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Reverts llvm/llvm-project#132274 Broke a test on LLDB Widows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/7726 ``` FAIL: test_dwarf (lldbsuite.test.lldbtest.TestExternCSymbols.test_dwarf) <...> self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Command 'expression -- foo()' did not return successfully Error output: error: Couldn't look up symbols: int foo(void) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ``` --- Patch is 38.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134995.diff 17 Files Affected: - (modified) lldb/include/lldb/Core/Mangled.h (-2) - (modified) lldb/include/lldb/Core/RichManglingContext.h (+14-2) - (modified) lldb/include/lldb/Target/Language.h (-98) - (modified) lldb/source/Core/CMakeLists.txt (+4-1) - (modified) lldb/source/Core/Mangled.cpp (+5-5) - (modified) lldb/source/Core/Module.cpp (+88-63) - (modified) lldb/source/Core/RichManglingContext.cpp (+13-9) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+5-6) - (modified) lldb/source/Plugins/Language/CMakeLists.txt (-2) - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+76-52) - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h (+49-9) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp (-13) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.h (-3) - (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+2-2) - (modified) lldb/unittests/Core/CMakeLists.txt (-1) - (modified) lldb/unittests/Core/RichManglingContextTest.cpp (-7) - (modified) lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (+11-11) ``diff diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 7db63eeeb6ee0..5988d919a89b8 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -246,8 +246,6 @@ class Mangled { /// for s, otherwise the enumerator for the mangling scheme detected. static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name); - static bool IsMangledName(llvm::StringRef name); - /// Decode a serialized version of this object from data. /// /// \param data diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 50ec2ae361098..3b79924e88a9a 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -12,7 +12,6 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" -#include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/Any.h" @@ -68,7 +67,11 @@ class RichManglingContext { char *m_ipd_buf; size_t m_ipd_buf_size = 2048; - std::unique_ptr m_cxx_method_parser; + /// Members for PluginCxxLanguage + /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The + /// respective header is in Plugins and including it from here causes cyclic + /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. + llvm::Any m_cxx_method_parser; /// Clean up memory when using PluginCxxLanguage void ResetCxxMethodParser(); @@ -78,6 +81,15 @@ class RichManglingContext { /// Uniform handling of string buffers for ItaniumPartialDemangler. llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len); + + /// Cast the given parser to the given type. Ideally we would have a type + /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we + /// can't access CPlusPlusLanguage::MethodName from within the header. + template static ParserT *get(llvm::Any parser) { +assert(parser.has_value()); +assert(llvm::any_cast(&parser)); +return *llvm::any_cast(&parser); + } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index d46969cb3b4e4..b699a90aff8e4 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -214,104 +214,6 @@ class Language : public PluginInterface { return std::vector(); }; - class MethodName { - public: -MethodName() {} - -MethodName(ConstString full) -: m_full(full), m_basename(), m_context(), m_arguments(), - m_qualifiers(), m_return_type(), m_scope_qualified(), m_parsed(false), - m_parse_error(false) {} - -virtual ~MethodName() {}; - -void Clear() { - m_full.Clear(); - m_basename = llvm::StringRef(); - m_context = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - m_return_type = llvm::StringRef(); - m_scope_qualified.clear();
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman converted_to_draft https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)
https://github.com/slydiman edited https://github.com/llvm/llvm-project/pull/135033 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove UnwindPlan::Row shared_ptrs, lite (PR #134081)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/134081 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target (PR #132688)
@@ -8,7 +8,10 @@ #include "LinuxSignals.h" -#ifdef __linux__ +// Now, because we do not support mips debugging, if we compile LLVM on mips +// target, would report error `static assertion failed:Value mismatch for signal +// number SIGBUS`, so add this condition to avoid error. yingopq wrote: @labath please help review again, thanks! https://github.com/llvm/llvm-project/pull/132688 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
@@ -637,48 +641,50 @@ void Driver::UpdateWindowSize() { } void sigwinch_handler(int signo) { - if (g_driver != nullptr) -g_driver->UpdateWindowSize(); + g_signal_loop.AddPendingCallback([](MainLoopBase &loop) { +if (g_driver != nullptr) + g_driver->UpdateWindowSize(); + }); } void sigint_handler(int signo) { #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); #endif - static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; - if (g_driver != nullptr) { -if (!g_interrupt_sent.test_and_set()) { - g_driver->GetDebugger().DispatchInputInterrupt(); - g_interrupt_sent.clear(); - return; + g_signal_loop.AddPendingCallback([signo](MainLoopBase &loop) { +static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; +if (g_driver != nullptr) { + if (!g_interrupt_sent.test_and_set()) { +g_driver->GetDebugger().DispatchInputInterrupt(); +g_interrupt_sent.clear(); +return; + } } - } - _exit(signo); +loop.RequestTermination(); +_exit(signo); + }); } #ifndef _WIN32 static void sigtstp_handler(int signo) { - if (g_driver != nullptr) -g_driver->GetDebugger().SaveInputTerminalState(); - - // Unblock the signal and remove our handler. - sigset_t set; - sigemptyset(&set); - sigaddset(&set, signo); - pthread_sigmask(SIG_UNBLOCK, &set, nullptr); - signal(signo, SIG_DFL); - - // Now re-raise the signal. We will immediately suspend... - raise(signo); - // ... and resume after a SIGCONT. - - // Now undo the modifications. - pthread_sigmask(SIG_BLOCK, &set, nullptr); - signal(signo, sigtstp_handler); - - if (g_driver != nullptr) -g_driver->GetDebugger().RestoreInputTerminalState(); + g_signal_loop.AddPendingCallback([signo](MainLoopBase &loop) { +if (g_driver != nullptr) + g_driver->GetDebugger().SaveInputTerminalState(); + +// Remove our handler. +signal(signo, SIG_DFL); labath wrote: We should use `sigaction` here to make sure we restore the handler state exactly as MainLoop has set it. Fiddling with the handlers installed by the main loop slightly rude, but it should work if we properly restore them afterwards. One possibility would be to add some sort of a flag to request that the MainLoop runs our handler with the default signal handler, but I'm not sure that would be much of an improvement. Another possibility would be to raise a SIGSTOP instead of SIGTSTP, but I think that's also not how one is "supposed to" handle a SIGTSTP. https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target (PR #132688)
labath wrote: The patch (still) looks good. I think what you need is for someone to push the submit button, so I'll do that now. https://github.com/llvm/llvm-project/pull/132688 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/134956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ea7dd70 - [lldb] Remove unused UnwindPlan functions (#134630)
Author: Pavel Labath Date: 2025-04-09T11:04:45+02:00 New Revision: ea7dd70b5326706141be2a768f2fd47ae71ee6a8 URL: https://github.com/llvm/llvm-project/commit/ea7dd70b5326706141be2a768f2fd47ae71ee6a8 DIFF: https://github.com/llvm/llvm-project/commit/ea7dd70b5326706141be2a768f2fd47ae71ee6a8.diff LOG: [lldb] Remove unused UnwindPlan functions (#134630) `GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and they create a bit of a problem for discontinuous functions, because the unwind plan for these consists of multiple eh_frame descriptors and (at least in theory) each of them could have a different value for these entities. We could say we only support functions for which these are always the same, or create some sort of a Address2LSDA lookup map, but I think it's better to leave this question to someone who actually needs this. Added: Modified: lldb/include/lldb/Symbol/FuncUnwinders.h lldb/include/lldb/Symbol/UnwindPlan.h lldb/source/Symbol/CompactUnwindInfo.cpp lldb/source/Symbol/DWARFCallFrameInfo.cpp lldb/source/Symbol/FuncUnwinders.cpp lldb/source/Symbol/UnwindPlan.cpp Removed: diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h index 479ccf87b6e2c..c21a1af5c56a2 100644 --- a/lldb/include/lldb/Symbol/FuncUnwinders.h +++ b/lldb/include/lldb/Symbol/FuncUnwinders.h @@ -61,19 +61,6 @@ class FuncUnwinders { }); } - // A function may have a Language Specific Data Area specified -- a block of - // data in - // the object file which is used in the processing of an exception throw / - // catch. If any of the UnwindPlans have the address of the LSDA region for - // this function, this will return it. - Address GetLSDAAddress(Target &target); - - // A function may have a Personality Routine associated with it -- used in the - // processing of throwing an exception. If any of the UnwindPlans have the - // address of the personality routine, this will return it. Read the target- - // pointer at this address to get the personality function address. - Address GetPersonalityRoutinePtrAddress(Target &target); - // The following methods to retrieve specific unwind plans should rarely be // used. Instead, clients should ask for the *behavior* they are looking for, // using one of the above UnwindPlan retrieval methods. diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index 0feb20b12e184..61c4bdeac272d 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -536,22 +536,10 @@ class UnwindPlan { m_plan_is_sourced_from_compiler = eLazyBoolCalculate; m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate; m_plan_is_for_signal_trap = eLazyBoolCalculate; -m_lsda_address.Clear(); -m_personality_func_addr.Clear(); } const RegisterInfo *GetRegisterInfo(Thread *thread, uint32_t reg_num) const; - Address GetLSDAAddress() const { return m_lsda_address; } - - void SetLSDAAddress(Address lsda_addr) { m_lsda_address = lsda_addr; } - - Address GetPersonalityFunctionPtr() const { return m_personality_func_addr; } - - void SetPersonalityFunctionPtr(Address presonality_func_ptr) { -m_personality_func_addr = presonality_func_ptr; - } - private: std::vector m_row_list; std::vector m_plan_valid_ranges; @@ -566,13 +554,6 @@ class UnwindPlan { lldb_private::LazyBool m_plan_is_sourced_from_compiler; lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations; lldb_private::LazyBool m_plan_is_for_signal_trap; - - Address m_lsda_address; // Where the language specific data area exists in the - // module - used - // in exception handling. - Address m_personality_func_addr; // The address of a pointer to the - // personality function - used in - // exception handling. }; // class UnwindPlan } // namespace lldb_private diff --git a/lldb/source/Symbol/CompactUnwindInfo.cpp b/lldb/source/Symbol/CompactUnwindInfo.cpp index 3c97d2ca11fbc..cdbbeb554c688 100644 --- a/lldb/source/Symbol/CompactUnwindInfo.cpp +++ b/lldb/source/Symbol/CompactUnwindInfo.cpp @@ -741,9 +741,6 @@ bool CompactUnwindInfo::CreateUnwindPlan_x86_64(Target &target, unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo); unwind_plan.SetRegisterKind(eRegisterKindEHFrame); - unwind_plan.SetLSDAAddress(function_info.lsda_address); - unwind_plan.SetPersonalityFunctionPtr(function_info.personality_ptr_address); - UnwindPlan::Row row; const int wordsize = 8; @@ -1011,9 +1008,6 @@ bool CompactUnwindInfo::CreateUnwindPlan_i386(Target &target, unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo); unwind_plan.SetRegisterKind(eRegisterKind
[Lldb-commits] [lldb] [lldb] Remove unused UnwindPlan functions (PR #134630)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/134630 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/131836 >From 96901b4937a7cfe14b2f595484c95178176dc178 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 11 Mar 2025 08:57:13 + Subject: [PATCH 1/5] [llvm][ItaniumDemangle] Add printLeft/printRight APIs to OutputBuffer This patch includes the necessary changes for the LLDB feature proposed in https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309. The TL;DR is that we want to track where certain parts of a demangled name begin/end so we can highlight them in backtraces. We introduce a new `printLeft`/`printRight` API that a client (in our case LLDB) can implement to track state while printing the demangle tree. This requires redirecting all calls to to `printLeft`/`printRight` to the `OutputBuffer`. One quirk with the new API is that `Utility.h` would now depend on `ItaniumDemangle.h` and vice-versa. To keep these files header-only I made the definitions `inline` and implement the new APIs in `ItaniumDemangle.h` (so the definition of `Node` is available to them). --- libcxxabi/src/demangle/ItaniumDemangle.h | 91 +++ libcxxabi/src/demangle/Utility.h | 10 ++ llvm/include/llvm/Demangle/ItaniumDemangle.h | 91 +++ llvm/include/llvm/Demangle/Utility.h | 10 ++ .../Demangle/ItaniumDemangleTest.cpp | 2 +- 5 files changed, 129 insertions(+), 75 deletions(-) diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h index 3df41b5f4d7d0..aa91b93e2a3bb 100644 --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -281,20 +281,11 @@ class Node { } void print(OutputBuffer &OB) const { -printLeft(OB); +OB.printLeft(*this); if (RHSComponentCache != Cache::No) - printRight(OB); + OB.printRight(*this); } - // Print the "left" side of this Node into OutputBuffer. - virtual void printLeft(OutputBuffer &) const = 0; - - // Print the "right". This distinction is necessary to represent C++ types - // that appear on the RHS of their subtype, such as arrays or functions. - // Since most types don't have such a component, provide a default - // implementation. - virtual void printRight(OutputBuffer &) const {} - // Print an initializer list of this type. Returns true if we printed a custom // representation, false if nothing has been printed and the default // representation should be used. @@ -310,6 +301,24 @@ class Node { #ifndef NDEBUG DEMANGLE_DUMP_METHOD void dump() const; #endif + +private: + friend class OutputBuffer; + + // Print the "left" side of this Node into OutputBuffer. + // + // Note, should only be called from OutputBuffer implementations. + // Call \ref OutputBuffer::printLeft instead. + virtual void printLeft(OutputBuffer &) const = 0; + + // Print the "right". This distinction is necessary to represent C++ types + // that appear on the RHS of their subtype, such as arrays or functions. + // Since most types don't have such a component, provide a default + // implementation. + // + // Note, should only be called from OutputBuffer implementations. + // Call \ref OutputBuffer::printRight instead. + virtual void printRight(OutputBuffer &) const {} }; class NodeArray { @@ -458,11 +467,11 @@ class QualType final : public Node { } void printLeft(OutputBuffer &OB) const override { -Child->printLeft(OB); +OB.printLeft(*Child); printQuals(OB); } - void printRight(OutputBuffer &OB) const override { Child->printRight(OB); } + void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); } }; class ConversionOperatorType final : public Node { @@ -491,7 +500,7 @@ class PostfixQualifiedType final : public Node { template void match(Fn F) const { F(Ty, Postfix); } void printLeft(OutputBuffer &OB) const override { -Ty->printLeft(OB); +OB.printLeft(*Ty); OB += Postfix; } }; @@ -577,7 +586,7 @@ struct AbiTagAttr : Node { std::string_view getBaseName() const override { return Base->getBaseName(); } void printLeft(OutputBuffer &OB) const override { -Base->printLeft(OB); +OB.printLeft(*Base); OB += "[abi:"; OB += Tag; OB += "]"; @@ -644,7 +653,7 @@ class PointerType final : public Node { // We rewrite objc_object* into id. if (Pointee->getKind() != KObjCProtoName || !static_cast(Pointee)->isObjCObject()) { - Pointee->printLeft(OB); + OB.printLeft(*Pointee); if (Pointee->hasArray(OB)) OB += " "; if (Pointee->hasArray(OB) || Pointee->hasFunction(OB)) @@ -663,7 +672,7 @@ class PointerType final : public Node { !static_cast(Pointee)->isObjCObject()) { if (Pointee->hasArray(OB) || Pointee->hasFunction(OB)) OB += ")"; - Pointee->printRight(OB); + OB.printRight(*Pointee); } } }; @@
[Lldb-commits] [lldb] [lldb] Remove unused UnwindPlan functions (PR #134630)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/134630 >From 5f226bc5fa08e1b098ee95ba860954079a71c83c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 4 Apr 2025 12:05:18 +0200 Subject: [PATCH] [lldb] Remove unused UnwindPlan functions `GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and they create a bit of a problem for discontinuous functions, because the unwind plan for these consists of multiple eh_frame descriptors and (at least in theory) each of them could have a different value for these entities. We could say we only support functions for which these are always the same, or create some sort of a Address2LSDA lookup map, but I think it's better to leave this question to someone who actually needs this. --- lldb/include/lldb/Symbol/FuncUnwinders.h | 13 lldb/include/lldb/Symbol/UnwindPlan.h | 19 lldb/source/Symbol/CompactUnwindInfo.cpp | 12 --- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 38 +++ lldb/source/Symbol/FuncUnwinders.cpp | 36 - lldb/source/Symbol/UnwindPlan.cpp | 13 6 files changed, 4 insertions(+), 127 deletions(-) diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h index 479ccf87b6e2c..c21a1af5c56a2 100644 --- a/lldb/include/lldb/Symbol/FuncUnwinders.h +++ b/lldb/include/lldb/Symbol/FuncUnwinders.h @@ -61,19 +61,6 @@ class FuncUnwinders { }); } - // A function may have a Language Specific Data Area specified -- a block of - // data in - // the object file which is used in the processing of an exception throw / - // catch. If any of the UnwindPlans have the address of the LSDA region for - // this function, this will return it. - Address GetLSDAAddress(Target &target); - - // A function may have a Personality Routine associated with it -- used in the - // processing of throwing an exception. If any of the UnwindPlans have the - // address of the personality routine, this will return it. Read the target- - // pointer at this address to get the personality function address. - Address GetPersonalityRoutinePtrAddress(Target &target); - // The following methods to retrieve specific unwind plans should rarely be // used. Instead, clients should ask for the *behavior* they are looking for, // using one of the above UnwindPlan retrieval methods. diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index 0feb20b12e184..61c4bdeac272d 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -536,22 +536,10 @@ class UnwindPlan { m_plan_is_sourced_from_compiler = eLazyBoolCalculate; m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate; m_plan_is_for_signal_trap = eLazyBoolCalculate; -m_lsda_address.Clear(); -m_personality_func_addr.Clear(); } const RegisterInfo *GetRegisterInfo(Thread *thread, uint32_t reg_num) const; - Address GetLSDAAddress() const { return m_lsda_address; } - - void SetLSDAAddress(Address lsda_addr) { m_lsda_address = lsda_addr; } - - Address GetPersonalityFunctionPtr() const { return m_personality_func_addr; } - - void SetPersonalityFunctionPtr(Address presonality_func_ptr) { -m_personality_func_addr = presonality_func_ptr; - } - private: std::vector m_row_list; std::vector m_plan_valid_ranges; @@ -566,13 +554,6 @@ class UnwindPlan { lldb_private::LazyBool m_plan_is_sourced_from_compiler; lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations; lldb_private::LazyBool m_plan_is_for_signal_trap; - - Address m_lsda_address; // Where the language specific data area exists in the - // module - used - // in exception handling. - Address m_personality_func_addr; // The address of a pointer to the - // personality function - used in - // exception handling. }; // class UnwindPlan } // namespace lldb_private diff --git a/lldb/source/Symbol/CompactUnwindInfo.cpp b/lldb/source/Symbol/CompactUnwindInfo.cpp index 3c97d2ca11fbc..cdbbeb554c688 100644 --- a/lldb/source/Symbol/CompactUnwindInfo.cpp +++ b/lldb/source/Symbol/CompactUnwindInfo.cpp @@ -741,9 +741,6 @@ bool CompactUnwindInfo::CreateUnwindPlan_x86_64(Target &target, unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo); unwind_plan.SetRegisterKind(eRegisterKindEHFrame); - unwind_plan.SetLSDAAddress(function_info.lsda_address); - unwind_plan.SetPersonalityFunctionPtr(function_info.personality_ptr_address); - UnwindPlan::Row row; const int wordsize = 8; @@ -1011,9 +1008,6 @@ bool CompactUnwindInfo::CreateUnwindPlan_i386(Target &target, unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo); unwind_plan.SetRegisterKind(eRegisterKindEHFrame); - unwind_plan.SetLSDAAddre
[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)
https://github.com/kusmour edited https://github.com/llvm/llvm-project/pull/134339 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)
real-mikhail wrote: Hi, I added the new option key `target.process.track-memory-cache-changes` (which defaults to `true`, meaning bulletproof behaviour). Setting it to `false` enables the optimization I initially suggested. I also added a new dump command and ensured with test that MemoryID is not changed when executing simple expressions. https://github.com/llvm/llvm-project/pull/129092 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove unused UnwindPlan functions (PR #134630)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/134630 >From ab6dc42c00fd52a0551ec59cfddb012bc56da277 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 4 Apr 2025 12:05:18 +0200 Subject: [PATCH] [lldb] Remove unused UnwindPlan functions `GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and they create a bit of a problem for discontinuous functions, because the unwind plan for these consists of multiple eh_frame descriptors and (at least in theory) each of them could have a different value for these entities. We could say we only support functions for which these are always the same, or create some sort of a Address2LSDA lookup map, but I think it's better to leave this question to someone who actually needs this. --- lldb/include/lldb/Symbol/FuncUnwinders.h | 13 lldb/include/lldb/Symbol/UnwindPlan.h | 23 +- lldb/source/Symbol/CompactUnwindInfo.cpp | 12 --- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 38 +++ lldb/source/Symbol/FuncUnwinders.cpp | 36 - lldb/source/Symbol/UnwindPlan.cpp | 13 6 files changed, 5 insertions(+), 130 deletions(-) diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h index 479ccf87b6e2c..c21a1af5c56a2 100644 --- a/lldb/include/lldb/Symbol/FuncUnwinders.h +++ b/lldb/include/lldb/Symbol/FuncUnwinders.h @@ -61,19 +61,6 @@ class FuncUnwinders { }); } - // A function may have a Language Specific Data Area specified -- a block of - // data in - // the object file which is used in the processing of an exception throw / - // catch. If any of the UnwindPlans have the address of the LSDA region for - // this function, this will return it. - Address GetLSDAAddress(Target &target); - - // A function may have a Personality Routine associated with it -- used in the - // processing of throwing an exception. If any of the UnwindPlans have the - // address of the personality routine, this will return it. Read the target- - // pointer at this address to get the personality function address. - Address GetPersonalityRoutinePtrAddress(Target &target); - // The following methods to retrieve specific unwind plans should rarely be // used. Instead, clients should ask for the *behavior* they are looking for, // using one of the above UnwindPlan retrieval methods. diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index 6640a23a3e868..eee932492a550 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -445,9 +445,7 @@ class UnwindPlan { m_plan_is_sourced_from_compiler(rhs.m_plan_is_sourced_from_compiler), m_plan_is_valid_at_all_instruction_locations( rhs.m_plan_is_valid_at_all_instruction_locations), -m_plan_is_for_signal_trap(rhs.m_plan_is_for_signal_trap), -m_lsda_address(rhs.m_lsda_address), -m_personality_func_addr(rhs.m_personality_func_addr) { +m_plan_is_for_signal_trap(rhs.m_plan_is_for_signal_trap) { m_row_list.reserve(rhs.m_row_list.size()); for (const RowSP &row_sp : rhs.m_row_list) m_row_list.emplace_back(new Row(*row_sp)); @@ -553,22 +551,10 @@ class UnwindPlan { m_plan_is_sourced_from_compiler = eLazyBoolCalculate; m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate; m_plan_is_for_signal_trap = eLazyBoolCalculate; -m_lsda_address.Clear(); -m_personality_func_addr.Clear(); } const RegisterInfo *GetRegisterInfo(Thread *thread, uint32_t reg_num) const; - Address GetLSDAAddress() const { return m_lsda_address; } - - void SetLSDAAddress(Address lsda_addr) { m_lsda_address = lsda_addr; } - - Address GetPersonalityFunctionPtr() const { return m_personality_func_addr; } - - void SetPersonalityFunctionPtr(Address presonality_func_ptr) { -m_personality_func_addr = presonality_func_ptr; - } - private: std::vector m_row_list; std::vector m_plan_valid_ranges; @@ -583,13 +569,6 @@ class UnwindPlan { lldb_private::LazyBool m_plan_is_sourced_from_compiler; lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations; lldb_private::LazyBool m_plan_is_for_signal_trap; - - Address m_lsda_address; // Where the language specific data area exists in the - // module - used - // in exception handling. - Address m_personality_func_addr; // The address of a pointer to the - // personality function - used in - // exception handling. }; // class UnwindPlan } // namespace lldb_private diff --git a/lldb/source/Symbol/CompactUnwindInfo.cpp b/lldb/source/Symbol/CompactUnwindInfo.cpp index 3c97d2ca11fbc..cdbbeb554c688 100644 --- a/lldb/source/Symbol/CompactUnwindInfo.cpp +++ b/lldb/source/Symbol/CompactUn
[Lldb-commits] [lldb] [lldb] Support negative function offsets in UnwindPlans (PR #134662)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/134662 >From 26b46c0f0e3bdb56afed5fb1e9ab1dd577a3ad66 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 4 Apr 2025 11:37:34 +0200 Subject: [PATCH 1/2] [lldb] Support negative function offsets in UnwindPlans These are needed for functions whose entry point is not their lowest address. --- lldb/include/lldb/Symbol/UnwindPlan.h | 10 +- .../UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp | 5 +++-- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 2 +- lldb/source/Symbol/UnwindPlan.cpp | 6 +++--- lldb/unittests/Symbol/UnwindPlanTest.cpp | 5 + 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index 0feb20b12e184..e2a1848b54807 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -356,11 +356,11 @@ class UnwindPlan { void RemoveRegisterInfo(uint32_t reg_num); -lldb::addr_t GetOffset() const { return m_offset; } +int64_t GetOffset() const { return m_offset; } -void SetOffset(lldb::addr_t offset) { m_offset = offset; } +void SetOffset(int64_t offset) { m_offset = offset; } -void SlideOffset(lldb::addr_t offset) { m_offset += offset; } +void SlideOffset(int64_t offset) { m_offset += offset; } const FAValue &GetCFAValue() const { return m_cfa_value; } FAValue &GetCFAValue() { return m_cfa_value; } @@ -420,7 +420,7 @@ class UnwindPlan { protected: typedef std::map collection; -lldb::addr_t m_offset = 0; // Offset into the function for this row +int64_t m_offset = 0; // Offset into the function for this row FAValue m_cfa_value; FAValue m_afa_value; @@ -455,7 +455,7 @@ class UnwindPlan { // practice, the UnwindPlan for a function with no known start address will be // the architectural default UnwindPlan which will only have one row. const UnwindPlan::Row * - GetRowForFunctionOffset(std::optional offset) const; + GetRowForFunctionOffset(std::optional offset) const; lldb::RegisterKind GetRegisterKind() const { return m_register_kind; } diff --git a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp index 823c6505d90cf..19e8b57e66f07 100644 --- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp +++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp @@ -1390,11 +1390,12 @@ bool x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite( // If we already have one row for this instruction, we can continue. while (row_id < unwind_plan.GetRowCount() && - unwind_plan.GetRowAtIndex(row_id)->GetOffset() <= offset) { + unwind_plan.GetRowAtIndex(row_id)->GetOffset() <= + static_cast(offset)) { row_id++; } const UnwindPlan::Row *original_row = unwind_plan.GetRowAtIndex(row_id - 1); -if (original_row->GetOffset() == offset) { +if (original_row->GetOffset() == static_cast(offset)) { row = *original_row; continue; } diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index 957818e8d077f..dca3f665b0b80 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -765,7 +765,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, __FUNCTION__, dwarf_offset, startaddr.GetFileAddress()); break; } - lldb::addr_t offset = row.GetOffset(); + int64_t offset = row.GetOffset(); row = std::move(stack.back()); stack.pop_back(); row.SetOffset(offset); diff --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp index 48999aadab1e2..9d33f71ce2fbb 100644 --- a/lldb/source/Symbol/UnwindPlan.cpp +++ b/lldb/source/Symbol/UnwindPlan.cpp @@ -398,10 +398,10 @@ void UnwindPlan::AppendRow(Row row) { } struct RowLess { - bool operator()(addr_t a, const UnwindPlan::Row &b) const { + bool operator()(int64_t a, const UnwindPlan::Row &b) const { return a < b.GetOffset(); } - bool operator()(const UnwindPlan::Row &a, addr_t b) const { + bool operator()(const UnwindPlan::Row &a, int64_t b) const { return a.GetOffset() < b; } }; @@ -418,7 +418,7 @@ void UnwindPlan::InsertRow(Row row, bool replace_existing) { } const UnwindPlan::Row * -UnwindPlan::GetRowForFunctionOffset(std::optional offset) const { +UnwindPlan::GetRowForFunctionOffset(std::optional offset) const { auto it = offset ? llvm::upper_bound(m_row_list, *offset, RowLess()) : m_row_list.end(); if (it == m_row_list.begin()) diff --git a/lldb/unittests/Symbol/UnwindPlanTest.cpp b/lldb/unittests/Symbol/U