[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/rastogishubham updated https://github.com/llvm/llvm-project/pull/83312 >From 563ef808aa3b06e97b89e7b52d518705e97d9e14 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Wed, 28 Feb 2024 10:28:55 -0800 Subject: [PATCH] Increase timeout to reduce test failure rate. The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. --- .../test/tools/lldb-dap/lldbdap_testcase.py | 1 + .../test/API/tools/lldb-dap/launch/TestDAP_launch.py | 12 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 288cc8cf9a48c8..f586a28f511a45 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -6,6 +6,7 @@ class DAPTestCaseBase(TestBase): +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) NO_DEBUG_INFO_TESTCASE = True def create_debug_adaptor(self, lldbDAPEnv=None): 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 04d741c1d47201..0760d358d9c0b3 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -44,7 +44,7 @@ def test_termination(self): self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -self.dap_server.process.wait(timeout=10) + self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -334,14 +334,14 @@ def test_commands(self): # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the second breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits @@ -402,21 +402,21 @@ def test_extra_launch_commands(self): self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits self.continue_to_exit() # Get output from the console. This should contain both the # "exitCommands" that were run after the second breakpoint was hit -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("exitCommands", output, exitCommands) @skipIfWindows ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 81d94ca - Revert "[lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS"
Author: Jonas Devlieghere Date: 2024-02-28T21:23:19-08:00 New Revision: 81d94cad6d655d66adb08805a3bbef5a58125999 URL: https://github.com/llvm/llvm-project/commit/81d94cad6d655d66adb08805a3bbef5a58125999 DIFF: https://github.com/llvm/llvm-project/commit/81d94cad6d655d66adb08805a3bbef5a58125999.diff LOG: Revert "[lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS" This reverts commit 793300988b7c723bacadce67879ea8bf71c87e70 as pexpect is not available on any of the GreenDragon bots. Added: Modified: lldb/test/CMakeLists.txt Removed: diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 4094c87aaa40e8..d8cbb24b6c9b81 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -12,8 +12,7 @@ endif() if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS) message(STATUS "Enforcing strict test requirements for LLDB") set(useful_python_modules -psutil # Lit uses psutil to do per-test timeouts. -pexpect # We no longer vendor pexpect. +psutil # Lit uses psutil to do per-test timeouts. ) foreach(module ${useful_python_modules}) lldb_find_python_module(${module}) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
JDevlieghere wrote: > @JDevlieghere @adrian-prantl we should consider adding this to the list of > required python modules on our bots too and enforce it with > `LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS`? Probably not in this PR, but after > we can get our bots configured correctly. Added in 793300988b7c. Let's see if this blows up on our bots :-) https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7933009 - [lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
Author: Jonas Devlieghere Date: 2024-02-28T21:20:40-08:00 New Revision: 793300988b7c723bacadce67879ea8bf71c87e70 URL: https://github.com/llvm/llvm-project/commit/793300988b7c723bacadce67879ea8bf71c87e70 DIFF: https://github.com/llvm/llvm-project/commit/793300988b7c723bacadce67879ea8bf71c87e70.diff LOG: [lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS This executed Alex' idea [1] of adding pexpect to the list of "strict test requirements" as we're planning to stop vendoring it. This will ensure all the bots have the package before we toggle the default. [1] https://github.com/llvm/llvm-project/pull/83191 Added: Modified: lldb/test/CMakeLists.txt Removed: diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index d8cbb24b6c9b81..4094c87aaa40e8 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -12,7 +12,8 @@ endif() if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS) message(STATUS "Enforcing strict test requirements for LLDB") set(useful_python_modules -psutil # Lit uses psutil to do per-test timeouts. +psutil # Lit uses psutil to do per-test timeouts. +pexpect # We no longer vendor pexpect. ) foreach(module ${useful_python_modules}) lldb_find_python_module(${module}) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
@@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); JDevlieghere wrote: Thanks Jordan. I've moved the `openlog` behind a `call_once` flag and omitted the `closelog`. I considered executing `syslog` on the debugger's thread pool but the fact that Core depends on Host means that would be a layering violation and there's no good place to manage the futures something like `std::async` would return. Right now the system log function is only used for the corresponding log handler which is purely opt-in. I do plan to use it in other places (e.g. the debugger diagnostics) but even then I expect it to be relatively low traffic. https://github.com/llvm/llvm-project/pull/83366 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/83366 >From c6599a05b5be0cbd279a96e98bed1c89d9de707e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 28 Feb 2024 18:12:45 -0800 Subject: [PATCH 1/2] [lldb] Log to system log instead of stderr from Host::SystemLog Currently, calls to Host::SystemLog print to stderr on all host platforms except Darwin. This severely limits its value on the command line, where we don't want to overload the user with log messages. Switch to using the syslog function on POSIX systems to send messages to the system logger instead of stdout. On Darwin systems this sends the log message to os_log, which matches what we do today. Nevertheless I kept the current implementation that uses os_log directly as it gives us more freedom. I'm not sure if there's an equivalent on Windows, so I kept the existing behavior of logging to stderr. --- lldb/source/Host/common/Host.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index f4cec97f5af633..1af01ef5025bc4 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); +} +#else void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; } #endif +#endif #if !defined(__APPLE__) && !defined(_WIN32) static thread_result_t >From 6656cf1248b8d04c2c7e7fe3c90b51479242b8ce Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 28 Feb 2024 21:03:28 -0800 Subject: [PATCH 2/2] [lldb] Call openlog only once and don't call closelog --- lldb/source/Host/common/Host.cpp | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 1af01ef5025bc4..565138ba17031f 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -92,9 +92,11 @@ using namespace lldb_private; #if !defined(_WIN32) #include void Host::SystemLog(llvm::StringRef message) { - openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + static llvm::once_flag g_openlog_once; + llvm::call_once(g_openlog_once, [] { +openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + }); syslog(LOG_INFO, "%s", message.data()); - closelog(); } #else void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
hawkinsw wrote: > Thanks for the second round of feedback @hawkinsw . Let me try to read the > Doxygen docs a little more closely tonight and see if the references I threw > in there might actually do what I hoped they would. I briefly looked at the > Doxygen docs to see the Grouping feature and got a little overwhelmed and > wasn't sure what the expected formatting would be. Not a problem at all! Just trying to help!! Will https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
@@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); rupprecht wrote: Also, cc @oontvoo who is looking at this stuff more closely now https://github.com/llvm/llvm-project/pull/83366 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
@@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); rupprecht wrote: It's been a while since I really looked deep into the syslog APIs, which are a little archaic. And it's possible that calls to `Host::SystemLog` are rare enough that none of these things are concerning, even if they are valid concerns for high load use cases: - I believe it's typical for `openlog` and `closelog` to only be called once. Opening and closing on every `syslog` call may be costly/unnecessary. - But actually, both `openlog` and `closelog` are technically optional -- still a good idea to at least call `openlog` so you can pass `ident` and `option` (the `facility` you could just pass in the `syslog` call). For `closelog`, I wonder if you could just skip that, and hopefully the `openlog()` call on subsequent `Host::SystemLog()` calls would end up being noop'd/cached? - IIRC, calls to `syslog` can block, e.g. if the daemon processing syslog entries gets backed up, then `syslog` will block until the queue becomes less full. Keeping `syslog` calls on a separate thread may be safer. https://github.com/llvm/llvm-project/pull/83366 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print a message when background tasks take a while to complete (PR #82799)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/82799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print a message when background tasks take a while to complete (PR #82799)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/82799 >From 3db25301ed07ed0b44ff0f8cbe8d1657ba899036 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 28 Feb 2024 20:00:43 -0800 Subject: [PATCH] [lldb] Print a message when background tasks take a while to complete When terminating the debugger, we wait for all background tasks to complete. Given that there's no way to interrupt those treads, this can take a while. When that happens, the debugger appears to hang at exit. The above situation is unfortunately not uncommon when background downloading of dSYMs is enabled (`symbols.auto-download background`). Even when calling dsymForUUID with a reasonable timeout, it can take a while to complete. This patch improves the user experience by printing a message from the driver when it takes more than one (1) second to terminate the debugger. --- lldb/tools/driver/Driver.cpp | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 9286abb27e1332..a821699c5e2ec2 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -801,6 +802,18 @@ int main(int argc, char const *argv[]) { } } - SBDebugger::Terminate(); + // When terminating the debugger we have to wait on all the background tasks + // to complete, which can take a while. Print a message when this takes longer + // than 1 second. + { +std::future future = +std::async(std::launch::async, []() { SBDebugger::Terminate(); }); + +if (future.wait_for(std::chrono::seconds(1)) == std::future_status::timeout) + fprintf(stderr, "Waiting for background tasks to complete...\n"); + +future.wait(); + } + return exit_code; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print a message when background tasks take a while to complete (PR #82799)
JDevlieghere wrote: I tried implementing this and waiting on the thread pool when the last debugger is being destroyed is easy: ``` // Only hold the debugger list lock long enough to check if we're the last // debugger being destroyed. bool last_debugger_being_destroyed = false; if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) { std::lock_guard guard(*g_debugger_list_mutex_ptr); last_debugger_being_destroyed = g_debugger_list_ptr->size() == 1 && (*g_debugger_list_ptr)[0].get() == debugger_sp.get(); } // Check if we should wait on the thread pool. If the debugger being destroyed // is the very last one, we can safely assume work is being done on its // behalf. We want to keep the debugger alive at least until the background // tasks are finished so they can report their progress. if (last_debugger_being_destroyed) g_thread_pool->wait(); ``` However, at that point there's no default event handler thread anymore: we tear it down when exiting `RunCommandInterpreter`. I think I'm just going to move the timeout to the driver and call it a day... https://github.com/llvm/llvm-project/pull/82799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
svs-quic wrote: > Change itself is fine. But could you please add a test in > `lldb/test/API/functionalities/completion/TestCompletion.py`? Specifically in > `do_test_variable_completion` Done https://github.com/llvm/llvm-project/pull/83234 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Currently, calls to Host::SystemLog print to stderr on all host platforms except Darwin. This severely limits its value on the command line, where we don't want to overload the user with log messages. Switch to using the syslog function on POSIX systems to send messages to the system logger instead of stdout. On Darwin systems this sends the log message to os_log, which matches what we do today. Nevertheless I kept the current implementation that uses os_log directly as it gives us more freedom. I'm not sure if there's an equivalent on Windows, so I kept the existing behavior of logging to stderr. --- Full diff: https://github.com/llvm/llvm-project/pull/83366.diff 1 Files Affected: - (modified) lldb/source/Host/common/Host.cpp (+9) ``diff diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index f4cec97f5af633..1af01ef5025bc4 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); +} +#else void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; } #endif +#endif #if !defined(__APPLE__) && !defined(_WIN32) static thread_result_t `` https://github.com/llvm/llvm-project/pull/83366 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/83366 Currently, calls to Host::SystemLog print to stderr on all host platforms except Darwin. This severely limits its value on the command line, where we don't want to overload the user with log messages. Switch to using the syslog function on POSIX systems to send messages to the system logger instead of stdout. On Darwin systems this sends the log message to os_log, which matches what we do today. Nevertheless I kept the current implementation that uses os_log directly as it gives us more freedom. I'm not sure if there's an equivalent on Windows, so I kept the existing behavior of logging to stderr. >From 06942859d49640470785796659678cf0d4207e6e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 28 Feb 2024 18:12:45 -0800 Subject: [PATCH] [lldb] Log to system log instead of stderr from Host::SystemLog Currently, calls to Host::SystemLog print to stderr on all host platforms except Darwin. This severely limits its value on the command line, where we don't want to overload the user with log messages. Switch to using the syslog function on POSIX systems to send messages to the system logger instead of stdout. On Darwin systems this sends the log message to os_log, which matches what we do today. Nevertheless I kept the current implementation that uses os_log directly as it gives us more freedom. I'm not sure if there's an equivalent on Windows, so I kept the existing behavior of logging to stderr. --- lldb/source/Host/common/Host.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index f4cec97f5af633..1af01ef5025bc4 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -89,8 +89,17 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_INFO, "%s", message.data()); + closelog(); +} +#else void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; } #endif +#endif #if !defined(__APPLE__) && !defined(_WIN32) static thread_result_t ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); JDevlieghere wrote: `lldb-instr` always puts a newline after `LLDB_INSTRUMENT_VA`. We should do the same here to be consistent with the rest of the SB API. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); + addr_t default_mask = 0; JDevlieghere wrote: Would it be worth making this a constant (e.g. `LLDB_DEFAULT_ADDRESS_MASK`) so that callers can verify whether they were given a valid address mask? https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/jimingham closed https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5784bf8 - Fix interactive use of "command script add". (#83350)
Author: jimingham Date: 2024-02-28T17:26:29-08:00 New Revision: 5784bf85bc5143266565586ece0113cd773a8616 URL: https://github.com/llvm/llvm-project/commit/5784bf85bc5143266565586ece0113cd773a8616 DIFF: https://github.com/llvm/llvm-project/commit/5784bf85bc5143266565586ece0113cd773a8616.diff LOG: Fix interactive use of "command script add". (#83350) There was a think-o in a previous commit that made us only able to define 1 line commands when using command script add interactively. There was also no test for this feature, so I fixed the think-o and added a test. Added: lldb/test/API/commands/command/script/cmd_file.lldb Modified: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/test/API/commands/command/script/TestCommandScript.py Removed: diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index a1ad3f569ec71a..ce52f359524785 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1417,7 +1417,7 @@ bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction( sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):", auto_generated_function_name.c_str()); - if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true) + if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false) .Success()) return false; diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 850552032902fd..fdd5216a1c6cc5 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -216,3 +216,17 @@ def test_persistence(self): # The result object will be replaced by an empty result object (in the # "Started" state). self.expect("script str(persistence.result_copy)", substrs=["Started"]) + +def test_interactive(self): +""" +Test that we can add multiple lines interactively. +""" +interp = self.dbg.GetCommandInterpreter() +cmd_file = self.getSourcePath("cmd_file.lldb") +result = lldb.SBCommandReturnObject() +interp.HandleCommand(f"command source {cmd_file}", result) +self.assertCommandReturn(result, "Sourcing the command should cause no errors.") +self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.") +interp.HandleCommand("my_cmd", result) +self.assertCommandReturn(result, "Running the command succeeds") +self.assertIn("My Command Result", result.GetOutput(), "Command was correct") diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb b/lldb/test/API/commands/command/script/cmd_file.lldb new file mode 100644 index 00..1589a7cfe0b8d9 --- /dev/null +++ b/lldb/test/API/commands/command/script/cmd_file.lldb @@ -0,0 +1,4 @@ +command script add my_cmd +result.PutCString("My Command Result") +result.SetStatus(lldb.eReturnStatusSuccessFinishResult) +DONE ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/jimingham updated https://github.com/llvm/llvm-project/pull/83350 >From 76eeb252b1f5fa71a68b439c84d13c8bcf042da7 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 28 Feb 2024 14:25:55 -0800 Subject: [PATCH 1/2] Fix interactive use of "command script add". There was a think-o in a previous commit that made us only able to define 1 line commands when using command script add interactively. There was also no test for this feature, so I fixed the think-o and added a test. --- .../Python/ScriptInterpreterPython.cpp | 2 +- .../commands/command/script/TestCommandScript.py | 16 .../API/commands/command/script/cmd_file.lldb| 4 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/commands/command/script/cmd_file.lldb diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index a1ad3f569ec71a..ce52f359524785 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1417,7 +1417,7 @@ bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction( sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):", auto_generated_function_name.c_str()); - if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true) + if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false) .Success()) return false; diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 850552032902fd..21ebfce2f3c437 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -216,3 +216,19 @@ def test_persistence(self): # The result object will be replaced by an empty result object (in the # "Started" state). self.expect("script str(persistence.result_copy)", substrs=["Started"]) + +def test_interactive(self): +""" +Test that we can add multiple lines interactively. +""" +interp = self.dbg.GetCommandInterpreter() +cmd_file = self.getSourcePath("cmd_file.lldb") +result = lldb.SBCommandReturnObject() +interp.HandleCommand(f"command source {cmd_file}", result) +self.assertCommandReturn(result, "Sourcing the command should cause no errors.") +self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.") +interp.HandleCommand("my_cmd", result) +self.assertCommandReturn(result, "Running the command succeeds") +self.assertIn("My Command Result", result.GetOutput(), "Command was correct") + + diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb b/lldb/test/API/commands/command/script/cmd_file.lldb new file mode 100644 index 00..1589a7cfe0b8d9 --- /dev/null +++ b/lldb/test/API/commands/command/script/cmd_file.lldb @@ -0,0 +1,4 @@ +command script add my_cmd +result.PutCString("My Command Result") +result.SetStatus(lldb.eReturnStatusSuccessFinishResult) +DONE >From fe7964403557ea03a56458214984f12502689ab3 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 28 Feb 2024 17:22:45 -0800 Subject: [PATCH 2/2] Formatting. --- lldb/test/API/commands/command/script/TestCommandScript.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 21ebfce2f3c437..fdd5216a1c6cc5 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -230,5 +230,3 @@ def test_interactive(self): interp.HandleCommand("my_cmd", result) self.assertCommandReturn(result, "Running the command succeeds") self.assertIn("My Command Result", result.GetOutput(), "Command was correct") - - ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: Thanks for the second round of feedback @hawkinsw . Let me try to read the Doxygen docs a little more closely tonight and see if the references I threw in there might actually do what I hoped they would. I briefly looked at the Doxygen docs to see the Grouping feature and got a little overwhelmed and wasn't sure what the expected formatting would be. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/83317 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f7a544d - [lldb] Ignore swig warnings about shadowed overloads (#83317)
Author: Alex Langford Date: 2024-02-28T16:54:32-08:00 New Revision: f7a544dd5f515c2f9b312142f573806cc8e64145 URL: https://github.com/llvm/llvm-project/commit/f7a544dd5f515c2f9b312142f573806cc8e64145 DIFF: https://github.com/llvm/llvm-project/commit/f7a544dd5f515c2f9b312142f573806cc8e64145.diff LOG: [lldb] Ignore swig warnings about shadowed overloads (#83317) This specifically addresses the warnings: $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char const *,int). There is exactly one declaration of SBCommandReturnObject::PutCString. The second parameter (of type `int`) has default value `-1`. Without investigating why SWIG believes there are 2 method declarations, I believe it is safe to ignore this warning. It does not appear to actually impact functionality in any way. rdar://117744660 Added: Modified: lldb/bindings/CMakeLists.txt Removed: diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt index b44ed59aa662b2..296eae1ae77f86 100644 --- a/lldb/bindings/CMakeLists.txt +++ b/lldb/bindings/CMakeLists.txt @@ -23,7 +23,11 @@ endif() set(SWIG_COMMON_FLAGS -c++ - -w361,362 # Ignore warnings about ignored operator overloads + # Ignored warnings: + # 361: operator! ignored. + # 362: operator= ignored. + # 509: Overloaded method declaration effectively ignored, shadowed by previous declaration. + -w361,362,509 -features autodoc -I${LLDB_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/3] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. jasonmolenda wrote: I need to read the Doxygen documentation more closely, I just made this up when I was trying to update to having references to these two documentation paragraphs, I don't know if it would render as anything meaningful. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. jasonmolenda wrote: Thanks, let me rewrite it to say "darwin likes addressable bits" directly :) On Linux the kernel provides a mask to apply to addresses to remove metadata, it's the most general representation so that's what we use internally in lldb. But with Darwin on AArch64, we're only concerned with the low order number of bits that are used for addressing -- the addressable bits. It's possible to calculate the mask incorrectly (I'm fixing my own bug with addressable-bits==64 in this patch), so I want to provide API for environments like Darwin where that's what the data they'll have from the OS etc. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/JDevlieghere approved this pull request. LGTM but please fix the formatting before landing. https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
https://github.com/jimingham closed https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9728170 - Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (#83341)
Author: jimingham Date: 2024-02-28T16:14:19-08:00 New Revision: 97281708ac176e0464b770686ee314af4da0a3d5 URL: https://github.com/llvm/llvm-project/commit/97281708ac176e0464b770686ee314af4da0a3d5 DIFF: https://github.com/llvm/llvm-project/commit/97281708ac176e0464b770686ee314af4da0a3d5.diff LOG: Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (#83341) The help for the `-r` option to `image list` says: -r[] ( --ref-count=[] ) Display the reference count if the module is still in the shared module cache. but that's not what it actually does. It unconditionally shows the use_count for all Module shared pointers, regardless of whether they are still in the shared module cache or whether they are just in the ModuleCollection and other entities are keeping them alive. That seems like a more useful behavior, but then it is also useful to know what's in the shared cache, so I changed this to: -r[] ( --ref-count=[] ) Display whether the module is still in the the shared module cache (Y/N), and its shared pointer use_count. So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and `{N 5}` if not. I didn't add tests for this because I'm not sure how much we want to fix shared cache behavior in the testsuite. Added: Modified: lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/Options.td Removed: diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 45265577e8b61c..b2346c2402a81d 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { case 'r': { size_t ref_count = 0; +char in_shared_cache = 'Y'; + ModuleSP module_sp(module->shared_from_this()); +if (!ModuleList::ModuleIsInCache(module)) + in_shared_cache = 'N'; if (module_sp) { // Take one away to make sure we don't count our local "module_sp" ref_count = module_sp.use_count() - 1; } if (width) - strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); + strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count); else - strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); + strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count); } break; case 's': diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ad4321d9a386cc..91d5eea830dedf 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -936,8 +936,8 @@ let Command = "target modules list" in { OptionalArg<"Width">, Desc<"Display the modification time with optional " "width of the module.">; def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>, -OptionalArg<"Width">, Desc<"Display the reference count if the module is " -"still in the shared module cache.">; +OptionalArg<"Width">, Desc<"Display whether the module is still in the " +"the shared module cache (Y/N), and its shared pointer use_count.">; def target_modules_list_pointer : Option<"pointer", "p">, Group<1>, OptionalArg<"None">, Desc<"Display the module pointer.">; def target_modules_list_global : Option<"global", "g">, Group<1>, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/medismailben approved this pull request. Thanks for fixing this think-o and adding a test https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)
https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/82094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)
@@ -209,25 +231,66 @@ class ThreadPool { /// Number of threads active for tasks in the given group (only non-zero). DenseMap ActiveGroups; -#if LLVM_ENABLE_THREADS // avoids warning for unused variable /// Signal for the destruction of the pool, asking thread to exit. bool EnableFlag = true; -#endif const ThreadPoolStrategy Strategy; /// Maximum number of threads to potentially grow this pool to. const unsigned MaxThreadCount; }; +/// A non-threaded implementation. +class SingleThreadExecutor : public ThreadPoolInterface { aganea wrote: I was gonna say, it happened several times in the past that the build was broken in `!LLVM_ENABLE_THREADS` configurations, which not many people are testing. https://github.com/llvm/llvm-project/pull/82094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)
@@ -209,25 +231,66 @@ class ThreadPool { /// Number of threads active for tasks in the given group (only non-zero). DenseMap ActiveGroups; -#if LLVM_ENABLE_THREADS // avoids warning for unused variable /// Signal for the destruction of the pool, asking thread to exit. bool EnableFlag = true; -#endif const ThreadPoolStrategy Strategy; /// Maximum number of threads to potentially grow this pool to. const unsigned MaxThreadCount; }; +/// A non-threaded implementation. +class SingleThreadExecutor : public ThreadPoolInterface { aganea wrote: In that case, do you think we can add or extend some of the existing unit tests, to exercise the `SingleThreadExecutor` explicitly? https://github.com/llvm/llvm-project/pull/82094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/bulbazord approved this pull request. Thinkos are the most insidious bugs. Nice catch. https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/83330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d3173f4 - [lldb] Remove -d(ebug) mode from the lldb driver (#83330)
Author: Jonas Devlieghere Date: 2024-02-28T15:23:55-08:00 New Revision: d3173f4ab61c17337908eb7df3f1c515ddcd428c URL: https://github.com/llvm/llvm-project/commit/d3173f4ab61c17337908eb7df3f1c515ddcd428c DIFF: https://github.com/llvm/llvm-project/commit/d3173f4ab61c17337908eb7df3f1c515ddcd428c.diff LOG: [lldb] Remove -d(ebug) mode from the lldb driver (#83330) The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. Since then, we were never check if the option is set. We were incorrectly toggling the internal variable (m_debug_mode) based on OPT_no_use_colors instead. Given that the functionality doesn't seem particularly useful and nobody noticed it has been broken for 5 years, I'm just removing the flag. Added: Modified: lldb/test/Shell/Driver/TestHelp.test lldb/tools/driver/Driver.cpp lldb/tools/driver/Driver.h Removed: diff --git a/lldb/test/Shell/Driver/TestHelp.test b/lldb/test/Shell/Driver/TestHelp.test index 0f73fdf0374fdd..2521b31a618836 100644 --- a/lldb/test/Shell/Driver/TestHelp.test +++ b/lldb/test/Shell/Driver/TestHelp.test @@ -37,8 +37,6 @@ CHECK: --arch CHECK: -a CHECK: --core CHECK: -c -CHECK: --debug -CHECK: -d CHECK: --editor CHECK: -e CHECK: --file diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index c63ff0ff597e5c..9286abb27e1332 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList , bool ) { if (args.hasArg(OPT_no_use_colors)) { m_debugger.SetUseColor(false); WithColor::setAutoDetectFunction(disable_color); -m_option_data.m_debug_mode = true; } if (args.hasArg(OPT_version)) { @@ -455,16 +454,7 @@ int Driver::MainLoop() { // Process lldbinit files before handling any options from the command line. SBCommandReturnObject result; sb_interpreter.SourceInitFileInGlobalDirectory(result); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } // Source the local .lldbinit file if it exists and we're allowed to source. // Here we want to always print the return object because it contains the @@ -536,11 +526,6 @@ int Driver::MainLoop() { "or -s) are ignored in REPL mode.\n"; } - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - const bool handle_events = true; const bool spawn_thread = false; diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h index d5779b3c2c91b5..83e0d8a41cfdb1 100644 --- a/lldb/tools/driver/Driver.h +++ b/lldb/tools/driver/Driver.h @@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster { std::vector m_after_file_commands; std::vector m_after_crash_commands; -bool m_debug_mode = false; bool m_source_quietly = false; bool m_print_version = false; bool m_print_python_path = false; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)
@@ -209,25 +231,66 @@ class ThreadPool { /// Number of threads active for tasks in the given group (only non-zero). DenseMap ActiveGroups; -#if LLVM_ENABLE_THREADS // avoids warning for unused variable /// Signal for the destruction of the pool, asking thread to exit. bool EnableFlag = true; -#endif const ThreadPoolStrategy Strategy; /// Maximum number of threads to potentially grow this pool to. const unsigned MaxThreadCount; }; +/// A non-threaded implementation. +class SingleThreadExecutor : public ThreadPoolInterface { joker-eph wrote: I was trying to use as little as possible so that the code is always at least "parsed" and we are less likely to break it (and also my IDE does not gray this entirely as a comment because of the macro). But this is a weak argument, happy to restore a big `#if LLVM_ENABLE_THREADS` `#else` around the two classes. https://github.com/llvm/llvm-project/pull/82094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)
kovdan01 wrote: > Can this code be hit when using an x86 core file? Thanks for suggestion! I'll try that and notify here if such approach succeeded. https://github.com/llvm/llvm-project/pull/82603 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][X86] Fix setting target features in ClangExpressionParser (PR #82364)
kovdan01 wrote: > Would this change be observable by a test? @adrian-prantl Theoretically, it should be: in `ClangExpressionParser::ClangExpressionParser`, we try to hardcode sse and sse2 for both x86 and x86_64, while in `X86TargetInfo::initFeatureMap`, sse2 (implying sse) is only hardcoded for x86_64. So, for x86 the observable behavior should change. Unfortunately, I'm not sure where and how this could be tested. I suppose the proper place for such a test is somewhere in lldb/unittests/Expression, but I don't see existing tests which check similar stuff. Please let me know if I miss something. @Michael137 would be glad to see your thoughts on this. https://github.com/llvm/llvm-project/pull/82364 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
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 4df364bc93af49ae413ec1ae8328f34ac70730c4...76eeb252b1f5fa71a68b439c84d13c8bcf042da7 lldb/test/API/commands/command/script/TestCommandScript.py `` View the diff from darker here. ``diff --- TestCommandScript.py2024-02-28 22:25:55.00 + +++ TestCommandScript.py2024-02-28 22:30:52.097582 + @@ -228,7 +228,5 @@ self.assertCommandReturn(result, "Sourcing the command should cause no errors.") self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.") interp.HandleCommand("my_cmd", result) self.assertCommandReturn(result, "Running the command succeeds") self.assertIn("My Command Result", result.GetOutput(), "Command was correct") - - `` https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jimingham) Changes There was a think-o in a previous commit that made us only able to define 1 line commands when using command script add interactively. There was also no test for this feature, so I fixed the think-o and added a test. --- Full diff: https://github.com/llvm/llvm-project/pull/83350.diff 3 Files Affected: - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+1-1) - (modified) lldb/test/API/commands/command/script/TestCommandScript.py (+16) - (added) lldb/test/API/commands/command/script/cmd_file.lldb (+4) ``diff diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index a1ad3f569ec71a..ce52f359524785 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1417,7 +1417,7 @@ bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction( sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):", auto_generated_function_name.c_str()); - if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true) + if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false) .Success()) return false; diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 850552032902fd..21ebfce2f3c437 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -216,3 +216,19 @@ def test_persistence(self): # The result object will be replaced by an empty result object (in the # "Started" state). self.expect("script str(persistence.result_copy)", substrs=["Started"]) + +def test_interactive(self): +""" +Test that we can add multiple lines interactively. +""" +interp = self.dbg.GetCommandInterpreter() +cmd_file = self.getSourcePath("cmd_file.lldb") +result = lldb.SBCommandReturnObject() +interp.HandleCommand(f"command source {cmd_file}", result) +self.assertCommandReturn(result, "Sourcing the command should cause no errors.") +self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.") +interp.HandleCommand("my_cmd", result) +self.assertCommandReturn(result, "Running the command succeeds") +self.assertIn("My Command Result", result.GetOutput(), "Command was correct") + + diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb b/lldb/test/API/commands/command/script/cmd_file.lldb new file mode 100644 index 00..1589a7cfe0b8d9 --- /dev/null +++ b/lldb/test/API/commands/command/script/cmd_file.lldb @@ -0,0 +1,4 @@ +command script add my_cmd +result.PutCString("My Command Result") +result.SetStatus(lldb.eReturnStatusSuccessFinishResult) +DONE `` https://github.com/llvm/llvm-project/pull/83350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)
https://github.com/jimingham created https://github.com/llvm/llvm-project/pull/83350 There was a think-o in a previous commit that made us only able to define 1 line commands when using command script add interactively. There was also no test for this feature, so I fixed the think-o and added a test. >From 76eeb252b1f5fa71a68b439c84d13c8bcf042da7 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 28 Feb 2024 14:25:55 -0800 Subject: [PATCH] Fix interactive use of "command script add". There was a think-o in a previous commit that made us only able to define 1 line commands when using command script add interactively. There was also no test for this feature, so I fixed the think-o and added a test. --- .../Python/ScriptInterpreterPython.cpp | 2 +- .../commands/command/script/TestCommandScript.py | 16 .../API/commands/command/script/cmd_file.lldb| 4 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/commands/command/script/cmd_file.lldb diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index a1ad3f569ec71a..ce52f359524785 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1417,7 +1417,7 @@ bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction( sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):", auto_generated_function_name.c_str()); - if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true) + if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false) .Success()) return false; diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 850552032902fd..21ebfce2f3c437 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -216,3 +216,19 @@ def test_persistence(self): # The result object will be replaced by an empty result object (in the # "Started" state). self.expect("script str(persistence.result_copy)", substrs=["Started"]) + +def test_interactive(self): +""" +Test that we can add multiple lines interactively. +""" +interp = self.dbg.GetCommandInterpreter() +cmd_file = self.getSourcePath("cmd_file.lldb") +result = lldb.SBCommandReturnObject() +interp.HandleCommand(f"command source {cmd_file}", result) +self.assertCommandReturn(result, "Sourcing the command should cause no errors.") +self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.") +interp.HandleCommand("my_cmd", result) +self.assertCommandReturn(result, "Running the command succeeds") +self.assertIn("My Command Result", result.GetOutput(), "Command was correct") + + diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb b/lldb/test/API/commands/command/script/cmd_file.lldb new file mode 100644 index 00..1589a7cfe0b8d9 --- /dev/null +++ b/lldb/test/API/commands/command/script/cmd_file.lldb @@ -0,0 +1,4 @@ +command script add my_cmd +result.PutCString("My Command Result") +result.SetStatus(lldb.eReturnStatusSuccessFinishResult) +DONE ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
https://github.com/medismailben approved this pull request. https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
medismailben wrote: > Does it make sense to have an image multiple times in the shared cache ? If > not, instead of saying `{Y/N count}` what about printing `{location(shared > cache/module collection)}` and only print it ref count if it's not in the > shared cache ? My bad, I thought you were talking about the `dyld` shared cache as opposed to the lldb shared module cache. LGTM then. https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)
kovdan01 wrote: > tbh I have no problems with the patch, but I think it's fixing something that > I think should be reconsidered altogether, I'm interested to hear more about > what the use case looks like that led to this being a problem. @jasonmolenda The use case is very simple, describing it "as is". I was working on AArch64-specific stuff in lldb in downstream and revealed an x86-related issue while reading the code (see https://github.com/llvm/llvm-project/pull/82364). When working on the latter issue, I tried to run a random x86-64 executable inside lldb and got this error. It occurs literally on the simplest use case: 1. run `lldb /usr/bin/ls` 2. inside lldb, hit `r` to run 3. get the nullptr dereference described Yes, it's *that* simple. https://github.com/llvm/llvm-project/pull/82603 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)
https://github.com/bulbazord approved this pull request. :) https://github.com/llvm/llvm-project/pull/83330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
medismailben wrote: Does it make sense to have an image multiple times in the shared cache ? If not, instead of saying `{Y/N count}` what about printing `{location(shared cache/module collection)} and only print it ref count if it's not in the shared cache ? https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/83317 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff e427e934f677567f8184ff900cb4cbdb8cf21a21 b95ffa364ecfc8593dc48a1986385d81cbeb05c2 -- lldb/source/Commands/CommandObjectTarget.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index b2346c2402..0d52fde961 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3377,7 +3377,7 @@ protected: case 'r': { size_t ref_count = 0; char in_shared_cache = 'Y'; - + ModuleSP module_sp(module->shared_from_this()); if (!ModuleList::ModuleIsInCache(module)) in_shared_cache = 'N'; @@ -3386,7 +3386,8 @@ protected: ref_count = module_sp.use_count() - 1; } if (width) - strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count); + strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, + (uint64_t)ref_count); else strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count); } break; `` https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jimingham) Changes The help for the `-r` option to `image list` says: -r[width] ( --ref-count=[width] ) Display the reference count if the module is still in the shared module cache. but that's not what it actually does. It unconditionally shows the use_count for all Module shared pointers, regardless of whether they are still in the shared module cache or whether they are just in the ModuleCollection and other entities are keeping them alive. That seems like a more useful behavior, but then it is also useful to know what's in the shared cache, so I changed this to: -r[width] ( --ref-count=[width] ) Display whether the module is still in the the shared module cache (Y/N), and its shared pointer use_count. So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and `{N 5}` if not. I didn't add tests for this because I'm not sure how much we want to fix shared cache behavior in the testsuite. --- Full diff: https://github.com/llvm/llvm-project/pull/83341.diff 2 Files Affected: - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+6-2) - (modified) lldb/source/Commands/Options.td (+2-2) ``diff diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 45265577e8b61c..b2346c2402a81d 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { case 'r': { size_t ref_count = 0; +char in_shared_cache = 'Y'; + ModuleSP module_sp(module->shared_from_this()); +if (!ModuleList::ModuleIsInCache(module)) + in_shared_cache = 'N'; if (module_sp) { // Take one away to make sure we don't count our local "module_sp" ref_count = module_sp.use_count() - 1; } if (width) - strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); + strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count); else - strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); + strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count); } break; case 's': diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ad4321d9a386cc..91d5eea830dedf 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -936,8 +936,8 @@ let Command = "target modules list" in { OptionalArg<"Width">, Desc<"Display the modification time with optional " "width of the module.">; def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>, -OptionalArg<"Width">, Desc<"Display the reference count if the module is " -"still in the shared module cache.">; +OptionalArg<"Width">, Desc<"Display whether the module is still in the " +"the shared module cache (Y/N), and its shared pointer use_count.">; def target_modules_list_pointer : Option<"pointer", "p">, Group<1>, OptionalArg<"None">, Desc<"Display the module pointer.">; def target_modules_list_global : Option<"global", "g">, Group<1>, `` https://github.com/llvm/llvm-project/pull/83341 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)
https://github.com/jimingham created https://github.com/llvm/llvm-project/pull/83341 The help for the `-r` option to `image list` says: -r[] ( --ref-count=[] ) Display the reference count if the module is still in the shared module cache. but that's not what it actually does. It unconditionally shows the use_count for all Module shared pointers, regardless of whether they are still in the shared module cache or whether they are just in the ModuleCollection and other entities are keeping them alive. That seems like a more useful behavior, but then it is also useful to know what's in the shared cache, so I changed this to: -r[] ( --ref-count=[] ) Display whether the module is still in the the shared module cache (Y/N), and its shared pointer use_count. So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and `{N 5}` if not. I didn't add tests for this because I'm not sure how much we want to fix shared cache behavior in the testsuite. >From b95ffa364ecfc8593dc48a1986385d81cbeb05c2 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 28 Feb 2024 13:12:46 -0800 Subject: [PATCH] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. --- lldb/source/Commands/CommandObjectTarget.cpp | 8 ++-- lldb/source/Commands/Options.td | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 45265577e8b61c..b2346c2402a81d 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { case 'r': { size_t ref_count = 0; +char in_shared_cache = 'Y'; + ModuleSP module_sp(module->shared_from_this()); +if (!ModuleList::ModuleIsInCache(module)) + in_shared_cache = 'N'; if (module_sp) { // Take one away to make sure we don't count our local "module_sp" ref_count = module_sp.use_count() - 1; } if (width) - strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); + strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, (uint64_t)ref_count); else - strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); + strm.Printf("{%c %" PRIu64 "}", in_shared_cache, (uint64_t)ref_count); } break; case 's': diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index ad4321d9a386cc..91d5eea830dedf 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -936,8 +936,8 @@ let Command = "target modules list" in { OptionalArg<"Width">, Desc<"Display the modification time with optional " "width of the module.">; def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>, -OptionalArg<"Width">, Desc<"Display the reference count if the module is " -"still in the shared module cache.">; +OptionalArg<"Width">, Desc<"Display whether the module is still in the " +"the shared module cache (Y/N), and its shared pointer use_count.">; def target_modules_list_pointer : Option<"pointer", "p">, Group<1>, OptionalArg<"None">, Desc<"Display the module pointer.">; def target_modules_list_global : Option<"global", "g">, Group<1>, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)
https://github.com/medismailben approved this pull request. Yeay 拾 https://github.com/llvm/llvm-project/pull/83317 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)
https://github.com/medismailben approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/83330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. Since then, we were never check if the option is set. We were incorrectly toggling the internal variable (m_debug_mode) based on OPT_no_use_colors instead. Given that the functionality doesn't seem particularly useful and nobody noticed it has been broken for 5 years, I'm just removing the flag. --- Full diff: https://github.com/llvm/llvm-project/pull/83330.diff 3 Files Affected: - (modified) lldb/test/Shell/Driver/TestHelp.test (-2) - (modified) lldb/tools/driver/Driver.cpp (-15) - (modified) lldb/tools/driver/Driver.h (-1) ``diff diff --git a/lldb/test/Shell/Driver/TestHelp.test b/lldb/test/Shell/Driver/TestHelp.test index 0f73fdf0374fdd..2521b31a618836 100644 --- a/lldb/test/Shell/Driver/TestHelp.test +++ b/lldb/test/Shell/Driver/TestHelp.test @@ -37,8 +37,6 @@ CHECK: --arch CHECK: -a CHECK: --core CHECK: -c -CHECK: --debug -CHECK: -d CHECK: --editor CHECK: -e CHECK: --file diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index c63ff0ff597e5c..9286abb27e1332 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList , bool ) { if (args.hasArg(OPT_no_use_colors)) { m_debugger.SetUseColor(false); WithColor::setAutoDetectFunction(disable_color); -m_option_data.m_debug_mode = true; } if (args.hasArg(OPT_version)) { @@ -455,16 +454,7 @@ int Driver::MainLoop() { // Process lldbinit files before handling any options from the command line. SBCommandReturnObject result; sb_interpreter.SourceInitFileInGlobalDirectory(result); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } // Source the local .lldbinit file if it exists and we're allowed to source. // Here we want to always print the return object because it contains the @@ -536,11 +526,6 @@ int Driver::MainLoop() { "or -s) are ignored in REPL mode.\n"; } - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - const bool handle_events = true; const bool spawn_thread = false; diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h index d5779b3c2c91b5..83e0d8a41cfdb1 100644 --- a/lldb/tools/driver/Driver.h +++ b/lldb/tools/driver/Driver.h @@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster { std::vector m_after_file_commands; std::vector m_after_crash_commands; -bool m_debug_mode = false; bool m_source_quietly = false; bool m_print_version = false; bool m_print_python_path = false; `` https://github.com/llvm/llvm-project/pull/83330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/83330 The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. Since then, we were never check if the option is set. We were incorrectly toggling the internal variable (m_debug_mode) based on OPT_no_use_colors instead. Given that the functionality doesn't seem particularly useful and nobody noticed it has been broken for 5 years, I'm just removing the flag. >From 0d2e89188398a69bdeb2ea3378e2ba4c86d4e98e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 28 Feb 2024 12:56:05 -0800 Subject: [PATCH] [lldb] Remove -d(ebug) mode from the lldb driver The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. Since then, we were never check if the option is set. We were incorrectly toggling the internal variable (m_debug_mode) based on OPT_no_use_colors instead. Given that the functionality doesn't seem particularly useful and nobody noticed it has been broken for 5 years, I'm just removing the flag. --- lldb/test/Shell/Driver/TestHelp.test | 2 -- lldb/tools/driver/Driver.cpp | 15 --- lldb/tools/driver/Driver.h | 1 - 3 files changed, 18 deletions(-) diff --git a/lldb/test/Shell/Driver/TestHelp.test b/lldb/test/Shell/Driver/TestHelp.test index 0f73fdf0374fdd..2521b31a618836 100644 --- a/lldb/test/Shell/Driver/TestHelp.test +++ b/lldb/test/Shell/Driver/TestHelp.test @@ -37,8 +37,6 @@ CHECK: --arch CHECK: -a CHECK: --core CHECK: -c -CHECK: --debug -CHECK: -d CHECK: --editor CHECK: -e CHECK: --file diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index c63ff0ff597e5c..9286abb27e1332 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList , bool ) { if (args.hasArg(OPT_no_use_colors)) { m_debugger.SetUseColor(false); WithColor::setAutoDetectFunction(disable_color); -m_option_data.m_debug_mode = true; } if (args.hasArg(OPT_version)) { @@ -455,16 +454,7 @@ int Driver::MainLoop() { // Process lldbinit files before handling any options from the command line. SBCommandReturnObject result; sb_interpreter.SourceInitFileInGlobalDirectory(result); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl); - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } // Source the local .lldbinit file if it exists and we're allowed to source. // Here we want to always print the return object because it contains the @@ -536,11 +526,6 @@ int Driver::MainLoop() { "or -s) are ignored in REPL mode.\n"; } - if (m_option_data.m_debug_mode) { -result.PutError(m_debugger.GetErrorFile()); -result.PutOutput(m_debugger.GetOutputFile()); - } - const bool handle_events = true; const bool spawn_thread = false; diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h index d5779b3c2c91b5..83e0d8a41cfdb1 100644 --- a/lldb/tools/driver/Driver.h +++ b/lldb/tools/driver/Driver.h @@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster { std::vector m_after_file_commands; std::vector m_after_crash_commands; -bool m_debug_mode = false; bool m_source_quietly = false; bool m_print_version = false; bool m_print_python_path = false; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 249cf35 - [lldb][test][NFC] Add option to exclude third_party packages (#83191)
Author: Jordan Rupprecht Date: 2024-02-28T15:00:41-06:00 New Revision: 249cf356ef21d0b6ed0d1fa962f3fc5a9e3fcc9e URL: https://github.com/llvm/llvm-project/commit/249cf356ef21d0b6ed0d1fa962f3fc5a9e3fcc9e DIFF: https://github.com/llvm/llvm-project/commit/249cf356ef21d0b6ed0d1fa962f3fc5a9e3fcc9e.diff LOG: [lldb][test][NFC] Add option to exclude third_party packages (#83191) The goal here is to remove the third_party/Python/module tree, which LLDB tests only use to `import pexpect`. This package is available on `pip`, and I believe should not be hard to obtain. However, in case it isn't easily available, deleting the tree right now could cause disruption. This introduces a `LLDB_TEST_USE_VENDOR_PACKAGES` cmake param that can be enabled, and the tests will continue loading that tree. By default, it is enabled, meaning there's really no change here. A followup change will disable it by default once all known build bots are updated to include this package. When disabled, an eager cmake check runs that makes sure `pexpect` is available before waiting for the test to fail in an obscure way. Later, this option will go away, and when it does, we can delete the tree too. Ideally this is not disruptive, and we can remove it in a week or two. Added: Modified: lldb/cmake/modules/LLDBConfig.cmake lldb/test/API/lit.cfg.py lldb/test/API/lit.site.cfg.py.in lldb/test/CMakeLists.txt lldb/use_lldb_suite_root.py lldb/utils/lldb-dotest/CMakeLists.txt lldb/utils/lldb-dotest/lldb-dotest.in Removed: diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index a758261073ac57..93c8ffe4b7d8a0 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -67,6 +67,8 @@ option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing ll option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing lldb." OFF) option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS "Fail to configure if certain requirements are not met for testing." OFF) +option(LLDB_TEST_USE_VENDOR_PACKAGES + "Use packages from lldb/third_party/Python/module instead of system deps." ON) set(LLDB_GLOBAL_INIT_DIRECTORY "" CACHE STRING "Path to the global lldbinit directory. Relative paths are resolved relative to the diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 12675edc0fd3b9..f9497b632fc504 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -309,3 +309,6 @@ def delete_module_cache(path): # Propagate XDG_CACHE_HOME if "XDG_CACHE_HOME" in os.environ: config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"] + +if is_configured("use_vendor_packages"): +config.environment["LLDB_TEST_USE_VENDOR_PACKAGES"] = "1" diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 053331dc4881f7..c2602acd2ef85a 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -38,6 +38,7 @@ config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@" # The API tests use their own module caches. config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api") config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api") +config.use_vendor_packages = @LLDB_TEST_USE_VENDOR_PACKAGES@ # Plugins lldb_build_intel_pt = '@LLDB_BUILD_INTEL_PT@' diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 1aa8843b6a2e78..d8cbb24b6c9b81 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -26,6 +26,20 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS) endforeach() endif() +# The "pexpect" package should come from the system environment, not from the +# LLDB tree. However, we delay the deletion of it from the tree in case +# users/buildbots don't have the package yet and need some time to install it. +if (NOT LLDB_TEST_USE_VENDOR_PACKAGES) + lldb_find_python_module(pexpect) + if (NOT PY_pexpect_FOUND) +message(FATAL_ERROR + "Python module 'pexpect' not found. Please install it via pip or via " + "your operating system's package manager. For a temporary workaround, " + "use a version from the LLDB tree with " + "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`") + endif() +endif() + if(LLDB_BUILT_STANDALONE) # In order to run check-lldb-* we need the correct map_config directives in # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB, @@ -240,7 +254,8 @@ llvm_canonicalize_cmake_booleans( LLDB_HAS_LIBCXX LLDB_TOOL_LLDB_SERVER_BUILD LLDB_USE_SYSTEM_DEBUGSERVER - LLDB_IS_64_BITS) + LLDB_IS_64_BITS + LLDB_TEST_USE_VENDOR_PACKAGES) # Configure the individual test suites. add_subdirectory(API) diff --git a/lldb/use_lldb_suite_root.py b/lldb/use_lldb_suite_root.py index fd42f63a3c7f30..b8f8acf5dd94a4
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
https://github.com/rupprecht closed https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
https://github.com/rupprecht edited https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/walter-erquinigo edited https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/walter-erquinigo requested changes to this pull request. could you create instead a variable at the base test class level that can be used by other DAP tests when setting timeouts? I'm pretty sure at least one other test file uses timeouts. https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2cacc7a - [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (#83192)
Author: Zequan Wu Date: 2024-02-28T14:56:55-05:00 New Revision: 2cacc7a61095577ff42177373d46c8cb8df0cb1f URL: https://github.com/llvm/llvm-project/commit/2cacc7a61095577ff42177373d46c8cb8df0cb1f DIFF: https://github.com/llvm/llvm-project/commit/2cacc7a61095577ff42177373d46c8cb8df0cb1f.diff LOG: [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (#83192) If a SetDataBreakpointsRequest contains a list data breakpoints which have duplicate starting addresses, the current behaviour is returning `{verified: true}` to both watchpoints with duplicated starting addresses. This confuses the client and what actually happens in lldb is the second one overwrite the first one. This fixes it by letting the last watchpoint at given address have `{verified: true}` and all previous watchpoints at the same address should have `{verfied: false}` at response. Added: Modified: lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py lldb/tools/lldb-dap/Watchpoint.cpp lldb/tools/lldb-dap/Watchpoint.h lldb/tools/lldb-dap/lldb-dap.cpp Removed: diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py index 17cdad89aa6d10..52c0bbfb33dad8 100644 --- a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py +++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py @@ -12,6 +12,51 @@ def setUp(self): lldbdap_testcase.DAPTestCaseBase.setUp(self) self.accessTypes = ["read", "write", "readWrite"] +@skipIfWindows +@skipIfRemote +def test_duplicate_start_addresses(self): +"""Test setDataBreakpoints with multiple watchpoints starting at the same addresses.""" +program = self.getBuildArtifact("a.out") +self.build_and_launch(program) +source = "main.cpp" +first_loop_break_line = line_number(source, "// first loop breakpoint") +self.set_source_breakpoints(source, [first_loop_break_line]) +self.continue_to_next_stop() +self.dap_server.get_stackFrame() +# Test setting write watchpoint using expressions: , arr+2 +response_x = self.dap_server.request_dataBreakpointInfo(0, "") +response_arr_2 = self.dap_server.request_dataBreakpointInfo(0, "arr+2") +# Test response from dataBreakpointInfo request. +self.assertEquals(response_x["body"]["dataId"].split("/")[1], "4") +self.assertEquals(response_x["body"]["accessTypes"], self.accessTypes) +self.assertEquals(response_arr_2["body"]["dataId"].split("/")[1], "4") +self.assertEquals(response_arr_2["body"]["accessTypes"], self.accessTypes) +# The first one should be overwritten by the third one as they start at +# the same address. This is indicated by returning {verified: False} for +# the first one. +dataBreakpoints = [ +{"dataId": response_x["body"]["dataId"], "accessType": "read"}, +{"dataId": response_arr_2["body"]["dataId"], "accessType": "write"}, +{"dataId": response_x["body"]["dataId"], "accessType": "write"}, +] +set_response = self.dap_server.request_setDataBreakpoint(dataBreakpoints) +self.assertEquals( +set_response["body"]["breakpoints"], +[{"verified": False}, {"verified": True}, {"verified": True}], +) + +self.continue_to_next_stop() +x_val = self.dap_server.get_local_variable_value("x") +i_val = self.dap_server.get_local_variable_value("i") +self.assertEquals(x_val, "2") +self.assertEquals(i_val, "1") + +self.continue_to_next_stop() +arr_2 = self.dap_server.get_local_variable_child("arr", "[2]") +i_val = self.dap_server.get_local_variable_value("i") +self.assertEquals(arr_2["value"], "42") +self.assertEquals(i_val, "2") + @skipIfWindows @skipIfRemote def test_expression(self): diff --git a/lldb/tools/lldb-dap/Watchpoint.cpp b/lldb/tools/lldb-dap/Watchpoint.cpp index 2f176e0da84f15..21765509449140 100644 --- a/lldb/tools/lldb-dap/Watchpoint.cpp +++ b/lldb/tools/lldb-dap/Watchpoint.cpp @@ -16,17 +16,11 @@ Watchpoint::Watchpoint(const llvm::json::Object ) : BreakpointBase(obj) { llvm::StringRef dataId = GetString(obj, "dataId"); std::string accessType = GetString(obj, "accessType").str(); auto [addr_str, size_str] = dataId.split('/'); - lldb::addr_t addr; - size_t size; llvm::to_integer(addr_str, addr, 16); llvm::to_integer(size_str, size); - lldb::SBWatchpointOptions options; options.SetWatchpointTypeRead(accessType != "write"); if (accessType != "read") options.SetWatchpointTypeWrite(lldb::eWatchpointWriteTypeOnModify); - wp =
[Lldb-commits] [lldb] [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (PR #83192)
https://github.com/ZequanWu closed https://github.com/llvm/llvm-project/pull/83192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (PR #83192)
https://github.com/rupprecht approved this pull request. https://github.com/llvm/llvm-project/pull/83192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alex Langford (bulbazord) Changes This specifically addresses the warnings: $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char const *,int). There is exactly one declaration of SBCommandReturnObject::PutCString. The second parameter (of type `int`) has default value `-1`. Without investigating why SWIG believes there are 2 method declarations, I believe it is safe to ignore this warning. It does not appear to actually impact functionality in any way. rdar://117744660 --- Full diff: https://github.com/llvm/llvm-project/pull/83317.diff 1 Files Affected: - (modified) lldb/bindings/CMakeLists.txt (+5-1) ``diff diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt index b44ed59aa662b2..296eae1ae77f86 100644 --- a/lldb/bindings/CMakeLists.txt +++ b/lldb/bindings/CMakeLists.txt @@ -23,7 +23,11 @@ endif() set(SWIG_COMMON_FLAGS -c++ - -w361,362 # Ignore warnings about ignored operator overloads + # Ignored warnings: + # 361: operator! ignored. + # 362: operator= ignored. + # 509: Overloaded method declaration effectively ignored, shadowed by previous declaration. + -w361,362,509 -features autodoc -I${LLDB_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} `` https://github.com/llvm/llvm-project/pull/83317 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/83317 This specifically addresses the warnings: $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char const *,int). There is exactly one declaration of SBCommandReturnObject::PutCString. The second parameter (of type `int`) has default value `-1`. Without investigating why SWIG believes there are 2 method declarations, I believe it is safe to ignore this warning. It does not appear to actually impact functionality in any way. rdar://117744660 >From 76a634a1ad00e90983391cdd04588f92b5f15432 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Wed, 28 Feb 2024 10:58:33 -0800 Subject: [PATCH] [lldb] Ignore swig warnings about shadowed overloads This specifically addresses the warnings: $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char const *,int). There is exactly one declaration of SBCommandReturnObject::PutCString. The second parameter (of type `int`) has default value `-1`. Without investigating why SWIG believes there are 2 method declarations, I believe it is safe to ignore this warning. It does not appear to actually impact functionality in any way. rdar://117744660 --- lldb/bindings/CMakeLists.txt | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt index b44ed59aa662b2..296eae1ae77f86 100644 --- a/lldb/bindings/CMakeLists.txt +++ b/lldb/bindings/CMakeLists.txt @@ -23,7 +23,11 @@ endif() set(SWIG_COMMON_FLAGS -c++ - -w361,362 # Ignore warnings about ignored operator overloads + # Ignored warnings: + # 361: operator! ignored. + # 362: operator= ignored. + # 509: Overloaded method declaration effectively ignored, shadowed by previous declaration. + -w361,362,509 -features autodoc -I${LLDB_SOURCE_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/83069 >From f38204941062691bf3e3f6e57d8171a5c0258f77 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Tue, 20 Feb 2024 13:56:53 -0800 Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress manager This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit. --- lldb/include/lldb/Core/Debugger.h | 10 +-- lldb/include/lldb/Core/Progress.h | 47 +- lldb/source/Core/Debugger.cpp | 19 +++--- lldb/source/Core/Progress.cpp | 73 +++--- lldb/unittests/Core/ProgressReportTest.cpp | 57 + 5 files changed, 156 insertions(+), 50 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 6ba90eb6ed8fdf..b65ec1029ab24b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -593,6 +593,7 @@ class Debugger : public std::enable_shared_from_this, friend class CommandInterpreter; friend class REPL; friend class Progress; + friend class ProgressManager; /// Report progress events. /// @@ -623,10 +624,11 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. - static void ReportProgress(uint64_t progress_id, std::string title, - std::string details, uint64_t completed, - uint64_t total, - std::optional debugger_id); + static void + ReportProgress(uint64_t progress_id, std::string title, std::string details, + uint64_t completed, uint64_t total, + std::optional debugger_id, + uint32_t progress_category_bit = eBroadcastBitProgress); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..450c0b439910f2 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -9,10 +9,11 @@ #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H -#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include +#include #include #include @@ -97,27 +98,36 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + /// Data belonging to this Progress event. This data is used by the Debugger + /// to broadcast the event and by the ProgressManager for bookkeeping. + struct ProgressData { +/// The title of the progress activity, also used as a category. +std::string title; +/// More specific information about the current file being displayed in the +/// report. +std::string details; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// How much work ([0...m_total]) that has been completed. +uint64_t completed; +/// Total amount of work, use a std::nullopt in the constructor for non +/// deterministic progress. +uint64_t total; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; - std::string m_details; std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; - /// Total amount of work, use a std::nullopt in the constructor for non - /// deterministic progress. - uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Data needed
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff f01ed3bc8884223bf3edbaad8d3685622444cbf5 40caaa80180d4845393fc4b80ee2dc09b7c87a7e -- lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/Progress.h lldb/source/Core/Debugger.cpp lldb/source/Core/Progress.cpp lldb/unittests/Core/ProgressReportTest.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index b2038a9ffd..450c0b4399 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -98,8 +98,8 @@ public: /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; -/// Data belonging to this Progress event. This data is used by the Debugger -/// to broadcast the event and by the ProgressManager for bookkeeping. + /// Data belonging to this Progress event. This data is used by the Debugger + /// to broadcast the event and by the ProgressManager for bookkeeping. struct ProgressData { /// The title of the progress activity, also used as a category. std::string title; `` https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/83069 >From 40caaa80180d4845393fc4b80ee2dc09b7c87a7e Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Tue, 20 Feb 2024 13:56:53 -0800 Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress manager This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit. --- lldb/include/lldb/Core/Debugger.h | 10 +-- lldb/include/lldb/Core/Progress.h | 47 +- lldb/source/Core/Debugger.cpp | 19 +++--- lldb/source/Core/Progress.cpp | 73 +++--- lldb/unittests/Core/ProgressReportTest.cpp | 57 + 5 files changed, 156 insertions(+), 50 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 6ba90eb6ed8fdf..b65ec1029ab24b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -593,6 +593,7 @@ class Debugger : public std::enable_shared_from_this, friend class CommandInterpreter; friend class REPL; friend class Progress; + friend class ProgressManager; /// Report progress events. /// @@ -623,10 +624,11 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. - static void ReportProgress(uint64_t progress_id, std::string title, - std::string details, uint64_t completed, - uint64_t total, - std::optional debugger_id); + static void + ReportProgress(uint64_t progress_id, std::string title, std::string details, + uint64_t completed, uint64_t total, + std::optional debugger_id, + uint32_t progress_category_bit = eBroadcastBitProgress); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..b2038a9ffd9317 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -9,10 +9,11 @@ #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H -#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include +#include #include #include @@ -97,27 +98,36 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; +/// Data belonging to this Progress event. This data is used by the Debugger +/// to broadcast the event and by the ProgressManager for bookkeeping. + struct ProgressData { +/// The title of the progress activity, also used as a category. +std::string title; +/// More specific information about the current file being displayed in the +/// report. +std::string details; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// How much work ([0...m_total]) that has been completed. +uint64_t completed; +/// Total amount of work, use a std::nullopt in the constructor for non +/// deterministic progress. +uint64_t total; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; - std::string m_details; std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; - /// Total amount of work, use a std::nullopt in the constructor for non - /// deterministic progress. - uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Data
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/83069 >From 03268312834c61a16c4bc28efc442fcd027ec0a9 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Tue, 20 Feb 2024 13:56:53 -0800 Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress manager This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit. --- lldb/include/lldb/Core/Debugger.h | 10 +-- lldb/include/lldb/Core/Progress.h | 48 +- lldb/source/Core/Debugger.cpp | 19 +++--- lldb/source/Core/Progress.cpp | 73 +++--- lldb/unittests/Core/ProgressReportTest.cpp | 57 + 5 files changed, 157 insertions(+), 50 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 6ba90eb6ed8fdf..b65ec1029ab24b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -593,6 +593,7 @@ class Debugger : public std::enable_shared_from_this, friend class CommandInterpreter; friend class REPL; friend class Progress; + friend class ProgressManager; /// Report progress events. /// @@ -623,10 +624,11 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. - static void ReportProgress(uint64_t progress_id, std::string title, - std::string details, uint64_t completed, - uint64_t total, - std::optional debugger_id); + static void + ReportProgress(uint64_t progress_id, std::string title, std::string details, + uint64_t completed, uint64_t total, + std::optional debugger_id, + uint32_t progress_category_bit = eBroadcastBitProgress); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..d3077ef4823eac 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -9,10 +9,11 @@ #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H -#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include +#include #include #include @@ -97,27 +98,37 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + /// Use a struct to send data from a Progress object to + /// the progress manager. + struct ProgressData { +/// Data belonging to this Progress event. This data is used by the Debugger +/// to broadcast the event and by the ProgressManager for bookkeeping. +std::string title; +/// More specific information about the current file being displayed in the +/// report. +std::string details; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// How much work ([0...m_total]) that has been completed. +uint64_t completed; +/// Total amount of work, use a std::nullopt in the constructor for non +/// deterministic progress. +uint64_t total; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; - std::string m_details; std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; - /// Total amount of work, use a std::nullopt in the constructor for non - /// deterministic progress. - uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete =
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
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 c1b8c6cf41df4a148e7a89c3a3c7e8049b0a47af...53c507046527e04b7faa70ea17cd59b45e724f55 lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py `` View the diff from darker here. ``diff --- TestDAP_launch.py 2024-02-28 18:40:35.00 + +++ TestDAP_launch.py 2024-02-28 18:44:39.052136 + @@ -42,11 +42,11 @@ # The lldb-dap process should finish even though # we didn't close the communication socket explicitly self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1) self.dap_server.process.wait(timeout=timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -333,11 +333,11 @@ # Continue after launch and hit the first breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1) output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the @@ -402,11 +402,11 @@ # Verify all "launchCommands" were found in console output # After execution, program should launch self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1) output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the `` https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Shubham Sandeep Rastogi (rastogishubham) Changes The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. --- Full diff: https://github.com/llvm/llvm-project/pull/83312.diff 1 Files Affected: - (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+9-6) ``diff 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 04d741c1d47201..635ec4f0baf190 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -44,7 +44,8 @@ def test_termination(self): self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -self.dap_server.process.wait(timeout=10) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +self.dap_server.process.wait(timeout=timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -334,14 +335,15 @@ def test_commands(self): # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the second breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits @@ -402,21 +404,22 @@ def test_extra_launch_commands(self): self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits self.continue_to_exit() # Get output from the console. This should contain both the # "exitCommands" that were run after the second breakpoint was hit -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("exitCommands", output, exitCommands) @skipIfWindows `` https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/rastogishubham created https://github.com/llvm/llvm-project/pull/83312 The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. >From 53c507046527e04b7faa70ea17cd59b45e724f55 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Wed, 28 Feb 2024 10:28:55 -0800 Subject: [PATCH] Increase timeout to reduce test failure rate. The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. --- .../API/tools/lldb-dap/launch/TestDAP_launch.py | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) 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 04d741c1d47201..635ec4f0baf190 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -44,7 +44,8 @@ def test_termination(self): self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -self.dap_server.process.wait(timeout=10) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +self.dap_server.process.wait(timeout=timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -334,14 +335,15 @@ def test_commands(self): # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the second breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits @@ -402,21 +404,22 @@ def test_extra_launch_commands(self): self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits self.continue_to_exit() # Get output from the console. This should contain both the # "exitCommands" that were run after the second breakpoint was hit -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=timeoutval) self.verify_commands("exitCommands", output, exitCommands) @skipIfWindows ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
@@ -82,20 +94,37 @@ ProgressManager ::Instance() { return *g_progress_manager; } -void ProgressManager::Increment(std::string title) { +void ProgressManager::Increment(Progress::ProgressData progress_data) { chelcassanova wrote: Yeah, the title is used for map queries but the data itself isn't stored in the map, it's passed on to `ProgressManager::ReportProgress`. If we change it to a const ref (`const Progress::ProgressData& progress_data`) here then we probably also want to do this for `Decrement` since it uses the map in a similar way. https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Layout information for a record gets stored in the `ClangASTImporter` associated with the `DWARFASTParserClang` that originally parsed the record. LLDB sometimes moves clang types from one AST to another (in the reproducer the origin AST was a precompiled-header and the destination was the AST backing the executable). When clang then asks LLDB to `layoutRecordType`, it will do so with the help of the `ClangASTImporter` the type is associated with. If the type's origin is actually in a different LLDB module (and thus a different `DWARFASTParserClang` was used to set its layout info), we won't find the layout info in our local `ClangASTImporter`. In the reproducer this meant we would drop the alignment info of the origin type and misread a variable's contents with `frame var` and `expr`. There is logic in `ClangASTSource::layoutRecordType` to import an origin's layout info. This patch re-uses that infrastructure to import an origin's layout from one `ClangASTImporter` instance to another. rdar://123274144 --- Full diff: https://github.com/llvm/llvm-project/pull/83295.diff 5 Files Affected: - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp (+16-7) - (added) lldb/test/API/lang/cpp/gmodules/alignment/Makefile (+4) - (added) lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py (+60) - (added) lldb/test/API/lang/cpp/gmodules/alignment/main.cpp (+10) - (added) lldb/test/API/lang/cpp/gmodules/alignment/pch.h (+21) ``diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..754191ad83fe8a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a different + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def test_frame_var(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect_expr( +"data", +result_type="MatrixData", +result_children=[ +ValueCheck( +name="section", +children=[ +
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
Michael137 wrote: relies on https://github.com/llvm/llvm-project/pull/83291 https://github.com/llvm/llvm-project/pull/83295 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/83295 Layout information for a record gets stored in the `ClangASTImporter` associated with the `DWARFASTParserClang` that originally parsed the record. LLDB sometimes moves clang types from one AST to another (in the reproducer the origin AST was a precompiled-header and the destination was the AST backing the executable). When clang then asks LLDB to `layoutRecordType`, it will do so with the help of the `ClangASTImporter` the type is associated with. If the type's origin is actually in a different LLDB module (and thus a different `DWARFASTParserClang` was used to set its layout info), we won't find the layout info in our local `ClangASTImporter`. In the reproducer this meant we would drop the alignment info of the origin type and misread a variable's contents with `frame var` and `expr`. There is logic in `ClangASTSource::layoutRecordType` to import an origin's layout info. This patch re-uses that infrastructure to import an origin's layout from one `ClangASTImporter` instance to another. rdar://123274144 >From 9a6ed480fd407f9a9f12d6faccffbad952de0855 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:52:54 + Subject: [PATCH] [lldb][ClangASTImporter] Import record layouts from origin if available --- .../Clang/ClangASTImporter.cpp| 23 --- .../API/lang/cpp/gmodules/alignment/Makefile | 4 ++ .../gmodules/alignment/TestPchAlignment.py| 60 +++ .../API/lang/cpp/gmodules/alignment/main.cpp | 10 .../API/lang/cpp/gmodules/alignment/pch.h | 21 +++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/Makefile create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/main.cpp create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/pch.h diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..754191ad83fe8a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a different + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/JDevlieghere approved this pull request. LGTM with the nit addressed. https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
@@ -82,20 +94,37 @@ ProgressManager ::Instance() { return *g_progress_manager; } -void ProgressManager::Increment(std::string title) { +void ProgressManager::Increment(Progress::ProgressData progress_data) { JDevlieghere wrote: This should take a const ref to avoid the copy `const Progress::ProgressData& progress_data`. If we'd unconditionally store it in the map I'd say the copy is fine as you'd be able to move it into the map, but I'm assuming most of the time we're only using the title to do the lookup. https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
@@ -97,27 +98,37 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + /// Use a struct to send data from a Progress object to + /// the progress manager. + struct ProgressData { +/// The title of the progress activity, also used as a category to group +/// reports. +std::string title; +/// More specific information about the current file being displayed in the +/// report. +std::string details; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// How much work ([0...m_total]) that has been completed. +uint64_t completed; +/// Total amount of work, use a std::nullopt in the constructor for non +/// deterministic progress. +uint64_t total; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; - std::string m_details; std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; - /// Total amount of work, use a std::nullopt in the constructor for non - /// deterministic progress. - uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Data needed by the debugger to broadcast a progress event. JDevlieghere wrote: Suggestion: ``` /// Data data belonging to this Progress event. This data is used by the Debugger to broadcast the event and by the ProgressManager for bookkeeping. ``` https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)
@@ -54,3 +55,16 @@ def test_basic_completion(self): self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"]) self.quit() + +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot DavidSpickett wrote: Fair enough, if there's no specific reason I bet it's a relic from when we had way too many bots on the same machine. Today we don't have as many as we used to, but not your problem to figure out. It's being run somewhere that's the main thing. https://github.com/llvm/llvm-project/pull/83203 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This patch moves the logic for copying the layout info of a `RecordDecl`s origin into a target AST. A follow-up patch re-uses the logic from within the `ClangASTImporter`, so the natural choice was to move it there. --- Patch is 26.73 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/83291.diff 4 Files Affected: - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp (+204) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h (+61) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (+20-258) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h (+5) ``diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..b9f2c834dd1197 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), + be = (IsVirtual ? record->vbases_end() : record->bases_end()); + bi != be; ++bi) { +if (!IsVirtual && bi->isVirtual()) + continue; + +const clang::Type *origin_base_type = bi->getType().getTypePtr(); +const clang::RecordType *origin_base_record_type = +origin_base_type->getAs(); + +if (!origin_base_record_type) + return false; + +DeclFromUser origin_base_record( +origin_base_record_type->getDecl()); + +if (origin_base_record.IsInvalid()) + return false; + +DeclFromUser origin_base_cxx_record( +DynCast(origin_base_record)); + +if (origin_base_cxx_record.IsInvalid()) + return false; + +CharUnits base_offset; + +if (IsVirtual) + base_offset = + record_layout.getVBaseClassOffset(origin_base_cxx_record.decl); +else + base_offset = + record_layout.getBaseClassOffset(origin_base_cxx_record.decl); + +base_offsets.insert(std::pair( +origin_base_cxx_record.decl, base_offset)); + } + + return true; +} + +bool ClangASTImporter::importRecordLayoutFromOrigin( +const RecordDecl *record, uint64_t , uint64_t , +llvm::DenseMap _offsets, +llvm::DenseMap +_offsets, +llvm::DenseMap +_offsets) { + + Log *log = GetLog(LLDBLog::Expressions); + + clang::ASTContext _ctx = record->getASTContext(); + LLDB_LOG(log, + "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" + "{2} [name = '{3}']", + _ctx, + TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, + record->getName()); + + DeclFromParser parser_record(record); + DeclFromUser origin_record(parser_record.GetOrigin(*this)); + + if (origin_record.IsInvalid()) +
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/83291 This patch moves the logic for copying the layout info of a `RecordDecl`s origin into a target AST. A follow-up patch re-uses the logic from within the `ClangASTImporter`, so the natural choice was to move it there. >From 7ffc5c966a7a0542cbde20ead3144344e68e648f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:32:01 + Subject: [PATCH] [lldb][NFC] Move helpers to import record layout into ClangASTImporter --- .../Clang/ClangASTImporter.cpp| 204 + .../ExpressionParser/Clang/ClangASTImporter.h | 61 .../ExpressionParser/Clang/ClangASTSource.cpp | 278 ++ .../ExpressionParser/Clang/ClangASTSource.h | 5 + 4 files changed, 290 insertions(+), 258 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..b9f2c834dd1197 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), + be = (IsVirtual ? record->vbases_end() : record->bases_end()); + bi != be; ++bi) { +if (!IsVirtual && bi->isVirtual()) + continue; + +const clang::Type *origin_base_type = bi->getType().getTypePtr(); +const clang::RecordType *origin_base_record_type = +origin_base_type->getAs(); + +if (!origin_base_record_type) + return false; + +DeclFromUser origin_base_record( +origin_base_record_type->getDecl()); + +if (origin_base_record.IsInvalid()) + return false; + +DeclFromUser origin_base_cxx_record( +DynCast(origin_base_record)); + +if (origin_base_cxx_record.IsInvalid()) + return false; + +CharUnits base_offset; + +if (IsVirtual) + base_offset = + record_layout.getVBaseClassOffset(origin_base_cxx_record.decl); +else + base_offset = + record_layout.getBaseClassOffset(origin_base_cxx_record.decl); + +base_offsets.insert(std::pair( +origin_base_cxx_record.decl, base_offset)); + } + + return true; +} + +bool ClangASTImporter::importRecordLayoutFromOrigin( +const RecordDecl *record, uint64_t , uint64_t , +llvm::DenseMap _offsets, +llvm::DenseMap +_offsets, +llvm::DenseMap +_offsets) { + + Log *log = GetLog(LLDBLog::Expressions); + + clang::ASTContext _ctx = record->getASTContext(); + LLDB_LOG(log, + "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" + "{2} [name = '{3}']", + _ctx, + TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, + record->getName()); + + DeclFromParser parser_record(record); + DeclFromUser origin_record(parser_record.GetOrigin(*this)); + + if
[Lldb-commits] [lldb] cd344a4 - [LLDB] Fix completion of space-only lines in the REPL on Linux (#83203)
Author: Walter Erquinigo Date: 2024-02-28T11:43:36-05:00 New Revision: cd344a4c20e295d49f8163ec9a0656c1061a6e42 URL: https://github.com/llvm/llvm-project/commit/cd344a4c20e295d49f8163ec9a0656c1061a6e42 DIFF: https://github.com/llvm/llvm-project/commit/cd344a4c20e295d49f8163ec9a0656c1061a6e42.diff LOG: [LLDB] Fix completion of space-only lines in the REPL on Linux (#83203) https://github.com/modularml/mojo/issues/1796 discovered that if you try to complete a space-only line in the REPL on Linux, LLDB crashes. I suspect that editline doesn't behave the same way on linux and on darwin, because I can't replicate this on darwin. Adding a boundary check in the completion code prevents the crash from happening. Added: Modified: lldb/source/Host/common/Editline.cpp lldb/test/API/repl/clang/TestClangREPL.py Removed: diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index ce707e530d008b..e66271e8a6ee99 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -1029,8 +1029,11 @@ unsigned char Editline::TabCommand(int ch) { case CompletionMode::Normal: { std::string to_add = completion.GetCompletion(); // Terminate the current argument with a quote if it started with a quote. - if (!request.GetParsedLine().empty() && request.GetParsedArg().IsQuoted()) + Args = request.GetParsedLine(); + if (!parsedLine.empty() && request.GetCursorIndex() < parsedLine.size() && + request.GetParsedArg().IsQuoted()) { to_add.push_back(request.GetParsedArg().GetQuoteChar()); + } to_add.push_back(' '); el_deletestr(m_editline, request.GetCursorArgumentPrefix().size()); el_insertstr(m_editline, to_add.c_str()); diff --git a/lldb/test/API/repl/clang/TestClangREPL.py b/lldb/test/API/repl/clang/TestClangREPL.py index 0b67955a7833c6..c37557fb94735d 100644 --- a/lldb/test/API/repl/clang/TestClangREPL.py +++ b/lldb/test/API/repl/clang/TestClangREPL.py @@ -1,7 +1,6 @@ -import lldb from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * from lldbsuite.test.lldbpexpect import PExpectTest +from lldbsuite.test.lldbtest import * class TestCase(PExpectTest): @@ -17,13 +16,7 @@ def expect_repl(self, expr, substrs=[]): self.current_repl_line_number += 1 self.child.expect_exact(str(self.current_repl_line_number) + ">") -# PExpect uses many timeouts internally and doesn't play well -# under ASAN on a loaded machine.. -@skipIfAsan -@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot -@skipIfEditlineSupportMissing -def test_basic_completion(self): -"""Test that we can complete a simple multiline expression""" +def start_repl(self): self.build() self.current_repl_line_number = 1 @@ -41,6 +34,14 @@ def test_basic_completion(self): self.child.send("expression --repl -l c --\n") self.child.expect_exact("1>") +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot +@skipIfEditlineSupportMissing +def test_basic_completion(self): +"""Test that we can complete a simple multiline expression""" +self.start_repl() # Try evaluating a simple expression. self.expect_repl("3 + 3", substrs=["(int) $0 = 6"]) @@ -54,3 +55,16 @@ def test_basic_completion(self): self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"]) self.quit() + +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot +@skipIfEditlineSupportMissing +def test_completion_with_space_only_line(self): +"""Test that we don't crash when completing lines with spaces only""" +self.start_repl() + +self.child.send(" ") +self.child.send("\t") +self.expect_repl("3 + 3", substrs=["(int) $0 = 6"]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)
https://github.com/walter-erquinigo closed https://github.com/llvm/llvm-project/pull/83203 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)
@@ -54,3 +55,16 @@ def test_basic_completion(self): self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"]) self.quit() + +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot walter-erquinigo wrote: I actually don't know. The existing test already has issues with basic expr eval, and the new test will have them as well, so I decided to just copy the same configuration. https://github.com/llvm/llvm-project/pull/83203 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various hawkinsw wrote: ```suggestion /// addressing, and that higher-order bits may be used for various ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various + /// metadata like pointer authentication, Type Byte Ignore, etc. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. hawkinsw wrote: Can our Doxygen system make a reference to the documentation for these named constants? Just a question. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for hawkinsw wrote: ```suggestion /// For example, a value of 42 indicates that the low 42 bits are relevant for ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various + /// metadata like pointer authentication, Type Byte Ignore, etc. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void + SetAddressableBits(AddressMaskType type, uint32_t num_bits, + AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Clear the non-addressable bits of an \a addr value and return a + /// virtual address in memory. + /// + /// Bits that are not used in addressing may be used for other purposes; + /// pointer authentication, or metadata in the top byte, or the 0th bit + /// of armv7 code addresses to indicate arm/thumb are common examples. + /// + /// \param[in] addr + /// The address that should be cleared of non-addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument.
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have hawkinsw wrote: ```suggestion /// On some architectures (e.g., AArch64), it is possible to have ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)
https://github.com/DavidSpickett approved this pull request. I'd like to know if there's a good reason for the skip beyond machine load, but this is fine as is. LGTM. https://github.com/llvm/llvm-project/pull/83203 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/hawkinsw commented: As I said before, I really appreciate you doing such in-depth documentation. I hope these little suggestions help! https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits