[Lldb-commits] [lldb] 2847020 - [lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes

2024-08-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2024-08-25T10:08:45+01:00
New Revision: 2847020dbd9b8f932ee564651ec72ce15fa37d07

URL: 
https://github.com/llvm/llvm-project/commit/2847020dbd9b8f932ee564651ec72ce15fa37d07
DIFF: 
https://github.com/llvm/llvm-project/commit/2847020dbd9b8f932ee564651ec72ce15fa37d07.diff

LOG: [lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes

If we fail to initialize the ASTContext builtins, LLDB
may crash in non-obvious ways down-the-line, e.g., when
it tries to call `ASTContext::getTypeSize` on a builtin like
`ast.UnsignedCharTy`, which would derefernce a `null` `QualType`.

The initialization can fail if we either didn't set the
`TypeSystemClang` target triple, or if the embedded clang isn't
enabled for a certain target.

This patch attempts to help pin-point the failure case post-mortem
by adding a log message here that prints the triple.

rdar://134260837

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 8f646803848096..695801da9da69a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -697,6 +697,10 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
+  else if (auto *log = GetLog(LLDBLog::Expressions))
+LLDB_LOG(log,
+ "Failed to initialize builtin ASTContext types for target '{0}'",
+ m_target_triple);
 
   GetASTMap().Insert(m_ast_up.get(), this);
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-25 Thread via lldb-commits

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/105990
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Paul Zander (negril)


Changes

Changed in python version 3.12:
  A backslash-character pair that is not a valid escape sequence now generates a
  SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+\.
  \d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
  strings for regular expression: re.compile(r"\d+\.\d+")). In a future Python
  version, SyntaxError will eventually be raised, instead of SyntaxWarning.
  (Contributed by Victor Stinner in gh-98401.)

Closes: https://github.com/llvm/llvm-project/issues/97815
See-also: 
https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences

---

Patch is 123.19 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/105990.diff


98 Files Affected:

- (modified) .github/workflows/version-check.py (+1-1) 
- (modified) clang/docs/tools/dump_ast_matchers.py (+2-2) 
- (modified) clang/test/Analysis/check-analyzer-fixit.py (+1-1) 
- (modified) compiler-rt/lib/asan/scripts/asan_symbolize.py (+2-2) 
- (modified) 
cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py (+2-2) 
- (modified) cross-project-tests/lit.cfg.py (+3-3) 
- (modified) libcxx/utils/synchronize_csv_status_files.py (+1-1) 
- (modified) lld/test/MachO/tools/validate-unwind-info.py (+1-1) 
- (modified) lld/utils/benchmark.py (+1-1) 
- (modified) lldb/examples/python/crashlog.py (+4-4) 
- (modified) lldb/examples/python/delta.py (+1-1) 
- (modified) lldb/examples/python/gdbremote.py (+3-3) 
- (modified) lldb/examples/python/jump.py (+3-3) 
- (modified) lldb/examples/python/performance.py (+1-1) 
- (modified) lldb/examples/python/symbolication.py (+3-3) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbpexpect.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/test_runner/process_control.py 
(+1-1) 
- (modified) lldb/test/API/commands/command/backticks/TestBackticksInAlias.py 
(+2-2) 
- (modified) 
lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py 
(+1-1) 
- (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1) 
- (modified) 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
(+1-1) 
- (modified) lldb/test/API/commands/help/TestHelp.py (+3-3) 
- (modified) 
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/register/register/TestRegistersUnavailable.py (+2-2) 
- (modified) 
lldb/test/API/commands/register/register/register_command/TestRegisters.py 
(+3-3) 
- (modified) lldb/test/API/commands/settings/TestSettings.py (+6-6) 
- (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py 
(+8-8) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py 
(+8-8) 
- (modified) lldb/test/API/commands/trace/TestTraceDumpInfo.py (+1-1) 
- (modified) lldb/test/API/commands/trace/TestTraceTSC.py (+5-5) 
- (modified) lldb/test/API/driver/quit_speed/TestQuitWithProcess.py (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
 (+8-8) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
 (+11-11) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
 (+2-2) 
- (modified) 
lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (+5-5) 
- (modified) lldb/test/API/functionalities/memory-region/TestMemoryRegion.py 
(+1-1) 
- (modified) lldb/test/API/functionalities/target_var/TestTargetVar.py (+1-1) 
- (modified) lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py 
(+1-1) 
- (modified) lldb/test/API/lang/c/enum_types/TestEnumTypes.py (+2-2) 
- (modified) lldb/test/API/lang/c/function_types/TestFunctionTypes.py (+1-1) 
- (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py 
(+1-1) 
- (modi

[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Paul Zander (negril)


Changes

Changed in python version 3.12:
  A backslash-character pair that is not a valid escape sequence now generates a
  SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+\.
  \d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
  strings for regular expression: re.compile(r"\d+\.\d+")). In a future Python
  version, SyntaxError will eventually be raised, instead of SyntaxWarning.
  (Contributed by Victor Stinner in gh-98401.)

Closes: https://github.com/llvm/llvm-project/issues/97815
See-also: 
https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences

---

Patch is 123.19 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/105990.diff


98 Files Affected:

- (modified) .github/workflows/version-check.py (+1-1) 
- (modified) clang/docs/tools/dump_ast_matchers.py (+2-2) 
- (modified) clang/test/Analysis/check-analyzer-fixit.py (+1-1) 
- (modified) compiler-rt/lib/asan/scripts/asan_symbolize.py (+2-2) 
- (modified) 
cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py (+2-2) 
- (modified) cross-project-tests/lit.cfg.py (+3-3) 
- (modified) libcxx/utils/synchronize_csv_status_files.py (+1-1) 
- (modified) lld/test/MachO/tools/validate-unwind-info.py (+1-1) 
- (modified) lld/utils/benchmark.py (+1-1) 
- (modified) lldb/examples/python/crashlog.py (+4-4) 
- (modified) lldb/examples/python/delta.py (+1-1) 
- (modified) lldb/examples/python/gdbremote.py (+3-3) 
- (modified) lldb/examples/python/jump.py (+3-3) 
- (modified) lldb/examples/python/performance.py (+1-1) 
- (modified) lldb/examples/python/symbolication.py (+3-3) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbpexpect.py (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/test_runner/process_control.py 
(+1-1) 
- (modified) lldb/test/API/commands/command/backticks/TestBackticksInAlias.py 
(+2-2) 
- (modified) 
lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py 
(+1-1) 
- (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1) 
- (modified) 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
(+1-1) 
- (modified) lldb/test/API/commands/help/TestHelp.py (+3-3) 
- (modified) 
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/register/register/TestRegistersUnavailable.py (+2-2) 
- (modified) 
lldb/test/API/commands/register/register/register_command/TestRegisters.py 
(+3-3) 
- (modified) lldb/test/API/commands/settings/TestSettings.py (+6-6) 
- (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py 
(+8-8) 
- (modified) 
lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py 
(+8-8) 
- (modified) lldb/test/API/commands/trace/TestTraceDumpInfo.py (+1-1) 
- (modified) lldb/test/API/commands/trace/TestTraceTSC.py (+5-5) 
- (modified) lldb/test/API/driver/quit_speed/TestQuitWithProcess.py (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
 (+3-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
 (+8-8) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
 (+11-11) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
 (+2-2) 
- (modified) 
lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (+5-5) 
- (modified) lldb/test/API/functionalities/memory-region/TestMemoryRegion.py 
(+1-1) 
- (modified) lldb/test/API/functionalities/target_var/TestTargetVar.py (+1-1) 
- (modified) lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py 
(+1-1) 
- (modified) lldb/test/API/lang/c/enum_types/TestEnumTypes.py (+2-2) 
- (modified) lldb/test/API/lang/c/function_types/TestFunctionTypes.py (+1-1) 
- (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py 
(+1-1) 
- (modif

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/3] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits


@@ -145,6 +167,17 @@ 
StackFrameRecognizerManager::GetRecognizerForFrame(StackFrameSP frame) {
   if (!entry.module_regexp->Execute(module_name.GetStringRef()))
 continue;
 
+ConstString function_name = [&]() {
+  switch (entry.mangling_preference) {
+  case Mangled::ePreferMangled:
+return function_name_mangled;
+  case Mangled::ePreferDemangled:
+return function_name_demangled;
+  case Mangled::ePreferDemangledWithoutArguments:
+return function_name_noargs;
+  }
+}();

vogelsgesang wrote:

> The demangling gets chached anyway (in the Mangled class). So wouldn't worry 
> about it

ah, great! I didn't know this. I removed the additional caching from 
`StackFrameRecognizer` again

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread via lldb-commits

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 
675c748bb606d75a959481e6014299849cf3094c...32786ae0abb7c465dfab602b1d53da11dd1dc7a7
 lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py 
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
``





View the diff from darker here.


``diff
--- std-function-recognizer/TestStdFunctionRecognizer.py2024-08-25 
21:07:43.00 +
+++ std-function-recognizer/TestStdFunctionRecognizer.py2024-08-25 
21:49:08.462694 +
@@ -15,14 +15,19 @@
 self, "// break here", lldb.SBFileSpec("main.cpp")
 )
 self.assertIn("foo", thread.GetFrameAtIndex(0).GetFunctionName())
 # Skip all hidden frames
 frame_id = 1
-while frame_id < thread.GetNumFrames() and 
thread.GetFrameAtIndex(frame_id).IsHidden():
+while (
+frame_id < thread.GetNumFrames()
+and thread.GetFrameAtIndex(frame_id).IsHidden()
+):
 frame_id = frame_id + 1
 # Expect `std::function<...>::operator()` to be the direct parent of 
`foo`
-self.assertIn("::operator()", 
thread.GetFrameAtIndex(frame_id).GetFunctionName())
+self.assertIn(
+"::operator()", thread.GetFrameAtIndex(frame_id).GetFunctionName()
+)
 # And right above that, there should be the `main` frame
 self.assertIn("main", thread.GetFrameAtIndex(frame_id + 
1).GetFunctionName())
 
 @add_test_categories(["libc++"])
 def test_backtrace(self):
--- std-invoke-recognizer/TestStdInvokeRecognizer.py2024-08-25 
21:07:43.00 +
+++ std-invoke-recognizer/TestStdInvokeRecognizer.py2024-08-25 
21:49:08.482565 +
@@ -14,18 +14,30 @@
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.cpp")
 )
 
 while process.GetState() != lldb.eStateExited:
-self.assertTrue(any(f in 
thread.GetFrameAtIndex(0).GetFunctionName() for f in ["print_num", "add", 
"PrintAdder"]))
+self.assertTrue(
+any(
+f in thread.GetFrameAtIndex(0).GetFunctionName()
+for f in ["print_num", "add", "PrintAdder"]
+)
+)
 print(thread.GetFrameAtIndex(0).GetFunctionName())
 # Skip all hidden frames
 frame_id = 1
-while frame_id < thread.GetNumFrames() and 
thread.GetFrameAtIndex(frame_id).IsHidden():
+while (
+frame_id < thread.GetNumFrames()
+and thread.GetFrameAtIndex(frame_id).IsHidden()
+):
 print(thread.GetFrameAtIndex(frame_id).GetFunctionName())
 frame_id = frame_id + 1
 print(thread.GetFrameAtIndex(frame_id).GetFunctionName())
 # Expect `std::invoke` to be the direct parent
-self.assertIn("::invoke", 
thread.GetFrameAtIndex(frame_id).GetFunctionName())
+self.assertIn(
+"::invoke", thread.GetFrameAtIndex(frame_id).GetFunctionName()
+)
 # And right above that, there should be the `main` frame
-self.assertIn("main", thread.GetFrameAtIndex(frame_id + 
1).GetFunctionName())
+self.assertIn(
+"main", thread.GetFrameAtIndex(frame_id + 1).GetFunctionName()
+)
 process.Continue()

``




https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread via lldb-commits

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 675c748bb606d75a959481e6014299849cf3094c 
32786ae0abb7c465dfab602b1d53da11dd1dc7a7 --extensions h,cpp -- 
lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp 
lldb/include/lldb/Target/StackFrameRecognizer.h 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
lldb/source/Target/StackFrameRecognizer.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 4ef0d1b2f5..ff10a7ada5 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -105,16 +105,15 @@ private:
 /// Class that provides a registry of known stack frame recognizers.
 class StackFrameRecognizerManager {
 public:
-  void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
- ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true,
- Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
-
-  void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
- lldb::RegularExpressionSP module,
- lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true,
- Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
+  void AddRecognizer(
+  lldb::StackFrameRecognizerSP recognizer, ConstString module,
+  llvm::ArrayRef symbols, bool first_instruction_only = true,
+  Mangled::NamePreference mangling_preference = Mangled::ePreferDemangled);
+
+  void AddRecognizer(
+  lldb::StackFrameRecognizerSP recognizer, lldb::RegularExpressionSP 
module,
+  lldb::RegularExpressionSP symbol, bool first_instruction_only = true,
+  Mangled::NamePreference mangling_preference = Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index bfd23ed9c3..38ebfcf392 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -106,8 +106,8 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
 StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},
 std::make_shared("^std::__[0-9]*::"),
-/*first_instruction_only=*/ false,
-/*mangling_preference=*/ Mangled::ePreferDemangledWithoutArguments);
+/*first_instruction_only=*/false,
+/*mangling_preference=*/Mangled::ePreferDemangledWithoutArguments);
 }
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {

``




https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits


@@ -145,6 +167,17 @@ 
StackFrameRecognizerManager::GetRecognizerForFrame(StackFrameSP frame) {
   if (!entry.module_regexp->Execute(module_name.GetStringRef()))
 continue;
 
+ConstString function_name = [&]() {
+  switch (entry.mangling_preference) {
+  case Mangled::ePreferMangled:
+return function_name_mangled;
+  case Mangled::ePreferDemangled:
+return function_name_demangled;
+  case Mangled::ePreferDemangledWithoutArguments:
+return function_name_noargs;
+  }
+}();

vogelsgesang wrote:

> @vogelsgesang I closed my PR, feel free to copy&paste what you find useful.

I did copy over:
* the improved comments in `StackFrameRecognizer.h`
* the printing improvements to `frame recognizer list` (but I am using a 
slightly different format)

However, I did not change the `VerboseTrapFrameRecognizer` and 
`AssertFrameRecognizer` to use the mangled names. I will leave this for a 
follow-up commit.

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits


@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;

vogelsgesang wrote:

I don't have direct push-access and piggy-backing it in this PR is less effort 
for me

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits


@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
 
 public:
   LibCXXFrameRecognizer()
-  : m_hidden_function_regex(
-R"(^std::__1::(__function.*::operator\(\)|__invoke))"
-R"((\[.*\])?)"// ABI tag.
-R"(( const)?$)"), // const.
+  : m_hidden_regex{
+// internal implementation details of std::function
+//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::__[0-9]*::)" // Namespace.
+  R"(__function::.*::operator\(\))"
+  R"((\[.*\])?)"// ABI tag.
+  R"(( const)?$)"}, // const.
+// internal implementation details of std::invoke
+//   std::__1::__invoke[abi:ne20]
+RegularExpression{
+  R"(^std::__[0-9]*::)" // Namespace.
+  R"(__invoke)"

vogelsgesang wrote:

I would like to defer switching to `^std::__[0-9]*::__.*` in a follow-up 
commit, if that's fine by you.

I am pretty sure that this commit here works without unintended side effects, 
but I am not sure if `^std::__[0-9]*::__.*` would regress debugability in 
unforeseen ways

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang edited 
https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang edited 
https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Petr Hosek via lldb-commits

petrhosek wrote:

> I reverted the reverts and pushed two commits to fix the missing 
> initialization.

The libc++ issue I described earlier still hasn't been addressed so I'm going 
to revert the changes again...

https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 68a1593 - [lldb] Support non-default libc++ ABI namespace

2024-08-25 Thread Petr Hosek via lldb-commits

Author: Petr Hosek
Date: 2024-08-26T01:23:09Z
New Revision: 68a1593a59c3d50aff43ef4f82ded224fc6a25db

URL: 
https://github.com/llvm/llvm-project/commit/68a1593a59c3d50aff43ef4f82ded224fc6a25db
DIFF: 
https://github.com/llvm/llvm-project/commit/68a1593a59c3d50aff43ef4f82ded224fc6a25db.diff

LOG: [lldb] Support non-default libc++ ABI namespace

This is a fix forward for the issue introduced in #104523.

Added: 


Modified: 
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..1e4a2cbb1133f7 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -54,7 +54,7 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
 public:
   LibCXXFrameRecognizer()
   : m_hidden_function_regex(
-R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"(^std::__.*::(__function.*::operator\(\)|__invoke))"
 R"((\[.*\])?)"// ABI tag.
 R"(( const)?$)"), // const.
 m_hidden_frame(new LibCXXHiddenFrame()) {}
@@ -81,7 +81,7 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
   if (process)
 process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
 StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},
-std::make_shared("^std::__1::"),
+std::make_shared("^std::__.*::"),
 /*first_instruction_only*/ false);
 }
 

diff  --git 
a/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py 
b/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
index 30fe3ecb1e4bf4..8d4b6bfe17166e 100644
--- 
a/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
+++ 
b/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
@@ -21,18 +21,18 @@ def test_backtrace(self):
 substrs=["frame", "foo", "frame", "main"],
 )
 self.expect(
-"thread backtrace", matching=False, 
patterns=["frame.*std::__1::__function"]
+"thread backtrace", matching=False, 
patterns=["frame.*std::__.*::__function"]
 )
 # Unfiltered.
 self.expect(
 "thread backtrace -u",
 ordered=True,
-patterns=["frame.*foo", "frame.*std::__1::__function", 
"frame.*main"],
+patterns=["frame.*foo", "frame.*std::__.*::__function", 
"frame.*main"],
 )
 self.expect(
 "thread backtrace --unfiltered",
 ordered=True,
-patterns=["frame.*foo", "frame.*std::__1::__function", 
"frame.*main"],
+patterns=["frame.*foo", "frame.*std::__.*::__function", 
"frame.*main"],
 )
 
 @add_test_categories(["libc++"])



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread Dmitrii Galimzianov via lldb-commits

https://github.com/DmT021 created 
https://github.com/llvm/llvm-project/pull/106030

`SymbolFileDWARF::FindTypes` was logged prior to [this 
commit](https://github.com/llvm/llvm-project/commit/dd9587795811ba21e6ca6ad52b4531e17e6babd6#diff-edef3a65d5d569bbb75a4158d35b827aa5d42ee03ccd3b0c1d4f354afa12210c).
This is a helpful log message for checking for redundant type searches, so 
maybe we should restore it?

>From 07a0426d27bc7f5fb9354e86c528626e3334714e Mon Sep 17 00:00:00 2001
From: Dmitrii Galimzianov 
Date: Mon, 26 Aug 2024 05:10:50 +0200
Subject: [PATCH] Add logs for SymbolFileDWARF::FindTypes

---
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp   | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 7e0cf36d0de1b8..53f1276ee07f8b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2737,10 +2737,18 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   if (results.AlreadySearched(this))
 return;
 
+  auto type_basename = query.GetTypeBasename();
+
+  if (Log *log = GetLog(DWARFLog::Lookups)) {
+GetObjectFile()->GetModule()->LogMessage(
+log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
+type_basename);
+  }
+
   std::lock_guard guard(GetModuleMutex());
 
   bool have_index_match = false;
-  m_index->GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+  m_index->GetTypes(type_basename, [&](DWARFDIE die) {
 // Check the language, but only if we have a language filter.
 if (query.HasLanguage()) {
   if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread via lldb-commits

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/106030
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread Dmitrii Galimzianov via lldb-commits

https://github.com/DmT021 ready_for_review 
https://github.com/llvm/llvm-project/pull/106030
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread Dmitrii Galimzianov via lldb-commits

DmT021 wrote:

@augusto2112 @clayborg please take a look

https://github.com/llvm/llvm-project/pull/106030
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitrii Galimzianov (DmT021)


Changes

`SymbolFileDWARF::FindTypes` was logged prior to [this 
commit](https://github.com/llvm/llvm-project/commit/dd9587795811ba21e6ca6ad52b4531e17e6babd6#diff-edef3a65d5d569bbb75a4158d35b827aa5d42ee03ccd3b0c1d4f354afa12210c).
This is a helpful log message for checking for redundant type searches, so 
maybe we should restore it?

---
Full diff: https://github.com/llvm/llvm-project/pull/106030.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+9-1) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 7e0cf36d0de1b8..53f1276ee07f8b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2737,10 +2737,18 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   if (results.AlreadySearched(this))
 return;
 
+  auto type_basename = query.GetTypeBasename();
+
+  if (Log *log = GetLog(DWARFLog::Lookups)) {
+GetObjectFile()->GetModule()->LogMessage(
+log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
+type_basename);
+  }
+
   std::lock_guard guard(GetModuleMutex());
 
   bool have_index_match = false;
-  m_index->GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+  m_index->GetTypes(type_basename, [&](DWARFDIE die) {
 // Check the language, but only if we have a language filter.
 if (query.HasLanguage()) {
   if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(

``




https://github.com/llvm/llvm-project/pull/106030
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] unique_ptr-ify some GetUserExpression APIs. (PR #106034)

2024-08-25 Thread Lang Hames via lldb-commits

https://github.com/lhames created 
https://github.com/llvm/llvm-project/pull/106034

These methods already returned a uniquely owned object, this just makes them 
self-documenting.

>From b115f38e01488e0622f5ab1d064b873f9459efeb Mon Sep 17 00:00:00 2001
From: Lang Hames 
Date: Mon, 26 Aug 2024 13:56:04 +1000
Subject: [PATCH] [lldb] unique_ptr-ify some GetUserExpression APIs.

These methods already returned a uniquely owned object, this just makes them
self-documenting.
---
 lldb/include/lldb/Symbol/TypeSystem.h  |  2 +-
 lldb/include/lldb/Target/Target.h  |  2 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp  |  4 ++--
 lldb/source/Breakpoint/Watchpoint.cpp  |  4 ++--
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp   |  6 +++---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h | 10 --
 lldb/source/Target/Target.cpp  |  6 +++---
 7 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..b1ed5df3013a2b 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -495,7 +495,7 @@ class TypeSystem : public PluginInterface,
 return IsPointerOrReferenceType(type, nullptr);
   }
 
-  virtual UserExpression *GetUserExpression(
+  virtual std::unique_ptr GetUserExpression(
   llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
   Expression::ResultType desired_type,
   const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7f4d607f5427df..95e3aaf02b19d5 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1174,7 +1174,7 @@ class Target : public 
std::enable_shared_from_this,
   // parameters have the same meaning as for the UserExpression constructor.
   // Returns a new-ed object which the caller owns.
 
-  UserExpression *
+  std::unique_ptr
   GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
Expression::ResultType desired_type,
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 41911fad41c648..8ef6b844230505 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -251,9 +251,9 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext 
&exe_ctx,
 if (comp_unit)
   language = comp_unit->GetLanguage();
 
-m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
+m_user_expression_sp = GetTarget().GetUserExpressionForLanguage(
 condition_text, llvm::StringRef(), language, 
Expression::eResultTypeAny,
-EvaluateExpressionOptions(), nullptr, error));
+EvaluateExpressionOptions(), nullptr, error);
 if (error.Fail()) {
   LLDB_LOGF(log, "Error getting condition expression: %s.",
 error.AsCString());
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 715e83c76697b2..577ee81d687dcb 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -463,9 +463,9 @@ void Watchpoint::SetCondition(const char *condition) {
   } else {
 // Pass nullptr for expr_prefix (no translation-unit level definitions).
 Status error;
-m_condition_up.reset(m_target.GetUserExpressionForLanguage(
+m_condition_up = m_target.GetUserExpressionForLanguage(
 condition, {}, {}, UserExpression::eResultTypeAny,
-EvaluateExpressionOptions(), nullptr, error));
+EvaluateExpressionOptions(), nullptr, error);
 if (error.Fail()) {
   // FIXME: Log something...
   m_condition_up.reset();
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 695801da9da69a..2e2f4be6343791 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9741,7 +9741,7 @@ void ScratchTypeSystemClang::Dump(llvm::raw_ostream 
&output) {
   }
 }
 
-UserExpression *ScratchTypeSystemClang::GetUserExpression(
+std::unique_ptr ScratchTypeSystemClang::GetUserExpression(
 llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
 Expression::ResultType desired_type,
 const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
@@ -9749,8 +9749,8 @@ UserExpression *ScratchTypeSystemClang::GetUserExpression(
   if (!target_sp)
 return nullptr;
 
-  return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
- desired_type, options, ctx_obj);
+  return std::make_unique(
+  *target_sp.get(), expr, pre

[Lldb-commits] [lldb] [lldb] unique_ptr-ify some GetUserExpression APIs. (PR #106034)

2024-08-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Lang Hames (lhames)


Changes

These methods already returned a uniquely owned object, this just makes them 
self-documenting.

---
Full diff: https://github.com/llvm/llvm-project/pull/106034.diff


7 Files Affected:

- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+1-1) 
- (modified) lldb/include/lldb/Target/Target.h (+1-1) 
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+2-2) 
- (modified) lldb/source/Breakpoint/Watchpoint.cpp (+2-2) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3-3) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+4-6) 
- (modified) lldb/source/Target/Target.cpp (+3-3) 


``diff
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..b1ed5df3013a2b 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -495,7 +495,7 @@ class TypeSystem : public PluginInterface,
 return IsPointerOrReferenceType(type, nullptr);
   }
 
-  virtual UserExpression *GetUserExpression(
+  virtual std::unique_ptr GetUserExpression(
   llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
   Expression::ResultType desired_type,
   const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 7f4d607f5427df..95e3aaf02b19d5 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1174,7 +1174,7 @@ class Target : public 
std::enable_shared_from_this,
   // parameters have the same meaning as for the UserExpression constructor.
   // Returns a new-ed object which the caller owns.
 
-  UserExpression *
+  std::unique_ptr
   GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
Expression::ResultType desired_type,
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 41911fad41c648..8ef6b844230505 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -251,9 +251,9 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext 
&exe_ctx,
 if (comp_unit)
   language = comp_unit->GetLanguage();
 
-m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
+m_user_expression_sp = GetTarget().GetUserExpressionForLanguage(
 condition_text, llvm::StringRef(), language, 
Expression::eResultTypeAny,
-EvaluateExpressionOptions(), nullptr, error));
+EvaluateExpressionOptions(), nullptr, error);
 if (error.Fail()) {
   LLDB_LOGF(log, "Error getting condition expression: %s.",
 error.AsCString());
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 715e83c76697b2..577ee81d687dcb 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -463,9 +463,9 @@ void Watchpoint::SetCondition(const char *condition) {
   } else {
 // Pass nullptr for expr_prefix (no translation-unit level definitions).
 Status error;
-m_condition_up.reset(m_target.GetUserExpressionForLanguage(
+m_condition_up = m_target.GetUserExpressionForLanguage(
 condition, {}, {}, UserExpression::eResultTypeAny,
-EvaluateExpressionOptions(), nullptr, error));
+EvaluateExpressionOptions(), nullptr, error);
 if (error.Fail()) {
   // FIXME: Log something...
   m_condition_up.reset();
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 695801da9da69a..2e2f4be6343791 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9741,7 +9741,7 @@ void ScratchTypeSystemClang::Dump(llvm::raw_ostream 
&output) {
   }
 }
 
-UserExpression *ScratchTypeSystemClang::GetUserExpression(
+std::unique_ptr ScratchTypeSystemClang::GetUserExpression(
 llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
 Expression::ResultType desired_type,
 const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
@@ -9749,8 +9749,8 @@ UserExpression *ScratchTypeSystemClang::GetUserExpression(
   if (!target_sp)
 return nullptr;
 
-  return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
- desired_type, options, ctx_obj);
+  return std::make_unique(
+  *target_sp.get(), expr, prefix, language, desired_type, options, 
ctx_obj);
 }
 
 FunctionCaller *ScratchTypeSystemClang::GetFunctionCaller(
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index e39aedec7e3902..fc2

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From 19b4370c240cfcf4a57a5c38a64c8ba933d8102c Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/5] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c60200ab186d09..3665e1a4c77e55 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Petr Hosek via lldb-commits

petrhosek wrote:

I attempted a fix forward in 
https://github.com/llvm/llvm-project/commit/68a1593a59c3d50aff43ef4f82ded224fc6a25db
 but the test is still failing, although with a slightly different error now:
```
==
FAIL: test_backtrace 
(TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_backtrace)
   Test that std::function implementation details are hidden in bt
--
Traceback (most recent call last):
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py",
 line 23, in test_backtrace
self.expect(
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2464, in expect
self.fail(log_msg)
AssertionError: Ran command:
"thread backtrace"

Got output:
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
  * frame #0: 0x56243befb40a a.out`foo(x=1, y=1) at main.cpp:4:10
frame #1: 0x56243befb819 a.out`decltype(std::declval()(std::declval(), std::declval())) 
std::__2::__invoke[abi:ne20](__f=0x7fff84d3db50, __args=0x7fff84d3dac4, 
__args=0x7fff84d3dac0) at invoke.h:149:25
frame #2: 0x56243befb7e5 a.out`int 
std::__2::__invoke_void_return_wrapper::__call[abi:ne20](__args=0x7fff84d3db50, __args=0x7fff84d3dac4, 
__args=0x7fff84d3dac0) at invoke.h:216:12
frame #4: 0x56243befb75b a.out`int 
std::__2::__function::__policy_invoker::__call_impl[abi:ne20]>(__buf=0x7fff84d3db50, __args=1, __args=1) 
at function.h:610:12
frame #6: 0x56243befb4f3 a.out`std::__2::function::operator()(this=0x7fff84d3db50, __arg=1, __arg=1) const at 
function.h:989:10
frame #7: 0x56243befb45b a.out`main(argc=1, argv=0x7fff84d3dc78) at 
main.cpp:9:10
frame #8: 0x7fc200d2ed0a libc.so.6`__libc_start_main + 234
frame #9: 0x56243befb36a a.out`_start + 42

Not expecting regex pattern: "frame.*std::__.*::__function" (was found, matched 
"frame #4: 0x56243befb75b a.out`int 
std::__2::__function::__policy_invoker::__call_impl[abi:ne20]https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

Would be interesting if this is fixed by #105695. How can I run the test cases 
against libc++'s unstable ABI locally?

https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Petr Hosek via lldb-commits

petrhosek wrote:

Looks like libc++ uses a different layout for `std::function` with ABI v1 and 
v2, see 
https://github.com/llvm/llvm-project/blob/52ae891036e3ab1f668eb103c46ca57257901c6b/libcxx/include/__functional/function.h#L827-L831.

https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Petr Hosek via lldb-commits

petrhosek wrote:

> Would be interesting if this is fixed by #105695. How can I run the test 
> cases against libc++'s unstable ABI locally?

Set `-D LIBCXX_ABI_VERSION=2` in your CMake invocation.

https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang edited 
https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Petr Hosek via lldb-commits


@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
 
 public:
   LibCXXFrameRecognizer()
-  : m_hidden_function_regex(
-R"(^std::__1::(__function.*::operator\(\)|__invoke))"
-R"((\[.*\])?)"// ABI tag.
-R"(( const)?$)"), // const.
+  : m_hidden_regex{
+// internal implementation details of std::function
+//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::__[0-9]*::)" // Namespace.
+  R"(__function::.*::operator\(\))"
+  R"((\[.*\])?)"// ABI tag.
+  R"(( const)?$)"}, // const.
+// internal implementation details of std::invoke
+//   std::__1::__invoke[abi:ne20]
+RegularExpression{
+  R"(^std::__[0-9]*::)" // Namespace.
+  R"(__invoke)"

petrhosek wrote:

libc++ ABI namespace doesn't have to be just a number, it can be any [string 
that starts with 
`__`](https://github.com/llvm/llvm-project/blob/c557d8520413476221a4f3bf2b7b3fed17681691/libcxx/CMakeLists.txt#L197).
 For example, in some of our Google projects we use `__ktl` and `__pw`. 
[libFuzzer uses 
`__Fuzzer`](https://github.com/llvm/llvm-project/blob/52ae891036e3ab1f668eb103c46ca57257901c6b/compiler-rt/lib/fuzzer/CMakeLists.txt#L166)
 in its internal libc++ build.

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Petr Hosek via lldb-commits

https://github.com/petrhosek edited 
https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/3] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/3] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/4] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,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 {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-25 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

I updated https://github.com/llvm/llvm-project/pull/105695 and locally verified 
that it now fixes the test case for libc++ ABI v2

https://github.com/llvm/llvm-project/pull/104523
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-25 Thread Michael Buch via lldb-commits

https://github.com/Michael137 approved this pull request.

I found this useful in the past, so LGTM, thanks!

We also seem to have lost the counterpart log message which tells us whether we 
found something or not:
```
  GetObjectFile()->GetModule()->LogMessage(
   log,
   "SymbolFileDWARF::FindTypes (sc, name=\"{0}\", parent_decl_ctx "
   "= NULL, max_matches={1}, type_list) => {2}",
   name.GetCString(), max_matches, types.GetSize());
```

Would be nice to restore that too (unless it's now logged elsewhere)

https://github.com/llvm/llvm-project/pull/106030
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits

https://github.com/Michael137 approved this pull request.

LGTM (with some minor comments). I'd wait for @adrian-prantl to also review this

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -196,8 +197,8 @@ 
AbortWithPayloadFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
   abort_dict_sp->AddStringItem(reason_key, reason_string);
   abort_dict_sp->AddIntegerItem(flags_key, flags_val);
 
-  // This will overwrite the abort_with_payload information in the dictionary  
-  // already.  But we can only crash on abort_with_payload once, so that 
+  // This will overwrite the abort_with_payload information in the dictionary
+  // already.  But we can only crash on abort_with_payload once, so that

Michael137 wrote:

Did you run `git clang-format` or just plain `clang-format`? You seem to have 
several formatting changes in otherwise untouched code

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibCxxStdFunctionRecognizerTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(["libc++"])
+def test_frame_recognizer(self):
+"""Test that implementation details details of `std::invoke`"""

Michael137 wrote:

```suggestion
"""Test that implementation details of `std::invoke`"""
```

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -0,0 +1,40 @@
+#include 
+#include 
+
+void print_num(int i) {
+  // break here
+  std::cout << i << '\n';

Michael137 wrote:

no need to print to `std::cout` anywhere in the test imo. Also, we usually try 
to avoid breakpoints on comments. So wrapping them in something like:
```
__builtin_printf("break here");
```
Is slightly preferred. Or might even get something with `__builtin_debugtrap()` 
working

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -305,7 +307,9 @@ def test_frame_recognizer_target_specific(self):
 
 self.expect(
 "frame recognizer list",
-substrs=["recognizer.MyFrameRecognizer, module a.out, symbol bar"],
+substrs=[
+"recognizer.MyFrameRecognizer, module a.out, demangled symbol 
bar"
+],

Michael137 wrote:

Don't seem to have tests for this with `ePreferDemangledWithoutArguments`

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -53,10 +54,39 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
 
 public:
   LibCXXFrameRecognizer()
-  : m_hidden_function_regex(
-R"(^std::__.*::(__function.*::operator\(\)|__invoke))"
-R"((\[.*\])?)"// ABI tag.
-R"(( const)?$)"), // const.
+  : m_hidden_regex{
+// internal implementation details of std::function
+//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\(\))"
+  R"((\[.*\])?)"// ABI tag.
+  R"(( const)?$)"}, // const.

Michael137 wrote:

I don't think we need to match on anything past the function name here? Feels 
redundant (even if we're going to remove this in favour of `std::__*` in the 
future).

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibCxxStdFunctionRecognizerTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(["libc++"])
+def test_frame_recognizer(self):
+"""Test that implementation details details of `std::invoke`"""
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
+
+while process.GetState() != lldb.eStateExited:
+self.assertTrue(
+any(
+f in thread.GetFrameAtIndex(0).GetFunctionName()
+for f in ["print_num", "add", "PrintAdder"]
+)
+)
+print(thread.GetFrameAtIndex(0).GetFunctionName())

Michael137 wrote:

Are all these `print` statements just leftovers from debugging?

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-25 Thread Michael Buch via lldb-commits


@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibCxxStdFunctionRecognizerTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(["libc++"])
+def test_frame_recognizer(self):
+"""Test that implementation details details of `std::invoke`"""

Michael137 wrote:

This comments feels incomplete

https://github.com/llvm/llvm-project/pull/105695
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits