[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/Michael137 deleted https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)
jmorse wrote: Ooooff, yeah we missed that. I think (90% confident) that overloading the relevant DIBuilder methods with iterator-taking versions should work fine, and we should be able to pick that into llvm20 before rc1, we'll look at it momentarily. (In theory downstream compatibility isn't a strong LLVM concern (?), but I think it'd be easy to support and ease transitions). https://github.com/llvm/llvm-project/pull/124287 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
https://github.com/JDevlieghere approved this pull request. 🥳 https://github.com/llvm/llvm-project/pull/124735 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)
@@ -44,12 +44,16 @@ class ProgressEventData : public EventData { uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { -std::string message = m_title; -if (!m_details.empty()) { - message.append(": "); - message.append(m_details); -} -return message; +// Only put the title in the message of the progress create event. +if (m_completed == 0) { + std::string message = m_title; + if (!m_details.empty()) { +message.append(": "); +message.append(m_details); + } + return message; +} else + return !m_details.empty() ? m_details : std::string(); Jlalond wrote: > Can we use `SBDebugger::GetProgressDataFromEvent` which returns > `SBStructuredData` with all the fields and then construct the message in > `lldb-dap`? This was going to be my alternative proposal. I assumed this wouldn't fly because I didn't know how many consumers need a workflow that doesn't follow the DAP rules. But based on the conversation I had with Greg offline the DAP progress events needs to handle it's own branching. I think the best way is returning a structured data to give us flexibility in the future. https://github.com/llvm/llvm-project/pull/124648 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
DavidSpickett wrote: I will deal with the formatting in a follow up after this lands. https://github.com/llvm/llvm-project/pull/124735 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)
@@ -44,12 +44,16 @@ class ProgressEventData : public EventData { uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { -std::string message = m_title; -if (!m_details.empty()) { - message.append(": "); - message.append(m_details); -} -return message; +// Only put the title in the message of the progress create event. +if (m_completed == 0) { + std::string message = m_title; + if (!m_details.empty()) { +message.append(": "); +message.append(m_details); + } + return message; +} else + return !m_details.empty() ? m_details : std::string(); JDevlieghere wrote: Agreed, that method was added exactly for that reason: so we didn't need to keep adding overloads to `GetProgressFromEvent` every time we added a new field. FWIW I personally think it's reasonable to construct the string in `lldb-dap`. https://github.com/llvm/llvm-project/pull/124648 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
https://github.com/felipepiovezan approved this pull request. https://github.com/llvm/llvm-project/pull/124811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/124811 This change is required as a result of the changes made in D132642 (bb26ebb4d18c1877cc6fd17aa803609abeb95096). >From 48ad5798b113db624ff2543ff35f907fcb3090ef Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 28 Jan 2025 10:31:03 -0800 Subject: [PATCH] [lldb] Fix lldb-dotest.in to use args determined by CMake This change is required as a result of the changes made in D132642 (bb26ebb4d18c1877cc6fd17aa803609abeb95096). --- lldb/utils/lldb-dotest/lldb-dotest.in | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index f20859e87b1e0b..9688b94d918429 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -4,7 +4,8 @@ import subprocess import sys dotest_path = '@LLDB_SOURCE_DIR_CONFIGURED@/test/API/dotest.py' -dotest_args_str = '@LLDB_DOTEST_ARGS_CONFIGURED@' +dotest_common_args_str = '@LLDB_TEST_COMMON_ARGS_CONFIGURED@' +dotest_user_args_str = '@LLDB_TEST_USER_ARGS_CONFIGURED@' arch = '@LLDB_TEST_ARCH@' executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@' compiler = '@LLDB_TEST_COMPILER_CONFIGURED@' @@ -26,8 +27,10 @@ if __name__ == '__main__': dotest_args = [] # split on an empty string will produce [''] and if you # add that to the command, it will be treated as a directory... -if len(dotest_args_str) > 0: -dotest_args = dotest_args_str.split(';') +if dotest_common_args_str: +dotest_args.extend(dotest_common_args_str.split(';')) +if dotest_user_args_str: +dotest_args.extend(dotest_user_args_str.split(';')) # Build dotest.py command. cmd = [sys.executable, dotest_path] cmd.extend(['--arch', arch]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes This change is required as a result of the changes made in D132642 (bb26ebb4d18c1877cc6fd17aa803609abeb95096). --- Full diff: https://github.com/llvm/llvm-project/pull/124811.diff 1 Files Affected: - (modified) lldb/utils/lldb-dotest/lldb-dotest.in (+6-3) ``diff diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index f20859e87b1e0b..9688b94d918429 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -4,7 +4,8 @@ import subprocess import sys dotest_path = '@LLDB_SOURCE_DIR_CONFIGURED@/test/API/dotest.py' -dotest_args_str = '@LLDB_DOTEST_ARGS_CONFIGURED@' +dotest_common_args_str = '@LLDB_TEST_COMMON_ARGS_CONFIGURED@' +dotest_user_args_str = '@LLDB_TEST_USER_ARGS_CONFIGURED@' arch = '@LLDB_TEST_ARCH@' executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@' compiler = '@LLDB_TEST_COMPILER_CONFIGURED@' @@ -26,8 +27,10 @@ if __name__ == '__main__': dotest_args = [] # split on an empty string will produce [''] and if you # add that to the command, it will be treated as a directory... -if len(dotest_args_str) > 0: -dotest_args = dotest_args_str.split(';') +if dotest_common_args_str: +dotest_args.extend(dotest_common_args_str.split(';')) +if dotest_user_args_str: +dotest_args.extend(dotest_user_args_str.split(';')) # Build dotest.py command. cmd = [sys.executable, dotest_path] cmd.extend(['--arch', arch]) `` https://github.com/llvm/llvm-project/pull/124811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
labath wrote: @rocallahan https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes **Do not merge before the 20 branch is taken!** As decided on https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731. LLDB 20 recommended >= 3.8 but did not remove support for anything earlier. Now we are in what will become LLDB 21, so I'm removing that support and making >= 3.8 required. See https://docs.python.org/3/c-api/apiabiversion.html#c.PY_VERSION_HEX for the format of PY_VERSION_HEX. --- Full diff: https://github.com/llvm/llvm-project/pull/124735.diff 6 Files Affected: - (modified) lldb/docs/resources/build.rst (+1-1) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (+1-58) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+1-26) - (modified) lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h (+2-2) - (modified) lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp (-6) - (modified) llvm/docs/ReleaseNotes.md (+3) ``diff diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst index c0d3c580d631c1..214c5f63f2c73b 100644 --- a/lldb/docs/resources/build.rst +++ b/lldb/docs/resources/build.rst @@ -62,7 +62,7 @@ CMake configuration error. +---+--+--+ | Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` | +---+--+--+ -| Python| Python scripting. >= 3.0 is required, >= 3.8 is recommended. | ``LLDB_ENABLE_PYTHON`` | +| Python| Python scripting. >= 3.8 is required. | ``LLDB_ENABLE_PYTHON`` | +---+--+--+ | Lua | Lua scripting. Lua 5.3 and 5.4 are supported. | ``LLDB_ENABLE_LUA`` | +---+--+--+ diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index a0f8cf954f8040..1340425aade438 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -73,10 +73,8 @@ Expected python::As(Expected &&obj) { static bool python_is_finalizing() { #if PY_VERSION_HEX >= 0x030d return Py_IsFinalizing(); -#elif PY_VERSION_HEX >= 0x0307 - return _Py_IsFinalizing(); #else - return _Py_Finalizing != nullptr; + return _Py_IsFinalizing(); #endif } @@ -810,7 +808,6 @@ bool PythonCallable::Check(PyObject *py_obj) { return PyCallable_Check(py_obj); } -#if PY_VERSION_HEX >= 0x0303 static const char get_arg_info_script[] = R"( from inspect import signature, Parameter, ismethod from collections import namedtuple @@ -832,15 +829,12 @@ def main(f): raise Exception(f'unknown parameter kind: {kind}') return ArgInfo(count, varargs) )"; -#endif Expected PythonCallable::GetArgInfo() const { ArgInfo result = {}; if (!IsValid()) return nullDeref(); -#if PY_VERSION_HEX >= 0x0303 - // no need to synchronize access to this global, we already have the GIL static PythonScript get_arg_info(get_arg_info_script); Expected pyarginfo = get_arg_info(*this); @@ -852,57 +846,6 @@ Expected PythonCallable::GetArgInfo() const { cantFail(As(pyarginfo.get().GetAttribute("has_varargs"))); result.max_positional_args = has_varargs ? ArgInfo::UNBOUNDED : count; -#else - PyObject *py_func_obj; - bool is_bound_method = false; - bool is_class = false; - - if (PyType_Check(m_py_obj) || PyClass_Check(m_py_obj)) { -auto init = GetAttribute("__init__"); -if (!init) - return init.takeError(); -py_func_obj = init.get().get(); -is_class = true; - } else { -py_func_obj = m_py_obj; - } - - if (PyMethod_Check(py_func_obj)) { -py_func_obj = PyMethod_GET_FUNCTION(py_func_obj); -PythonObject im_self = GetAttributeValue("im_self"); -if (im_self.IsValid() && !im_self.IsNone()) - is_bound_method = true; - } else { -// see if this is a callable object with an __call__ method -if (!PyFunction_Check(py_func_obj)) { - PythonObject __call__ = GetAttributeValue("__call__"); - if (__call__.IsValid()) { -auto __callable__ = __call__.AsType(); -if (__callable__.IsValid()) { - py_func_obj = PyMethod_GET_FUNCTION(__callable__.get()); - PythonObject im_self = __callable__.GetAttributeValue("im_self"); - if (im_self.IsValid() && !im_self.IsNone()) -is_bound_method = true; -
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/124735 **Do not merge before the 20 branch is taken!** As decided on https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731. LLDB 20 recommended >= 3.8 but did not remove support for anything earlier. Now we are in what will become LLDB 21, so I'm removing that support and making >= 3.8 required. See https://docs.python.org/3/c-api/apiabiversion.html#c.PY_VERSION_HEX for the format of PY_VERSION_HEX. >From 7d2b1ef31e16aeb369c2e45edae01feebfef866b Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 28 Jan 2025 10:58:34 + Subject: [PATCH] [lldb] Make Python >= 3.8 required for LLDB 21 As decided on https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731. LLDB 20 recommended >= 3.8 but did not remove support for anything earlier. Now we are in what will become LLDB 21, so I'm removing that support and making >= 3.8 required. See https://docs.python.org/3/c-api/apiabiversion.html#c.PY_VERSION_HEX for the format of PY_VERSION_HEX. --- lldb/docs/resources/build.rst | 2 +- .../Python/PythonDataObjects.cpp | 59 +-- .../Python/ScriptInterpreterPython.cpp| 27 + .../ScriptInterpreter/Python/lldb-python.h| 4 +- .../Python/PythonDataObjectsTests.cpp | 6 -- llvm/docs/ReleaseNotes.md | 3 + 6 files changed, 8 insertions(+), 93 deletions(-) diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst index c0d3c580d631c1..214c5f63f2c73b 100644 --- a/lldb/docs/resources/build.rst +++ b/lldb/docs/resources/build.rst @@ -62,7 +62,7 @@ CMake configuration error. +---+--+--+ | Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` | +---+--+--+ -| Python| Python scripting. >= 3.0 is required, >= 3.8 is recommended. | ``LLDB_ENABLE_PYTHON`` | +| Python| Python scripting. >= 3.8 is required. | ``LLDB_ENABLE_PYTHON`` | +---+--+--+ | Lua | Lua scripting. Lua 5.3 and 5.4 are supported. | ``LLDB_ENABLE_LUA`` | +---+--+--+ diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index a0f8cf954f8040..1340425aade438 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -73,10 +73,8 @@ Expected python::As(Expected &&obj) { static bool python_is_finalizing() { #if PY_VERSION_HEX >= 0x030d return Py_IsFinalizing(); -#elif PY_VERSION_HEX >= 0x0307 - return _Py_IsFinalizing(); #else - return _Py_Finalizing != nullptr; + return _Py_IsFinalizing(); #endif } @@ -810,7 +808,6 @@ bool PythonCallable::Check(PyObject *py_obj) { return PyCallable_Check(py_obj); } -#if PY_VERSION_HEX >= 0x0303 static const char get_arg_info_script[] = R"( from inspect import signature, Parameter, ismethod from collections import namedtuple @@ -832,15 +829,12 @@ def main(f): raise Exception(f'unknown parameter kind: {kind}') return ArgInfo(count, varargs) )"; -#endif Expected PythonCallable::GetArgInfo() const { ArgInfo result = {}; if (!IsValid()) return nullDeref(); -#if PY_VERSION_HEX >= 0x0303 - // no need to synchronize access to this global, we already have the GIL static PythonScript get_arg_info(get_arg_info_script); Expected pyarginfo = get_arg_info(*this); @@ -852,57 +846,6 @@ Expected PythonCallable::GetArgInfo() const { cantFail(As(pyarginfo.get().GetAttribute("has_varargs"))); result.max_positional_args = has_varargs ? ArgInfo::UNBOUNDED : count; -#else - PyObject *py_func_obj; - bool is_bound_method = false; - bool is_class = false; - - if (PyType_Check(m_py_obj) || PyClass_Check(m_py_obj)) { -auto init = GetAttribute("__init__"); -if (!init) - return init.takeError(); -py_func_obj = init.get().get(); -is_class = true; - } else { -py_func_obj = m_py_obj; - } - - if (PyMethod_Check(py_func_obj)) { -py_func_obj = PyMethod_GET_FUNCTION(py_func_obj); -PythonObject im_self = GetAttributeValue("im_self"); -if (im_self.IsValid() && !im_self.IsNone()) - is_bound_method = true; - } else { -// see if this is a callable object with an __call__ method -if (!PyFunction_Check
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
@@ -447,6 +447,9 @@ Changes to the LLVM tools Changes to LLDB - +* When building LLDB with Python support, the minimum version of Python is now + 3.8. + DavidSpickett wrote: This looks weird now but when I rebase after the branching, this will be the one and only note here. https://github.com/llvm/llvm-project/pull/124735 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Add register fields for Guarded Control Stack registers (PR #124295)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/124295 >From de84dc94ee6e5f15450f9e2729bfdbafd212b7f0 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 27 Aug 2024 14:35:28 +0100 Subject: [PATCH] [lldb][AArch64] Add register fields for Guarded Control Stack registers The features and locked registers hold the same bits, the latter is a lock for the former. Tested with core files and live processes. I thought about setting a non-zero lock register in the core file, however: * We can be pretty sure it's reading correctly because its between the 2 other GCS registers in the same core file note. * I can't make the test case modify lock bits because userspace can't clear them and we don't know what the libc has locked (probably all feature bits). --- .../Utility/RegisterFlagsDetector_arm64.cpp | 16 .../Utility/RegisterFlagsDetector_arm64.h| 5 - .../API/linux/aarch64/gcs/TestAArch64LinuxGCS.py | 15 ++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp index 9f82c935c0e7ed..1438a45f37d724 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp @@ -17,6 +17,7 @@ #define HWCAP_ASIMDHP (1ULL << 10) #define HWCAP_DIT (1ULL << 24) #define HWCAP_SSBS (1ULL << 28) +#define HWCAP_GCS (1UL << 32) #define HWCAP2_BTI (1ULL << 17) #define HWCAP2_MTE (1ULL << 18) @@ -50,6 +51,21 @@ Arm64RegisterFlagsDetector::DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2) { }; } +Arm64RegisterFlagsDetector::Fields +Arm64RegisterFlagsDetector::DetectGCSFeatureFields(uint64_t hwcap, + uint64_t hwcap2) { + (void)hwcap2; + + if (!(hwcap & HWCAP_GCS)) +return {}; + + return { + {"PUSH", 2}, + {"WRITE", 1}, + {"ENABLE", 0}, + }; +} + Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) { (void)hwcap; diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h index 0f3d53d93892bd..7daebcc71db044 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h @@ -61,6 +61,7 @@ class Arm64RegisterFlagsDetector { static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2); static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2); static Fields DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2); + static Fields DetectGCSFeatureFields(uint64_t hwcap, uint64_t hwcap2); struct RegisterEntry { RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector) @@ -70,13 +71,15 @@ class Arm64RegisterFlagsDetector { llvm::StringRef m_name; RegisterFlags m_flags; DetectorFn m_detector; - } m_registers[6] = { + } m_registers[8] = { RegisterEntry("cpsr", 4, DetectCPSRFields), RegisterEntry("fpsr", 4, DetectFPSRFields), RegisterEntry("fpcr", 4, DetectFPCRFields), RegisterEntry("mte_ctrl", 8, DetectMTECtrlFields), RegisterEntry("svcr", 8, DetectSVCRFields), RegisterEntry("fpmr", 8, DetectFPMRFields), + RegisterEntry("gcs_features_enabled", 8, DetectGCSFeatureFields), + RegisterEntry("gcs_features_locked", 8, DetectGCSFeatureFields), }; // Becomes true once field detection has been run for all registers. diff --git a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py index adbef69c5c38b0..f5a2ca356bbe81 100644 --- a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py +++ b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py @@ -223,7 +223,10 @@ def test_gcs_registers(self): self.runCmd(f"register write gcs_features_enabled {enabled}") self.expect( "register read gcs_features_enabled", -substrs=[f"gcs_features_enabled = 0x{enabled:016x}"], +substrs=[ +f"gcs_features_enabled = 0x{enabled:016x}", +f"= (PUSH = {(enabled >> 2) & 1}, WRITE = {(enabled >> 1) & 1}, ENABLE = {enabled & 1})", +], ) # With GCS disabled, the invalid guarded control stack pointer is not @@ -399,6 +402,16 @@ def test_gcs_core_file(self): ], ) +# Should get register fields for both. They have the same fields. +self.expect( +"register read gcs_features_enabled", +substrs=["= (PUSH = 0, WRITE = 0, ENABLE = 1)"], +) +self.expect( +"register read gcs_features_locked", +substrs=["= (PUSH = 0, WRITE = 0, ENABLE = 0)"], +
[Lldb-commits] [lldb] [llvm] [lldb] Make Python >= 3.8 required for LLDB 21 (PR #124735)
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 2c934dc5e1a3ef7b717400f27d6b9ea21f4e20a0 7d2b1ef31e16aeb369c2e45edae01feebfef866b --extensions h,cpp -- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index e78e6068de..91b86f7ec9 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -152,13 +152,14 @@ public: private: void InitializeThreadsPrivate() { -// Since Python 3.7 `Py_Initialize` calls `PyEval_InitThreads` inside itself, -// so there is no way to determine whether the embedded interpreter -// was already initialized by some external code. `PyEval_ThreadsInitialized` -// would always return `true` and `PyGILState_Ensure/Release` flow would be -// executed instead of unlocking GIL with `PyEval_SaveThread`. When -// an another thread calls `PyGILState_Ensure` it would get stuck in deadlock. -// The only case we should go further and acquire the GIL: it is unlocked. +// Since Python 3.7 `Py_Initialize` calls `PyEval_InitThreads` inside +// itself, so there is no way to determine whether the embedded interpreter +// was already initialized by some external code. +// `PyEval_ThreadsInitialized` would always return `true` and +// `PyGILState_Ensure/Release` flow would be executed instead of unlocking +// GIL with `PyEval_SaveThread`. When an another thread calls +// `PyGILState_Ensure` it would get stuck in deadlock. The only case we +// should go further and acquire the GIL: it is unlocked. if (PyGILState_Check()) return; `` https://github.com/llvm/llvm-project/pull/124735 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/124733 >From bf011ccc02c0122e7dfd74e089143eb833c1686e Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 28 Jan 2025 12:27:46 +0100 Subject: [PATCH] [lldb] Add support for gdb-style 'x' packet DO NOT SUBMIT until the mechanism for detection of the packet format is confirmed. --- .../Python/lldbsuite/test/gdbclientutils.py | 6 .../GDBRemoteCommunicationClient.cpp | 22 +++- .../gdb-remote/GDBRemoteCommunicationClient.h | 9 +++-- .../Process/gdb-remote/ProcessGDBRemote.cpp | 36 --- .../gdb_remote_client/TestReadMemory.py | 36 +++ 5 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 lldb/test/API/functionalities/gdb_remote_client/TestReadMemory.py diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 1784487323ad6b..4b782b3b470fe2 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -126,6 +126,9 @@ def respond(self, packet): if packet[0] == "m": addr, length = [int(x, 16) for x in packet[1:].split(",")] return self.readMemory(addr, length) +if packet[0] == "x": +addr, length = [int(x, 16) for x in packet[1:].split(",")] +return self.x(addr, length) if packet[0] == "M": location, encoded_data = packet[1:].split(":") addr, length = [int(x, 16) for x in location.split(",")] @@ -267,6 +270,9 @@ def writeRegister(self, register, value_hex): def readMemory(self, addr, length): return "00" * length +def x(self, addr, length): +return "" + def writeMemory(self, addr, data_hex): return "OK" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index b3f1c6f052955b..581dd8f8e0b6b6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -275,7 +275,6 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_supports_p = eLazyBoolCalculate; -m_supports_x = eLazyBoolCalculate; m_supports_QSaveRegisterState = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_curr_pid_is_valid = eLazyBoolCalculate; @@ -295,6 +294,7 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; +m_x_packet_state.reset(); m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; m_supports_qUserName = true; @@ -348,6 +348,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_memory_tagging = eLazyBoolNo; m_supports_qSaveCore = eLazyBoolNo; m_uses_native_signals = eLazyBoolNo; + m_x_packet_state.reset(); m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if // not, we assume no limit @@ -401,6 +402,8 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qSaveCore = eLazyBoolYes; else if (x == "native-signals+") m_uses_native_signals = eLazyBoolYes; + else if (x == "binary-upload+") +m_x_packet_state = xPacketState::Prefixed; // Look for a list of compressions in the features list e.g. // qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib- // deflate,lzma @@ -715,19 +718,20 @@ Status GDBRemoteCommunicationClient::WriteMemoryTags( return status; } -bool GDBRemoteCommunicationClient::GetxPacketSupported() { - if (m_supports_x == eLazyBoolCalculate) { +GDBRemoteCommunicationClient::xPacketState +GDBRemoteCommunicationClient::GetxPacketState() { + if (!m_x_packet_state) +GetRemoteQSupported(); + if (!m_x_packet_state) { StringExtractorGDBRemote response; -m_supports_x = eLazyBoolNo; -char packet[256]; -snprintf(packet, sizeof(packet), "x0,0"); -if (SendPacketAndWaitForResponse(packet, response) == +m_x_packet_state = xPacketState::Unimplemented; +if (SendPacketAndWaitForResponse("x0,0", response) == PacketResult::Success) { if (response.IsOKResponse()) -m_supports_x = eLazyBoolYes; +m_x_packet_state = xPacketState::Bare; } } - return m_supports_x; + return *m_x_packet_state; } lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCom
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/124733 DO NOT SUBMIT until the mechanism for detection of the packet format is confirmed. >From dfecd933978f1554624eb93d7c78f93364b8965a Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 28 Jan 2025 12:27:46 +0100 Subject: [PATCH] [lldb] Add support for gdb-style 'x' packet DO NOT SUBMIT until the mechanism for detection of the packet format is confirmed. --- .../Python/lldbsuite/test/gdbclientutils.py | 6 .../GDBRemoteCommunicationClient.cpp | 22 +++- .../gdb-remote/GDBRemoteCommunicationClient.h | 9 +++-- .../Process/gdb-remote/ProcessGDBRemote.cpp | 35 --- .../gdb_remote_client/TestReadMemory.py | 35 +++ 5 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 lldb/test/API/functionalities/gdb_remote_client/TestReadMemory.py diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 1784487323ad6b..4b782b3b470fe2 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -126,6 +126,9 @@ def respond(self, packet): if packet[0] == "m": addr, length = [int(x, 16) for x in packet[1:].split(",")] return self.readMemory(addr, length) +if packet[0] == "x": +addr, length = [int(x, 16) for x in packet[1:].split(",")] +return self.x(addr, length) if packet[0] == "M": location, encoded_data = packet[1:].split(":") addr, length = [int(x, 16) for x in location.split(",")] @@ -267,6 +270,9 @@ def writeRegister(self, register, value_hex): def readMemory(self, addr, length): return "00" * length +def x(self, addr, length): +return "" + def writeMemory(self, addr, data_hex): return "OK" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index b3f1c6f052955b..581dd8f8e0b6b6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -275,7 +275,6 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_supports_p = eLazyBoolCalculate; -m_supports_x = eLazyBoolCalculate; m_supports_QSaveRegisterState = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_curr_pid_is_valid = eLazyBoolCalculate; @@ -295,6 +294,7 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; +m_x_packet_state.reset(); m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; m_supports_qUserName = true; @@ -348,6 +348,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_memory_tagging = eLazyBoolNo; m_supports_qSaveCore = eLazyBoolNo; m_uses_native_signals = eLazyBoolNo; + m_x_packet_state.reset(); m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if // not, we assume no limit @@ -401,6 +402,8 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qSaveCore = eLazyBoolYes; else if (x == "native-signals+") m_uses_native_signals = eLazyBoolYes; + else if (x == "binary-upload+") +m_x_packet_state = xPacketState::Prefixed; // Look for a list of compressions in the features list e.g. // qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib- // deflate,lzma @@ -715,19 +718,20 @@ Status GDBRemoteCommunicationClient::WriteMemoryTags( return status; } -bool GDBRemoteCommunicationClient::GetxPacketSupported() { - if (m_supports_x == eLazyBoolCalculate) { +GDBRemoteCommunicationClient::xPacketState +GDBRemoteCommunicationClient::GetxPacketState() { + if (!m_x_packet_state) +GetRemoteQSupported(); + if (!m_x_packet_state) { StringExtractorGDBRemote response; -m_supports_x = eLazyBoolNo; -char packet[256]; -snprintf(packet, sizeof(packet), "x0,0"); -if (SendPacketAndWaitForResponse(packet, response) == +m_x_packet_state = xPacketState::Unimplemented; +if (SendPacketAndWaitForResponse("x0,0", response) == PacketResult::Success) { if (response.IsOKResponse()) -m_supports_x = eLazyBoolYes; +m_x_packet_state = xPacketState::Bare; } } - return m_supports_x; + return *m_x_packet_state; } lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
kastiglione wrote: the build failures are unrelated (`clang/Driver/Options.td`) https://github.com/llvm/llvm-project/pull/124811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update API headers for SBProgress (PR #124836)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/124836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/124811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/124843 I wanted to clarify the semantics around SBProgress. Given the nature of Progress events, copying seems like the wrong idea. Making SBProgress move-only (like SBStream) seems like the better choice here. >From cf30e0c12ceef36dbdd65157962b699eebfe8f75 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 28 Jan 2025 13:24:32 -0800 Subject: [PATCH] [lldb] Make SBProgress move-only I wanted to clarify the semantics around SBProgress. Given the nature of Progress events, copying seems like the wrong idea. Making SBProgress move-only (like SBStream) seems like the better choice here. --- lldb/include/lldb/API/SBProgress.h | 7 +++ lldb/source/API/SBProgress.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/lldb/include/lldb/API/SBProgress.h b/lldb/include/lldb/API/SBProgress.h index d2eaf0a743cb3a..d574d1d2982b96 100644 --- a/lldb/include/lldb/API/SBProgress.h +++ b/lldb/include/lldb/API/SBProgress.h @@ -51,6 +51,10 @@ class LLDB_API SBProgress { SBProgress(const char *title, const char *details, uint64_t total_units, SBDebugger &debugger); +#ifndef SWIG + SBProgress(SBProgress &&rhs); +#endif + ~SBProgress(); void Increment(uint64_t amount, const char *description = nullptr); @@ -59,6 +63,9 @@ class LLDB_API SBProgress { lldb_private::Progress &ref() const; private: + SBProgress(const SBProgress &rhs) = delete; + const SBProgress &operator=(const SBProgress &rhs) = delete; + std::unique_ptr m_opaque_up; }; // SBProgress } // namespace lldb diff --git a/lldb/source/API/SBProgress.cpp b/lldb/source/API/SBProgress.cpp index d6ed5f0d15fc94..e67e289a60eff4 100644 --- a/lldb/source/API/SBProgress.cpp +++ b/lldb/source/API/SBProgress.cpp @@ -32,6 +32,9 @@ SBProgress::SBProgress(const char *title, const char *details, lldb_private::Progress::Origin::eExternal); } +SBProgress::SBProgress(SBProgress &&rhs) +: m_opaque_up(std::move(rhs.m_opaque_up)) {} + SBProgress::~SBProgress() = default; void SBProgress::Increment(uint64_t amount, const char *description) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alex Langford (bulbazord) Changes I wanted to clarify the semantics around SBProgress. Given the nature of Progress events, copying seems like the wrong idea. Making SBProgress move-only (like SBStream) seems like the better choice here. --- Full diff: https://github.com/llvm/llvm-project/pull/124843.diff 2 Files Affected: - (modified) lldb/include/lldb/API/SBProgress.h (+7) - (modified) lldb/source/API/SBProgress.cpp (+3) ``diff diff --git a/lldb/include/lldb/API/SBProgress.h b/lldb/include/lldb/API/SBProgress.h index d2eaf0a743cb3a..d574d1d2982b96 100644 --- a/lldb/include/lldb/API/SBProgress.h +++ b/lldb/include/lldb/API/SBProgress.h @@ -51,6 +51,10 @@ class LLDB_API SBProgress { SBProgress(const char *title, const char *details, uint64_t total_units, SBDebugger &debugger); +#ifndef SWIG + SBProgress(SBProgress &&rhs); +#endif + ~SBProgress(); void Increment(uint64_t amount, const char *description = nullptr); @@ -59,6 +63,9 @@ class LLDB_API SBProgress { lldb_private::Progress &ref() const; private: + SBProgress(const SBProgress &rhs) = delete; + const SBProgress &operator=(const SBProgress &rhs) = delete; + std::unique_ptr m_opaque_up; }; // SBProgress } // namespace lldb diff --git a/lldb/source/API/SBProgress.cpp b/lldb/source/API/SBProgress.cpp index d6ed5f0d15fc94..e67e289a60eff4 100644 --- a/lldb/source/API/SBProgress.cpp +++ b/lldb/source/API/SBProgress.cpp @@ -32,6 +32,9 @@ SBProgress::SBProgress(const char *title, const char *details, lldb_private::Progress::Origin::eExternal); } +SBProgress::SBProgress(SBProgress &&rhs) +: m_opaque_up(std::move(rhs.m_opaque_up)) {} + SBProgress::~SBProgress() = default; void SBProgress::Increment(uint64_t amount, const char *description) { `` https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9d79998 - [lldb] Update API headers for SBProgress (#124836)
Author: Alex Langford Date: 2025-01-28T13:30:14-08:00 New Revision: 9d7999885a6aa2c4afc252a645448b4f1666e951 URL: https://github.com/llvm/llvm-project/commit/9d7999885a6aa2c4afc252a645448b4f1666e951 DIFF: https://github.com/llvm/llvm-project/commit/9d7999885a6aa2c4afc252a645448b4f1666e951.diff LOG: [lldb] Update API headers for SBProgress (#124836) Some clients only include LLDB.h and they won't get access to SBProgress without this. Added: Modified: lldb/include/lldb/API/LLDB.h lldb/include/lldb/API/SBDefines.h Removed: diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index 40368e036e0e40..126fcef31b4166 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -54,6 +54,7 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBProcessInfo.h" #include "lldb/API/SBProcessInfoList.h" +#include "lldb/API/SBProgress.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBReproducer.h" diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 159a9ba799b181..31e8c9279f8b8b 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -95,6 +95,7 @@ class LLDB_API SBPlatformShellCommand; class LLDB_API SBProcess; class LLDB_API SBProcessInfo; class LLDB_API SBProcessInfoList; +class LLDB_API SBProgress; class LLDB_API SBQueue; class LLDB_API SBQueueItem; class LLDB_API SBReplayOptions; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
https://github.com/Jlalond edited https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
@@ -59,6 +63,9 @@ class LLDB_API SBProgress { lldb_private::Progress &ref() const; private: + SBProgress(const SBProgress &rhs) = delete; Jlalond wrote: Oh! I didn't originally do this because I thought we weren't adding deletes in the header. https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
https://github.com/Jlalond approved this pull request. LGTM, left you one comment @bulbazord that is mostly a question https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
@@ -51,6 +51,10 @@ class LLDB_API SBProgress { SBProgress(const char *title, const char *details, uint64_t total_units, SBDebugger &debugger); +#ifndef SWIG Jlalond wrote: Why the move operator for only Swig? Wouldn't this be useful if say DAP wanted to grab it's own progress object and then potentially move it? https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update API headers for SBProgress (PR #124836)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/124836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lldb-dotest.in to use args determined by CMake (PR #124811)
https://github.com/kastiglione closed https://github.com/llvm/llvm-project/pull/124811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e89e7c4 - [lldb] Fix lldb-dotest.in to use args determined by CMake (#124811)
Author: Dave Lee Date: 2025-01-28T13:36:40-08:00 New Revision: e89e7c4685aa673173220eace7a0a8b64dbd2391 URL: https://github.com/llvm/llvm-project/commit/e89e7c4685aa673173220eace7a0a8b64dbd2391 DIFF: https://github.com/llvm/llvm-project/commit/e89e7c4685aa673173220eace7a0a8b64dbd2391.diff LOG: [lldb] Fix lldb-dotest.in to use args determined by CMake (#124811) This change is required as a result of the changes made in D132642 (bb26ebb4d18c1877cc6fd17aa803609abeb95096). Added: Modified: lldb/utils/lldb-dotest/lldb-dotest.in Removed: diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index f20859e87b1e0b..9688b94d918429 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -4,7 +4,8 @@ import subprocess import sys dotest_path = '@LLDB_SOURCE_DIR_CONFIGURED@/test/API/dotest.py' -dotest_args_str = '@LLDB_DOTEST_ARGS_CONFIGURED@' +dotest_common_args_str = '@LLDB_TEST_COMMON_ARGS_CONFIGURED@' +dotest_user_args_str = '@LLDB_TEST_USER_ARGS_CONFIGURED@' arch = '@LLDB_TEST_ARCH@' executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@' compiler = '@LLDB_TEST_COMPILER_CONFIGURED@' @@ -26,8 +27,10 @@ if __name__ == '__main__': dotest_args = [] # split on an empty string will produce [''] and if you # add that to the command, it will be treated as a directory... -if len(dotest_args_str) > 0: -dotest_args = dotest_args_str.split(';') +if dotest_common_args_str: +dotest_args.extend(dotest_common_args_str.split(';')) +if dotest_user_args_str: +dotest_args.extend(dotest_user_args_str.split(';')) # Build dotest.py command. cmd = [sys.executable, dotest_path] cmd.extend(['--arch', arch]) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/puremourning created https://github.com/llvm/llvm-project/pull/124847 The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- The included test fails prior to this patch and succeeds after. That is previously specifying `False` for `modify` would still stop on _write_, but after the patch correctly only stops on _read_ >From a3ee813d5deb4179a916906c4b1b1dd10c4b586e Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 28 Jan 2025 21:47:24 + Subject: [PATCH] LLDB: WatchAddress ignores modify option The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- lldb/source/API/SBTarget.cpp | 4 +- .../watchpoint/TestWatchpointRead.py | 130 ++ .../watchlocation/TestTargetWatchAddress.py | 71 +- 3 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..9192f0be1c85b9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..67b04464748108 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,130 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetWatchpointAPITestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress( +value.GetLoadAddress(), 1, True, False, error +) +self.assertTrue( +value and local and watchpoint, "Successfully found the values and set a watchpoint" +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, +"The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/puremourning updated https://github.com/llvm/llvm-project/pull/124847 >From afae250c45e769006a5ae7d078e2e0ae39a4d8c0 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 28 Jan 2025 21:47:24 + Subject: [PATCH] LLDB: WatchAddress ignores modify option The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- lldb/source/API/SBTarget.cpp | 4 +- .../watchpoint/TestWatchpointRead.py | 130 ++ .../watchlocation/TestTargetWatchAddress.py | 71 +- 3 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..9192f0be1c85b9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..21ba4760071276 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,130 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetReadOnlyWatchpointTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress( +value.GetLoadAddress(), 1, True, False, error +) +self.assertTrue( +value and local and watchpoint, "Successfully found the values and set a watchpoint" +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, +"The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +proces
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/puremourning updated https://github.com/llvm/llvm-project/pull/124847 >From 3baafc236fb722a27799bd3abccb74e01656afab Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 28 Jan 2025 21:47:24 + Subject: [PATCH] LLDB: WatchAddress ignores modify option The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- lldb/source/API/SBTarget.cpp | 4 +- .../watchpoint/TestWatchpointRead.py | 130 ++ .../watchlocation/TestTargetWatchAddress.py | 71 +- 3 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..9192f0be1c85b9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..21ba4760071276 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,130 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetReadOnlyWatchpointTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress( +value.GetLoadAddress(), 1, True, False, error +) +self.assertTrue( +value and local and watchpoint, "Successfully found the values and set a watchpoint" +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, +"The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +proces
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
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 2e5a5237daf82a657561c490845c406e13657311...afae250c45e769006a5ae7d078e2e0ae39a4d8c0 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py `` View the diff from darker here. ``diff --- TestWatchpointRead.py 2025-01-28 21:55:17.00 + +++ TestWatchpointRead.py 2025-01-28 21:58:57.760913 + @@ -18,11 +18,10 @@ self.source = "main.c" # Find the line number to break inside main(). self.line = line_number(self.source, "// Set break point at this line.") self.build() - def test_read_watchpoint_watch_address(self): exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -40,20 +39,18 @@ process = target.GetProcess() self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) - value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) error = lldb.SBError() -watchpoint = target.WatchAddress( -value.GetLoadAddress(), 1, True, False, error -) +watchpoint = target.WatchAddress(value.GetLoadAddress(), 1, True, False, error) self.assertTrue( -value and local and watchpoint, "Successfully found the values and set a watchpoint" +value and local and watchpoint, +"Successfully found the values and set a watchpoint", ) self.DebugSBValue(value) self.DebugSBValue(local) # Hide stdout if not running with '-t' option. @@ -68,12 +65,11 @@ if self.TraceOn(): lldbutil.print_stacktraces(process) self.assertTrue( -local.GetValueAsSigned() > 0, -"The local variable has been incremented" +local.GetValueAsSigned() > 0, "The local variable has been incremented" ) def test_read_watchpoint_watch_create_by_address(self): exe = self.getBuildArtifact("a.out") @@ -93,22 +89,22 @@ process = target.GetProcess() self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) - value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) error = lldb.SBError() wp_opts = lldb.SBWatchpointOptions() wp_opts.SetWatchpointTypeRead(True) watchpoint = target.WatchpointCreateByAddress( value.GetLoadAddress(), 1, wp_opts, error ) self.assertTrue( -value and local and watchpoint, "Successfully found the values and set a watchpoint" +value and local and watchpoint, +"Successfully found the values and set a watchpoint", ) self.DebugSBValue(value) self.DebugSBValue(local) # Hide stdout if not running with '-t' option. @@ -123,8 +119,7 @@ if self.TraceOn(): lldbutil.print_stacktraces(process) self.assertTrue( -local.GetValueAsSigned() > 0, -"The local variable has been incremented" +local.GetValueAsSigned() > 0, "The local variable has been incremented" ) `` https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ben Jackson (puremourning) Changes The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- The included test fails prior to this patch and succeeds after. That is previously specifying `False` for `modify` would still stop on _write_, but after the patch correctly only stops on _read_ --- Full diff: https://github.com/llvm/llvm-project/pull/124847.diff 3 Files Affected: - (modified) lldb/source/API/SBTarget.cpp (+3-1) - (added) lldb/test/API/python_api/watchpoint/TestWatchpointRead.py (+130) - (modified) lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py (+70-1) ``diff diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..9192f0be1c85b9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..67b04464748108 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,130 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetWatchpointAPITestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress( +value.GetLoadAddress(), 1, True, False, error +) +self.assertTrue( +value and local and watchpoint, "Successfully found the values and set a watchpoint" +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, +"The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1f7eb6f - [lldb] Make SBProgress move-only (#124843)
Author: Alex Langford Date: 2025-01-28T14:03:17-08:00 New Revision: 1f7eb6f403bc0e453b76d9274994d840561e96cf URL: https://github.com/llvm/llvm-project/commit/1f7eb6f403bc0e453b76d9274994d840561e96cf DIFF: https://github.com/llvm/llvm-project/commit/1f7eb6f403bc0e453b76d9274994d840561e96cf.diff LOG: [lldb] Make SBProgress move-only (#124843) I wanted to clarify the semantics around SBProgress. Given the nature of Progress events, copying seems like the wrong idea. Making SBProgress move-only (like SBStream) seems like the better choice here. Added: Modified: lldb/include/lldb/API/SBProgress.h lldb/source/API/SBProgress.cpp Removed: diff --git a/lldb/include/lldb/API/SBProgress.h b/lldb/include/lldb/API/SBProgress.h index d2eaf0a743cb3a..d574d1d2982b96 100644 --- a/lldb/include/lldb/API/SBProgress.h +++ b/lldb/include/lldb/API/SBProgress.h @@ -51,6 +51,10 @@ class LLDB_API SBProgress { SBProgress(const char *title, const char *details, uint64_t total_units, SBDebugger &debugger); +#ifndef SWIG + SBProgress(SBProgress &&rhs); +#endif + ~SBProgress(); void Increment(uint64_t amount, const char *description = nullptr); @@ -59,6 +63,9 @@ class LLDB_API SBProgress { lldb_private::Progress &ref() const; private: + SBProgress(const SBProgress &rhs) = delete; + const SBProgress &operator=(const SBProgress &rhs) = delete; + std::unique_ptr m_opaque_up; }; // SBProgress } // namespace lldb diff --git a/lldb/source/API/SBProgress.cpp b/lldb/source/API/SBProgress.cpp index d6ed5f0d15fc94..e67e289a60eff4 100644 --- a/lldb/source/API/SBProgress.cpp +++ b/lldb/source/API/SBProgress.cpp @@ -32,6 +32,9 @@ SBProgress::SBProgress(const char *title, const char *details, lldb_private::Progress::Origin::eExternal); } +SBProgress::SBProgress(SBProgress &&rhs) +: m_opaque_up(std::move(rhs.m_opaque_up)) {} + SBProgress::~SBProgress() = default; void SBProgress::Increment(uint64_t amount, const char *description) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
@@ -51,6 +51,10 @@ class LLDB_API SBProgress { SBProgress(const char *title, const char *details, uint64_t total_units, SBDebugger &debugger); +#ifndef SWIG bulbazord wrote: This is a header guard that prevents SWIG from processing the move constructor. SWIG generates the bindings by reading the API headers and doesn't handle move constructors well. SBStream does the same thing. When the headers are installed for distribution, this header guard is removed with `unifdef`. https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/puremourning updated https://github.com/llvm/llvm-project/pull/124847 >From 1edd2a7cae5acbe11ae58f486f5bca7c182184f5 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 28 Jan 2025 21:47:24 + Subject: [PATCH] LLDB: WatchAddress ignores modify option The WatchAddress API includes a flag to indicate if watchpoint should be for read, modify or both. This API uses 2 booleans, but the 'modify' flag was ignored and WatchAddress unconditionally watched write (actually modify). We now only watch for modify when the modify flag is true. --- lldb/source/API/SBTarget.cpp | 4 +- .../watchpoint/TestWatchpointRead.py | 125 ++ .../watchlocation/TestTargetWatchAddress.py | 71 +- 3 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/watchpoint/TestWatchpointRead.py diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2a33161bc21edc..9192f0be1c85b9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } return WatchpointCreateByAddress(addr, size, options, error); } diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py new file mode 100644 index 00..c0d06e41faea47 --- /dev/null +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointRead.py @@ -0,0 +1,125 @@ +""" +Use lldb Python SBTarget API to set read watchpoints +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class SetReadOnlyWatchpointTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) +# Our simple source filename. +self.source = "main.c" +# Find the line number to break inside main(). +self.line = line_number(self.source, "// Set break point at this line.") +self.build() + +def test_read_watchpoint_watch_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame0 = thread.GetFrameAtIndex(0) + +value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) +local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) +error = lldb.SBError() + +watchpoint = target.WatchAddress(value.GetLoadAddress(), 1, True, False, error) +self.assertTrue( +value and local and watchpoint, +"Successfully found the values and set a watchpoint", +) +self.DebugSBValue(value) +self.DebugSBValue(local) + +# Hide stdout if not running with '-t' option. +if not self.TraceOn(): +self.HideStdout() + +print(watchpoint) + +# Continue. Expect the program to stop due to the variable being +# read, but *not* written to. +process.Continue() + +if self.TraceOn(): +lldbutil.print_stacktraces(process) + +self.assertTrue( +local.GetValueAsSigned() > 0, "The local variable has been incremented" +) + +def test_read_watchpoint_watch_create_by_address(self): +exe = self.getBuildArtifact("a.out") + +target = self.dbg.CreateTarget(exe) +self.assertTrue(target, VALID_TARGET) + +# Now create a breakpoint on main.c. +breakpoint = target.BreakpointCreateByLocation(self.source, self.line) +self.assertTrue( +breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT +) + +# Now launch the process, and do not stop at the entry point. +process = target.LaunchSimple(None, None, self.get_process_working_directory()) + +# We should be stopped due to the breakpoint. Get frame #0. +process = target.GetProcess() +
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
@@ -59,6 +63,9 @@ class LLDB_API SBProgress { lldb_private::Progress &ref() const; private: + SBProgress(const SBProgress &rhs) = delete; bulbazord wrote: SBStream does this to enforce no copying. :) https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
@@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); - options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + if (modify) { +options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify); + } JDevlieghere wrote: Nit: [Don’t use braces on simple single-statement bodies of if/else/loop statements ](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements) https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
@@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); JDevlieghere wrote: Shouldn't this check the `read` flag in a similar fashion? https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make SBProgress move-only (PR #124843)
https://github.com/bulbazord edited https://github.com/llvm/llvm-project/pull/124843 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c5840cc - [lldb][AArch64] Add register fields for Guarded Control Stack registers (#124295)
Author: David Spickett Date: 2025-01-28T12:05:24Z New Revision: c5840cc609a3674cf7453a45946f7e4a2a73590b URL: https://github.com/llvm/llvm-project/commit/c5840cc609a3674cf7453a45946f7e4a2a73590b DIFF: https://github.com/llvm/llvm-project/commit/c5840cc609a3674cf7453a45946f7e4a2a73590b.diff LOG: [lldb][AArch64] Add register fields for Guarded Control Stack registers (#124295) The features and locked registers hold the same bits, the latter is a lock for the former. Tested with core files and live processes. I thought about setting a non-zero lock register in the core file, however: * We can be pretty sure it's reading correctly because its between the 2 other GCS registers in the same core file note. * I can't make the test case modify lock bits because userspace can't clear them (without using ptrace) and we don't know what the libc has locked (probably all feature bits). Added: Modified: lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py Removed: diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp index 9f82c935c0e7ed..1438a45f37d724 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp @@ -17,6 +17,7 @@ #define HWCAP_ASIMDHP (1ULL << 10) #define HWCAP_DIT (1ULL << 24) #define HWCAP_SSBS (1ULL << 28) +#define HWCAP_GCS (1UL << 32) #define HWCAP2_BTI (1ULL << 17) #define HWCAP2_MTE (1ULL << 18) @@ -50,6 +51,21 @@ Arm64RegisterFlagsDetector::DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2) { }; } +Arm64RegisterFlagsDetector::Fields +Arm64RegisterFlagsDetector::DetectGCSFeatureFields(uint64_t hwcap, + uint64_t hwcap2) { + (void)hwcap2; + + if (!(hwcap & HWCAP_GCS)) +return {}; + + return { + {"PUSH", 2}, + {"WRITE", 1}, + {"ENABLE", 0}, + }; +} + Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) { (void)hwcap; diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h index 0f3d53d93892bd..7daebcc71db044 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h @@ -61,6 +61,7 @@ class Arm64RegisterFlagsDetector { static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2); static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2); static Fields DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2); + static Fields DetectGCSFeatureFields(uint64_t hwcap, uint64_t hwcap2); struct RegisterEntry { RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector) @@ -70,13 +71,15 @@ class Arm64RegisterFlagsDetector { llvm::StringRef m_name; RegisterFlags m_flags; DetectorFn m_detector; - } m_registers[6] = { + } m_registers[8] = { RegisterEntry("cpsr", 4, DetectCPSRFields), RegisterEntry("fpsr", 4, DetectFPSRFields), RegisterEntry("fpcr", 4, DetectFPCRFields), RegisterEntry("mte_ctrl", 8, DetectMTECtrlFields), RegisterEntry("svcr", 8, DetectSVCRFields), RegisterEntry("fpmr", 8, DetectFPMRFields), + RegisterEntry("gcs_features_enabled", 8, DetectGCSFeatureFields), + RegisterEntry("gcs_features_locked", 8, DetectGCSFeatureFields), }; // Becomes true once field detection has been run for all registers. diff --git a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py index adbef69c5c38b0..f5a2ca356bbe81 100644 --- a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py +++ b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py @@ -223,7 +223,10 @@ def test_gcs_registers(self): self.runCmd(f"register write gcs_features_enabled {enabled}") self.expect( "register read gcs_features_enabled", -substrs=[f"gcs_features_enabled = 0x{enabled:016x}"], +substrs=[ +f"gcs_features_enabled = 0x{enabled:016x}", +f"= (PUSH = {(enabled >> 2) & 1}, WRITE = {(enabled >> 1) & 1}, ENABLE = {enabled & 1})", +], ) # With GCS disabled, the invalid guarded control stack pointer is not @@ -399,6 +402,16 @@ def test_gcs_core_file(self): ], ) +# Should get register fields for both. They have the same fields. +self.expect( +"register read gcs_features_enabled", +substrs=["= (PUSH = 0, WRITE = 0, ENABLE
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,370 @@ +//===-- PlatformAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +uint32_t +PlatformAIX::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) { + uint32_t resume_count = 0; + + // Always resume past the initial stop when we use eLaunchFlagDebug + if (launch_info.GetFlags().Test(eLaunchFlagDebug)) { +// Resume past the stop for the final exec into the true inferior. +++resume_count; + } + + // If we're not launching a shell, we're done. + const FileSpec &shell = launch_info.GetShell(); + if (!shell) +return resume_count; + + std::string shell_string = shell.GetPath(); + // We're in a shell, so for sure we have to resume past the shell exec. + ++resume_count; + + // Figure out what shell we're planning on using. + const char *shell_name
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -0,0 +1,37 @@ +""" +Test LLDB type promotion of unscoped enums. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestCPPEnumPromotion(TestBase): +@skipIf(debug_info=no_match(["dwarf", "dwo"])) Michael137 wrote: Any reason we're skipping this for `dSYM`s? https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)
hvdijk wrote: Hi, in principle this change makes sense but it causes a bit of an issue with [`DIBuilder`](https://llvm.org/doxygen/classllvm_1_1DIBuilder.html) not yet having been updated to take iterators. The workaround for that at the moment is trivial (change e.g. `DIB.insertDeclare(..., BB.getFirstNonPHIOrDbg())` to `DIB.insertDeclare(..., &*BB.getFirstNonPHIOrDbg())` as you do in other places in this PR), but that workaround would break when the update does land to have `insertDeclare` etc. take iterators. Could I ask what the best way forward here is for downstream users that need to remain compatible with multiple LLVM versions? Is it better to make this change in downstream projects, or would we be able to update `DIBuilder` quickly enough that we can avoid that? https://github.com/llvm/llvm-project/pull/124287 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -3903,6 +3903,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: Michael137 wrote: Can we not just leave this whole block in `TypeSystemClang::CompleteTagDeclarationDefinition`? That way you can just pass the `NumNegativeBits`/`NumPositiveBits` to `EnumDecl::completeDefinition` like we used to. Why do we need to move it over here? https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Add Guarded Control Stack support for Linux core files (PR #124293)
https://github.com/omjavaid approved this pull request. Looks good. Thanks! https://github.com/llvm/llvm-project/pull/124293 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 75aa5a3 - [lldb][AArch64] Add Guarded Control Stack support for Linux core files (#124293)
Author: David Spickett Date: 2025-01-28T11:32:24Z New Revision: 75aa5a35568b9e0b3eabd1e7f991a6a0f5525e0c URL: https://github.com/llvm/llvm-project/commit/75aa5a35568b9e0b3eabd1e7f991a6a0f5525e0c DIFF: https://github.com/llvm/llvm-project/commit/75aa5a35568b9e0b3eabd1e7f991a6a0f5525e0c.diff LOG: [lldb][AArch64] Add Guarded Control Stack support for Linux core files (#124293) This allows you to read the same registers as you would for a live process. As the content of proc/pid/smaps is not included in the core file, we don't get the "ss" marker that tell us that it is shadow stack. The GCS region is still in the list though. Added: lldb/test/API/linux/aarch64/gcs/corefile Modified: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h lldb/source/Plugins/Process/elf-core/RegisterUtilities.h lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py Removed: diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp index 2ddf8440aeb035..bd02bb0e69a4d3 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp @@ -69,6 +69,15 @@ RegisterContextCorePOSIX_arm64::Create(Thread &thread, const ArchSpec &arch, if (fpmr_data.GetByteSize() >= sizeof(uint64_t)) opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskFPMR); + DataExtractor gcs_data = getRegset(notes, arch.GetTriple(), AARCH64_GCS_Desc); + struct __attribute__((packed)) gcs_regs { +uint64_t features_enabled; +uint64_t features_locked; +uint64_t gcspr_e0; + }; + if (gcs_data.GetByteSize() >= sizeof(gcs_regs)) +opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskGCS); + auto register_info_up = std::make_unique(arch, opt_regsets); return std::unique_ptr( @@ -136,6 +145,9 @@ RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64( if (m_register_info_up->IsFPMRPresent()) m_fpmr_data = getRegset(notes, target_triple, AARCH64_FPMR_Desc); + if (m_register_info_up->IsGCSPresent()) +m_gcs_data = getRegset(notes, target_triple, AARCH64_GCS_Desc); + ConfigureRegisterContext(); } @@ -330,6 +342,11 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info, assert(offset < m_mte_data.GetByteSize()); value.SetFromMemoryData(*reg_info, m_mte_data.GetDataStart() + offset, reg_info->byte_size, lldb::eByteOrderLittle, error); + } else if (IsGCS(reg)) { +offset = reg_info->byte_offset - m_register_info_up->GetGCSOffset(); +assert(offset < m_gcs_data.GetByteSize()); +value.SetFromMemoryData(*reg_info, m_gcs_data.GetDataStart() + offset, +reg_info->byte_size, lldb::eByteOrderLittle, error); } else if (IsSME(reg)) { // If you had SME in the process, active or otherwise, there will at least // be a ZA header. No header, no SME at all. diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h index 35588c40c2eb1a..6140f805ffc78a 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h @@ -63,6 +63,7 @@ class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 { lldb_private::DataExtractor m_mte_data; lldb_private::DataExtractor m_zt_data; lldb_private::DataExtractor m_fpmr_data; + lldb_private::DataExtractor m_gcs_data; SVEState m_sve_state = SVEState::Unknown; uint16_t m_sve_vector_length = 0; diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h index b97279b0d735b8..59382a12cde0a2 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h +++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h @@ -148,6 +148,10 @@ constexpr RegsetDesc AARCH64_FPMR_Desc[] = { {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_FPMR}, }; +constexpr RegsetDesc AARCH64_GCS_Desc[] = { +{llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_GCS}, +}; + constexpr RegsetDesc PPC_VMX_Desc[] = { {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX}, {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX}, diff --git a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py index 797551b061a237..adbef69c5c38b0 100644 --- a/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py +++ b/lldb/test/API/linux/aarch64/gcs/TestAArch64LinuxGCS.py @@ -374,3 +37
[Lldb-commits] [lldb] [lldb][AArch64] Add Guarded Control Stack support for Linux core files (PR #124293)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/124293 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Add register fields for Guarded Control Stack registers (PR #124295)
https://github.com/omjavaid approved this pull request. Looks Good Thanks https://github.com/llvm/llvm-project/pull/124295 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6d0dd3d - [lldb][Docs] Add Guarded Control Stack to AArch64 Linux page (#117860)
Author: David Spickett Date: 2025-01-28T11:38:58Z New Revision: 6d0dd3d5c41e5b564714de9226c0623012538051 URL: https://github.com/llvm/llvm-project/commit/6d0dd3d5c41e5b564714de9226c0623012538051 DIFF: https://github.com/llvm/llvm-project/commit/6d0dd3d5c41e5b564714de9226c0623012538051.diff LOG: [lldb][Docs] Add Guarded Control Stack to AArch64 Linux page (#117860) The meat of this is how we execute expressions and deal with the aftermath. For most users this will never be a concern, so it functions more as a design doc than anything else. Added: Modified: lldb/docs/use/aarch64-linux.md Removed: diff --git a/lldb/docs/use/aarch64-linux.md b/lldb/docs/use/aarch64-linux.md index 393838dc0bb4f5..164d25cef6721e 100644 --- a/lldb/docs/use/aarch64-linux.md +++ b/lldb/docs/use/aarch64-linux.md @@ -229,3 +229,64 @@ bytes. `zt0`'s value and whether it is active or not will be saved prior to expression evaluation and restored afterwards. + +## Guarded Control Stack Extension (GCS) + +GCS support includes the following new registers: + +* `gcs_features_enabled` +* `gcs_features_locked` +* `gcspr_el0` + +These map to the registers ptrace provides. The first two have a `gcs_` +prefix added as their names are too generic without it. + +When the GCS is enabled the kernel allocates a memory region for it. This region +has a special attribute that LLDB will detect and presents like this: +``` + (lldb) memory region --all + <...> + [0xf7a0-0xf7e0) rw- + shadow stack: yes + [0xf7e0-0xf7e1) --- +``` + +`shadow stack` is a generic term used in the kernel for secure stack +extensions like GCS. + +### Expression Evaluation + +To execute an expression when GCS is enabled, LLDB must push the return +address of the expression wrapper (usually the entry point of the program) +to the Guarded Control Stack. It does this by decrementing `gcspr_el0` and +writing to the location now pointed to by `gcspr_el0` (instead of using the +GCS push instructions). + +After an expression finishes, LLDB will restore the contents of all 3 +GCS registers, apart from the enable bit of `gcs_features_enabled`. This is +because there are limits on how often and from where you can set this +bit. + +GCS cannot be enabled from ptrace and it is expected that a process which +has enabled and then disabled GCS, will not enable it again. The simplest +choice was to not restore the enable bit at all. It is up to the user or +program to manage that bit. + +The return address that LLDB pushed onto the Guarded Control Stack will be left +in place. As will any values that were pushed to the stack by functions run +during the expression. + +When the process resumes, `gcspr_el0` will be pointing to the original entry +on the guarded control stack. So the other values will have no effect and +likely be overwritten by future function calls. + +LLDB does not track and restore changes to general memory during expressions, +so not restoring the GCS contents fits with the current behaviour. + +Note that if GCS is disabled and an expression enables it, LLDB will not +be able to setup the return address and it is up to that expression to do that +if it wants to return to LLDB correctly. + +If it does not do this, the expression will fail and although most process +state will be restored, GCS will be left enabled. Which means that the program +is very unlikely to be able to progress. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Docs] Add Guarded Control Stack to AArch64 Linux page (PR #117860)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/117860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); Michael137 wrote: Oh I didn't realize you're doing this over a loop. And you're mimicking the behaviour of SemaDecl. Hmmm again this feels like something we could share with Clang. Something like `bool computeEnumBits(unsigned &NumNegativeBits, unsigned &NumPositiveBits` (where the return value implies `MembersRepresentableByInt`). Then just call it from `TypeSystemClang::CompleteTagDeclarationDefinition`. What do you think? I feel like that would reduce the diff in this patch quite nicely https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -3903,6 +3903,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: Michael137 wrote: I see why you moved it. It's because we're iterating over the enumerator values there. But i think it's still possible to do it from TypeSystemClang (see my other comment: https://github.com/llvm/llvm-project/pull/115005/files#r1931986605) https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
@@ -2367,11 +2369,38 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); Michael137 wrote: Can we not just leave this whole block in TypeSystemClang::CompleteTagDeclarationDefinition? That way you can just pass the `NumNegativeBits`/`NumPositiveBits` to `EnumDecl::completeDefinition`. Why do we need to move it over here? https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
labath wrote: > If this were super difficult, I'd be uncomfortable about telling other people > that their usages were too esoteric to support but willing to do so as a > tradeoff. But I don't think it's a good idea to do that unless we have to. > After all, you're basing the argument on common uses of vectors, but really > it should be about "the usage of any data type someone might have pointers > to, and want to see the summary of." We're providing the tools, not the uses. It's not super-difficult, but it's not free either. In particular, any user-facing API we add to support this use case is something that we may have to live with for a very long time. If the uses are there, then so be it, but I don't think that's the case, which is why I'm asking if you (or anyone) knows of something like that (and also providing some reasons as to why I think it's unlikely to exist). > > The thing I like about doing this for one level is that (as Zequan points > > out) it nicely matches what our SBValue API does, which makes most > > formatters "just work". > I still don't see the force of this argument, it's just arguing by analogy. It's not a killer argument for sure, but it's nice when things are consistent. I think this behavior is nice and consistent because the pretty printer does not have to worry about the kind of object it gets. It can just call `GetChildMemberWithName` and things will probably work. The current situation is a bit of a footgun, because you may not realize (or even want) that your formatter will work with double pointer values. And unless you're very thorough with testing, you won't even notice it until someone tries to print a double pointer and see that it prints bogus values. (And even they may not realize its a formatter problem -- they may think their program produces corrupt values). > `type summary add` and friends don't have that many options. Adding a > "pointer matching depth" option, and having --skip-pointers and > `--pointer-match-depth` be in separate option groups so you can't > accidentally provide them together would also work. I don't know how easy would it be, but another option would be to keep a single option, but treat `true` and `false` as aliases for 1 and 0, respectively. That won't help with the python API though... https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Add register fields for Guarded Control Stack registers (PR #124295)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/124295 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
@@ -5028,48 +5021,128 @@ int main(int argc, char *argv[]) { #endif // Initialize LLDB first before we do anything. - lldb::SBDebugger::Initialize(); + lldb::SBError error = lldb::SBDebugger::InitializeWithErrorHandling(); + if (error.Fail()) { +llvm::errs() << "Failed to initialize LLDB: " << error.GetCString() << "\n"; +return EXIT_FAILURE; + } // Terminate the debugger before the C++ destructor chain kicks in. auto terminate_debugger = llvm::make_scope_exit([] { lldb::SBDebugger::Terminate(); }); - DAP dap = DAP(program_path.str(), default_repl_mode); + auto HandleClient = [=](int out_fd, int err_fd, StreamDescriptor input, + StreamDescriptor output) { +DAP dap = DAP(program_path, log, default_repl_mode, pre_init_commands); +dap.input.descriptor = std::move(input); +dap.output.descriptor = std::move(output); +RegisterRequestCallbacks(dap); + +if (auto Err = dap.ConfigureIO(out_fd, err_fd)) { + if (log) +*log << "configureIO failed: " << llvm::toStringWithoutConsuming(Err) + << "\n"; + std::cerr << "failed to configureIO: " << llvm::toString(std::move(Err)) ashgti wrote: I am using `llvm::errs()` instead for reporting errors when running in server mode. https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/116392 >From 61fefbe13eaf98600d308e0873e98134fbadc452 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Tue, 28 Jan 2025 12:39:38 -0800 Subject: [PATCH] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. This adjusts the lldb-dap listening mode to accept multiple clients. Each client initializes a new instanceo of DAP and an associated lldb::SBDebugger instance. The listening mode is configured with the `--connection` option and supports listening on a port or a unix socket on supported platforms. --- .../test/tools/lldb-dap/dap_server.py | 57 +++- .../test/tools/lldb-dap/lldbdap_testcase.py | 6 +- lldb/test/API/tools/lldb-dap/server/Makefile | 3 + .../tools/lldb-dap/server/TestDAP_server.py | 84 ++ lldb/test/API/tools/lldb-dap/server/main.c| 10 + lldb/test/Shell/DAP/TestOptions.test | 4 +- lldb/tools/lldb-dap/DAP.cpp | 12 +- lldb/tools/lldb-dap/DAP.h | 5 +- lldb/tools/lldb-dap/Options.td| 22 +- lldb/tools/lldb-dap/lldb-dap.cpp | 281 +++--- 10 files changed, 351 insertions(+), 133 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/server/Makefile create mode 100644 lldb/test/API/tools/lldb-dap/server/TestDAP_server.py create mode 100644 lldb/test/API/tools/lldb-dap/server/main.c diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index c29992ce9c7848..6a71579030afcf 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -903,7 +903,7 @@ def request_setBreakpoints(self, file_path, line_array, data=None): "sourceModified": False, } if line_array is not None: -args_dict["lines"] = "%s" % line_array +args_dict["lines"] = line_array breakpoints = [] for i, line in enumerate(line_array): breakpoint_data = None @@ -1150,11 +1150,12 @@ def request_setInstructionBreakpoints(self, memory_reference=[]): } return self.send_recv(command_dict) + class DebugAdaptorServer(DebugCommunication): def __init__( self, executable=None, -port=None, +connection=None, init_commands=[], log_file=None, env=None, @@ -1167,21 +1168,61 @@ def __init__( if log_file: adaptor_env["LLDBDAP_LOG"] = log_file +args = [executable] + +if connection is not None: +args.append("--connection") +args.append(connection) + self.process = subprocess.Popen( -[executable], +args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=adaptor_env, ) + +if connection is not None: +# If the process was also launched, parse the connection from the +# resolved connection. For example, if the connection +# `connection://localhost:0` was specified then the OS would pick a +# random port for listening and lldb-dap would print the listening +# port to stdout. +if self.process is not None: +# lldb-dap will print the listening address once the listener is +# made to stdout. The listener is formatted like +# `connection://host:port` or `unix-connection:///path`. +expected_prefix = "Listening for: " +out = self.process.stdout.readline().decode() +if not out.startswith(expected_prefix): +self.process.kill() +raise ValueError( +"lldb-dap failed to print listening address, expected '{}', got '{}'".format( +expected_prefix, out +) +) + +# If the listener expanded into multiple addresses, use the first. +connection = ( + out.removeprefix(expected_prefix).rstrip("\r\n").split(",", 1)[0] +) + +if connection.startswith("unix-connect://"): # unix-connect:///path +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +s.connect(connection.removeprefix("unix-connect://")) +elif connection.startswith("connection://"): # connection://[host]:port +host, port = connection.removeprefix("connection://").rsplit(":", 1) +# create_connection with try both ipv4 and ipv6. +s = socket.create_connection((host.strip("[]"), int(port))) +el
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/116392 >From f946fd70bb550320bb153a59b8acd702dc97e75d Mon Sep 17 00:00:00 2001 From: John Harrison Date: Tue, 28 Jan 2025 12:39:38 -0800 Subject: [PATCH] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. This adjusts the lldb-dap listening mode to accept multiple clients. Each client initializes a new instance of DAP and an associated `lldb::SBDebugger` instance. The listening mode is configured with the `--connection` option and supports listening on a port or a unix socket on supported platforms. --- .../test/tools/lldb-dap/dap_server.py | 57 +++- .../test/tools/lldb-dap/lldbdap_testcase.py | 6 +- lldb/test/API/tools/lldb-dap/server/Makefile | 3 + .../tools/lldb-dap/server/TestDAP_server.py | 84 ++ lldb/test/API/tools/lldb-dap/server/main.c| 10 + lldb/test/Shell/DAP/TestOptions.test | 4 +- lldb/tools/lldb-dap/DAP.cpp | 12 +- lldb/tools/lldb-dap/DAP.h | 5 +- lldb/tools/lldb-dap/Options.td| 22 +- lldb/tools/lldb-dap/lldb-dap.cpp | 281 +++--- 10 files changed, 351 insertions(+), 133 deletions(-) create mode 100644 lldb/test/API/tools/lldb-dap/server/Makefile create mode 100644 lldb/test/API/tools/lldb-dap/server/TestDAP_server.py create mode 100644 lldb/test/API/tools/lldb-dap/server/main.c diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index c29992ce9c7848..6a71579030afcf 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -903,7 +903,7 @@ def request_setBreakpoints(self, file_path, line_array, data=None): "sourceModified": False, } if line_array is not None: -args_dict["lines"] = "%s" % line_array +args_dict["lines"] = line_array breakpoints = [] for i, line in enumerate(line_array): breakpoint_data = None @@ -1150,11 +1150,12 @@ def request_setInstructionBreakpoints(self, memory_reference=[]): } return self.send_recv(command_dict) + class DebugAdaptorServer(DebugCommunication): def __init__( self, executable=None, -port=None, +connection=None, init_commands=[], log_file=None, env=None, @@ -1167,21 +1168,61 @@ def __init__( if log_file: adaptor_env["LLDBDAP_LOG"] = log_file +args = [executable] + +if connection is not None: +args.append("--connection") +args.append(connection) + self.process = subprocess.Popen( -[executable], +args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=adaptor_env, ) + +if connection is not None: +# If the process was also launched, parse the connection from the +# resolved connection. For example, if the connection +# `connection://localhost:0` was specified then the OS would pick a +# random port for listening and lldb-dap would print the listening +# port to stdout. +if self.process is not None: +# lldb-dap will print the listening address once the listener is +# made to stdout. The listener is formatted like +# `connection://host:port` or `unix-connection:///path`. +expected_prefix = "Listening for: " +out = self.process.stdout.readline().decode() +if not out.startswith(expected_prefix): +self.process.kill() +raise ValueError( +"lldb-dap failed to print listening address, expected '{}', got '{}'".format( +expected_prefix, out +) +) + +# If the listener expanded into multiple addresses, use the first. +connection = ( + out.removeprefix(expected_prefix).rstrip("\r\n").split(",", 1)[0] +) + +if connection.startswith("unix-connect://"): # unix-connect:///path +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +s.connect(connection.removeprefix("unix-connect://")) +elif connection.startswith("connection://"): # connection://[host]:port +host, port = connection.removeprefix("connection://").rsplit(":", 1) +# create_connection with try both ipv4 and ipv6. +s = socket.create_connection((host.strip("[]"), int(port))) +e
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
jasonmolenda wrote: For lldb-server/debugserver, we might want to distinguish if the connecting lldb is old-lldb (only knows the lldb x) or new-lldb (knows lldb x and gdb x). I think in `GDBRemoteCommunicationClient::GetRemoteQSupported` lldb should add `binary-upload+` to the `features` list it sends to debugserver/lldb-server, and lldb-server/debugserver should reply with `binary-upload+` in its response. Then lldb-server/debugserver knows to send a gdb-style x, and lldb knows to expect that response. For right now, lldb-server and debugserver will default to lldb-x behavior, unless it was requested (`binary-upload+`) to use gdb-x behavior. We will switch that default behavior after a short while, when we are comfortable that old-lldb's will not be connecting to current-debugserver/lldb-servers. When lldb is sniffing the capability of the remote stub, `x0,0 -> OK` means lldb-x unambiguously. `x0,0 -> b` and `x0,0 -> Exx` are gdb-x unambiguously. Any other response (e.g. empty-packet response, indicating an unknown packet) will make lldb fall back to using the asciihex `m` packet to read memory. Does this seem like a good approach for compatibility? https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
@@ -1342,7 +1342,9 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, SBWatchpointOptions options; options.SetWatchpointTypeRead(read); puremourning wrote: It doesn't need to: It passes read bool directly to the Set... method so it's set based on the value of 'read' https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
ZequanWu wrote: > > > I'd rather keep the flexibility, if you don't mind doing the work to add > > > that. For now, it seems okay for the current libc++/libstdc++ ones to > > > declare what they support (which is 1 pointer depth). If someone has a > > > reason to come back and extend these ones in the future, that's fine but > > > a separate piece of work. > > > > > > After rethinking about the option, it will cause some compatibility issues. > > Currently, --skip-pointers is boolean option and python formatters use the > > flag lldb.eTypeOptionSkipPointers to disable/enable it. If we switch it to > > accept a numeric number, we probably need a new SBAPI to specify the > > parameter, and this will break existing users who use the > > `lldb.eTypeOptionSkipPointers` flag. > > `type summary add` and friends don't have that many options. Adding a > "pointer matching depth" option, and having --skip-pointers and > `--pointer-match-depth` be in separate option groups so you can't > accidentally provide them together would also work. I find this is tricky because all the flags for data formatters are set with `TypeSummaryImpl::Flags` which is a 4 byte unsigned integer. I could add a new unsigned integer in `TypeSummaryImpl` for that. But for users who use SBAPI to create formatters, they need to do something like `CreateWithSummaryString(..., options)` and then `SetPointerMatchDepth(depth)` to specify the pointer match depth because we cannot break the existing `CreateWithSummaryString` APIs. That looks not desired, or maybe not that bad. What do you think? https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: > > > > I'd rather keep the flexibility, if you don't mind doing the work to > > > > add that. For now, it seems okay for the current libc++/libstdc++ ones > > > > to declare what they support (which is 1 pointer depth). If someone has > > > > a reason to come back and extend these ones in the future, that's fine > > > > but a separate piece of work. > > > > > > > > > After rethinking about the option, it will cause some compatibility > > > issues. Currently, --skip-pointers is boolean option and python > > > formatters use the flag lldb.eTypeOptionSkipPointers to disable/enable > > > it. If we switch it to accept a numeric number, we probably need a new > > > SBAPI to specify the parameter, and this will break existing users who > > > use the `lldb.eTypeOptionSkipPointers` flag. > > > > > > `type summary add` and friends don't have that many options. Adding a > > "pointer matching depth" option, and having --skip-pointers and > > `--pointer-match-depth` be in separate option groups so you can't > > accidentally provide them together would also work. > > I find this is tricky because all the flags for data formatters are set with > `TypeSummaryImpl::Flags` which is a 4 byte unsigned integer. I could add a > new unsigned integer in `TypeSummaryImpl` for that. But for users who use > SBAPI to create formatters, they need to do something like > `CreateWithSummaryString(..., options)` and then > `SetPointerMatchDepth(depth)` to specify the pointer match depth because we > cannot break the existing `CreateWithSummaryString` APIs. That looks not > desired, or maybe not that bad. What do you think? If you want to preserve the current behavior, then CreateWithSummaryString should set the summary up to recurse infinitely. Then people who wanted new behavior would have to call SetPointerMatchDepth. Since that's new behavior, it's fine that the old API's don't support it. We allow overloads that are going to be unambiguous on the Python side - so we could also make a version that takes an extra depth parameter, you wouldn't have to add the API. , whenever we've made an APi that takes some set of options in the SB API's and we've done it with some bools or some flags, we always end up regretting it. We have an SBTypeSummaryOptions, maybe we should add the flags ivar to that and some API's to set it's various bits, and add the depth to that, and provide versions of the API that take this options object. But that's a bunch more work you maybe haven't signed up for... In which case, adding the depth variant would be fine too. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove PATH workaround for Android (PR #124682)
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 cc97653d534e80745a0cfb0143972e8d4dec9f74 60d2ba572b2f597f66e5876d3796d295bbb1aa27 --extensions cpp -- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 1dec7d080b..3e956290c3 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -237,8 +237,7 @@ ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) disable_aslr(info.GetFlags().Test(eLaunchFlagDisableASLR)), wd(info.GetWorkingDirectory().GetPath()), argv(info.GetArguments().GetConstArgumentVector()), - envp(info.GetEnvironment().getEnvp()), - actions(MakeForkActions(info)) {} + envp(info.GetEnvironment().getEnvp()), actions(MakeForkActions(info)) {} HostProcess ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, `` https://github.com/llvm/llvm-project/pull/124682 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove PATH workaround for Android (PR #124682)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/124682 >From 9046fce2f1ff2e4ff540e47c2daa70d1ea6df34e Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 27 Jan 2025 22:16:53 -0500 Subject: [PATCH] [lldb] Remove PATH workaround for Android --- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 7d856954684c49..3e956290c3055a 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -230,16 +230,6 @@ MakeForkActions(const ProcessLaunchInfo &info) { return result; } -static Environment::Envp FixupEnvironment(Environment env) { -#ifdef __ANDROID__ - // If there is no PATH variable specified inside the environment then set the - // path to /system/bin. It is required because the default path used by - // execve() is wrong on android. - env.try_emplace("PATH", "/system/bin"); -#endif - return env.getEnvp(); -} - ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) : separate_process_group( info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)), @@ -247,8 +237,7 @@ ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) disable_aslr(info.GetFlags().Test(eLaunchFlagDisableASLR)), wd(info.GetWorkingDirectory().GetPath()), argv(info.GetArguments().GetConstArgumentVector()), - envp(FixupEnvironment(info.GetEnvironment())), - actions(MakeForkActions(info)) {} + envp(info.GetEnvironment().getEnvp()), actions(MakeForkActions(info)) {} HostProcess ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
@@ -904,11 +928,14 @@ bool StartDebuggingRequestHandler::DoExecute( "startDebugging", llvm::json::Object{{"request", request}, {"configuration", std::move(*configuration)}}, - [](llvm::Expected value) { + [](auto dap, auto value) { ashgti wrote: Added the explicit types here instead of `auto`. https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
ashgti wrote: I've updated this after splitting parts of this off into multiple smaller patches (#118330, #118565, #122783) https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
@@ -1154,34 +1154,38 @@ class DebugAdaptorServer(DebugCommunication): def __init__( self, executable=None, +launch=True, port=None, +unix_socket=None, init_commands=[], log_file=None, env=None, ): self.process = None -if executable is not None: -adaptor_env = os.environ.copy() -if env is not None: -adaptor_env.update(env) - -if log_file: -adaptor_env["LLDBDAP_LOG"] = log_file -self.process = subprocess.Popen( -[executable], -stdin=subprocess.PIPE, -stdout=subprocess.PIPE, -stderr=subprocess.PIPE, -env=adaptor_env, +if launch: +self.process = DebugAdaptorServer.launch( +executable, +port=port, +unix_socket=unix_socket, +log_file=log_file, +env=env, ) -DebugCommunication.__init__( -self, self.process.stdout, self.process.stdin, init_commands, log_file -) -elif port is not None: + +if port: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("127.0.0.1", port)) DebugCommunication.__init__( -self, s.makefile("r"), s.makefile("w"), init_commands +self, s.makefile("rb"), s.makefile("wb"), init_commands, log_file +) +elif unix_socket: +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +s.connect(unix_socket) +DebugCommunication.__init__( +self, s.makefile("rb"), s.makefile("wb"), init_commands, log_file +) ashgti wrote: This should work with both tcp/unix sockets by parsing the `--connection` flag. https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
@@ -32,35 +34,44 @@ using namespace lldb_dap; namespace lldb_dap { -DAP::DAP(llvm::StringRef path, ReplMode repl_mode) -: debug_adaptor_path(path), broadcaster("lldb-dap"), - exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), - stop_at_entry(false), is_attach(false), +DAP::DAP(llvm::StringRef path, llvm::raw_ostream *log, ReplMode repl_mode, + std::vector pre_init_commands) +: debug_adaptor_path(path), broadcaster("lldb-dap"), log(log), + exception_breakpoints(), pre_init_commands(pre_init_commands), + focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), display_extended_backtrace(false), restarting_process_id(LLDB_INVALID_PROCESS_ID), configuration_done_sent(false), waiting_for_run_in_terminal(false), progress_event_reporter( [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }), - reverse_request_seq(0), repl_mode(repl_mode) { - const char *log_file_path = getenv("LLDBDAP_LOG"); -#if defined(_WIN32) - // Windows opens stdout and stdin in text mode which converts \n to 13,10 - // while the value is just 10 on Darwin/Linux. Setting the file mode to binary - // fixes this. - int result = _setmode(fileno(stdout), _O_BINARY); - assert(result); - result = _setmode(fileno(stdin), _O_BINARY); - UNUSED_IF_ASSERT_DISABLED(result); - assert(result); -#endif - if (log_file_path) -log.reset(new std::ofstream(log_file_path)); -} + reverse_request_seq(0), repl_mode(repl_mode) {} DAP::~DAP() = default; +llvm::Error DAP::ConfigureIO(int out_fd, int err_fd) { + llvm::Expected new_stdout_fd = + RedirectFd(out_fd, [this](llvm::StringRef data) { +SendOutput(OutputType::Stdout, data); + }); ashgti wrote: I've refactored the IO handling in #122783 to ensure the DAP instance + SBDebugger has its own dedicated file handles for the DAP session. https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)
@@ -180,8 +195,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { if (host_port->hostname == "*") host_port->hostname = "0.0.0.0"; - std::vector addresses = SocketAddress::GetAddressInfo( - host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + std::vector addresses = + SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr, +AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); ashgti wrote: Reverted https://github.com/llvm/llvm-project/pull/116392 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] LLDB: WatchAddress ignores modify option (PR #124847)
https://github.com/jasonmolenda approved this pull request. This looks good to me, thanks for fixing this. This method used to take two bools, `read`, and `write`, I redefined the second to `modified` when I changed the default watchpoints to be modify-style. The method previously had a block doing ``` -uint32_t watch_type = 0; -if (read) - watch_type |= LLDB_WATCH_TYPE_READ; -if (write) - watch_type |= LLDB_WATCH_TYPE_WRITE; ``` and in rewriting this to set an SBWatchpointOptions object, I didn't update it correctly to allow someone to request a read-only watchpoint. The test cases look good, thanks for taking the time to write those. I'd address the nit Jonas pointed out. https://github.com/llvm/llvm-project/pull/124847 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove PATH workaround for Android (PR #124682)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/124682 >From fa2ef2fb98942b4d0f52c441f29fa48063b314b4 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 27 Jan 2025 22:16:53 -0500 Subject: [PATCH] [lldb] Remove PATH workaround for Android --- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 7d856954684c49..3e956290c3055a 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -230,16 +230,6 @@ MakeForkActions(const ProcessLaunchInfo &info) { return result; } -static Environment::Envp FixupEnvironment(Environment env) { -#ifdef __ANDROID__ - // If there is no PATH variable specified inside the environment then set the - // path to /system/bin. It is required because the default path used by - // execve() is wrong on android. - env.try_emplace("PATH", "/system/bin"); -#endif - return env.getEnvp(); -} - ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) : separate_process_group( info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)), @@ -247,8 +237,7 @@ ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) disable_aslr(info.GetFlags().Test(eLaunchFlagDisableASLR)), wd(info.GetWorkingDirectory().GetPath()), argv(info.GetArguments().GetConstArgumentVector()), - envp(FixupEnvironment(info.GetEnvironment())), - actions(MakeForkActions(info)) {} + envp(info.GetEnvironment().getEnvp()), actions(MakeForkActions(info)) {} HostProcess ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add RISCV for Makefile.rules (PR #124758)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (kper) Changes As discussed with @DavidSpickett in discord. Running the test runner caused the following issue: ``` gmake: Entering directory '/home/kper/oss/llvm-project/build/lldb-test-build.noindex/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.test' /home/kper/oss/llvm-project/build/bin/clang++ -std=c++11 -g -O0 -mriscv -I/home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/kper/oss/llvm-project/build/tools/lldb/include -I/home/kper/oss/llvm-project/lldb/test/API/functionalities/thread/concurrent_events -I/home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info --driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o /home/kper/oss/llvm-project/lldb/test/API/functionalities/thread/concurrent_events/main.cpp clang++: error: unknown argument: '-mriscv' gmake: *** [Makefile.rules:619: main.o] Error 1 ``` By overriding the flags, we avoid the `-mriscv`. --- Full diff: https://github.com/llvm/llvm-project/pull/124758.diff 1 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+4) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 2da6ff226b615c..06959f226066ac 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -207,6 +207,10 @@ else override ARCH := override ARCHFLAG := endif + ifeq "$(ARCH)" "riscv" + override ARCH := + override ARCHFLAG := + endif ifeq "$(findstring mips,$(ARCH))" "mips" override ARCHFLAG := - endif `` https://github.com/llvm/llvm-project/pull/124758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add RISCV for Makefile.rules (PR #124758)
https://github.com/kper created https://github.com/llvm/llvm-project/pull/124758 As discussed with @DavidSpickett in discord. Running the test runner caused the following issue: ``` gmake: Entering directory '/home/kper/oss/llvm-project/build/lldb-test-build.noindex/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.test' /home/kper/oss/llvm-project/build/bin/clang++ -std=c++11 -g -O0 -mriscv -I/home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/kper/oss/llvm-project/build/tools/lldb/include -I/home/kper/oss/llvm-project/lldb/test/API/functionalities/thread/concurrent_events -I/home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/kper/oss/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info --driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o /home/kper/oss/llvm-project/lldb/test/API/functionalities/thread/concurrent_events/main.cpp clang++: error: unknown argument: '-mriscv' gmake: *** [Makefile.rules:619: main.o] Error 1 ``` By overriding the flags, we avoid the `-mriscv`. >From 4ea5df2aae805fab0ace107b6f9e4b9b9c19b2f3 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 28 Jan 2025 14:44:44 + Subject: [PATCH] lldb: Add RISCV for Makefile.rules --- lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 4 1 file changed, 4 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 2da6ff226b615c..06959f226066ac 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -207,6 +207,10 @@ else override ARCH := override ARCHFLAG := endif + ifeq "$(ARCH)" "riscv" + override ARCH := + override ARCHFLAG := + endif ifeq "$(findstring mips,$(ARCH))" "mips" override ARCHFLAG := - endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
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 f8ab91f74f152c8a6d8aaedb8165109c497a618d...be1c2a0b1b2014b66fe0f4418230395a25016cc8 lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py `` View the diff from darker here. ``diff --- gdb_remote_client/TestGDBServerTargetXML.py 2025-01-28 15:23:54.00 + +++ gdb_remote_client/TestGDBServerTargetXML.py 2025-01-28 16:33:09.693976 + @@ -658,44 +658,42 @@ def test_riscv64_regs(self): """Test grabbing various riscv64 registers from gdbserver.""" class MyResponder(MockGDBServerResponder): reg_data = ( -( -"0102030405060708" # zero -"0102030405060708" # ra -"0102030405060708" # sp -"0102030405060708" # gp -"0102030405060708" # tp -"0102030405060708" # t0 -"0102030405060708" # t1 -"0102030405060708" # t2 -"0102030405060708" # fp -"0102030405060708" # s1 -"0102030405060708" # a0 -"0102030405060708" # a1 -"0102030405060708" # a2 -"0102030405060708" # a3 -"0102030405060708" # a4 -"0102030405060708" # a5 -"0102030405060708" # a6 -"0102030405060708" # a7 -"0102030405060708" # s2 -"0102030405060708" # s3 -"0102030405060708" # s4 -"0102030405060708" # s5 -"0102030405060708" # s6 -"0102030405060708" # s7 -"0102030405060708" # s8 -"0102030405060708" # s9 -"0102030405060708" # s10 -"0102030405060708" # s11 -"0102030405060708" # t3 -"0102030405060708" # t4 -"0102030405060708" # t5 -"0102030405060708" # t6 -) +"0102030405060708" # zero +"0102030405060708" # ra +"0102030405060708" # sp +"0102030405060708" # gp +"0102030405060708" # tp +"0102030405060708" # t0 +"0102030405060708" # t1 +"0102030405060708" # t2 +"0102030405060708" # fp +"0102030405060708" # s1 +"0102030405060708" # a0 +"0102030405060708" # a1 +"0102030405060708" # a2 +"0102030405060708" # a3 +"0102030405060708" # a4 +"0102030405060708" # a5 +"0102030405060708" # a6 +"0102030405060708" # a7 +"0102030405060708" # s2 +"0102030405060708" # s3 +"0102030405060708" # s4 +"0102030405060708" # s5 +"0102030405060708" # s6 +"0102030405060708" # s7 +"0102030405060708" # s8 +"0102030405060708" # s9 +"0102030405060708" # s10 +"0102030405060708" # s11 +"0102030405060708" # t3 +"0102030405060708" # t4 +"0102030405060708" # t5 +"0102030405060708" ) def qXferRead(self, obj, annex, offset, length): if annex == "target.xml": return ( @@ -797,11 +795,10 @@ self.match("register read x27", ["s11 = 0x0807060504030201"]) self.match("register read x28", ["t3 = 0x0807060504030201"]) self.match("register read x29", ["t4 = 0x0807060504030201"]) self.match("register read x30", ["t5 = 0x0807060504030201"]) self.match("register read x31", ["t6 = 0x0807060504030201"]) - @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("X86") def test_x86_64_no_duplicate_subregs(self): `` https://github.com/llvm/llvm-project/pull/124475 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes See also https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288 and https://sourceware.org/pipermail/gdb/2025-January/051705.html --- Full diff: https://github.com/llvm/llvm-project/pull/124733.diff 5 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/gdbclientutils.py (+6) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+13-9) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (+7-2) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+23-13) - (added) lldb/test/API/functionalities/gdb_remote_client/TestReadMemory.py (+36) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 1784487323ad6b..4b782b3b470fe2 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -126,6 +126,9 @@ def respond(self, packet): if packet[0] == "m": addr, length = [int(x, 16) for x in packet[1:].split(",")] return self.readMemory(addr, length) +if packet[0] == "x": +addr, length = [int(x, 16) for x in packet[1:].split(",")] +return self.x(addr, length) if packet[0] == "M": location, encoded_data = packet[1:].split(":") addr, length = [int(x, 16) for x in location.split(",")] @@ -267,6 +270,9 @@ def writeRegister(self, register, value_hex): def readMemory(self, addr, length): return "00" * length +def x(self, addr, length): +return "" + def writeMemory(self, addr, data_hex): return "OK" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index b3f1c6f052955b..581dd8f8e0b6b6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -275,7 +275,6 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_supports_p = eLazyBoolCalculate; -m_supports_x = eLazyBoolCalculate; m_supports_QSaveRegisterState = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_curr_pid_is_valid = eLazyBoolCalculate; @@ -295,6 +294,7 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; +m_x_packet_state.reset(); m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; m_supports_qUserName = true; @@ -348,6 +348,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_memory_tagging = eLazyBoolNo; m_supports_qSaveCore = eLazyBoolNo; m_uses_native_signals = eLazyBoolNo; + m_x_packet_state.reset(); m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if // not, we assume no limit @@ -401,6 +402,8 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qSaveCore = eLazyBoolYes; else if (x == "native-signals+") m_uses_native_signals = eLazyBoolYes; + else if (x == "binary-upload+") +m_x_packet_state = xPacketState::Prefixed; // Look for a list of compressions in the features list e.g. // qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib- // deflate,lzma @@ -715,19 +718,20 @@ Status GDBRemoteCommunicationClient::WriteMemoryTags( return status; } -bool GDBRemoteCommunicationClient::GetxPacketSupported() { - if (m_supports_x == eLazyBoolCalculate) { +GDBRemoteCommunicationClient::xPacketState +GDBRemoteCommunicationClient::GetxPacketState() { + if (!m_x_packet_state) +GetRemoteQSupported(); + if (!m_x_packet_state) { StringExtractorGDBRemote response; -m_supports_x = eLazyBoolNo; -char packet[256]; -snprintf(packet, sizeof(packet), "x0,0"); -if (SendPacketAndWaitForResponse(packet, response) == +m_x_packet_state = xPacketState::Unimplemented; +if (SendPacketAndWaitForResponse("x0,0", response) == PacketResult::Success) { if (response.IsOKResponse()) -m_supports_x = eLazyBoolYes; +m_x_packet_state = xPacketState::Bare; } } - return m_supports_x; + return *m_x_packet_state; } lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugi
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
https://github.com/kper updated https://github.com/llvm/llvm-project/pull/124475 >From 096eb85718d70721cec1e539cfa4b05a96475c7a Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sun, 26 Jan 2025 17:34:17 + Subject: [PATCH 1/3] lldb: Extended if conditions to support alias names for registers --- .../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 54 +++ 1 file changed, 54 insertions(+) diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 8412991933d277..c463bd006b3db4 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo( it.value().alt_name.SetCString("x3"); else if (it.value().name == "fp") it.value().alt_name.SetCString("s0"); +else if (it.value().name == "tp") + it.value().alt_name.SetCString("x4"); else if (it.value().name == "s0") it.value().alt_name.SetCString("x8"); +else if (it.value().name == "s1") + it.value().alt_name.SetCString("x9"); +else if (it.value().name == "t0") + it.value().alt_name.SetCString("x5"); +else if (it.value().name == "t1") + it.value().alt_name.SetCString("x6"); +else if (it.value().name == "t2") + it.value().alt_name.SetCString("x7"); +else if (it.value().name == "a0") + it.value().alt_name.SetCString("x10"); +else if (it.value().name == "a1") + it.value().alt_name.SetCString("x11"); +else if (it.value().name == "a2") + it.value().alt_name.SetCString("x12"); +else if (it.value().name == "a3") + it.value().alt_name.SetCString("x13"); +else if (it.value().name == "a4") + it.value().alt_name.SetCString("x14"); +else if (it.value().name == "a5") + it.value().alt_name.SetCString("x15"); +else if (it.value().name == "a6") + it.value().alt_name.SetCString("x16"); +else if (it.value().name == "a7") + it.value().alt_name.SetCString("x17"); +else if (it.value().name == "s2") + it.value().alt_name.SetCString("x18"); +else if (it.value().name == "s3") + it.value().alt_name.SetCString("x19"); +else if (it.value().name == "s4") + it.value().alt_name.SetCString("x20"); +else if (it.value().name == "s5") + it.value().alt_name.SetCString("x21"); +else if (it.value().name == "s6") + it.value().alt_name.SetCString("x22"); +else if (it.value().name == "s7") + it.value().alt_name.SetCString("x23"); +else if (it.value().name == "s8") + it.value().alt_name.SetCString("x24"); +else if (it.value().name == "s9") + it.value().alt_name.SetCString("x25"); +else if (it.value().name == "s10") + it.value().alt_name.SetCString("x26"); +else if (it.value().name == "s11") + it.value().alt_name.SetCString("x27"); +else if (it.value().name == "t3") + it.value().alt_name.SetCString("x28"); +else if (it.value().name == "t4") + it.value().alt_name.SetCString("x29"); +else if (it.value().name == "t5") + it.value().alt_name.SetCString("x30"); +else if (it.value().name == "t6") + it.value().alt_name.SetCString("x31"); // Set generic regnum so lldb knows what the PC, etc is it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef()); >From ad3dfa270953a04f755773c402941fd10165a098 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 28 Jan 2025 15:23:54 + Subject: [PATCH 2/3] Added RISCV reg test for the ServerTargetXML --- .../TestGDBServerTargetXML.py | 149 ++ 1 file changed, 149 insertions(+) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py index 22f5553e40802d..c74726a88aa6ff 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py @@ -652,6 +652,155 @@ def haltReason(self): ) self.match("register read s31", ["s31 = 128"]) +@skipIfXmlSupportMissing +@skipIfRemote +@skipIfLLVMTargetMissing("RISCV") +def test_riscv64_regs(self): +"""Test grabbing various riscv64 registers from gdbserver.""" + +class MyResponder(MockGDBServerResponder): +reg_data = ( +( +"0102030405060708" # zero +"0102030405060708" # ra +"0102030405060708" # sp +"0102030405060708" # gp +"0102030405060708" # tp +"0102030405060708" # t0 +"0102030405060708" # t1 +"0102030405060708" # t2 +"0102030405060708" # fp +"0102030405060708" # s1 +"0102030405060708" # a0 +"01
[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)
jmorse wrote: Prototype here https://github.com/jmorse/llvm-project/commit/8e68a722e0e2925f042cd6479f8b86578ba3042d , is that the sort of thing that would be useful? It's lacking unit test coverage right now. https://github.com/llvm/llvm-project/pull/124287 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)
hvdijk wrote: Yes, thank you, something like that looks great! I should be able to do some testing with that tomorrow to check to make sure I am not missing anything. https://github.com/llvm/llvm-project/pull/124287 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add RISCV for Makefile.rules (PR #124758)
https://github.com/DavidSpickett approved this pull request. LGTM, thanks. My understanding of this is it generates `-m64` and `-m32` flags for architectures that need it, and RISC-V is not one of those. (I have heard of toolchains with both 32 and 64 bit but they use a different triple for each iirc) https://github.com/llvm/llvm-project/pull/124758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
kper wrote: I have created two tests. However, it turned out that `register read x8` is not working. I think, there is some edge case because it has `fp` and `s0`. I am not sure whether to try to fix this in this PR or another one? https://github.com/llvm/llvm-project/pull/124475 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
labath wrote: Gdb uses the same feature string to detect the packet, and a version with that fix is going to released soon. I've tested that an lldb with this patch can communicate with gdbserver with the fix (at least that they get far enough to start reading memory). (We are also able to communicate with the gdbserver without that fix, but in that case we do that using the `m` packets (because gdbserver does not respond `OK` to our `x0,0` probe)) https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0cf6714 - [lldb][AArch64] Fix GCS register field detection
Author: David Spickett Date: 2025-01-28T13:50:58Z New Revision: 0cf6714279d4146ee5d6a5e34195d6fae56ed475 URL: https://github.com/llvm/llvm-project/commit/0cf6714279d4146ee5d6a5e34195d6fae56ed475 DIFF: https://github.com/llvm/llvm-project/commit/0cf6714279d4146ee5d6a5e34195d6fae56ed475.diff LOG: [lldb][AArch64] Fix GCS register field detection Fixes c5840cc609a3674cf7453a45946f7e4a2a73590b. On platforms where UL is 32 bit, like Windows or 32 bit Linux, this shift was not correct, so we assumed GCS was not present. Use ULL instead, to match the other HWCAP constants. Added: Modified: lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp Removed: diff --git a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp index 1438a45f37d724..042940b7dff6e0 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp @@ -17,7 +17,7 @@ #define HWCAP_ASIMDHP (1ULL << 10) #define HWCAP_DIT (1ULL << 24) #define HWCAP_SSBS (1ULL << 28) -#define HWCAP_GCS (1UL << 32) +#define HWCAP_GCS (1ULL << 32) #define HWCAP2_BTI (1ULL << 17) #define HWCAP2_MTE (1ULL << 18) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove PATH workaround for Android (PR #124682)
enh-google wrote: > Let's delete the FixupEnvironment function as well (replace it with a direct > `env.getEnvp() call`) -- it only exists to hide the android hack. +1 --- seems weird to say "fix up" when doing nothing. otherwise lgtm... https://github.com/llvm/llvm-project/pull/124682 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for gdb-style 'x' packet (PR #124733)
https://github.com/labath ready_for_review https://github.com/llvm/llvm-project/pull/124733 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update API headers for SBProgress (PR #124836)
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/124836 Some clients only include LLDB.h and they won't get access to SBProgress without this. >From f740e0f6fd3a355dc427c6e5b6de823bd6182426 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 28 Jan 2025 12:57:21 -0800 Subject: [PATCH] [lldb] Update API headers for SBProgress Some clients only include LLDB.h and they won't get access to SBProgress without this. --- lldb/include/lldb/API/LLDB.h | 1 + lldb/include/lldb/API/SBDefines.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index 40368e036e0e40..126fcef31b4166 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -54,6 +54,7 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBProcessInfo.h" #include "lldb/API/SBProcessInfoList.h" +#include "lldb/API/SBProgress.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBReproducer.h" diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 159a9ba799b181..31e8c9279f8b8b 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -95,6 +95,7 @@ class LLDB_API SBPlatformShellCommand; class LLDB_API SBProcess; class LLDB_API SBProcessInfo; class LLDB_API SBProcessInfoList; +class LLDB_API SBProgress; class LLDB_API SBQueue; class LLDB_API SBQueueItem; class LLDB_API SBReplayOptions; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update API headers for SBProgress (PR #124836)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alex Langford (bulbazord) Changes Some clients only include LLDB.h and they won't get access to SBProgress without this. --- Full diff: https://github.com/llvm/llvm-project/pull/124836.diff 2 Files Affected: - (modified) lldb/include/lldb/API/LLDB.h (+1) - (modified) lldb/include/lldb/API/SBDefines.h (+1) ``diff diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index 40368e036e0e40..126fcef31b4166 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -54,6 +54,7 @@ #include "lldb/API/SBProcess.h" #include "lldb/API/SBProcessInfo.h" #include "lldb/API/SBProcessInfoList.h" +#include "lldb/API/SBProgress.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBReproducer.h" diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 159a9ba799b181..31e8c9279f8b8b 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -95,6 +95,7 @@ class LLDB_API SBPlatformShellCommand; class LLDB_API SBProcess; class LLDB_API SBProcessInfo; class LLDB_API SBProcessInfoList; +class LLDB_API SBProgress; class LLDB_API SBQueue; class LLDB_API SBQueueItem; class LLDB_API SBReplayOptions; `` https://github.com/llvm/llvm-project/pull/124836 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
https://github.com/kper updated https://github.com/llvm/llvm-project/pull/124475 >From 096eb85718d70721cec1e539cfa4b05a96475c7a Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sun, 26 Jan 2025 17:34:17 + Subject: [PATCH 1/5] lldb: Extended if conditions to support alias names for registers --- .../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 54 +++ 1 file changed, 54 insertions(+) diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index 8412991933d277..c463bd006b3db4 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo( it.value().alt_name.SetCString("x3"); else if (it.value().name == "fp") it.value().alt_name.SetCString("s0"); +else if (it.value().name == "tp") + it.value().alt_name.SetCString("x4"); else if (it.value().name == "s0") it.value().alt_name.SetCString("x8"); +else if (it.value().name == "s1") + it.value().alt_name.SetCString("x9"); +else if (it.value().name == "t0") + it.value().alt_name.SetCString("x5"); +else if (it.value().name == "t1") + it.value().alt_name.SetCString("x6"); +else if (it.value().name == "t2") + it.value().alt_name.SetCString("x7"); +else if (it.value().name == "a0") + it.value().alt_name.SetCString("x10"); +else if (it.value().name == "a1") + it.value().alt_name.SetCString("x11"); +else if (it.value().name == "a2") + it.value().alt_name.SetCString("x12"); +else if (it.value().name == "a3") + it.value().alt_name.SetCString("x13"); +else if (it.value().name == "a4") + it.value().alt_name.SetCString("x14"); +else if (it.value().name == "a5") + it.value().alt_name.SetCString("x15"); +else if (it.value().name == "a6") + it.value().alt_name.SetCString("x16"); +else if (it.value().name == "a7") + it.value().alt_name.SetCString("x17"); +else if (it.value().name == "s2") + it.value().alt_name.SetCString("x18"); +else if (it.value().name == "s3") + it.value().alt_name.SetCString("x19"); +else if (it.value().name == "s4") + it.value().alt_name.SetCString("x20"); +else if (it.value().name == "s5") + it.value().alt_name.SetCString("x21"); +else if (it.value().name == "s6") + it.value().alt_name.SetCString("x22"); +else if (it.value().name == "s7") + it.value().alt_name.SetCString("x23"); +else if (it.value().name == "s8") + it.value().alt_name.SetCString("x24"); +else if (it.value().name == "s9") + it.value().alt_name.SetCString("x25"); +else if (it.value().name == "s10") + it.value().alt_name.SetCString("x26"); +else if (it.value().name == "s11") + it.value().alt_name.SetCString("x27"); +else if (it.value().name == "t3") + it.value().alt_name.SetCString("x28"); +else if (it.value().name == "t4") + it.value().alt_name.SetCString("x29"); +else if (it.value().name == "t5") + it.value().alt_name.SetCString("x30"); +else if (it.value().name == "t6") + it.value().alt_name.SetCString("x31"); // Set generic regnum so lldb knows what the PC, etc is it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef()); >From ad3dfa270953a04f755773c402941fd10165a098 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 28 Jan 2025 15:23:54 + Subject: [PATCH 2/5] Added RISCV reg test for the ServerTargetXML --- .../TestGDBServerTargetXML.py | 149 ++ 1 file changed, 149 insertions(+) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py index 22f5553e40802d..c74726a88aa6ff 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py @@ -652,6 +652,155 @@ def haltReason(self): ) self.match("register read s31", ["s31 = 128"]) +@skipIfXmlSupportMissing +@skipIfRemote +@skipIfLLVMTargetMissing("RISCV") +def test_riscv64_regs(self): +"""Test grabbing various riscv64 registers from gdbserver.""" + +class MyResponder(MockGDBServerResponder): +reg_data = ( +( +"0102030405060708" # zero +"0102030405060708" # ra +"0102030405060708" # sp +"0102030405060708" # gp +"0102030405060708" # tp +"0102030405060708" # t0 +"0102030405060708" # t1 +"0102030405060708" # t2 +"0102030405060708" # fp +"0102030405060708" # s1 +"0102030405060708" # a0 +"01