[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

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

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

LGTM (left some minor comments)

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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

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


@@ -145,15 +148,27 @@ std::string CXXFunctionSummaryFormat::GetDescription() {
   return std::string(sstr.GetString());
 }
 
+std::string CXXFunctionSummaryFormat::GetName() { return m_description; }
+
+std::string CXXFunctionSummaryFormat::GetSummaryKindName() { return "c++"; }
+
 ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags &flags,
  const char *function_name,
  const char *python_script)
 : TypeSummaryImpl(Kind::eScript, flags), m_function_name(),
   m_python_script(), m_script_function_sp() {
-  if (function_name)
+  // Take preference in the python script name over the function name.;
+  if (function_name) {
 m_function_name.assign(function_name);
-  if (python_script)
+m_script_formatter_name = function_name;
+  }
+  if (python_script) {
 m_python_script.assign(python_script);
+m_script_formatter_name = python_script;
+  }
+
+  m_script_formatter_name = m_script_formatter_name.erase(

Michael137 wrote:

Can we add a comment here for why this is necessary?

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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

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


@@ -0,0 +1,64 @@
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-private.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb_private;
+using Duration = std::chrono::duration;
+
+class DummySummaryImpl : public lldb_private::TypeSummaryImpl {
+public:
+  DummySummaryImpl(Duration sleepTime)
+  : TypeSummaryImpl(TypeSummaryImpl::Kind::eSummaryString,
+TypeSummaryImpl::Flags()),
+m_sleepTime(sleepTime) {}
+
+  std::string GetName() override { return "DummySummary"; }
+
+  std::string GetSummaryKindName() override { return "dummy"; }
+
+  std::string GetDescription() override { return ""; }
+
+  bool FormatObject(ValueObject *valobj, std::string &dest,
+const TypeSummaryOptions &options) override {
+return false;
+  }
+
+  void FakeFormat() { std::this_thread::sleep_for(m_sleepTime); }
+
+private:
+  Duration m_sleepTime;
+};
+
+TEST(MultithreadFormatting, Multithread) {
+  SummaryStatisticsCache statistics_cache;
+  DummySummaryImpl summary(Duration(1));
+  std::vector threads;
+  for (int i = 0; i < 10; ++i) {
+threads.emplace_back(std::thread([&statistics_cache, &summary]() {
+  auto sp = statistics_cache.GetSummaryStatisticsForProvider(summary);
+  {
+SummaryStatistics::SummaryInvocation invocation(sp);
+summary.FakeFormat();

Michael137 wrote:

Can we just call something like 
`std::this_thread::sleep_for(std::chrono::milliseconds(50))` here directly?

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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

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


@@ -145,15 +148,27 @@ std::string CXXFunctionSummaryFormat::GetDescription() {
   return std::string(sstr.GetString());
 }
 
+std::string CXXFunctionSummaryFormat::GetName() { return m_description; }
+
+std::string CXXFunctionSummaryFormat::GetSummaryKindName() { return "c++"; }
+
 ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags &flags,
  const char *function_name,
  const char *python_script)
 : TypeSummaryImpl(Kind::eScript, flags), m_function_name(),
   m_python_script(), m_script_function_sp() {
-  if (function_name)
+  // Take preference in the python script name over the function name.;

Michael137 wrote:

```suggestion
  // Take preference in the python script name over the function name.
```

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


[Lldb-commits] [lldb] [LLDB][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

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

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/102708
___
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-23 Thread Michael Buch 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)"

Michael137 wrote:

Agreed. Don't think we want to maintain this list.

(also, side-note, I think matching on `const` and `abi_tag` is probably 
redundant. Not a concern if we just filter out all the `std::__*::__` stuff).

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-23 Thread Michael Buch via lldb-commits


@@ -81,8 +105,9 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
   if (process)
 process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
 StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},
-std::make_shared("^std::__1::"),
-/*first_instruction_only*/ false);
+std::make_shared("std::__[0-9]*::"),

Michael137 wrote:

```suggestion
std::make_shared("^std::__[0-9]*::"),
```

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-23 Thread Michael Buch 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">;

Michael137 wrote:

Can just push this as an NFC separately

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-23 Thread Michael Buch 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;
+  }
+}();

Michael137 wrote:

Can't we just pass `symctx.GetFunctionName(entry.mangling_preference)` here 
right?

No need for the switch statement here and above and also no need to keep a map 
of `m_used_manglings`

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] Support frame recognizer regexp on mangled names. (PR #105756)

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


@@ -927,6 +928,32 @@ class CommandObjectFrameRecognizerClear : public 
CommandObjectParsed {
   }
 };
 
+static void
+PrintRecognizerDetails(Stream &strm, const std::string &module,
+   llvm::ArrayRef symbols,
+   Mangled::NamePreference preference, bool regexp) {
+  if (!module.empty())
+strm << ", module " << module;
+  for (auto &symbol : symbols) {

Michael137 wrote:

We could be fancy and use an `llvm::interleaveComma` here

https://github.com/llvm/llvm-project/pull/105756
___
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-23 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-23 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:

I wasn't sure about performance here. The code previously computed the demanded 
name only once and then checked against all frame recognizers. I am not sure 
how expensive it is to demangle a 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-23 Thread Michael Buch 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;
+  }
+}();

Michael137 wrote:

The demangling gets chached anyway. So wouldn't worry about it

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-23 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] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)

2024-08-23 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-23 Thread Rahul Joshi via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFC] Moved the SharedSocket class to Socket.* (PR #104787)

2024-08-23 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman edited 
https://github.com/llvm/llvm-project/pull/104787
___
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-23 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:

By the way: I don't think I will be merging this part of my commit in the end. 
https://github.com/llvm/llvm-project/pull/105756 is very similar, and I think I 
will just rebase on it, after it got merged

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] Support frame recognizer regexp on mangled names. (PR #105756)

2024-08-23 Thread Adrian Prantl via lldb-commits


@@ -92,11 +95,13 @@ void StackFrameRecognizerManager::ForEach(
 symbol_name = entry.symbol_regexp->GetText().str();
 
   callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
-   llvm::ArrayRef(ConstString(symbol_name)), true);
+   llvm::ArrayRef(ConstString(symbol_name)), entry.symbol_mangling,
+   true);
 
 } else {
   callback(entry.recognizer_id, entry.recognizer->GetName(),
-   entry.module.GetCString(), entry.symbols, false);
+   entry.module.GetCString(), entry.symbols, entry.symbol_mangling,
+   false);
 }
   }
 }

adrian-prantl wrote:

Ah looks like we had the same idea!

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


[Lldb-commits] [lldb] fd7904a - Revert "[lldb] Speculative fix for trap_frame_sym_ctx.test"

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T09:25:24-07:00
New Revision: fd7904a07bc26950fa7735fb6871a064e3ebc836

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

LOG: Revert "[lldb] Speculative fix for trap_frame_sym_ctx.test"

This reverts commit 19d3f3417100dc99caa4394fbd26fc0c4702264e.

Added: 


Modified: 
lldb/test/Shell/Unwind/trap_frame_sym_ctx.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test 
b/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
index 08a26616240e68..1bf1fb1d6e85f9 100644
--- a/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
+++ b/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
@@ -15,7 +15,7 @@ breakpoint set -n bar
 process launch
 # CHECK: stop reason = breakpoint 1.1
 
-thread backtrace -u
+thread backtrace
 # CHECK: frame #0: {{.*}}`bar
 # CHECK: frame #1: {{.*}}`tramp
 # CHECK: frame #2: {{.*}}`main



___
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-23 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

@gribozavr Thanks for pointing this out. This is funny: I forgot to initialize 
the generation counter in StackFrame.  I didn't notice because this actually 
doesn't cause a bug; it just needs to increment and wrap around so the starting 
position doesn't matter.

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] Support frame recognizer regexp on mangled names. (PR #105756)

2024-08-23 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support frame recognizer regexp on mangled names. (PR #105756)

2024-08-23 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Retiring in favor of https://github.com/llvm/llvm-project/pull/105695/.

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


[Lldb-commits] [lldb] [lldb] Support frame recognizer regexp on mangled names. (PR #105756)

2024-08-23 Thread Adrian Prantl via lldb-commits


@@ -92,11 +95,13 @@ void StackFrameRecognizerManager::ForEach(
 symbol_name = entry.symbol_regexp->GetText().str();
 
   callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
-   llvm::ArrayRef(ConstString(symbol_name)), true);
+   llvm::ArrayRef(ConstString(symbol_name)), entry.symbol_mangling,
+   true);
 
 } else {
   callback(entry.recognizer_id, entry.recognizer->GetName(),
-   entry.module.GetCString(), entry.symbols, false);
+   entry.module.GetCString(), entry.symbols, entry.symbol_mangling,
+   false);
 }
   }
 }

adrian-prantl wrote:

I'll let you commit your PR instead.

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


[Lldb-commits] [lldb] b7c1be1 - Revert "Revert "[lldb] Speculative fix for trap_frame_sym_ctx.test""

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T11:06:01-07:00
New Revision: b7c1be1a7f49539ea644ff3fd8b55f237e37b35e

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

LOG: Revert "Revert "[lldb] Speculative fix for trap_frame_sym_ctx.test""

This reverts commit fd7904a07bc26950fa7735fb6871a064e3ebc836.

Added: 


Modified: 
lldb/test/Shell/Unwind/trap_frame_sym_ctx.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test 
b/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
index 1bf1fb1d6e85f9..08a26616240e68 100644
--- a/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
+++ b/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
@@ -15,7 +15,7 @@ breakpoint set -n bar
 process launch
 # CHECK: stop reason = breakpoint 1.1
 
-thread backtrace
+thread backtrace -u
 # CHECK: frame #0: {{.*}}`bar
 # CHECK: frame #1: {{.*}}`tramp
 # CHECK: frame #2: {{.*}}`main



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


[Lldb-commits] [lldb] 3c0fba4 - Revert "Revert "[lldb] Extend frame recognizers to hide frames from backtraces (#104523)""

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T11:06:01-07:00
New Revision: 3c0fba4f2471cacb27d787c7d8f54f21d9dcafae

URL: 
https://github.com/llvm/llvm-project/commit/3c0fba4f2471cacb27d787c7d8f54f21d9dcafae
DIFF: 
https://github.com/llvm/llvm-project/commit/3c0fba4f2471cacb27d787c7d8f54f21d9dcafae.diff

LOG: Revert "Revert "[lldb] Extend frame recognizers to hide frames from 
backtraces (#104523)""

This reverts commit 547917aebd1e79a8929b53f0ddf3b5185ee4df74.

Added: 
lldb/test/API/lang/cpp/std-function-recognizer/Makefile
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
lldb/test/API/lang/cpp/std-function-recognizer/main.cpp

Modified: 
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBFrame.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/StackFrame.h
lldb/include/lldb/Target/StackFrameList.h
lldb/include/lldb/Target/StackFrameRecognizer.h
lldb/include/lldb/Target/Thread.h
lldb/source/API/SBFrame.cpp
lldb/source/API/SBThread.cpp
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/Options.td
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Target/Process.cpp
lldb/source/Target/StackFrame.cpp
lldb/source/Target/StackFrameList.cpp
lldb/source/Target/StackFrameRecognizer.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadPlanStepOut.cpp
lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
lldb/test/API/commands/frame/recognizer/main.m
lldb/test/API/commands/frame/recognizer/recognizer.py

Removed: 




diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 8f050643fa68b3..2ce42e3e017d5b 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -813,7 +813,7 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecogni
 }
 
 PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
-PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
   static char callee_name[] = "get_recognized_arguments";
 
   PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
@@ -824,6 +824,22 @@ PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArgument
   return result;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
+  static char callee_name[] = "should_hide";
+
+  PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
+
+  PythonString str(callee_name);
+
+  PyObject *result =
+  PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
+  bool ret_val = result ? PyObject_IsTrue(result) : false;
+  Py_XDECREF(result);
+
+  return result;
+}
+
 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
 void *module, const char *setting, const lldb::TargetSP &target_sp) {
   if (!module || !setting)

diff  --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 821ff3cf7ce519..e0d15c3ecc5b1c 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -104,6 +104,10 @@ class LLDB_API SBFrame {
 
   bool IsArtificial() const;
 
+  /// Return whether a frame recognizer decided this frame should not
+  /// be displayes in backtraces etc.
+  bool IsHidden() const;
+
   /// The version that doesn't supply a 'use_dynamic' value will use the
   /// target's default.
   lldb::SBValue EvaluateExpression(const char *expr);

diff  --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 05f0d7f0955f3e..89a480a28880aa 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -252,6 +252,11 @@ class ScriptInterpreter : public PluginInterface {
 return lldb::ValueObjectListSP();
   }
 
+  virtual bool ShouldHide(const StructuredData::ObjectSP &implementor,
+  lldb::StackFrameSP frame_sp) {
+return false;
+  }
+
   virtual StructuredData::GenericSP
   CreateScriptedBreakpointResolver(const char *class_name,
const StructuredDataImpl &args_data,

diff  --git a/lldb/include/lldb/Target/StackFrame

[Lldb-commits] [lldb] 9e9e823 - Revert "Revert "[lldb-dap] Mark hidden frames as "subtle" (#105457)""

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T11:06:01-07:00
New Revision: 9e9e8238df63b9f10c6635d3f16d8a0fbc7f00c4

URL: 
https://github.com/llvm/llvm-project/commit/9e9e8238df63b9f10c6635d3f16d8a0fbc7f00c4
DIFF: 
https://github.com/llvm/llvm-project/commit/9e9e8238df63b9f10c6635d3f16d8a0fbc7f00c4.diff

LOG: Revert "Revert "[lldb-dap] Mark hidden frames as "subtle" (#105457)""

This reverts commit aa70f83e660453c006193aab7ba67c94db236948.

Added: 
lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp

Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
new file mode 100644
index 00..1e41e841e39bc8
--- /dev/null
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -0,0 +1,29 @@
+"""
+Test lldb-dap stack trace response
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+
+import lldbdap_testcase
+from lldbsuite.test.lldbtest import *
+
+
+class TestDAP_subtleFrames(lldbdap_testcase.DAPTestCaseBase):
+@add_test_categories(["libc++"])
+def test_subtleFrames(self):
+"""
+Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
+self.continue_to_next_stop()
+
+frames = self.get_stackFrames()
+for f in frames:
+if "__function" in f["name"]:
+self.assertEqual(f["presentationHint"], "subtle")
+self.assertTrue(any(f.get("presentationHint") == "subtle" for f in 
frames))

diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
new file mode 100644
index 00..71944528441e38
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
@@ -0,0 +1,13 @@
+#include 
+#include 
+
+void greet() {
+  // BREAK HERE
+  std::cout << "Hello\n";
+}
+
+int main() {
+  std::function func{greet};
+  func();
+  return 0;
+}

diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index a8b85f55939e17..c080fd395b7288 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -763,6 +763,9 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
 object.try_emplace("instructionPointerReference", formatted_addr);
   }
 
+  if (frame.IsArtificial() || frame.IsHidden())
+object.try_emplace("presentationHint", "subtle");
+
   return llvm::json::Value(std::move(object));
 }
 



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


[Lldb-commits] [lldb] ad75775 - Revert "Revert "[lldb][swig] Use the correct variable in the return statement""

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T11:06:01-07:00
New Revision: ad7577524286ae6070dc7f18bde35cf050d31e5e

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

LOG: Revert "Revert "[lldb][swig] Use the correct variable in the return 
statement""

This reverts commit 7323e7eee3a819e9a2d8ec29f00d362bcad87731.

Added: 


Modified: 
lldb/bindings/python/python-wrapper.swig

Removed: 




diff  --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 2ce42e3e017d5b..360c392235a866 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -837,7 +837,7 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
   bool ret_val = result ? PyObject_IsTrue(result) : false;
   Py_XDECREF(result);
 
-  return result;
+  return ret_val;
 }
 
 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(



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


[Lldb-commits] [lldb] 11d2de4 - [lldb] Fix uninitialized variable

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T11:06:02-07:00
New Revision: 11d2de436cbab8667fe1f99d7b538e6fb555b4d7

URL: 
https://github.com/llvm/llvm-project/commit/11d2de436cbab8667fe1f99d7b538e6fb555b4d7
DIFF: 
https://github.com/llvm/llvm-project/commit/11d2de436cbab8667fe1f99d7b538e6fb555b4d7.diff

LOG: [lldb] Fix uninitialized variable

Added: 


Modified: 
lldb/include/lldb/Target/StackFrame.h

Removed: 




diff  --git a/lldb/include/lldb/Target/StackFrame.h 
b/lldb/include/lldb/Target/StackFrame.h
index e4d17847763acf..5cc0fccee03b8f 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -539,7 +539,7 @@ class StackFrame : public ExecutionContextScope,
   Flags m_flags;
   Scalar m_frame_base;
   Status m_frame_base_error;
-  uint16_t m_frame_recognizer_generation;
+  uint16_t m_frame_recognizer_generation = 0;
   /// Does this frame have a CFA?  Different from CFA == LLDB_INVALID_ADDRESS.
   bool m_cfa_is_valid;
   Kind m_stack_frame_kind;



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


[Lldb-commits] [lldb] [lldb] Support frame recognizer regexp on mangled names. (PR #105756)

2024-08-23 Thread Adrian Prantl via lldb-commits


@@ -92,11 +95,13 @@ void StackFrameRecognizerManager::ForEach(
 symbol_name = entry.symbol_regexp->GetText().str();
 
   callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
-   llvm::ArrayRef(ConstString(symbol_name)), true);
+   llvm::ArrayRef(ConstString(symbol_name)), entry.symbol_mangling,
+   true);
 
 } else {
   callback(entry.recognizer_id, entry.recognizer->GetName(),
-   entry.module.GetCString(), entry.symbols, false);
+   entry.module.GetCString(), entry.symbols, entry.symbol_mangling,
+   false);
 }
   }
 }

adrian-prantl wrote:

I relanded everything in 11d2de436cbab8667fe1f99d7b538e6fb555b4d7.

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


[Lldb-commits] [lldb] [lldb][NFC] Defer python init until ScriptInterpreter is created (PR #105757)

2024-08-23 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

There's a few things I don't really like about this patch: 

 - It's very specific to a single plugin. 
 - It sidesteps the plugin's `Initialize/Terminate` paradigm. It happens to 
work because `ScriptInterpreterPython::Terminate` is a NOOP (see the comment 
for `ScriptInterpreterPythonImpl::Terminate` on why). It's not that we don't 
have other places where things persist after termination, but as we've seen, 
that can cause problems, for example in unit testing. 
 - It relies on changing the scripting language early enough to make sure the 
plugin doesn't get loaded. If the code changes and tries to use the plugin 
before you have the opportunity to call `SetScriptLanguage` you're back to 
square one.  

If it's important to disable certain plugins at runtime, I wonder if we 
shouldn't do this in a more structured way. 

 - We could make the initialization of all plugins lazy. If we're always going 
through the plugin interface, this should work. The question is if this is 
beneficial. 
 - We could extend `SBDebugger::Initialize` with a list of plugins to disable. 
I expect this to be somewhat contentious though, as there are certain plugins 
that depend on other plugins. We had a long discussion about this when I wrote 
a patch to do this at compile time, which would have the same limitations as 
doing it at runtime. 
 - A combination or hybrid of the two, where you can tell which plugins to load 
lazily and which ones not to load. 

Can you elaborate on why it's important that the `PythonScriptInterepter` 
doesn't get initialized? Maybe that can help guide the solution instead of 
working back from the current patch. 

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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/105873

The existing algorithm was performing the following comparisons for an 
`aaa,bbb,ccc,ddd`:

aaa\0bbb,ccc,ddd == "stack"
aaa\0bbb\0ccc,ddd == "stack"
aaa\0bbb\0ccc\0ddd == "stack"

Which wouldn't work. This commit just dispatches to a known algorithm 
implementation.

>From 8ef8ecdc8d87d474b906835d04ffdd9a19216406 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Fri, 23 Aug 2024 11:43:16 -0700
Subject: [PATCH] [GDBRemote] Fix processing of comma-separated memory region
 entries

The existing algorithm was performing the following comparisons for an
`aaa,bbb,ccc,ddd`:

aaa\0bbb,ccc,ddd == "stack"
aaa\0bbb\0ccc,ddd == "stack"
aaa\0bbb\0ccc\0ddd == "stack"

Which wouldn't work. This commit just dispatches to a known algorithm
implementation.
---
 .../gdb-remote/GDBRemoteCommunicationClient.cpp  | 12 ++--
 .../gdb-remote/GDBRemoteCommunicationClientTest.cpp  |  7 +--
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 83ba27783da471..d80ccae0518088 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1632,17 +1632,9 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
 }
   }
 } else if (name == "type") {
-  std::string comma_sep_str = value.str();
-  size_t comma_pos;
-  while ((comma_pos = comma_sep_str.find(',')) != std::string::npos) {
-comma_sep_str[comma_pos] = '\0';
-if (comma_sep_str == "stack") {
+  for (llvm::StringRef entry: llvm::split(value, ',')) {
+if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
-}
-  }
-  // handle final (or only) type of "stack"
-  if (comma_sep_str == "stack") {
-region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);
diff --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 11e14f9472164d..18020c8e43fe06 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -343,24 +343,27 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
   EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
   EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags:;");
+   "start:a000;size:2000;flags:;type:stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags: mt  zz mt  ;");
+   "start:a000;size:2000;flags: mt  zz mt  ;type:ha,ha,stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {

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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

The existing algorithm was performing the following comparisons for an 
`aaa,bbb,ccc,ddd`:

aaa\0bbb,ccc,ddd == "stack"
aaa\0bbb\0ccc,ddd == "stack"
aaa\0bbb\0ccc\0ddd == "stack"

Which wouldn't work. This commit just dispatches to a known algorithm 
implementation.

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


2 Files Affected:

- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+2-10) 
- (modified) 
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (+5-2) 


``diff
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 83ba27783da471..d80ccae0518088 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1632,17 +1632,9 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
 }
   }
 } else if (name == "type") {
-  std::string comma_sep_str = value.str();
-  size_t comma_pos;
-  while ((comma_pos = comma_sep_str.find(',')) != std::string::npos) {
-comma_sep_str[comma_pos] = '\0';
-if (comma_sep_str == "stack") {
+  for (llvm::StringRef entry: llvm::split(value, ',')) {
+if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
-}
-  }
-  // handle final (or only) type of "stack"
-  if (comma_sep_str == "stack") {
-region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);
diff --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 11e14f9472164d..18020c8e43fe06 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -343,24 +343,27 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
   EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
   EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags:;");
+   "start:a000;size:2000;flags:;type:stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags: mt  zz mt  ;");
+   "start:a000;size:2000;flags: mt  zz mt  ;type:ha,ha,stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {

``




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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Jason Molenda via lldb-commits

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

Thanks for fixing this, looks perfect.

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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 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 aec3ec04ac611f9a3d1e1ad075d50f62c1d1a1e2 
8ef8ecdc8d87d474b906835d04ffdd9a19216406 --extensions cpp -- 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index d80ccae051..d7a0baa488 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1632,7 +1632,7 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
 }
   }
 } else if (name == "type") {
-  for (llvm::StringRef entry: llvm::split(value, ',')) {
+  for (llvm::StringRef entry : llvm::split(value, ',')) {
 if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
   }

``




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


[Lldb-commits] [lldb] a0fac6f - [lldb] Add missing initialization (NFC)

2024-08-23 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-23T12:09:19-07:00
New Revision: a0fac6f2d868316a88aa5b62963e26dca9bfa372

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

LOG: [lldb] Add missing initialization (NFC)

Added: 


Modified: 
lldb/include/lldb/Target/StackFrameRecognizer.h

Removed: 




diff  --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 8acebc12c4b1dc..2f5c5caa6a4561 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -146,7 +146,7 @@ class StackFrameRecognizerManager {
   };
 
   std::deque m_recognizers;
-  uint16_t m_generation;
+  uint16_t m_generation = 0;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue



___
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-23 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

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

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][Data Formatters] Calculate average and total time for summary providers within lldb (PR #102708)

2024-08-23 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@Michael137 implemented your feedback, and I got gcf to work. I'm going to let 
CI run and then merge. Thanks for your patience!

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


[Lldb-commits] [lldb] [lldb-dap] show dialog when executable is not found (PR #104711)

2024-08-23 Thread via lldb-commits

Da-Viper wrote:

![Screenshot from 2024-08-23 
20-16-35](https://github.com/user-attachments/assets/433234ab-dc1c-4907-a222-1961c97b0673)

This is what is shown when I return undefined from the 
createDebugAdapterDescriptor function 

If I also throw ```vscode.FileSystemError.FileExists(`Debug path: ${path} is 
not vaild`)```
It shows the same as above but with the file path as a description 

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


[Lldb-commits] [lldb] [lldb-dap] show dialog when executable is not found (PR #104711)

2024-08-23 Thread via lldb-commits

https://github.com/Da-Viper updated 
https://github.com/llvm/llvm-project/pull/104711

>From 2cda519a06d46bd6a5ae02e8be8daacb39a49b3e Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Thu, 22 Aug 2024 01:42:17 +0100
Subject: [PATCH 1/3] Rebase and add check dap path on config change

---
 .../lldb-dap/src-ts/debug-adapter-factory.ts  | 42 ++
 lldb/tools/lldb-dap/src-ts/extension.ts   | 43 ++-
 2 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 01c671f41ff782..8a8f441581b29e 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -14,10 +14,52 @@ export class LLDBDapDescriptorFactory
 this.lldbDapOptions = lldbDapOptions;
   }
 
+  public static async validateDebugAdapterPath(pathUri: vscode.Uri) {
+try {
+  const fileStats = await vscode.workspace.fs.stat(pathUri);
+  if (!(fileStats.type & vscode.FileType.File)) {
+this.showErrorMessage(pathUri.path);
+  }
+} catch (err) {
+  this.showErrorMessage(pathUri.path);
+}
+  }
+
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
 executable: vscode.DebugAdapterExecutable | undefined,
   ): Promise {
+const config = vscode.workspace.getConfiguration(
+  "lldb-dap",
+  session.workspaceFolder,
+);
+const customPath = config.get("executable-path");
+const path: string = customPath ? customPath : executable!!.command;
+
+await LLDBDapDescriptorFactory.validateDebugAdapterPath(
+  vscode.Uri.file(path),
+);
 return this.lldbDapOptions.createDapExecutableCommand(session, executable);
   }
+
+  /**
+   * Shows a message box when the debug adapter's path is not found
+   */
+  private static showErrorMessage(path: string) {
+const openSettingsAction = "Open Settings";
+vscode.window
+  .showErrorMessage(
+`Debug adapter path: ${path} is not a valid file`,
+{ modal: false },
+openSettingsAction,
+  )
+  .then((callBackValue) => {
+if (openSettingsAction === callBackValue) {
+  vscode.commands.executeCommand(
+"workbench.action.openSettings",
+"lldb-dap.executable-path",
+  );
+}
+  });
+  }
 }
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts 
b/lldb/tools/lldb-dap/src-ts/extension.ts
index 7df09f7a29dad7..12565a8fbe9a0a 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -14,26 +14,32 @@ function createDefaultLLDBDapOptions(): LLDBDapOptions {
   session: vscode.DebugSession,
   packageJSONExecutable: vscode.DebugAdapterExecutable | undefined,
 ): Promise {
-  const config = vscode.workspace
-.getConfiguration("lldb-dap", session.workspaceFolder);
+  const config = vscode.workspace.getConfiguration(
+"lldb-dap",
+session.workspaceFolder,
+  );
   const path = config.get("executable-path");
   const log_path = config.get("log-path");
 
-  let env : { [key: string]: string } = {};
+  let env: { [key: string]: string } = {};
   if (log_path) {
 env["LLDBDAP_LOG"] = log_path;
   }
 
   if (path) {
-return new vscode.DebugAdapterExecutable(path, [], {env});
+return new vscode.DebugAdapterExecutable(path, [], { env });
   } else if (packageJSONExecutable) {
-return new 
vscode.DebugAdapterExecutable(packageJSONExecutable.command, 
packageJSONExecutable.args, {
-  ...packageJSONExecutable.options,
-  env: {
-...packageJSONExecutable.options?.env,
-...env
-  }
-});
+return new vscode.DebugAdapterExecutable(
+  packageJSONExecutable.command,
+  packageJSONExecutable.args,
+  {
+...packageJSONExecutable.options,
+env: {
+  ...packageJSONExecutable.options?.env,
+  ...env,
+},
+  },
+);
   } else {
 return undefined;
   }
@@ -58,6 +64,21 @@ export class LLDBDapExtension extends DisposableContext {
 new LLDBDapDescriptorFactory(this.lldbDapOptions),
   ),
 );
+
+this.pushSubscription(
+  vscode.workspace.onDidChangeConfiguration((event) => {
+if (event.affectsConfiguration("lldb-dap.executable-path")) {
+  const dapPath = vscode.workspace
+.getConfiguration("lldb-dap")
+.get("executable-path");
+  if (dapPath) {
+LLDBDapDescriptorFactory.validateDebugAdapterPath(
+  vscode.Uri.file(dapPath),
+);
+  }
+}
+  }),
+);
   }
 }
 

>From 443c71a4af2fa03eb911deb9b086a2e7e6f1daf1 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Thu, 22 Aug 2024 18:54:03 +0100
Subject: [PATCH 2/3] Resol

[Lldb-commits] [lldb] [lldb][NFC] Defer python init until ScriptInterpreter is created (PR #105757)

2024-08-23 Thread Daniel Xu via lldb-commits

danobi wrote:

 Hi @JDevlieghere , thanks for taking a look at this.

I'm not very familiar with lldb in general so I can't comment much on 
alternatives. Lazy loading does some fairly reasonable to me but I don't know 
what kind of code changes that'd require.

The motivation behind this change starts with 
https://github.com/bpftrace/bpftrace/issues/3329. Basically we got a bug report 
from a user saying they're getting python errors when running bpftrace. 
bpftrace does not use python at runtime anywhere, so it was quite surprising. 
It turns out that lldb was running python standard library code. And the 
environment bpftrace was running in (appimage) does not have any python 
support, so no standard library available.

For context, bpftrace uses liblldb to parse DWARF. We used to directly use 
libdw but it was kinda hard to work with. liblldb has very nice high level API 
that we found useful for velocity. We never have (and probably never will) use 
python bindings to lldb.
The reason we can't just compile out python bindings is b/c we need to build 
with whatever distros give us. And my understanding is that distros are more or 
less forced to build with bindings on so that lldb (the cli tool) will function.

You're right that this patch only addresses a subset of the real goal - the 
real goal being we want to disable all plugins at runtime. It'd probably help 
with performance for other liblldb users as well.

Hopefully this essay makes the goal more clear. Please lemme know how we should 
proceed. I'd be happy to help out if it's not too complicated.


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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Since this is mostly uncontroversial, I am going to go ahead and merge it now. 
Happy to address feedback in post! 

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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/105873

>From fbe4fdfb0e804c281ed5c52382ef4bb16ec9fce5 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Fri, 23 Aug 2024 11:43:16 -0700
Subject: [PATCH] [GDBRemote] Fix processing of comma-separated memory region
 entries

The existing algorithm was performing the following comparisons for an
`aaa,bbb,ccc,ddd`:

aaa\0bbb,ccc,ddd == "stack"
aaa\0bbb\0ccc,ddd == "stack"
aaa\0bbb\0ccc\0ddd == "stack"

Which wouldn't work. This commit just dispatches to a known algorithm
implementation.
---
 .../gdb-remote/GDBRemoteCommunicationClient.cpp  | 12 ++--
 .../gdb-remote/GDBRemoteCommunicationClientTest.cpp  |  7 +--
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 83ba27783da471..d7a0baa488edc5 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1632,17 +1632,9 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
 }
   }
 } else if (name == "type") {
-  std::string comma_sep_str = value.str();
-  size_t comma_pos;
-  while ((comma_pos = comma_sep_str.find(',')) != std::string::npos) {
-comma_sep_str[comma_pos] = '\0';
-if (comma_sep_str == "stack") {
+  for (llvm::StringRef entry : llvm::split(value, ',')) {
+if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
-}
-  }
-  // handle final (or only) type of "stack"
-  if (comma_sep_str == "stack") {
-region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);
diff --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 11e14f9472164d..18020c8e43fe06 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -343,24 +343,27 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
   EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
   EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags:;");
+   "start:a000;size:2000;flags:;type:stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags: mt  zz mt  ;");
+   "start:a000;size:2000;flags: mt  zz mt  ;type:ha,ha,stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {

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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Fixed clang format issue

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


[Lldb-commits] [lldb] 8b4147d - [GDBRemote] Fix processing of comma-separated memory region entries (#105873)

2024-08-23 Thread via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2024-08-23T13:09:31-07:00
New Revision: 8b4147d14c460f8886e882db48361d4c101917d7

URL: 
https://github.com/llvm/llvm-project/commit/8b4147d14c460f8886e882db48361d4c101917d7
DIFF: 
https://github.com/llvm/llvm-project/commit/8b4147d14c460f8886e882db48361d4c101917d7.diff

LOG: [GDBRemote] Fix processing of comma-separated memory region entries 
(#105873)

The existing algorithm was performing the following comparisons for an
`aaa,bbb,ccc,ddd`:

aaa\0bbb,ccc,ddd == "stack"
aaa\0bbb\0ccc,ddd == "stack"
aaa\0bbb\0ccc\0ddd == "stack"

Which wouldn't work. This commit just dispatches to a known algorithm
implementation.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 83ba27783da471..d7a0baa488edc5 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1632,17 +1632,9 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
 }
   }
 } else if (name == "type") {
-  std::string comma_sep_str = value.str();
-  size_t comma_pos;
-  while ((comma_pos = comma_sep_str.find(',')) != std::string::npos) {
-comma_sep_str[comma_pos] = '\0';
-if (comma_sep_str == "stack") {
+  for (llvm::StringRef entry : llvm::split(value, ',')) {
+if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
-}
-  }
-  // handle final (or only) type of "stack"
-  if (comma_sep_str == "stack") {
-region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);

diff  --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 11e14f9472164d..18020c8e43fe06 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -343,24 +343,27 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
   EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
   EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags:;");
+   "start:a000;size:2000;flags:;type:stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 
   result = std::async(std::launch::async, [&] {
 return client.GetMemoryRegionInfo(addr, region_info);
   });
 
   HandlePacket(server, "qMemoryRegionInfo:a000",
-   "start:a000;size:2000;flags: mt  zz mt  ;");
+   "start:a000;size:2000;flags: mt  zz mt  ;type:ha,ha,stack;");
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
+  EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {



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


[Lldb-commits] [lldb] [GDBRemote] Fix processing of comma-separated memory region entries (PR #105873)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/105883

This should cause the memory region info "is stack" field to be set to "no".

>From 0730cd7f48dd4b80fba0275fed9beadcf6193987 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Fri, 23 Aug 2024 13:10:00 -0700
Subject: [PATCH] [GDBRemote] Handle 'heap' memory region info type

This should cause the memory region info "is stack" field to be set to "no".
---
 .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp  | 2 ++
 .../gdb-remote/GDBRemoteCommunicationClientTest.cpp  | 9 +
 2 files changed, 11 insertions(+)

diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index d7a0baa488edc5..6fbbfb03ed1176 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1635,6 +1635,8 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
   for (llvm::StringRef entry : llvm::split(value, ',')) {
 if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
+if (entry == "heap")
+  region_info.SetIsStackMemory(MemoryRegionInfo::eNo);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);
diff --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 18020c8e43fe06..ce5ab2cf508293 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -364,6 +364,15 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
+
+  result = std::async(std::launch::async, [&] {
+return client.GetMemoryRegionInfo(addr, region_info);
+  });
+
+  HandlePacket(server, "qMemoryRegionInfo:a000",
+   "start:a000;size:2000;type:heap;");
+  EXPECT_TRUE(result.get().Success());
+  EXPECT_EQ(MemoryRegionInfo::eNo, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {

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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

This should cause the memory region info "is stack" field to be set to "no".

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


2 Files Affected:

- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+2) 
- (modified) 
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (+9) 


``diff
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index d7a0baa488edc5..6fbbfb03ed1176 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1635,6 +1635,8 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
   for (llvm::StringRef entry : llvm::split(value, ',')) {
 if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
+if (entry == "heap")
+  region_info.SetIsStackMemory(MemoryRegionInfo::eNo);
   }
 } else if (name == "error") {
   StringExtractorGDBRemote error_extractor(value);
diff --git 
a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp 
b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 18020c8e43fe06..ce5ab2cf508293 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -364,6 +364,15 @@ TEST_F(GDBRemoteCommunicationClientTest, 
GetMemoryRegionInfo) {
   EXPECT_TRUE(result.get().Success());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
   EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
+
+  result = std::async(std::launch::async, [&] {
+return client.GetMemoryRegionInfo(addr, region_info);
+  });
+
+  HandlePacket(server, "qMemoryRegionInfo:a000",
+   "start:a000;size:2000;type:heap;");
+  EXPECT_TRUE(result.get().Success());
+  EXPECT_EQ(MemoryRegionInfo::eNo, region_info.IsStackMemory());
 }
 
 TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {

``




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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Jason Molenda via lldb-commits

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

Looks good!

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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Dave Lee via lldb-commits

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


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


[Lldb-commits] [lldb] [GDBRemote] Handle 'heap' memory region info type (PR #105883)

2024-08-23 Thread Dave Lee via lldb-commits


@@ -1635,6 +1635,8 @@ Status GDBRemoteCommunicationClient::GetMemoryRegionInfo(
   for (llvm::StringRef entry : llvm::split(value, ',')) {
 if (entry == "stack")
   region_info.SetIsStackMemory(MemoryRegionInfo::eYes);
+if (entry == "heap")

kastiglione wrote:

else if?

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


[Lldb-commits] [lldb] [lldb-dap] show dialog when executable is not found (PR #104711)

2024-08-23 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Thanks for the screenshot, man!

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


[Lldb-commits] [lldb] [lldb] Don't scan more than 10MB of assembly insns (PR #105890)

2024-08-23 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda created 
https://github.com/llvm/llvm-project/pull/105890

For supported architectures, lldb will do a static scan of the assembly 
instructions of a function to detect stack/frame pointer changes, register 
stores and loads, so we can retrieve register values for the caller stack 
frames.  We trust that the function address range reflects the actual function 
range, but in a stripped binary or other unusual environment, we can end up 
scanning all of the text as a single "function" which is (1) incorrect and 
useless, but more importantly (2) slow.

Cap the max size we will profile to 10MB of instructions.  There will surely be 
functions longer than this with no unwind info, and we will miss the final 
epilogue or mid-function epilogues past the first 10MB, but I think this will 
be unusual, and the failure more to missing the epilogue is that the user will 
need to step out an extra time or two as the StackID is not correctly 
calculated mid-epilogue.  I think this is a good tradeoff of behaviors.

rdar://134391577

>From fe4da52529c3a5988ecabe6289951c5e6833c6f7 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Fri, 23 Aug 2024 14:09:21 -0700
Subject: [PATCH] [lldb] Don't scan more than 10MB of assembly insns

For supported architectures, lldb will do a static scan of the
assembly instructions of a function to detect stack/frame pointer
changes, register stores and loads, so we can retrieve register
values for the caller stack frames.  We trust that the function
address range reflects the actual function range, but in a stripped
binary or other unusual environment, we can end up scanning all of
the text as a single "function" which is (1) incorrect and useless,
but more importantly (2) slow.

Cap the max size we will profile to 10MB of instructions.  There
will surely be functions longer than this with no unwind info, and
we will miss the final epilogue or mid-function epilogues past the
first 10MB, but I think this will be unusual, and the failure more
to missing the epilogue is that the user will need to step out an
extra time or two as the StackID is not correctly calculated
mid-epilogue.  I think this is a good tradeoff of behaviors.

rdar://134391577
---
 lldb/source/Symbol/FuncUnwinders.cpp | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Symbol/FuncUnwinders.cpp 
b/lldb/source/Symbol/FuncUnwinders.cpp
index d67c0a828eb350..228d9a1072deca 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -334,12 +334,22 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target 
&target,
 
   m_tried_unwind_plan_assembly = true;
 
+  // Don't analyze more than 10 megabytes of instructions,
+  // if a function is legitimately larger than that, we'll
+  // miss the epilogue instructions, but guard against a
+  // bogusly large function and analyzing large amounts of
+  // non-instruction data.
+  AddressRange range = m_range;
+  const addr_t func_size =
+  std::min(range.GetByteSize(), (addr_t)1024 * 10 * 10);
+  range.SetByteSize(func_size);
+
   UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
   if (assembly_profiler_sp) {
 m_unwind_plan_assembly_sp =
 std::make_shared(lldb::eRegisterKindGeneric);
 if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly(
-m_range, thread, *m_unwind_plan_assembly_sp)) {
+range, thread, *m_unwind_plan_assembly_sp)) {
   m_unwind_plan_assembly_sp.reset();
 }
   }

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


[Lldb-commits] [lldb] [lldb] Don't scan more than 10MB of assembly insns (PR #105890)

2024-08-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)


Changes

For supported architectures, lldb will do a static scan of the assembly 
instructions of a function to detect stack/frame pointer changes, register 
stores and loads, so we can retrieve register values for the caller stack 
frames.  We trust that the function address range reflects the actual function 
range, but in a stripped binary or other unusual environment, we can end up 
scanning all of the text as a single "function" which is (1) incorrect and 
useless, but more importantly (2) slow.

Cap the max size we will profile to 10MB of instructions.  There will surely be 
functions longer than this with no unwind info, and we will miss the final 
epilogue or mid-function epilogues past the first 10MB, but I think this will 
be unusual, and the failure more to missing the epilogue is that the user will 
need to step out an extra time or two as the StackID is not correctly 
calculated mid-epilogue.  I think this is a good tradeoff of behaviors.

rdar://134391577

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


1 Files Affected:

- (modified) lldb/source/Symbol/FuncUnwinders.cpp (+11-1) 


``diff
diff --git a/lldb/source/Symbol/FuncUnwinders.cpp 
b/lldb/source/Symbol/FuncUnwinders.cpp
index d67c0a828eb350..228d9a1072deca 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -334,12 +334,22 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target 
&target,
 
   m_tried_unwind_plan_assembly = true;
 
+  // Don't analyze more than 10 megabytes of instructions,
+  // if a function is legitimately larger than that, we'll
+  // miss the epilogue instructions, but guard against a
+  // bogusly large function and analyzing large amounts of
+  // non-instruction data.
+  AddressRange range = m_range;
+  const addr_t func_size =
+  std::min(range.GetByteSize(), (addr_t)1024 * 10 * 10);
+  range.SetByteSize(func_size);
+
   UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
   if (assembly_profiler_sp) {
 m_unwind_plan_assembly_sp =
 std::make_shared(lldb::eRegisterKindGeneric);
 if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly(
-m_range, thread, *m_unwind_plan_assembly_sp)) {
+range, thread, *m_unwind_plan_assembly_sp)) {
   m_unwind_plan_assembly_sp.reset();
 }
   }

``




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


[Lldb-commits] [lldb] [lldb] Don't scan more than 10MB of assembly insns (PR #105890)

2024-08-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

This has always been a small perf issue with stripped binaries, but there is an 
unusual case where it became a big problem:  wine, the windows environment, has 
a symbol at a low address like 0x1000, and it reserves the first 4GB of address 
space to load 32-bit windows binaries (without lldb's knowledge).  lldb has a 
backtrace where there is a saved pc near the high end of this range, we find 
the nearest symbol at 0x1000, and proceed to analyze 4GB of instructions which 
is quite slow.

I don't know how to represent this in a test case, unfortunately.  

We do have a similar limit over in 
UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly where we 
limit the disassembly to 9 instructions, this is not an entirely new idea.  
But there are codepaths that will not go through this method and still try to 
disassemble any size "function".

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


[Lldb-commits] [lldb] [lldb] Pick the correct architecutre when target and core file disagree (PR #105576)

2024-08-23 Thread Adrian Prantl via lldb-commits


@@ -562,17 +562,22 @@ Status ProcessMachCore::DoLoadCore() {
 
   SetCanJIT(false);
 
-  // The corefile's architecture is our best starting point.
-  ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
-
   CreateMemoryRegions();
 
   LoadBinariesAndSetDYLD();
 
   CleanupMemoryRegionPermissions();
 
+  ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
+  if (exe_module_sp && exe_module_sp->GetArchitecture().IsValid()) {
+GetTarget().SetArchitecture(exe_module_sp->GetArchitecture());
+  } else {
+// The corefile's architecture is our best starting point.
+ArchSpec arch(m_core_module_sp->GetArchitecture());
+if (arch.IsValid())
+  GetTarget().SetArchitecture(arch);
+  }

adrian-prantl wrote:

Is this more readable? (not sure)
```
 ArchSpec arch;
 if (ModuleSP exe_module_sp = GetTarget().GetExecutableModule())
   arch = exe_module_sp->GetArchitecture();
 if (!arch.IsValid())
   // The corefile's architecture is our best starting point.
   arch = m_core_module_sp->GetArchitecture();
 if (arch.IsValid())
   GetTarget().SetArchitecture(arch);
```

https://github.com/llvm/llvm-project/pull/105576
___
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-23 Thread Adrian Prantl 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;
+  }
+}();

adrian-prantl wrote:

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

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-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/105905

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.

>From 7641ce09208883f205c9a9deb19bae9d01f8cd70 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 Aug 2024 16:04:44 -0700
Subject: [PATCH] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP
 request handlers.

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.
---
 .../Python/lldbsuite/test/lldbplatformutil.py |  16 ++
 .../test/tools/lldb-dap/dap_server.py |  11 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   9 +-
 .../API/tools/lldb-dap/exception/Makefile |   2 +-
 .../lldb-dap/exception/TestDAP_exception.py   |   8 +-
 .../API/tools/lldb-dap/exception/cpp/Makefile |   3 +
 .../exception/cpp/TestDAP_exception_cpp.py|  26 ++
 .../API/tools/lldb-dap/exception/cpp/main.cpp |   6 +
 .../lldb-dap/exception/{main.cpp => main.c}   |   2 +-
 .../tools/lldb-dap/exception/objc/Makefile|   9 +
 .../exception/objc/TestDAP_exception_objc.py  |  27 ++
 .../API/tools/lldb-dap/exception/objc/main.m  |   8 +
 .../lldb-dap/extendedStackTrace/Makefile  |   5 +
 .../TestDAP_extendedStackTrace.py |  69 +
 .../tools/lldb-dap/extendedStackTrace/main.m  |  28 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |   4 +-
 .../TestDAP_stackTraceMissingFunctionName.py  |   5 -
 lldb/tools/lldb-dap/DAP.cpp   |   1 -
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  40 +++
 lldb/tools/lldb-dap/JSONUtils.h   |   3 +
 lldb/tools/lldb-dap/lldb-dap.cpp  | 253 +-
 22 files changed, 449 insertions(+), 88 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp
 rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, t

[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.

---

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


22 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+16) 
- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+11) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+7-2) 
- (modified) lldb/test/API/tools/lldb-dap/exception/Makefile (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py (+5-3) 
- (added) lldb/test/API/tools/lldb-dap/exception/cpp/Makefile (+3) 
- (added) lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py 
(+26) 
- (added) lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp (+6) 
- (renamed) lldb/test/API/tools/lldb-dap/exception/main.c (+1-1) 
- (added) lldb/test/API/tools/lldb-dap/exception/objc/Makefile (+9) 
- (added) lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py 
(+27) 
- (added) lldb/test/API/tools/lldb-dap/exception/objc/main.m (+8) 
- (added) lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile (+5) 
- (added) 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py 
(+69) 
- (added) lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m (+28) 
- (modified) lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py 
(+1-3) 
- (modified) 
lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py
 (-5) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (-1) 
- (modified) lldb/tools/lldb-dap/DAP.h (+1-1) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+40) 
- (modified) lldb/tools/lldb-dap/JSONUtils.h (+3) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+182-71) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, threadId=None):
+if threadId is None:
+threadId = self.get_thread_id()
+args_dict = {"threadId": threadId}
+command_dict = {
+"command": "exceptionInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 86eba355da83db..40d61636380588 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -100,13 +100,14 @@ def verify_breakpoint_hit(self, breakpoint_ids):
 return
 self.assertTrue(False, "breakpoint not hit")
 
-def verify_stop_exception_info(self, expected_description):
+def verify_stop_exception_info(s

[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

ashgti wrote:

This was based on the comments in 
https://github.com/llvm/llvm-project/pull/104874

LMKWYT

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


[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/105905

>From 7641ce09208883f205c9a9deb19bae9d01f8cd70 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 Aug 2024 16:04:44 -0700
Subject: [PATCH 1/2] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP
 request handlers.

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.
---
 .../Python/lldbsuite/test/lldbplatformutil.py |  16 ++
 .../test/tools/lldb-dap/dap_server.py |  11 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   9 +-
 .../API/tools/lldb-dap/exception/Makefile |   2 +-
 .../lldb-dap/exception/TestDAP_exception.py   |   8 +-
 .../API/tools/lldb-dap/exception/cpp/Makefile |   3 +
 .../exception/cpp/TestDAP_exception_cpp.py|  26 ++
 .../API/tools/lldb-dap/exception/cpp/main.cpp |   6 +
 .../lldb-dap/exception/{main.cpp => main.c}   |   2 +-
 .../tools/lldb-dap/exception/objc/Makefile|   9 +
 .../exception/objc/TestDAP_exception_objc.py  |  27 ++
 .../API/tools/lldb-dap/exception/objc/main.m  |   8 +
 .../lldb-dap/extendedStackTrace/Makefile  |   5 +
 .../TestDAP_extendedStackTrace.py |  69 +
 .../tools/lldb-dap/extendedStackTrace/main.m  |  28 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |   4 +-
 .../TestDAP_stackTraceMissingFunctionName.py  |   5 -
 lldb/tools/lldb-dap/DAP.cpp   |   1 -
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  40 +++
 lldb/tools/lldb-dap/JSONUtils.h   |   3 +
 lldb/tools/lldb-dap/lldb-dap.cpp  | 253 +-
 22 files changed, 449 insertions(+), 88 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp
 rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, threadId=None):
+if threadId is None:
+threadId = self.get_thread_id()
+args_dict = {"threadId": threadId}
+command_dict = {
+"command": "exceptionInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.

[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/105905

>From 7641ce09208883f205c9a9deb19bae9d01f8cd70 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 Aug 2024 16:04:44 -0700
Subject: [PATCH 1/3] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP
 request handlers.

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.
---
 .../Python/lldbsuite/test/lldbplatformutil.py |  16 ++
 .../test/tools/lldb-dap/dap_server.py |  11 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   9 +-
 .../API/tools/lldb-dap/exception/Makefile |   2 +-
 .../lldb-dap/exception/TestDAP_exception.py   |   8 +-
 .../API/tools/lldb-dap/exception/cpp/Makefile |   3 +
 .../exception/cpp/TestDAP_exception_cpp.py|  26 ++
 .../API/tools/lldb-dap/exception/cpp/main.cpp |   6 +
 .../lldb-dap/exception/{main.cpp => main.c}   |   2 +-
 .../tools/lldb-dap/exception/objc/Makefile|   9 +
 .../exception/objc/TestDAP_exception_objc.py  |  27 ++
 .../API/tools/lldb-dap/exception/objc/main.m  |   8 +
 .../lldb-dap/extendedStackTrace/Makefile  |   5 +
 .../TestDAP_extendedStackTrace.py |  69 +
 .../tools/lldb-dap/extendedStackTrace/main.m  |  28 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |   4 +-
 .../TestDAP_stackTraceMissingFunctionName.py  |   5 -
 lldb/tools/lldb-dap/DAP.cpp   |   1 -
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  40 +++
 lldb/tools/lldb-dap/JSONUtils.h   |   3 +
 lldb/tools/lldb-dap/lldb-dap.cpp  | 253 +-
 22 files changed, 449 insertions(+), 88 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp
 rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, threadId=None):
+if threadId is None:
+threadId = self.get_thread_id()
+args_dict = {"threadId": threadId}
+command_dict = {
+"command": "exceptionInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.

[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/105905

>From 7641ce09208883f205c9a9deb19bae9d01f8cd70 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 Aug 2024 16:04:44 -0700
Subject: [PATCH 1/4] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP
 request handlers.

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.
---
 .../Python/lldbsuite/test/lldbplatformutil.py |  16 ++
 .../test/tools/lldb-dap/dap_server.py |  11 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   9 +-
 .../API/tools/lldb-dap/exception/Makefile |   2 +-
 .../lldb-dap/exception/TestDAP_exception.py   |   8 +-
 .../API/tools/lldb-dap/exception/cpp/Makefile |   3 +
 .../exception/cpp/TestDAP_exception_cpp.py|  26 ++
 .../API/tools/lldb-dap/exception/cpp/main.cpp |   6 +
 .../lldb-dap/exception/{main.cpp => main.c}   |   2 +-
 .../tools/lldb-dap/exception/objc/Makefile|   9 +
 .../exception/objc/TestDAP_exception_objc.py  |  27 ++
 .../API/tools/lldb-dap/exception/objc/main.m  |   8 +
 .../lldb-dap/extendedStackTrace/Makefile  |   5 +
 .../TestDAP_extendedStackTrace.py |  69 +
 .../tools/lldb-dap/extendedStackTrace/main.m  |  28 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |   4 +-
 .../TestDAP_stackTraceMissingFunctionName.py  |   5 -
 lldb/tools/lldb-dap/DAP.cpp   |   1 -
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  40 +++
 lldb/tools/lldb-dap/JSONUtils.h   |   3 +
 lldb/tools/lldb-dap/lldb-dap.cpp  | 253 +-
 22 files changed, 449 insertions(+), 88 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp
 rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, threadId=None):
+if threadId is None:
+threadId = self.get_thread_id()
+args_dict = {"threadId": threadId}
+command_dict = {
+"command": "exceptionInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.

[Lldb-commits] [lldb] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP request handlers (PR #105905)

2024-08-23 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/105905

>From ebcf4842c7d6c5ac0da4976c9cffb68bc3b22807 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 23 Aug 2024 16:04:44 -0700
Subject: [PATCH 1/4] [lldb-dap] Improve `stackTrace` and `exceptionInfo` DAP
 request handlers.

Refactoring `stackTrace` to perform frame look ups in a more on-demand fashion 
to improve overall performance.

Additionally adding additional information to the `exceptionInfo` request to 
report exception stacks there instead of merging the exception stack into the 
stack trace. The `exceptionInfo` request is only called if a stop event occurs 
with `reason='exception'`, which should mitigate the performance of 
`SBThread::GetCurrentException` calls.

Adding unit tests for exception handling and stack trace supporting.
---
 .../Python/lldbsuite/test/lldbplatformutil.py |  16 ++
 .../test/tools/lldb-dap/dap_server.py |  11 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   9 +-
 .../API/tools/lldb-dap/exception/Makefile |   2 +-
 .../lldb-dap/exception/TestDAP_exception.py   |   8 +-
 .../API/tools/lldb-dap/exception/cpp/Makefile |   3 +
 .../exception/cpp/TestDAP_exception_cpp.py|  26 ++
 .../API/tools/lldb-dap/exception/cpp/main.cpp |   6 +
 .../lldb-dap/exception/{main.cpp => main.c}   |   2 +-
 .../tools/lldb-dap/exception/objc/Makefile|   9 +
 .../exception/objc/TestDAP_exception_objc.py  |  27 ++
 .../API/tools/lldb-dap/exception/objc/main.m  |   8 +
 .../lldb-dap/extendedStackTrace/Makefile  |   5 +
 .../TestDAP_extendedStackTrace.py |  69 +
 .../tools/lldb-dap/extendedStackTrace/main.m  |  28 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |   4 +-
 .../TestDAP_stackTraceMissingFunctionName.py  |   5 -
 lldb/tools/lldb-dap/DAP.cpp   |   1 -
 lldb/tools/lldb-dap/DAP.h |   2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  40 +++
 lldb/tools/lldb-dap/JSONUtils.h   |   3 +
 lldb/tools/lldb-dap/lldb-dap.cpp  | 253 +-
 22 files changed, 449 insertions(+), 88 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/cpp/main.cpp
 rename lldb/test/API/tools/lldb-dap/exception/{main.cpp => main.c} (56%)
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/exception/objc/TestDAP_exception_objc.py
 create mode 100644 lldb/test/API/tools/lldb-dap/exception/objc/main.m
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py
 create mode 100644 lldb/test/API/tools/lldb-dap/extendedStackTrace/main.m

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 602e15d207e94a..3d8c713562e9bf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -181,6 +181,22 @@ def findMainThreadCheckerDylib():
 return ""
 
 
+def findBacktraceRecordingDylib():
+if not platformIsDarwin():
+return ""
+
+if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
+return "/Developer/usr/lib/libBacktraceRecording.dylib"
+
+with os.popen("xcode-select -p") as output:
+xcode_developer_path = output.read().strip()
+mtc_dylib_path = "%s/usr/lib/libBacktraceRecording.dylib" % 
xcode_developer_path
+if os.path.isfile(mtc_dylib_path):
+return mtc_dylib_path
+
+return ""
+
+
 class _PlatformContext(object):
 """Value object class which contains platform-specific options."""
 
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 874383a13e2bb6..167142779cf12c 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -707,6 +707,17 @@ def request_evaluate(self, expression, frameIndex=0, 
threadId=None, context=None
 }
 return self.send_recv(command_dict)
 
+def request_exceptionInfo(self, threadId=None):
+if threadId is None:
+threadId = self.get_thread_id()
+args_dict = {"threadId": threadId}
+command_dict = {
+"command": "exceptionInfo",
+"type": "request",
+"arguments": args_dict,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.

[Lldb-commits] [lldb] Fix dap stacktrace perf issue (PR #104874)

2024-08-23 Thread via lldb-commits

jeffreytan81 wrote:

As another data point, I just encountered a telemetry data from a customer. 
Taking profile trace from that session shows "stackTrace" request takes more 
than 4 seconds. Around 94% of the time was spent in this hot path performing 
function evaluation:  
```
   lldb_dap::DAP::Loop()
   lldb_dap::DAP::HandleObject(llvm::json::Object const&)
   (anonymous namespace)::request_stackTrace(llvm::json::Object 
const&)
   |
   |--93.90%--lldb::SBThread::GetCurrentExceptionBacktrace()
   |  lldb_private::Thread::GetCurrentExceptionBacktrace()
   |  lldb_private::Thread::GetCurrentException()
   |  
lldb_private::ItaniumABILanguageRuntime::GetExceptionObjectForThread(std::shared_ptr)
   |  |
   |  
|--91.09%--lldb_private::FunctionCaller::ExecuteFunction(lldb_private::ExecutionContext&,
 unsigned long*, lldb_private::EvaluateExpressionOptions const&, 
lldb_private::DiagnosticManager&, lldb_private::Value&)
   |  |  |
   |  |  
|--87.22%--lldb_private::FunctionCaller::InsertFunction(lldb_private::ExecutionContext&,
 unsigned long&, lldb_private::DiagnosticManager&)
   |  |  |  |
   |  |  |   
--87.13%--lldb_private::FunctionCaller::WriteFunctionWrapper(lldb_private::ExecutionContext&,
 lldb_private::DiagnosticManager&)
   |  |  | |
   |  |  |  
--86.33%--lldb_private::IRExecutionUnit::GetJITModule()
   |  |  |
lldb_private::Module::SetLoadAddress(lldb_private::Target&, unsigned long, 
bool, bool&)
   |  |  |
lldb_private::ObjectFileJIT::SetLoadAddress(lldb_private::Target&, unsigned 
long, bool)
```

So this will fix a potential massive performance issue in VSCode IDE. 

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


[Lldb-commits] [lldb] Fix dap stacktrace perf issue (PR #104874)

2024-08-23 Thread via lldb-commits

jeffreytan81 wrote:

And just for fun, here is an extreme one with 18 seconds of sampling time, 
99.6% time is from this hot path. Note: they are all from linux machines 
because we only enable perf sampling by default for linux platform so we have 
no Mac data.

```
# time of first sample : 2646936.334980
# time of last sample : 2646954.518041
# sample duration :  18183.061 ms

99.63% 0.00%  lldb-dap lldb-dap  [.] main
|
---main
   lldb_dap::DAP::Loop()
   lldb_dap::DAP::HandleObject(llvm::json::Object const&)
   (anonymous namespace)::request_stackTrace(llvm::json::Object 
const&)
   |
--99.60%--lldb::SBThread::GetCurrentExceptionBacktrace()
  lldb_private::Thread::GetCurrentExceptionBacktrace()
  lldb_private::Thread::GetCurrentException()
  
lldb_private::ItaniumABILanguageRuntime::GetExceptionObjectForThread(std::shared_ptr)
  |
   
--99.60%--lldb_private::FunctionCaller::ExecuteFunction(lldb_private::ExecutionContext&,
 unsigned long*, lldb_private::EvaluateExpressionOptions const&, 
lldb_private::DiagnosticManager&, lldb_private::Value&)
 |
 
|--44.33%--lldb_private::ClangFunctionCaller::CompileFunction(std::shared_ptr,
 lldb_private::DiagnosticManager&)
 |  |
 |  
|--39.56%--lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&,
 clang::CodeCompleteConsumer*, unsigned int, unsigned int)
 |  |  |
 |  |  
|--21.86%--clang::ParseAST(clang::Sema&, bool, bool)
 |  |  |  |
 |  |  |  
|--17.47%--clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&,
 clang::Sema::ModuleImportState&)
 |  |  |  | 
 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&)
 |  |  |  | 
 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*)
 |  |  |  | 
 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier)
 |  |  |  | 
 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec&,
...
```

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/105765

>From 6a27ad3be748a6072014a805a5a94dede9321432 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 22 Aug 2024 18:29:55 -0700
Subject: [PATCH 1/2] [lldb] Remove limit on max memory read size

`memory read` will return an error if you try to read more than 1k
bytes in a single command, instructing you to set
`target.max-memory-read-size` or use `--force` if you intended to
read more than that.  This is a safeguard for a command where people
are being explicit about how much memory they would like lldb to
read (either to display, or save to a file) and is an annoyance
every time you need to read more than a small amount.  If someone
confuses the --count argument with the start address, lldb may begin
dumping gigabytes of data but I'd rather that behavior than requiring
everyone to special-case their way around a common use case.
---
 lldb/source/Target/TargetProperties.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 7bb5bd53688b14..f553d92f7c64f6 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -102,7 +102,7 @@ let Definition = "target" in {
 DefaultUnsignedValue<1024>,
 Desc<"Maximum number of characters to show when using %s in summary 
strings.">;
   def MaxMemReadSize: Property<"max-memory-read-size", "UInt64">,
-DefaultUnsignedValue<1024>,
+DefaultUnsignedValue<4294967295>,
 Desc<"Maximum number of bytes that 'memory read' will fetch before --force 
must be specified.">;
   def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", 
"Boolean">,
 DefaultTrue,

>From 3d63f0b0c6c7f28422d271f89977635d2e8cd4df Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Fri, 23 Aug 2024 19:14:01 -0700
Subject: [PATCH 2/2] Change to using a hex value in .td, fix API test

---
 lldb/source/Target/TargetProperties.td  | 2 +-
 .../memory/big-read/TestMemoryReadMaximumSize.py| 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index f553d92f7c64f6..0f68deb543f90e 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -102,7 +102,7 @@ let Definition = "target" in {
 DefaultUnsignedValue<1024>,
 Desc<"Maximum number of characters to show when using %s in summary 
strings.">;
   def MaxMemReadSize: Property<"max-memory-read-size", "UInt64">,
-DefaultUnsignedValue<4294967295>,
+DefaultUnsignedValue<0x>,
 Desc<"Maximum number of bytes that 'memory read' will fetch before --force 
must be specified.">;
   def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", 
"Boolean">,
 DefaultTrue,
diff --git 
a/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py 
b/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
index 259fde71a63626..1bc227dfce9bef 100644
--- a/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
+++ b/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
@@ -22,6 +22,8 @@ def test_memory_read_max_setting(self):
 )
 self.assertTrue(self.bp.IsValid())
 
+self.runCmd("settings set target.max-memory-read-size 1024")
+
 self.expect(
 "mem rea -f x -s 4 -c 2048 `&c`",
 error=True,

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Updated patch to a hex constant in the .td file as per Ismail's suggestion, 
fixed the new TestMemoryReadMaximumSize.py test to work with the new default.

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Med Ismail Bennani via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

both of the linux PR tests failed in Unwind/trap_frame_sym_ctx.test, I could 
have sworn the only test failure I had before was in 
TestMemoryReadMaximumSize.py, I don't see how this PR breaks that test case. 
Hmm.

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> both of the linux PR tests failed in Unwind/trap_frame_sym_ctx.test, I could 
> have sworn the only test failure I had before was in 
> TestMemoryReadMaximumSize.py, I don't see how this PR breaks that test case. 
> Hmm.

I believe that failure is unrelated to your PR since another user have the 
exact same issue in theirs: https://github.com/llvm/llvm-project/pull/105757. 
The issue seems to be resolved by 
https://github.com/llvm/llvm-project/pull/105695.

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> > both of the linux PR tests failed in Unwind/trap_frame_sym_ctx.test, I 
> > could have sworn the only test failure I had before was in 
> > TestMemoryReadMaximumSize.py, I don't see how this PR breaks that test 
> > case. Hmm.
> 
> I believe that failure is unrelated to your PR since another user have the 
> exact same issue in theirs: #105757. The issue seems to be resolved by 
> #105695.

thanks!  I want to leave this PR open until next week in case @clayborg has an 
opinion (this is def his orig code), but I won't look into that fail any 
further.

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


[Lldb-commits] [lldb] [lldb] Remove limit on max memory read size (PR #105765)

2024-08-23 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/105765

>From 6a27ad3be748a6072014a805a5a94dede9321432 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 22 Aug 2024 18:29:55 -0700
Subject: [PATCH 1/2] [lldb] Remove limit on max memory read size

`memory read` will return an error if you try to read more than 1k
bytes in a single command, instructing you to set
`target.max-memory-read-size` or use `--force` if you intended to
read more than that.  This is a safeguard for a command where people
are being explicit about how much memory they would like lldb to
read (either to display, or save to a file) and is an annoyance
every time you need to read more than a small amount.  If someone
confuses the --count argument with the start address, lldb may begin
dumping gigabytes of data but I'd rather that behavior than requiring
everyone to special-case their way around a common use case.
---
 lldb/source/Target/TargetProperties.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 7bb5bd53688b14..f553d92f7c64f6 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -102,7 +102,7 @@ let Definition = "target" in {
 DefaultUnsignedValue<1024>,
 Desc<"Maximum number of characters to show when using %s in summary 
strings.">;
   def MaxMemReadSize: Property<"max-memory-read-size", "UInt64">,
-DefaultUnsignedValue<1024>,
+DefaultUnsignedValue<4294967295>,
 Desc<"Maximum number of bytes that 'memory read' will fetch before --force 
must be specified.">;
   def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", 
"Boolean">,
 DefaultTrue,

>From 3d63f0b0c6c7f28422d271f89977635d2e8cd4df Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Fri, 23 Aug 2024 19:14:01 -0700
Subject: [PATCH 2/2] Change to using a hex value in .td, fix API test

---
 lldb/source/Target/TargetProperties.td  | 2 +-
 .../memory/big-read/TestMemoryReadMaximumSize.py| 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index f553d92f7c64f6..0f68deb543f90e 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -102,7 +102,7 @@ let Definition = "target" in {
 DefaultUnsignedValue<1024>,
 Desc<"Maximum number of characters to show when using %s in summary 
strings.">;
   def MaxMemReadSize: Property<"max-memory-read-size", "UInt64">,
-DefaultUnsignedValue<4294967295>,
+DefaultUnsignedValue<0x>,
 Desc<"Maximum number of bytes that 'memory read' will fetch before --force 
must be specified.">;
   def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", 
"Boolean">,
 DefaultTrue,
diff --git 
a/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py 
b/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
index 259fde71a63626..1bc227dfce9bef 100644
--- a/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
+++ b/lldb/test/API/functionalities/memory/big-read/TestMemoryReadMaximumSize.py
@@ -22,6 +22,8 @@ def test_memory_read_max_setting(self):
 )
 self.assertTrue(self.bp.IsValid())
 
+self.runCmd("settings set target.max-memory-read-size 1024")
+
 self.expect(
 "mem rea -f x -s 4 -c 2048 `&c`",
 error=True,

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