[Lldb-commits] [lldb] [lldb-dap] Rename `enableDisplayExtendedBacktrace` (PR #109521)
https://github.com/jeffreytan81 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/109521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Rename `enableDisplayExtendedBacktrace` (PR #109521)
https://github.com/vogelsgesang created https://github.com/llvm/llvm-project/pull/109521 The `enable` prefix is a filler word which adds no additional information. Rename the setting to `displayExtendedBacktrace` Given that this setitng was only introduced a month ago, and that there has not been any release since then, I assume that usage is still rather low. As such, it should be fine to not provide backwards-compatibility workarounds. >From 8b58b2ecd246d18fc3e6f24b5cf5f68184145966 Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Sat, 21 Sep 2024 08:11:47 + Subject: [PATCH] [lldb-dap] Rename `enableDisplayExtendedBacktrace` The `enable` prefix is a filler word which adds no additional information. Rename the setting to `displayExtendedBacktrace` Given that this setitng was only introduced a month ago, and that there has not been any release since then, I assume that usage is still rather low. As such, it should be fine to not provide backwards-compatibility workarounds. --- .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 4 ++-- .../lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py | 8 .../extendedStackTrace/TestDAP_extendedStackTrace.py | 2 +- lldb/tools/lldb-dap/DAP.cpp| 2 +- lldb/tools/lldb-dap/DAP.h | 2 +- lldb/tools/lldb-dap/README.md | 4 ++-- lldb/tools/lldb-dap/lldb-dap.cpp | 10 +- lldb/tools/lldb-dap/package.json | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index bbd701efa3a666..449af1b67d8022 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 @@ -778,7 +778,7 @@ def request_launch( runInTerminal=False, postRunCommands=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -831,7 +831,7 @@ def request_launch( args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries args_dict["enableSyntheticChildDebugging"] = enableSyntheticChildDebugging -args_dict["enableDisplayExtendedBacktrace"] = enableDisplayExtendedBacktrace +args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace args_dict["commandEscapePrefix"] = commandEscapePrefix command_dict = {"command": "launch", "type": "request", "arguments": args_dict} response = self.send_recv(command_dict) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 7b192d62881729..7e80912be44642 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -386,7 +386,7 @@ def launch( expectFailure=False, postRunCommands=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -428,7 +428,7 @@ def cleanup(): runInTerminal=runInTerminal, postRunCommands=postRunCommands, enableAutoVariableSummaries=enableAutoVariableSummaries, -enableDisplayExtendedBacktrace=enableDisplayExtendedBacktrace, +displayExtendedBacktrace=displayExtendedBacktrace, enableSyntheticChildDebugging=enableSyntheticChildDebugging, commandEscapePrefix=commandEscapePrefix, customFrameFormat=customFrameFormat, @@ -468,7 +468,7 @@ def build_and_launch( postRunCommands=None, lldbDAPEnv=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -505,7 +505,7 @@ def build_and_launch( postRunCommands=postRunCommands, enableAutoVariableSummaries=enableAutoVariableSummaries, enableSyntheticChildDebugging=enableSyntheticChildDebugging, -enableDisplayExtendedBacktrace=enableDisplayExtendedBacktrace, +displayExtendedBacktrace=displayExtendedBacktrace, commandEscapePrefix=commandEscapePrefix, customFrameFormat=customFrameFormat, customThreadFormat=customThreadFormat, diff --git a/lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_
[Lldb-commits] [lldb] [lldb-dap] Rename `enableDisplayExtendedBacktrace` (PR #109521)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Adrian Vogelsgesang (vogelsgesang) Changes The `enable` prefix is a filler word which adds no additional information. Rename the setting to `displayExtendedBacktrace` Given that this setitng was only introduced a month ago, and that there has not been any release since then, I assume that usage is still rather low. As such, it should be fine to not provide backwards-compatibility workarounds. --- Full diff: https://github.com/llvm/llvm-project/pull/109521.diff 8 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py (+2-2) - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+4-4) - (modified) lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py (+1-1) - (modified) lldb/tools/lldb-dap/DAP.cpp (+1-1) - (modified) lldb/tools/lldb-dap/DAP.h (+1-1) - (modified) lldb/tools/lldb-dap/README.md (+2-2) - (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+5-5) - (modified) lldb/tools/lldb-dap/package.json (+2-2) ``diff 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 bbd701efa3a666..449af1b67d8022 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 @@ -778,7 +778,7 @@ def request_launch( runInTerminal=False, postRunCommands=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -831,7 +831,7 @@ def request_launch( args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries args_dict["enableSyntheticChildDebugging"] = enableSyntheticChildDebugging -args_dict["enableDisplayExtendedBacktrace"] = enableDisplayExtendedBacktrace +args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace args_dict["commandEscapePrefix"] = commandEscapePrefix command_dict = {"command": "launch", "type": "request", "arguments": args_dict} response = self.send_recv(command_dict) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 7b192d62881729..7e80912be44642 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -386,7 +386,7 @@ def launch( expectFailure=False, postRunCommands=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -428,7 +428,7 @@ def cleanup(): runInTerminal=runInTerminal, postRunCommands=postRunCommands, enableAutoVariableSummaries=enableAutoVariableSummaries, -enableDisplayExtendedBacktrace=enableDisplayExtendedBacktrace, +displayExtendedBacktrace=displayExtendedBacktrace, enableSyntheticChildDebugging=enableSyntheticChildDebugging, commandEscapePrefix=commandEscapePrefix, customFrameFormat=customFrameFormat, @@ -468,7 +468,7 @@ def build_and_launch( postRunCommands=None, lldbDAPEnv=None, enableAutoVariableSummaries=False, -enableDisplayExtendedBacktrace=False, +displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, commandEscapePrefix=None, customFrameFormat=None, @@ -505,7 +505,7 @@ def build_and_launch( postRunCommands=postRunCommands, enableAutoVariableSummaries=enableAutoVariableSummaries, enableSyntheticChildDebugging=enableSyntheticChildDebugging, -enableDisplayExtendedBacktrace=enableDisplayExtendedBacktrace, +displayExtendedBacktrace=displayExtendedBacktrace, commandEscapePrefix=commandEscapePrefix, customFrameFormat=customFrameFormat, customThreadFormat=customThreadFormat, diff --git a/lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py b/lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py index 0cc8534daf4e94..ba35ea9e0b64e6 100644 --- a/lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py +++ b/lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py @@ -36,7 +36,7 @@ def test_stackTrace(self): "DYLD_LIBRARY_PATH=/usr/lib/system/introspection", "DYLD_INSERT_LIBRARIES=" + backtrace_recording_lib
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
@@ -0,0 +1,67 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibCxxInternalsRecognizerTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +@add_test_categories(["libc++"]) +def test_frame_recognizer(self): +"""Test that implementation details of libc++ are hidden""" +self.build() +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "break here", lldb.SBFileSpec("main.cpp") +) + +expected_parents = { +"sort_less(int, int)": ["::sort", "test_algorithms"], +# `std::ranges::sort` is implemented as an object of types `__sort`. frederick-vs-ja wrote: There're a large number of such customization point objects (and niebloids, which will be respecified as CPOs soon, see [P3136R0](https://wg21.link/p3136r0)) since C++20. Should we invent some convention to recognize them uniformly? https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
@@ -0,0 +1,67 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibCxxInternalsRecognizerTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +@add_test_categories(["libc++"]) +def test_frame_recognizer(self): +"""Test that implementation details of libc++ are hidden""" +self.build() +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "break here", lldb.SBFileSpec("main.cpp") +) + +expected_parents = { +"sort_less(int, int)": ["::sort", "test_algorithms"], +# `std::ranges::sort` is implemented as an object of types `__sort`. vogelsgesang wrote: Not sure that would be necessary. With the current heuristic ("never hide a frame which was immediately called from user code"), the end result to the user is fine, despite the debug info containing the `__sort::operator()` function name https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Rename `enableDisplayExtendedBacktrace` (PR #109521)
https://github.com/vogelsgesang edited https://github.com/llvm/llvm-project/pull/109521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/108870 >From 04daaac0eade25a439856bbb287e15860aba1dfd Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Tue, 27 Aug 2024 17:34:11 + Subject: [PATCH 1/5] [lldb][libc++] Hide all libc++ implementation details from stacktraces This commit changes the libc++ frame recognizer to hide implementation details of libc++ more aggressively. The applied heuristic is rather straightforward: We consider every function name starting with `__` as an implementation detail. This works pretty neatly for `std::invoke`, `std::function`, `std::sort`, `std::map::emplace` and many others. Also, this should align quite nicely with libc++'s general coding convention of using the `__` for their implementation details, thereby keeping the future maintenance effort low. However, it is noteworthy, that this does not work 100% in all cases: E.g., for `std::ranges::sort`, itself is not really a function call, but an object with an overloaded `operator()`, which means that there is no actual call `std::ranges::sort` in the call stack. --- libcxx/docs/UserDocumentation.rst | 26 ++ .../CPlusPlus/CPPLanguageRuntime.cpp | 27 ++ .../cpp/libcxx-internals-recognizer/Makefile | 5 ++ .../TestLibcxxInternalsRecognizer.py | 56 .../cpp/libcxx-internals-recognizer/main.cpp | 86 +++ 5 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/Makefile create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/main.cpp diff --git a/libcxx/docs/UserDocumentation.rst b/libcxx/docs/UserDocumentation.rst index 6659fa54f49df5..8999b4f23e91d2 100644 --- a/libcxx/docs/UserDocumentation.rst +++ b/libcxx/docs/UserDocumentation.rst @@ -346,6 +346,32 @@ Third-party Integrations Libc++ provides integration with a few third-party tools. +Debugging libc++ internals in LLDB +-- + +LLDB hides the implementation details of libc++ by default. + +E.g., when setting a breakpoint in a comparator passed to ``std::sort``, the +backtrace will read as + +.. code-block:: + + (lldb) thread backtrace + * thread #1, name = 'a.out', stop reason = breakpoint 3.1 +* frame #0: 0x520e a.out`my_comparator(a=1, b=8) at test-std-sort.cpp:6:3 + frame #7: 0x5615 a.out`void std::__1::sort[abi:ne20], bool (*)(int, int)>(__first=(item = 8), __last=(item = 0), __comp=(a.out`my_less(int, int) at test-std-sort.cpp:5)) at sort.h:1003:3 + frame #8: 0x531a a.out`main at test-std-sort.cpp:24:3 + +Note how the caller of ``my_comparator`` is shown as ``std::sort``. Looking at +the frame numbers, we can see that frames #1 until #6 were hidden. Those frames +represent internal implementation details such as ``__sort4`` and similar +utility functions. + +To also show those implementation details, use ``thread backtrace -u``. +Alternatively, to disable those compact backtraces for good, use +``frame recognizer list`` and ``frame recognizer delete`` to delete the libc++ +frame recognizer. + GDB Pretty printers for libc++ -- diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index faa05e8f834ea1..d0e84bdeb94f01 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -45,7 +45,7 @@ char CPPLanguageRuntime::ID = 0; /// A frame recognizer that is installed to hide libc++ implementation /// details from the backtrace. class LibCXXFrameRecognizer : public StackFrameRecognizer { - std::array m_hidden_regex; + std::array m_hidden_regex; RecognizedStackFrameSP m_hidden_frame; struct LibCXXHiddenFrame : public RecognizedStackFrame { @@ -55,28 +55,17 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer { public: LibCXXFrameRecognizer() : m_hidden_regex{ -// internal implementation details of std::function +// internal implementation details in the `std::` namespace //std::__1::__function::__alloc_func, void ()>::operator()[abi:ne20] //std::__1::__function::__func, void ()>::operator() //std::__1::__function::__value_func::operator()[abi:ne20]() const -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. - R"(__function::.*::operator\(\))"}, -// internal implementation details of std::function in ABI v2 //std::__2::__function::__policy_invoker::__call_impl[abi:ne20]> -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. -
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
https://github.com/vogelsgesang edited https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Implement value locations for function pointers (PR #104589)
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/104589 >From a7876a20b5caa53dace056c84a1b7f1e798088f0 Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Mon, 12 Aug 2024 14:53:31 + Subject: [PATCH 1/4] [lldb-dap] Implement value locations for function pointers This commit adds `valueLocationReference` to function pointers and function references. Thereby, users can navigate directly to the pointed-to function from within the "variables" pane. In general, it would be useful to also a similar location references also to member function pointers, `std::source_location`, `std::function`, and many more. Doing so would require extending the formatters to provide such a source code location. There were two RFCs about this a while ago: https://discourse.llvm.org/t/rfc-extending-formatters-with-a-source-code-reference/68375 https://discourse.llvm.org/t/rfc-sbvalue-metadata-provider/68377/26 However, both RFCs ended without a conclusion. As such, this commit now solve the lowest-hanging fruit, i.e. function pointers. If people find it useful, I will revive the RFC afterwards. --- .../API/tools/lldb-dap/locations/Makefile | 2 +- .../lldb-dap/locations/TestDAP_locations.py | 49 +++- lldb/test/API/tools/lldb-dap/locations/main.c | 5 - .../API/tools/lldb-dap/locations/main.cpp | 11 ++ lldb/tools/lldb-dap/JSONUtils.cpp | 33 - lldb/tools/lldb-dap/JSONUtils.h | 3 + lldb/tools/lldb-dap/lldb-dap.cpp | 113 +- 7 files changed, 176 insertions(+), 40 deletions(-) delete mode 100644 lldb/test/API/tools/lldb-dap/locations/main.c create mode 100644 lldb/test/API/tools/lldb-dap/locations/main.cpp diff --git a/lldb/test/API/tools/lldb-dap/locations/Makefile b/lldb/test/API/tools/lldb-dap/locations/Makefile index 10495940055b63..8b20bcb050 100644 --- a/lldb/test/API/tools/lldb-dap/locations/Makefile +++ b/lldb/test/API/tools/lldb-dap/locations/Makefile @@ -1,3 +1,3 @@ -C_SOURCES := main.c +CXX_SOURCES := main.cpp include Makefile.rules diff --git a/lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py b/lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py index 76d938d3908492..45f836a2fa3c39 100644 --- a/lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py +++ b/lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py @@ -19,11 +19,11 @@ def test_locations(self): """ program = self.getBuildArtifact("a.out") self.build_and_launch(program) -source = "main.c" +source = "main.cpp" self.source_path = os.path.join(os.getcwd(), source) self.set_source_breakpoints( source, -[line_number(source, "// BREAK HERE")], +[line_number(source, "break here")], ) self.continue_to_next_stop() @@ -36,5 +36,46 @@ def test_locations(self): locals["var1"]["declarationLocationReference"] ) self.assertTrue(loc_var1["success"]) -self.assertTrue(loc_var1["body"]["source"]["path"].endswith("main.c")) -self.assertEqual(loc_var1["body"]["line"], 2) + self.assertTrue(loc_var1["body"]["source"]["path"].endswith("main.cpp")) +self.assertEqual(loc_var1["body"]["line"], 6) + +# func_ptr has both a declaration and a valueLocation +self.assertIn("declarationLocationReference", locals["func_ptr"].keys()) +self.assertIn("valueLocationReference", locals["func_ptr"].keys()) +decl_loc_func_ptr = self.dap_server.request_locations( +locals["func_ptr"]["declarationLocationReference"] +) +self.assertTrue(decl_loc_func_ptr["success"]) +self.assertTrue( +decl_loc_func_ptr["body"]["source"]["path"].endswith("main.cpp") +) +self.assertEqual(decl_loc_func_ptr["body"]["line"], 7) +val_loc_func_ptr = self.dap_server.request_locations( +locals["func_ptr"]["valueLocationReference"] +) +self.assertTrue(val_loc_func_ptr["success"]) + self.assertTrue(val_loc_func_ptr["body"]["source"]["path"].endswith("main.cpp")) +self.assertEqual(val_loc_func_ptr["body"]["line"], 3) + +# func_ref has both a declaration and a valueLocation +self.assertIn("declarationLocationReference", locals["func_ref"].keys()) +self.assertIn("valueLocationReference", locals["func_ref"].keys()) +decl_loc_func_ref = self.dap_server.request_locations( +locals["func_ref"]["declarationLocationReference"] +) +self.assertTrue(decl_loc_func_ref["success"]) +self.assertTrue( +decl_loc_func_ref["body"]["source"]["path"].endswith("main.cpp") +) +self.assertEqual(decl_loc_func_ref["body"]["line"], 8) +val_loc_func_ref = self.dap_server.request_locations( +locals["func_ref"]["valueLocationReference"] +) +s
[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)
rocallahan wrote: @clayborg @jimingham Can I please have some love? I don't want to keep telling users "you should be using GDB" and I've done a significant amount of work here. https://github.com/llvm/llvm-project/pull/99736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/108870 >From 04daaac0eade25a439856bbb287e15860aba1dfd Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Tue, 27 Aug 2024 17:34:11 + Subject: [PATCH 1/3] [lldb][libc++] Hide all libc++ implementation details from stacktraces This commit changes the libc++ frame recognizer to hide implementation details of libc++ more aggressively. The applied heuristic is rather straightforward: We consider every function name starting with `__` as an implementation detail. This works pretty neatly for `std::invoke`, `std::function`, `std::sort`, `std::map::emplace` and many others. Also, this should align quite nicely with libc++'s general coding convention of using the `__` for their implementation details, thereby keeping the future maintenance effort low. However, it is noteworthy, that this does not work 100% in all cases: E.g., for `std::ranges::sort`, itself is not really a function call, but an object with an overloaded `operator()`, which means that there is no actual call `std::ranges::sort` in the call stack. --- libcxx/docs/UserDocumentation.rst | 26 ++ .../CPlusPlus/CPPLanguageRuntime.cpp | 27 ++ .../cpp/libcxx-internals-recognizer/Makefile | 5 ++ .../TestLibcxxInternalsRecognizer.py | 56 .../cpp/libcxx-internals-recognizer/main.cpp | 86 +++ 5 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/Makefile create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/main.cpp diff --git a/libcxx/docs/UserDocumentation.rst b/libcxx/docs/UserDocumentation.rst index 6659fa54f49df5..8999b4f23e91d2 100644 --- a/libcxx/docs/UserDocumentation.rst +++ b/libcxx/docs/UserDocumentation.rst @@ -346,6 +346,32 @@ Third-party Integrations Libc++ provides integration with a few third-party tools. +Debugging libc++ internals in LLDB +-- + +LLDB hides the implementation details of libc++ by default. + +E.g., when setting a breakpoint in a comparator passed to ``std::sort``, the +backtrace will read as + +.. code-block:: + + (lldb) thread backtrace + * thread #1, name = 'a.out', stop reason = breakpoint 3.1 +* frame #0: 0x520e a.out`my_comparator(a=1, b=8) at test-std-sort.cpp:6:3 + frame #7: 0x5615 a.out`void std::__1::sort[abi:ne20], bool (*)(int, int)>(__first=(item = 8), __last=(item = 0), __comp=(a.out`my_less(int, int) at test-std-sort.cpp:5)) at sort.h:1003:3 + frame #8: 0x531a a.out`main at test-std-sort.cpp:24:3 + +Note how the caller of ``my_comparator`` is shown as ``std::sort``. Looking at +the frame numbers, we can see that frames #1 until #6 were hidden. Those frames +represent internal implementation details such as ``__sort4`` and similar +utility functions. + +To also show those implementation details, use ``thread backtrace -u``. +Alternatively, to disable those compact backtraces for good, use +``frame recognizer list`` and ``frame recognizer delete`` to delete the libc++ +frame recognizer. + GDB Pretty printers for libc++ -- diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index faa05e8f834ea1..d0e84bdeb94f01 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -45,7 +45,7 @@ char CPPLanguageRuntime::ID = 0; /// A frame recognizer that is installed to hide libc++ implementation /// details from the backtrace. class LibCXXFrameRecognizer : public StackFrameRecognizer { - std::array m_hidden_regex; + std::array m_hidden_regex; RecognizedStackFrameSP m_hidden_frame; struct LibCXXHiddenFrame : public RecognizedStackFrame { @@ -55,28 +55,17 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer { public: LibCXXFrameRecognizer() : m_hidden_regex{ -// internal implementation details of std::function +// internal implementation details in the `std::` namespace //std::__1::__function::__alloc_func, void ()>::operator()[abi:ne20] //std::__1::__function::__func, void ()>::operator() //std::__1::__function::__value_func::operator()[abi:ne20]() const -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. - R"(__function::.*::operator\(\))"}, -// internal implementation details of std::function in ABI v2 //std::__2::__function::__policy_invoker::__call_impl[abi:ne20]> -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. -
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
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 65c57066e099fe7f1357485cd6c4fb068bc82323 d31e3c541cab88c1b7589120a6eed88c667e1191 --extensions cpp -- lldb/test/API/lang/cpp/libcxx-internals-recognizer/main.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index a3fc876476..2a35182b42 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -80,18 +80,22 @@ public: return {}; // Check if we have a regex match -bool matches_regex = false; +bool matches_regex = false; for (RegularExpression &r : m_hidden_regex) if (r.Execute(sc.function->GetNameNoArguments())) { - matches_regex = true; - break; +matches_regex = true; +break; } if (matches_regex) { // Only hide this frame if the immediate caller is also within libc++. - lldb::StackFrameSP parent_frame = frame_sp->GetThread()->GetStackFrameAtIndex(frame_sp->GetFrameIndex() + 1); - const auto& parent_sc = parent_frame->GetSymbolContext(lldb::eSymbolContextFunction); - if (parent_sc.function->GetNameNoArguments().GetStringRef().starts_with("std::")) { + lldb::StackFrameSP parent_frame = + frame_sp->GetThread()->GetStackFrameAtIndex( + frame_sp->GetFrameIndex() + 1); + const auto &parent_sc = + parent_frame->GetSymbolContext(lldb::eSymbolContextFunction); + if (parent_sc.function->GetNameNoArguments().GetStringRef().starts_with( + "std::")) { return m_hidden_frame; } } `` https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
vogelsgesang wrote: > We really should add a "disable" to the frame recognizers Merged #109219 > I wonder if a heuristic for the callback case could be: mark all but the > first libc++ entry point as an implementation detail. Would this be even more > aggressive? Also, the implementation of this might be a bit awkward. Not > sure. Wdyt? I combined your approach with the `__`-based heuristic. I am quite happy with the result. It's more robust now, as can be seen by the updated test expectations for `ranges::sort`: The top-level `std::__1::ranges::__sort::operator()` is no longer hidden https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
https://github.com/vogelsgesang edited https://github.com/llvm/llvm-project/pull/108870 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/108870 >From 04daaac0eade25a439856bbb287e15860aba1dfd Mon Sep 17 00:00:00 2001 From: Adrian Vogelsgesang Date: Tue, 27 Aug 2024 17:34:11 + Subject: [PATCH 1/4] [lldb][libc++] Hide all libc++ implementation details from stacktraces This commit changes the libc++ frame recognizer to hide implementation details of libc++ more aggressively. The applied heuristic is rather straightforward: We consider every function name starting with `__` as an implementation detail. This works pretty neatly for `std::invoke`, `std::function`, `std::sort`, `std::map::emplace` and many others. Also, this should align quite nicely with libc++'s general coding convention of using the `__` for their implementation details, thereby keeping the future maintenance effort low. However, it is noteworthy, that this does not work 100% in all cases: E.g., for `std::ranges::sort`, itself is not really a function call, but an object with an overloaded `operator()`, which means that there is no actual call `std::ranges::sort` in the call stack. --- libcxx/docs/UserDocumentation.rst | 26 ++ .../CPlusPlus/CPPLanguageRuntime.cpp | 27 ++ .../cpp/libcxx-internals-recognizer/Makefile | 5 ++ .../TestLibcxxInternalsRecognizer.py | 56 .../cpp/libcxx-internals-recognizer/main.cpp | 86 +++ 5 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/Makefile create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py create mode 100644 lldb/test/API/lang/cpp/libcxx-internals-recognizer/main.cpp diff --git a/libcxx/docs/UserDocumentation.rst b/libcxx/docs/UserDocumentation.rst index 6659fa54f49df5..8999b4f23e91d2 100644 --- a/libcxx/docs/UserDocumentation.rst +++ b/libcxx/docs/UserDocumentation.rst @@ -346,6 +346,32 @@ Third-party Integrations Libc++ provides integration with a few third-party tools. +Debugging libc++ internals in LLDB +-- + +LLDB hides the implementation details of libc++ by default. + +E.g., when setting a breakpoint in a comparator passed to ``std::sort``, the +backtrace will read as + +.. code-block:: + + (lldb) thread backtrace + * thread #1, name = 'a.out', stop reason = breakpoint 3.1 +* frame #0: 0x520e a.out`my_comparator(a=1, b=8) at test-std-sort.cpp:6:3 + frame #7: 0x5615 a.out`void std::__1::sort[abi:ne20], bool (*)(int, int)>(__first=(item = 8), __last=(item = 0), __comp=(a.out`my_less(int, int) at test-std-sort.cpp:5)) at sort.h:1003:3 + frame #8: 0x531a a.out`main at test-std-sort.cpp:24:3 + +Note how the caller of ``my_comparator`` is shown as ``std::sort``. Looking at +the frame numbers, we can see that frames #1 until #6 were hidden. Those frames +represent internal implementation details such as ``__sort4`` and similar +utility functions. + +To also show those implementation details, use ``thread backtrace -u``. +Alternatively, to disable those compact backtraces for good, use +``frame recognizer list`` and ``frame recognizer delete`` to delete the libc++ +frame recognizer. + GDB Pretty printers for libc++ -- diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index faa05e8f834ea1..d0e84bdeb94f01 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -45,7 +45,7 @@ char CPPLanguageRuntime::ID = 0; /// A frame recognizer that is installed to hide libc++ implementation /// details from the backtrace. class LibCXXFrameRecognizer : public StackFrameRecognizer { - std::array m_hidden_regex; + std::array m_hidden_regex; RecognizedStackFrameSP m_hidden_frame; struct LibCXXHiddenFrame : public RecognizedStackFrame { @@ -55,28 +55,17 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer { public: LibCXXFrameRecognizer() : m_hidden_regex{ -// internal implementation details of std::function +// internal implementation details in the `std::` namespace //std::__1::__function::__alloc_func, void ()>::operator()[abi:ne20] //std::__1::__function::__func, void ()>::operator() //std::__1::__function::__value_func::operator()[abi:ne20]() const -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. - R"(__function::.*::operator\(\))"}, -// internal implementation details of std::function in ABI v2 //std::__2::__function::__policy_invoker::__call_impl[abi:ne20]> -RegularExpression{"" - R"(^std::__[^:]*::)" // Namespace. -
[Lldb-commits] [lldb] [lldb][dap] always add column field in StackFrame body (#73393) (PR #109531)
https://github.com/glingy closed https://github.com/llvm/llvm-project/pull/109531 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][dap] always add column field in StackFrame body (#73393) (PR #109531)
glingy wrote: Created by mistake, current main works fine. https://github.com/llvm/llvm-project/pull/109531 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][dap] always add column field in StackFrame body (#73393) (PR #109531)
https://github.com/glingy created https://github.com/llvm/llvm-project/pull/109531 None >From 1d39760e03c78d7c5ef68d947f560dc00900078d Mon Sep 17 00:00:00 2001 From: Gregory Ling <17791817+gli...@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:47:05 -0500 Subject: [PATCH] Change error column response to 1 as VSCode expects --- lldb/tools/lldb-dap/JSONUtils.cpp | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 4f9c9c01cf4b6b..b4358ff9ebd2bf 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -769,10 +769,14 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) { else object.try_emplace("line", 0); auto column = line_entry.GetColumn(); -object.try_emplace("column", column); +if (column == 0) + object.try_emplace("column", 1); +else + object.try_emplace("column", column); } else { object.try_emplace("line", 0); -object.try_emplace("column", 0); +// column indices start at 1 by default, column 0 is an invalid response +object.try_emplace("column", 1); } const auto pc = frame.GetPC(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][dap] always add column field in StackFrame body (#73393) (PR #109531)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/109531 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits