[Lldb-commits] [PATCH] D137247: [lldb] Allow plugins to extend DWARF expression parsing for vendor extensions

2022-11-03 Thread Philip Pfaffe via Phabricator via lldb-commits
pfaffe updated this revision to Diff 472863.
pfaffe marked 4 inline comments as done.
pfaffe added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137247/new/

https://reviews.llvm.org/D137247

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/include/lldb/Target/Platform.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/DWARFExpressionList.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -9,9 +9,11 @@
 #include "lldb/Expression/DWARFExpression.h"
 #include "Plugins/Platform/Linux/PlatformLinux.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Core/dwarf.h"
 #include "lldb/Host/HostInfo.h"
@@ -514,3 +516,242 @@
   ASSERT_EQ(result.GetValueType(), Value::ValueType::LoadAddress);
   ASSERT_EQ(result.GetScalar().UInt(), 0x5678u);
 }
+
+class CustomSymbolFileDWARF : public SymbolFileDWARF {
+  static char ID;
+
+public:
+  using SymbolFileDWARF::SymbolFileDWARF;
+
+  bool isA(const void *ClassID) const override {
+return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+
+  static llvm::StringRef GetPluginNameStatic() { return "custom_dwarf"; }
+
+  static llvm::StringRef GetPluginDescriptionStatic() {
+return "Symbol file reader with expression extensions.";
+  }
+
+  static void Initialize() {
+PluginManager::RegisterPlugin(GetPluginNameStatic(),
+  GetPluginDescriptionStatic(), CreateInstance,
+  SymbolFileDWARF::DebuggerInitialize);
+  }
+
+  static void Terminate() { PluginManager::UnregisterPlugin(CreateInstance); }
+
+  static lldb_private::SymbolFile *
+  CreateInstance(lldb::ObjectFileSP objfile_sp) {
+return new CustomSymbolFileDWARF(std::move(objfile_sp),
+ /*dwo_section_list*/ nullptr);
+  }
+
+  lldb::offset_t
+  GetVendorDWARFOpcodeSize(const lldb_private::DataExtractor &data,
+   const lldb::offset_t data_offset,
+   const uint8_t op) const final {
+auto offset = data_offset;
+if (op != DW_OP_WASM_location) {
+  return LLDB_INVALID_OFFSET;
+}
+
+// DW_OP_WASM_location WASM_GLOBAL:0x03 index:u32
+// Called with "arguments" 0x03 and 0x04
+// Location type:
+if (data.GetU8(&offset) != /* global */ 0x03) {
+  return LLDB_INVALID_OFFSET;
+}
+
+// Index
+if (data.GetU32(&offset) != 0x04) {
+  return LLDB_INVALID_OFFSET;
+}
+
+// Report the skipped distance:
+return offset - data_offset;
+  }
+
+  bool
+  ParseVendorDWARFOpcode(uint8_t op, const lldb_private::DataExtractor &opcodes,
+ lldb::offset_t &offset,
+ std::vector &stack) const final {
+if (op != DW_OP_WASM_location) {
+  return false;
+}
+
+// DW_OP_WASM_location WASM_GLOBAL:0x03 index:u32
+// Called with "arguments" 0x03 and  0x04
+// Location type:
+if (opcodes.GetU8(&offset) != /* global */ 0x03) {
+  return false;
+}
+
+// Index:
+if (opcodes.GetU32(&offset) != 0x04) {
+  return false;
+}
+
+// Return some value:
+stack.push_back({GetScalar(32, 42, false)});
+return true;
+  }
+};
+
+char CustomSymbolFileDWARF::ID;
+
+static auto testExpressionVendorExtensions(lldb::ModuleSP module_sp,
+   DWARFUnit &dwarf_unit) {
+  // Test that expression extensions can be evaluated, for example
+  // DW_OP_WASM_location which is not currently handled by DWARFExpression:
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_WASM_location, 0x03, // WASM_GLOBAL:0x03
+ 0x04, 0x00, 0x00,  // index:u32
+ 0x00, DW_OP_stack_value},
+module_sp, &dwarf_unit),
+   llvm::HasValue(GetScalar(32, 42, false)));
+
+  // Test that searches for opcodes work in the presence of extensions:
+  uint8_t expr[] = {DW_OP_WASM_location,   0x03, 0x04, 0x00, 0x00, 0x00,
+DW_OP_form_tls_address};
+  DataExtractor extractor(expr, sizeof(expr), lldb::eByteOrderLittle,
+  /*addr_size*/

[Lldb-commits] [PATCH] D137247: [lldb] Allow plugins to extend DWARF expression parsing for vendor extensions

2022-11-03 Thread Philip Pfaffe via Phabricator via lldb-commits
pfaffe added inline comments.



Comment at: lldb/unittests/Expression/DWARFExpressionTest.cpp:719
+  Type:ET_EXEC
+  Machine: EM_386
+Sections:

DavidSpickett wrote:
> I know it's just a test but is there an `EM_WASM` you could use?
> 
> Maybe lldb doesn't understand that name yet so it makes no difference anyway.
There's no EM_WASM, in fact wasm has it's own non-ELF container. I picked x86 
ELF  because ELFYAML has the DWARF section which is convenient, WASMYAML sadly 
does not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137247/new/

https://reviews.llvm.org/D137247

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


[Lldb-commits] [PATCH] D137312: [LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()

2022-11-03 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.

LGTM. Follows the same logic AArch64 does. (meaning: we don't support debugging 
32 bit from a 64 bit lldb very well, if it all, but it's still noted here as 
possible)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137312/new/

https://reviews.llvm.org/D137312

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


[Lldb-commits] [PATCH] D137272: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

2022-11-03 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Test passes on AArch64 Ubuntu 20.04.4, where it failed prior to this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137272/new/

https://reviews.llvm.org/D137272

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


[Lldb-commits] [PATCH] D137272: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

2022-11-03 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Thanks.

I haven't tried the patch myself, but I see no reason why it should behave for 
me (x86) any different than on aarch64.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137272/new/

https://reviews.llvm.org/D137272

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


[Lldb-commits] [PATCH] D137272: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

2022-11-03 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Thanks for confirming @DavidSpickett


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137272/new/

https://reviews.llvm.org/D137272

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


[Lldb-commits] [lldb] c188910 - [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

2022-11-03 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-11-03T06:30:14-07:00
New Revision: c188910694ab821aabc0ca11f4636b69f5f7b4f1

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

LOG: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across 
platforms

On Linux the `std::function` behaved differently to that on Darwin.

This patch removes usage of `std::function` in the test but attempts
to retain the test-coverage. We mainly want function types appearing
in the template argument and function argument lists.

Also add a `char const*` overload to one of the test functions to
cover the "format function argument using ValueObject formatter" code-path.

Differential Revision: https://reviews.llvm.org/D137272

Added: 


Modified: 
lldb/test/Shell/Settings/Inputs/names.cpp
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

Removed: 




diff  --git a/lldb/test/Shell/Settings/Inputs/names.cpp 
b/lldb/test/Shell/Settings/Inputs/names.cpp
index 461c6d091a0f4..cf6982abb8f35 100644
--- a/lldb/test/Shell/Settings/Inputs/names.cpp
+++ b/lldb/test/Shell/Settings/Inputs/names.cpp
@@ -1,5 +1,3 @@
-#include 
-
 namespace detail {
 template  struct Quux {};
 } // namespace detail
@@ -7,15 +5,16 @@ template  struct Quux {};
 using FuncPtr = detail::Quux (*(*)(int))(float);
 
 struct Foo {
-  template  void foo(T const &t) const noexcept(true) {}
+  template  void foo(T arg) const noexcept(true) {}
 
-  template  void operator<<(size_t) {}
+  template  void operator<<(int) {}
 
   template  FuncPtr returns_func_ptr(detail::Quux &&) const 
noexcept(false) { return nullptr; }
 };
 
 namespace ns {
-template  int foo(T const &t) noexcept(false) { return 0; }
+template  int foo(char const *str) noexcept(false) { return 0; }
+template  int foo(T t) { return 1; }
 
 template  FuncPtr returns_func_ptr(detail::Quux &&) { return 
nullptr; }
 } // namespace ns
@@ -24,20 +23,20 @@ int bar() { return 1; }
 
 namespace {
 int anon_bar() { return 1; }
-auto anon_lambda = [](std::function) mutable {};
+auto anon_lambda = [] {};
 } // namespace
 
 int main() {
-  ns::foo(bar);
-  ns::foo(std::function{bar});
+  ns::foo(bar);
+  ns::foo("bar");
   ns::foo(anon_lambda);
-  ns::foo(std::function{anon_bar});
-  ns::foo(&Foo::foo>);
+  ns::foo(anon_bar);
+  ns::foo)>("method");
   ns::returns_func_ptr(detail::Quux{});
   Foo f;
-  f.foo(std::function{bar});
-  f.foo(std::function{anon_bar});
+  f.foo(anon_bar);
   f.operator<< <(2 > 1)>(0);
   f.returns_func_ptr(detail::Quux{});
+
   return 0;
 }

diff  --git a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test 
b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
index d990114f57845..dc4dedadee80a 100644
--- a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-darwin
+# UNSUPPORTED: system-windows
 # RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
@@ -8,21 +8,19 @@ break set -n returns_func_ptr
 run
 # CHECK: frame int ns::foo(t={{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = bar() )
+# CHECK: frame int ns::foo(str="bar")
 c
-# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
+# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous 
namespace)::(unnamed class) @ {{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = 
(anonymous namespace)::anon_bar() )
+# CHECK: frame int ns::foo(t=({{.*}}`(anonymous 
namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame int ns::foo 
const&) const noexcept>(t={{.*}})
+# CHECK: frame int ns::foo(str="method")
 c
 # CHECK: frame ns::returns_func_ptr((null)={{.*}})
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = bar() ) const
+# CHECK: frame void Foo::foo(this={{.*}}, arg=({{.*}}`(anonymous 
namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = (anonymous namespace)::anon_bar() ) const
-c
-# CHECK: frame void Foo::operator<<<1ul>(this={{.*}}, (null)=0)
+# CHECK: frame void Foo::operator<<<1>(this={{.*}}, (null)=0)
 c
 # CHECK: frame Foo::returns_func_ptr(this={{.*}}, (null)={{.*}})
 q



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


[Lldb-commits] [PATCH] D137272: [lldb][Test] Make TestFrameFormatNameWithArgs.test more compatible across platforms

2022-11-03 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc188910694ab: [lldb][Test] Make 
TestFrameFormatNameWithArgs.test more compatible across… (authored by 
Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137272/new/

https://reviews.llvm.org/D137272

Files:
  lldb/test/Shell/Settings/Inputs/names.cpp
  lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test


Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
===
--- lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-darwin
+# UNSUPPORTED: system-windows
 # RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
@@ -8,21 +8,19 @@
 run
 # CHECK: frame int ns::foo(t={{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = bar() )
+# CHECK: frame int ns::foo(str="bar")
 c
-# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
+# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous 
namespace)::(unnamed class) @ {{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = 
(anonymous namespace)::anon_bar() )
+# CHECK: frame int ns::foo(t=({{.*}}`(anonymous 
namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame int ns::foo 
const&) const noexcept>(t={{.*}})
+# CHECK: frame int ns::foo(str="method")
 c
 # CHECK: frame ns::returns_func_ptr((null)={{.*}})
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = bar() ) const
+# CHECK: frame void Foo::foo(this={{.*}}, arg=({{.*}}`(anonymous 
namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= 
Function = (anonymous namespace)::anon_bar() ) const
-c
-# CHECK: frame void Foo::operator<<<1ul>(this={{.*}}, (null)=0)
+# CHECK: frame void Foo::operator<<<1>(this={{.*}}, (null)=0)
 c
 # CHECK: frame Foo::returns_func_ptr(this={{.*}}, (null)={{.*}})
 q
Index: lldb/test/Shell/Settings/Inputs/names.cpp
===
--- lldb/test/Shell/Settings/Inputs/names.cpp
+++ lldb/test/Shell/Settings/Inputs/names.cpp
@@ -1,5 +1,3 @@
-#include 
-
 namespace detail {
 template  struct Quux {};
 } // namespace detail
@@ -7,15 +5,16 @@
 using FuncPtr = detail::Quux (*(*)(int))(float);
 
 struct Foo {
-  template  void foo(T const &t) const noexcept(true) {}
+  template  void foo(T arg) const noexcept(true) {}
 
-  template  void operator<<(size_t) {}
+  template  void operator<<(int) {}
 
   template  FuncPtr returns_func_ptr(detail::Quux &&) const 
noexcept(false) { return nullptr; }
 };
 
 namespace ns {
-template  int foo(T const &t) noexcept(false) { return 0; }
+template  int foo(char const *str) noexcept(false) { return 0; }
+template  int foo(T t) { return 1; }
 
 template  FuncPtr returns_func_ptr(detail::Quux &&) { return 
nullptr; }
 } // namespace ns
@@ -24,20 +23,20 @@
 
 namespace {
 int anon_bar() { return 1; }
-auto anon_lambda = [](std::function) mutable {};
+auto anon_lambda = [] {};
 } // namespace
 
 int main() {
-  ns::foo(bar);
-  ns::foo(std::function{bar});
+  ns::foo(bar);
+  ns::foo("bar");
   ns::foo(anon_lambda);
-  ns::foo(std::function{anon_bar});
-  ns::foo(&Foo::foo>);
+  ns::foo(anon_bar);
+  ns::foo)>("method");
   ns::returns_func_ptr(detail::Quux{});
   Foo f;
-  f.foo(std::function{bar});
-  f.foo(std::function{anon_bar});
+  f.foo(anon_bar);
   f.operator<< <(2 > 1)>(0);
   f.returns_func_ptr(detail::Quux{});
+
   return 0;
 }


Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
===
--- lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
+++ lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-darwin
+# UNSUPPORTED: system-windows
 # RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out
 # RUN: %lldb -b -s %s %t.out | FileCheck %s
 settings set -f frame-format "frame ${function.name-with-args}\n"
@@ -8,21 +8,19 @@
 run
 # CHECK: frame int ns::foo(t={{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = bar() )
+# CHECK: frame int ns::foo(str="bar")
 c
-# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t={{.*}})
+# CHECK: frame int ns::foo<(anonymous namespace)::$_0>(t=(anonymous namespace)::(unnamed class) @ {{.*}})
 c
-# CHECK: frame int ns::foo>(t= Function = (anonymous namespace)::anon_bar() )
+# CHECK: frame int ns::foo(t=({{.*}}`(anonymous namespace)::anon_bar() at {{.*}}))
 c
-# CHECK: frame int ns::foo const&) const noexcept>(t={{.*}})
+# CHECK: frame int ns::foo(str="method")
 c
 # CHECK: frame ns::returns_func_ptr((null)={{.*}})
 c
-# CHECK: frame void Foo::foo>(this={{.*}}, t= Function = bar() ) const
+# CHECK: frame void Foo::foo(this={{.*}}, arg=({

[Lldb-commits] [PATCH] D134066: [LLDB][NativePDB] Forcefully complete a record type it has incomplete type debug info.

2022-11-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D134066#3903831 , @zequanwu wrote:

> It shouldn't reach the code path to complete a class with empty debug info.

How about this?

  $ cat a.cc
  struct A { int x; A(); }; A::A() : x(47) {}
  
  $ cat b.cc
  struct A { int x; A(); };
  struct B : A {};
  
  B b;
  int main(){}
  
  $ bin\clang a.cc -o a.o -c
  
  $ bin\clang.exe a.o b.cc -g -o b.exe
  
  $ bin\lldb b.exe
  (lldb) target create "b.exe"
  (lldb) Current executable set to 'b.exe' (x86_64).
  (lldb) b main
  Breakpoint 1: where = b.exe`main at b.cc:5, address = 0x000140007100
  (lldb) r
  (lldb) Process 14288 launched: 'b.exe' (x86_64)
  Process 14288 stopped
  * thread #1, stop reason = breakpoint 1.1
  frame #0: 0x7ff6f37f7100 b.exe`main at b.cc:5
 2struct B : A {};
 3
 4B b;
  -> 5int main(){}
  (lldb) p b
  Assertion failed: DD && "queried property of class with no definition", file 
clang\include\clang/AST/DeclCXX.h, line 443


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134066/new/

https://reviews.llvm.org/D134066

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


[Lldb-commits] [PATCH] D84974: Enable Launching the Debugee in VSCode Terminal

2022-11-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm pretty sure that's because YAMA prevents the attach operation. The test 
probably needs to launch the binary through something like this 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84974/new/

https://reviews.llvm.org/D84974

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


[Lldb-commits] [PATCH] D136795: [LLDB] Add a `(not loaded) ` prefix to placeholder object filename to indicate they are not loaded.

2022-11-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

That's exactly why i don't like this stringly typed `GetPluginName` API. If you 
had to write `isa(objfile)`, or even just 
`objfile->GetPluginName()==ProcessMinidump::Placeholder::GetPluginNameStatic()` 
, you'll be a lot less likely to think that you can get away with it.

You weren't around then, but back when this "plugin" was introduced, I made the 
point that the functionality is not really minidump-specific -- and it was 
dismissed because it was "experimental".  At some point, I think it stopped 
being that.

Since this is essentially adding support for the placeholder concept into the 
generic code, why not just admit that, and move the code somewhere else. 
That'll open up a lot of other cool features as well.

I expect that when the user starts seeing this "placeholder" annotation, his 
next request will be like "oh, but I know where to find that file -- why don't 
you let me load it?". Well, if we had first class support for this, we could 
add a command that does just that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136795/new/

https://reviews.llvm.org/D136795

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


[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names when looking up functions

2022-11-03 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

In D137098#3903547 , @aeubanks wrote:

> In D137098#3902140 , @labath wrote:
>
>> Why is it that the other indexes don't need an equivalent fix? Could it be 
>> that you just haven't tried those code paths?
>>
>> If they do need it, then it'd be good if we could make the fix in a single 
>> place. Possibly by putting the retry logic at a higher level?
>
> Other indexes as in the other manual index indexes? Or as in other higher 
> level indexes?

I meant the compiler-generated indexes (implementations in AppleDWARFIndex and 
DebugNamesDWARFIndex).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137098/new/

https://reviews.llvm.org/D137098

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


[Lldb-commits] [PATCH] D125860: [clang] Only use major version in resource dir

2022-11-03 Thread Michał Górny via Phabricator via lldb-commits
mgorny added reviewers: serge-sans-paille, sylvestre.ledru, phosek, MaskRay.
mgorny added a comment.
Herald added subscribers: Michael137, StephenFan.

To be honest, I've never seen much purpose in the x.y.z directory naming and I 
feel like it's making packaging unnecessarily more complex, at least for us in 
Gentoo.

That said, I'd personally prefer if the directory was entirely configurable 
just like CLANG_RESOURCE_DIR can specify arbitrary path right now. But I'm also 
fine with this as-is.

Adding some more people who may have an opinion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125860/new/

https://reviews.llvm.org/D125860

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


[Lldb-commits] [PATCH] D125860: [clang] Only use major version in resource dir

2022-11-03 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

The consensus in the discourse thread you mention is not super strong, but I 
tend to agree with that patch. +1 for me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125860/new/

https://reviews.llvm.org/D125860

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


[Lldb-commits] [PATCH] D137287: [Test] Fix CHECK typo.

2022-11-03 Thread Paul Robinson via Phabricator via lldb-commits
probinson added a comment.

Nice work!
have you verified that all the modified tests pass? naively it looks like you'd 
need at least 3 different targets to run them all (windows, webassembly, 
powerpc)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137287/new/

https://reviews.llvm.org/D137287

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


[Lldb-commits] [PATCH] D125860: [clang] Only use major version in resource dir

2022-11-03 Thread Sylvestre Ledru via Phabricator via lldb-commits
sylvestre.ledru added a comment.

i hope not too many people rely on it.
LGTM but please add it to the release notes


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125860/new/

https://reviews.llvm.org/D125860

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


[Lldb-commits] [PATCH] D135547: [lldb/Utility] Add GetDescription(Stream&) to StructureData::*

2022-11-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGMT with the missing periods fixed.




Comment at: lldb/source/Utility/StructuredData.cpp:208
+
+// Reset original indentation level
+s.SetIndentLevel(indentation_level);

Comments should include punctuation. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135547/new/

https://reviews.llvm.org/D135547

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


[Lldb-commits] [PATCH] D126260: [lldb/crashlog] Add support for Application Specific Backtraces & Information

2022-11-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

A few nits but overall this LGTM.




Comment at: lldb/examples/python/crashlog.py:601-605
+for idx, backtrace in enumerate(json_app_specific_bts):
+thread = self.crashlog.Thread(idx, True)
+thread.queue = "Application Specific Backtrace"
+if parse_asi_backtrace(self, thread, backtrace):
+self.crashlog.threads.append(thread)

I don't think it's correct to treat the ASI as just another thread. IIUC it's 
the same as the crashing thread, just at another point in time (when the 
exception was thrown). To me that sounds like it should be its own thing.



Comment at: lldb/examples/python/crashlog.py:581-597
+def parse_asi_backtrace(self, thread, bt):
+for line in bt.split('\n'):
+frame_match = TextCrashLogParser.frame_regex.search(line)
+if not frame_match:
+print("error: can't parse application specific backtrace.")
+return False
+

mib wrote:
> JDevlieghere wrote:
> > Can this be a top level function? It's hard to tell if this is capturing 
> > anything. We have other place where we have helper functions that are 
> > called from a loop.
> This parses a single backtrace. I'm not sure what you mean by "We have other 
> place where we have helper functions that are called from a loop."
ping



Comment at: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py:59
+
+if (self.app_specific_thread):
+self.extended_thread_info = \





Comment at: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h:105
+
+  virtual StructuredData::ArraySP GetExtendedInfo() { return nullptr; }
 };





Comment at: lldb/include/lldb/Target/Process.h:2431
+  /// information related to the process.
+  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+





Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:985
+  if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey("asi"))
+return nullptr;
+




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126260/new/

https://reviews.llvm.org/D126260

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


[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.

2022-11-03 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

@jingham any comments on https://reviews.llvm.org/D137000#3897162?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137000/new/

https://reviews.llvm.org/D137000

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


[Lldb-commits] [PATCH] D137301: PlatformDarwinKernel::GetSupportedArchitectures should report all supported architectures

2022-11-03 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd2065b70f2a: Have GetSupportedArchitectures report all 
supported arches (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137301/new/

https://reviews.llvm.org/D137301

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1436,7 +1436,8 @@
 if (!m_arch.GetSpec().IsValid()) {
   m_arch = executable_sp->GetArchitecture();
   LLDB_LOG(log,
-   "setting architecture to {0} ({1}) based on executable file",
+   "Target::SetExecutableModule setting architecture to {0} ({1}) "
+   "based on executable file",
m_arch.GetSpec().GetArchitectureName(),
m_arch.GetSpec().GetTriple().getTriple());
 }
@@ -1536,7 +1537,9 @@
 // specified
 if (replace_local_arch)
   m_arch = other;
-LLDB_LOG(log, "set architecture to {0} ({1})",
+LLDB_LOG(log,
+ "Target::SetArchitecture merging compatible arch; arch "
+ "is now {0} ({1})",
  m_arch.GetSpec().GetArchitectureName(),
  m_arch.GetSpec().GetTriple().getTriple());
 return true;
@@ -1544,9 +1547,13 @@
 
   // If we have an executable file, try to reset the executable to the desired
   // architecture
-  LLDB_LOGF(log, "Target::SetArchitecture changing architecture to %s (%s)",
-arch_spec.GetArchitectureName(),
-arch_spec.GetTriple().getTriple().c_str());
+  LLDB_LOGF(
+  log,
+  "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
+  arch_spec.GetArchitectureName(),
+  arch_spec.GetTriple().getTriple().c_str(),
+  m_arch.GetSpec().GetArchitectureName(),
+  m_arch.GetSpec().GetTriple().getTriple().c_str());
   m_arch = other;
   ModuleSP executable_sp = GetExecutableModule();
 
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -986,11 +986,8 @@
 std::vector PlatformDarwinKernel::GetSupportedArchitectures(
 const ArchSpec &process_host_arch) {
   std::vector result;
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   ARMGetSupportedArchitectures(result);
-#else
   x86GetSupportedArchitectures(result);
-#endif
   return result;
 }
 


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1436,7 +1436,8 @@
 if (!m_arch.GetSpec().IsValid()) {
   m_arch = executable_sp->GetArchitecture();
   LLDB_LOG(log,
-   "setting architecture to {0} ({1}) based on executable file",
+   "Target::SetExecutableModule setting architecture to {0} ({1}) "
+   "based on executable file",
m_arch.GetSpec().GetArchitectureName(),
m_arch.GetSpec().GetTriple().getTriple());
 }
@@ -1536,7 +1537,9 @@
 // specified
 if (replace_local_arch)
   m_arch = other;
-LLDB_LOG(log, "set architecture to {0} ({1})",
+LLDB_LOG(log,
+ "Target::SetArchitecture merging compatible arch; arch "
+ "is now {0} ({1})",
  m_arch.GetSpec().GetArchitectureName(),
  m_arch.GetSpec().GetTriple().getTriple());
 return true;
@@ -1544,9 +1547,13 @@
 
   // If we have an executable file, try to reset the executable to the desired
   // architecture
-  LLDB_LOGF(log, "Target::SetArchitecture changing architecture to %s (%s)",
-arch_spec.GetArchitectureName(),
-arch_spec.GetTriple().getTriple().c_str());
+  LLDB_LOGF(
+  log,
+  "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
+  arch_spec.GetArchitectureName(),
+  arch_spec.GetTriple().getTriple().c_str(),
+  m_arch.GetSpec().GetArchitectureName(),
+  m_arch.GetSpec().GetTriple().getTriple().c_str());
   m_arch = other;
   ModuleSP executable_sp = GetExecutableModule();
 
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -986,11 +986,8 @@
 std::vector PlatformDarwinKernel::GetSupportedArchitectures(
 const ArchSpec &process_host_arch) {
   std::vector result;
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   ARMGetSupportedArchitectures(result);
-#else
   x86GetSupp

[Lldb-commits] [lldb] fd2065b - Have GetSupportedArchitectures report all supported arches

2022-11-03 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2022-11-03T10:46:48-07:00
New Revision: fd2065b70f2a74503725ebadb39c5dd2f9aa15c9

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

LOG: Have GetSupportedArchitectures report all supported arches

PlatformDarwinKernel::GetSupportedArchitectures returns a list
of architectures that are possible for this platform; it was using
a compile-time check for the debug host to decide the list of arches
that were valid.  This was copied from a codepath doing native process
debugging, and was clearly wrong for kernel debugging, but it had
not happened to cause problems so it went unnoticed for a long time.

Small NFC change to the logging messages of Target::SetArchitecture
to make them a little more explicit about how the architecture is
being modified/replaced.

Differential Revision: https://reviews.llvm.org/D137301
rdar://101690111

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 8ae211f102cb3..3c9cc8e77189e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -986,11 +986,8 @@ bool 
PlatformDarwinKernel::LoadPlatformBinaryAndSetup(Process *process,
 std::vector PlatformDarwinKernel::GetSupportedArchitectures(
 const ArchSpec &process_host_arch) {
   std::vector result;
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   ARMGetSupportedArchitectures(result);
-#else
   x86GetSupportedArchitectures(result);
-#endif
   return result;
 }
 

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index f1a311b7252cb..33a792b683ca4 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1436,7 +1436,8 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
 if (!m_arch.GetSpec().IsValid()) {
   m_arch = executable_sp->GetArchitecture();
   LLDB_LOG(log,
-   "setting architecture to {0} ({1}) based on executable file",
+   "Target::SetExecutableModule setting architecture to {0} ({1}) "
+   "based on executable file",
m_arch.GetSpec().GetArchitectureName(),
m_arch.GetSpec().GetTriple().getTriple());
 }
@@ -1536,7 +1537,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 // specified
 if (replace_local_arch)
   m_arch = other;
-LLDB_LOG(log, "set architecture to {0} ({1})",
+LLDB_LOG(log,
+ "Target::SetArchitecture merging compatible arch; arch "
+ "is now {0} ({1})",
  m_arch.GetSpec().GetArchitectureName(),
  m_arch.GetSpec().GetTriple().getTriple());
 return true;
@@ -1544,9 +1547,13 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   // If we have an executable file, try to reset the executable to the desired
   // architecture
-  LLDB_LOGF(log, "Target::SetArchitecture changing architecture to %s (%s)",
-arch_spec.GetArchitectureName(),
-arch_spec.GetTriple().getTriple().c_str());
+  LLDB_LOGF(
+  log,
+  "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
+  arch_spec.GetArchitectureName(),
+  arch_spec.GetTriple().getTriple().c_str(),
+  m_arch.GetSpec().GetArchitectureName(),
+  m_arch.GetSpec().GetTriple().getTriple().c_str());
   m_arch = other;
   ModuleSP executable_sp = GetExecutableModule();
 



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


[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Just have the case when debug info is not enabled return "Status()" (a default 
constructed error with no error) and this will be good to go.




Comment at: lldb/source/Symbol/SymbolFileOnDemand.cpp:281
+ __FUNCTION__);
+return this->CalculateFrameVariableError(frame);
+  }

This will create an infinite loop right? See code change suggestions for fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137284/new/

https://reviews.llvm.org/D137284

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


[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The refactoring comment should be done as well for this diff as suggested.




Comment at: 
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py:564-566
+@no_debug_info_test
+@skipUnlessDarwin
+def test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled(self):

If this function is just like the test_darwin_dwarf_missing_obj, I would 
suggest refactoring test_darwin_dwarf_missing_obj into a function that doesn't 
start with "test", and then having both test_darwin_dwarf_missing_obj and 
test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled call it. 

So copy the "test_darwin_dwarf_missing_obj" function and name it 
"darwin_dwarf_missing_obj" and add a new parameter named "initCommands":

```
def darwin_dwarf_missing_obj(self, initCommands):
```
Then copy the code from this function into that function, and replace the 
remove the line:
```
initCommands = ['settings set symbols.load-on-demand true']
```
Then just modify the code for both tests to call the refactored function
```
@no_debug_info_test
@skipUnlessDarwin
def test_darwin_dwarf_missing_obj(self):
'''
Test that if we build a binary with DWARF in .o files and we remove
the .o file for main.cpp, that we get a variable named ""
whose value matches the appriopriate error. Errors when getting
variables are returned in the LLDB API when the user should be
notified of issues that can easily be solved by rebuilding or
changing compiler options and are designed to give better feedback
to the user.
'''
darwin_dwarf_missing_obj(self, None)

@no_debug_info_test
@skipUnlessDarwin
def test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled(self):
'''
Test that if we build a binary with DWARF in .o files and we remove
the .o file for main.cpp, that we get a variable named ""
whose value matches the appriopriate error. Test with 
symbol_ondemand_enabled.
'''
darwin_dwarf_missing_obj(self, ['settings set symbols.load-on-demand 
true'])
```

Any method on a test suite class that doesn't start with "test" is just a help 
function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137284/new/

https://reviews.llvm.org/D137284

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


[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread Yubo Hu via Phabricator via lldb-commits
GeorgeHuyubo updated this revision to Diff 472998.
GeorgeHuyubo added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137284/new/

https://reviews.llvm.org/D137284

Files:
  lldb/include/lldb/Symbol/SymbolFileOnDemand.h
  lldb/source/Symbol/SymbolFileOnDemand.cpp
  lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py

Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -85,6 +85,40 @@
   'variable "%s" in verify dictionary' % (name))
 self.verify_values(verify_dict[name], variable, varref_dict)
 
+def darwin_dwarf_missing_obj(self, initCommands):
+self.build(debug_info="dwarf")
+program = self.getBuildArtifact("a.out")
+main_obj = self.getBuildArtifact("main.o")
+self.assertTrue(os.path.exists(main_obj))
+# Delete the main.o file that contains the debug info so we force an
+# error when we run to main and try to get variables
+os.unlink(main_obj)
+
+self.create_debug_adaptor()
+self.assertTrue(os.path.exists(program), 'executable must exist')
+
+self.launch(program=program,
+initCommands=initCommands)
+
+functions = ['main']
+breakpoint_ids = self.set_function_breakpoints(functions)
+self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint")
+self.continue_to_breakpoints(breakpoint_ids)
+
+locals = self.vscode.get_local_variables()
+
+verify_locals = {
+'': {
+'equals': {'type': 'const char *'},
+'contains': { 'value': [
+'debug map object file ',
+'main.o" containing debug info does not exist, debug info will not be loaded']
+}
+},
+}
+varref_dict = {}
+self.verify_variables(verify_locals, locals, varref_dict)
+
 @skipIfWindows
 @skipIfRemote
 def test_scopes_variables_setVariable_evaluate(self):
@@ -529,33 +563,16 @@
 changing compiler options and are designed to give better feedback
 to the user.
 '''
-self.build(debug_info="dwarf")
-program = self.getBuildArtifact("a.out")
-main_obj = self.getBuildArtifact("main.o")
-self.assertTrue(os.path.exists(main_obj))
-# Delete the main.o file that contains the debug info so we force an
-# error when we run to main and try to get variables
-os.unlink(main_obj)
-
-self.create_debug_adaptor()
-self.assertTrue(os.path.exists(program), 'executable must exist')
-self.launch(program)
-
-functions = ['main']
-breakpoint_ids = self.set_function_breakpoints(functions)
-self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint")
-self.continue_to_breakpoints(breakpoint_ids)
+self.darwin_dwarf_missing_obj(None)
 
-locals = self.vscode.get_local_variables()
 
-verify_locals = {
-'': {
-'equals': {'type': 'const char *'},
-'contains': { 'value': [
-'debug map object file ',
-'main.o" containing debug info does not exist, debug info will not be loaded']
-}
-},
-}
-varref_dict = {}
-self.verify_variables(verify_locals, locals, varref_dict)
+@no_debug_info_test
+@skipUnlessDarwin
+def test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled(self):
+'''
+Test that if we build a binary with DWARF in .o files and we remove
+the .o file for main.cpp, that we get a variable named ""
+whose value matches the appriopriate error. Test with symbol_ondemand_enabled.
+'''
+initCommands = ['settings set symbols.load-on-demand true']
+self.darwin_dwarf_missing_obj(initCommands)
Index: lldb/source/Symbol/SymbolFileOnDemand.cpp
===
--- lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -274,6 +274,15 @@
   return m_sym_file_impl->ResolveSymbolContext(so_addr, resolve_scope, sc);
 }
 
+Status SymbolFileOnDemand::CalculateFrameVariableError(StackFrame &frame) {
+  if (!m_debug_info_enabled) {
+LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(),
+ __FUNCTION__);
+return Status();
+  }
+  return m_sym_file_impl->CalculateFrameVariableError(frame);
+}
+
 uint32_t SymbolFileOnDemand::ResolveSymbolContext(
 const SourceLocationSpec &src_location_spec,
 SymbolContextItem resolve_scope, SymbolC

[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Looks good!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137284/new/

https://reviews.llvm.org/D137284

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


[Lldb-commits] [PATCH] D137359: [lldb/Plugins] Use default initializers for StructuredData::*SP (NFC)

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch replaces the ScriptedProcessInterface getters to return
default initializers for StructureData shared pointers instead of
returning a null pointer.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137359

Files:
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h


Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -24,7 +24,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
@@ -41,22 +41,22 @@
 return {};
   }
 
-  virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
 
   virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual lldb::DataExtractorSP
   ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
-return nullptr;
+return {};
   }
 
-  virtual StructuredData::ArraySP GetLoadedImages() { return nullptr; }
+  virtual StructuredData::ArraySP GetLoadedImages() { return {}; }
 
   virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
 
@@ -66,12 +66,12 @@
 return llvm::None;
   }
 
-  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+  virtual StructuredData::DictionarySP GetMetadata() { return {}; }
 
 protected:
   friend class ScriptedThread;
   virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
-return nullptr;
+return {};
   }
 };
 
@@ -81,7 +81,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
@@ -92,17 +92,17 @@
 
   virtual llvm::Optional GetQueue() { return llvm::None; }
 
-  virtual StructuredData::DictionarySP GetStopReason() { return nullptr; }
+  virtual StructuredData::DictionarySP GetStopReason() { return {}; }
 
-  virtual StructuredData::ArraySP GetStackFrames() { return nullptr; }
+  virtual StructuredData::ArraySP GetStackFrames() { return {}; }
 
-  virtual StructuredData::DictionarySP GetRegisterInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
 
   virtual llvm::Optional GetRegisterContext() {
 return llvm::None;
   }
 
-  virtual StructuredData::ArraySP GetExtendedInfo() { return nullptr; }
+  virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }
 };
 } // namespace lldb_private
 


Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -24,7 +24,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
@@ -41,22 +41,22 @@
 return {};
   }
 
-  virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
 
   virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual lldb::DataExtractorSP
   ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
-return nullptr;
+return {};
   }
 
-  virtual StructuredData::ArraySP GetLoadedImages() { return nullptr; }
+  virtual StructuredData::ArraySP GetLoadedImages() { return {}; }
 
   virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
 
@@ -66,12 +66,12 @@
 return llvm::None;
   }
 
-  virtual StructuredData::DictionarySP GetMetadata() { return nu

[Lldb-commits] [PATCH] D126260: [lldb/crashlog] Add support for Application Specific Backtraces & Information

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 7 inline comments as done.
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:601-605
+for idx, backtrace in enumerate(json_app_specific_bts):
+thread = self.crashlog.Thread(idx, True)
+thread.queue = "Application Specific Backtrace"
+if parse_asi_backtrace(self, thread, backtrace):
+self.crashlog.threads.append(thread)

JDevlieghere wrote:
> I don't think it's correct to treat the ASI as just another thread. IIUC it's 
> the same as the crashing thread, just at another point in time (when the 
> exception was thrown). To me that sounds like it should be its own thing.
This allows to show the Application Specific Backtrace with other threads when 
using the non-interactive crashlog command.

For interactive crashlogs, the Application Specific Backtrace is attached to 
the crashed thread as its extended backtrace and would only be show when doing 
`thread backtrace --extended true`



Comment at: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h:105
+
+  virtual StructuredData::ArraySP GetExtendedInfo() { return nullptr; }
 };

JDevlieghere wrote:
> 
ditto



Comment at: lldb/include/lldb/Target/Process.h:2431
+  /// information related to the process.
+  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+

JDevlieghere wrote:
> 
I'll make a follow-up patch to update this. (D137359)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126260/new/

https://reviews.llvm.org/D126260

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


[Lldb-commits] [PATCH] D126260: [lldb/crashlog] Add support for Application Specific Backtraces & Information

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 473036.
mib added a comment.

Addressed @JDevlieghere feedbacks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126260/new/

https://reviews.llvm.org/D126260

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
  lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.ips
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.yaml
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/main.m
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
@@ -0,0 +1,52 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/asi %S/Inputs/application_specific_info/asi.ips' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status --verbose
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT: frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK: Extended Crash Information:
+# CHECK:   Application Specific Information:
+# CHECK-NEXT: CoreFoundation: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'
+# CHECK-NEXT: libc++abi.dylib: terminating with uncaught exception of type NSException
+# CHECK-NEXT: libsystem_c.dylib: abort() called
+
+
+# CHECK: (lldb) thread backtrace --extended true
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT:   * frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK-NEXT: frame #1: 0x0001a08fdceb{{.*}}[artificial]
+# CHECK-NEXT: frame #2: 0x0001a08372c7{{.*}}[artificial]
+# CHECK-NEXT: frame #3: 0x0001a08b7b17{{.*}}[artificial]
+# CHECK-NEXT: frame #4: 0x0001a08a7a0b{{.*}}[artificial]
+# CHECK-NEXT: frame #5: 0x0001a05ab763{{.*}}[artificial]
+# CHECK-NEXT: frame #6: 0x0001a08b6eb3{{.*}}[artificial]
+# CHECK-NEXT: frame #7: 0x0001a08b9c2b{{.*}}[artificial]
+# CHECK-NEXT: frame #8: 0x0001a08b9bd7{{.*}}[artificial]
+# CHECK-NEXT: frame #9: 0x0001a05a3007{{.*}}[artificial]
+# CHECK-NEXT: frame #10: 0x0001a0b3dcc3{{.*}}[artificial]
+# CHECK-NEXT: frame #11: 0x0001a0b46af3{{.*}}[artificial]
+# CHECK-NEXT: frame #12: 0x0001a09a12a3{{.*}}[artificial]
+# CHECK-NEXT: frame #13: 0x0001047e3ecf asi`main{{.*}}[artificial]
+# CHECK-NEXT: frame #14: 0x0001a05d3e4f{{.*}}[artificial]
+
+# CHECK:   thread #4294967295: tid = 0x0001, 0x0001a0a58418{{.*}}, queue = 'Application Specific Backtrace'
+# CHECK-NEXT: frame #0: 0x0001a0a58418{{.*}}
+# CHECK-NEXT: frame #1: 0x0001a05a2ea7{{.*}}
+# CHECK-NEXT: frame #2: 0x0001a0b3dcc3{{.*}}
+# CHECK-NEXT: frame #3: 0x0001a0b46af3{{.*}}
+# CHECK-NEXT: frame #4: 0x0001a09a12a3{{.*}}
+# CHECK-NEXT: frame #5: 0x0001047e3ecf asi`main{{.*}}
+# CHECK-NEXT: frame #6: 0x0001a05d3e4f dyld`start{{.*}}
+
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1: tid = 0x1af8f3, 0x0001a08c7224{{.*}}, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
Index: lldb/test/Shell/ScriptInterpreter/Python/C

[Lldb-commits] [PATCH] D135310: [lldb/crashlog] Add support for 32bit frame addresses

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3be864333a88: [lldb/crashlog] Add support for 32bit frame 
addresses (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135310/new/

https://reviews.llvm.org/D135310

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -613,10 +613,10 @@
 frame_regex = re.compile(r'^(\d+)\s+'  # id
  r'(.+?)\s+'   # img_name
  r'(?:' +version+ r'\s+)?' # img_version
- r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r'(0x[0-9a-fA-F]{4,})'# addr (4 chars or more)
  r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{4,} +')
 image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
   r'\s+-\s+'   #   -
   r'(0x[0-9a-fA-F]+)\s+'   # img_hi


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -613,10 +613,10 @@
 frame_regex = re.compile(r'^(\d+)\s+'  # id
  r'(.+?)\s+'   # img_name
  r'(?:' +version+ r'\s+)?' # img_version
- r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r'(0x[0-9a-fA-F]{4,})'# addr (4 chars or more)
  r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{4,} +')
 image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
   r'\s+-\s+'   #   -
   r'(0x[0-9a-fA-F]+)\s+'   # img_hi
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3be8643 - [lldb/crashlog] Add support for 32bit frame addresses

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:52-07:00
New Revision: 3be864333a8843534465bcbf3d355fcd12b42369

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

LOG: [lldb/crashlog] Add support for 32bit frame addresses

This patch adds support for 32bit stack frame addresses in the `crashlog`
command.

For crash reports that are generated from a arm64_32 process, `PAGEZERO`
is loaded at 0x4000 so no code address will be less than 0x4000.

This patch changes the crashlog frame address regex group to match
addresses as small as 4 hex characters.

rdar://100805026

Differential Revision: https://reviews.llvm.org/D135310

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index e80ecd91579ad..77d54ce303868 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -613,10 +613,10 @@ class TextCrashLogParser(CrashLogParser):
 frame_regex = re.compile(r'^(\d+)\s+'  # id
  r'(.+?)\s+'   # img_name
  r'(?:' +version+ r'\s+)?' # img_version
- r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r'(0x[0-9a-fA-F]{4,})'# addr (4 chars or more)
  r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{4,} +')
 image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
   r'\s+-\s+'   #   -
   r'(0x[0-9a-fA-F]+)\s+'   # img_hi



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


[Lldb-commits] [lldb] 42df155 - [lldb/crashlog] Fix the image_regex_uuid to skip null UUID images

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:52-07:00
New Revision: 42df155ae628b4ae756a858bd09b105ee10b86eb

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

LOG: [lldb/crashlog] Fix the image_regex_uuid to skip null UUID images

This patch updates the image_regex_uuid matcher to match null-UUID
images in the plain text crashlog parser.

It updates the regex to match one or more '?' characters or the image
full path.

rdar://100904019

Differential Revision: https://reviews.llvm.org/D135482

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 77d54ce303868..8aaf7c165684a 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -623,7 +623,7 @@ class TextCrashLogParser(CrashLogParser):
   r'[+]?(.+?)\s+'  # img_name
   r'(?:(' +version+ r')\s+)?'  # img_version
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)' # img_path
+  r'(\?+|/.*)' # img_path
  )
 exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
 exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
index c02150c7f15a9..16a95586a13b4 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
@@ -47,3 +47,4 @@ Trap Number: 14
 
 Binary Images:
0x1 -0x2 +a.out (0) <@UUID@> @EXEC@
+   0x0 - 0x ??? (*) 
<----> ???



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


[Lldb-commits] [lldb] cc05487 - [lldb/Plugins] Cleanup error handling in Scripted{Process, Thread} (NFC)

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:52-07:00
New Revision: cc05487a834e55659072918393f5c7490af67ed2

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

LOG: [lldb/Plugins] Cleanup error handling in Scripted{Process,Thread} (NFC)

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 11692cbb69d48..174c00e985595 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -411,7 +411,7 @@ ScriptedProcess::GetLoadedDynamicLibrariesInfos() {
   StructuredData::ArraySP loaded_images_sp = GetInterface().GetLoadedImages();
 
   if (!loaded_images_sp || !loaded_images_sp->GetSize())
-return GetInterface().ErrorWithMessage(
+return ScriptedInterface::ErrorWithMessage(
 LLVM_PRETTY_FUNCTION, "No loaded images.", error);
 
   ModuleList module_list;
@@ -477,7 +477,7 @@ ScriptedProcess::GetLoadedDynamicLibrariesInfos() {
   };
 
   if (!loaded_images_sp->ForEach(reload_image))
-return GetInterface().ErrorWithMessage(
+return ScriptedInterface::ErrorWithMessage(
 LLVM_PRETTY_FUNCTION, "Couldn't reload all images.", error);
 
   target.ModulesDidLoad(module_list);

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index c655ec12ecda3..b19331b5b1082 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -171,9 +171,7 @@ bool ScriptedThread::LoadArtificialStackFrames() {
   StackFrameListSP frames = GetStackFrameList();
 
   for (size_t idx = 0; idx < arr_size; idx++) {
-
 StructuredData::Dictionary *dict;
-
 if (!arr_sp->GetItemAtIndexAsDictionary(idx, dict) || !dict)
   return ScriptedInterface::ErrorWithMessage(
   LLVM_PRETTY_FUNCTION,
@@ -334,11 +332,10 @@ std::shared_ptr 
ScriptedThread::GetDynamicRegisterInfo() {
 
 Status error;
 if (!reg_info)
-  return GetInterface()
-  ->ErrorWithMessage>(
-  LLVM_PRETTY_FUNCTION,
-  "Failed to get scripted thread registers info.", error,
-  LLDBLog::Thread);
+  return ScriptedInterface::ErrorWithMessage<
+  std::shared_ptr>(
+  LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers 
info.",
+  error, LLDBLog::Thread);
 
 m_register_info_sp = std::make_shared(
 *reg_info, m_scripted_process.GetTarget().GetArchitecture());



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


[Lldb-commits] [lldb] 268628c - [lldb/Commands] Add newline for extended backtrace thread (NFCI)

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:52-07:00
New Revision: 268628cb79b0f8bb0edec86d9d500c16eadd516a

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

LOG: [lldb/Commands] Add newline for extended backtrace thread (NFCI)

This adds a new line between the real thread and the extended backtrace
thread when it's available. This should improve readability for the user.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Commands/CommandObjectThread.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectThread.cpp 
b/lldb/source/Commands/CommandObjectThread.cpp
index bfe85043f3703..5e817635bbe6b 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -189,6 +189,7 @@ class CommandObjectThreadBacktrace : public 
CommandObjectIterateOverThreads {
 if (ext_thread_sp && ext_thread_sp->IsValid()) {
   const uint32_t num_frames_with_source = 0;
   const bool stop_format = false;
+  strm.PutChar('\n');
   if (ext_thread_sp->GetStatus(strm, m_options.m_start,
m_options.m_count,
num_frames_with_source, stop_format)) {



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


[Lldb-commits] [lldb] e861d05 - [lldb/Utility] Add GetDescription(Stream&) to StructureData::*

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:53-07:00
New Revision: e861d053dd43f2e5a63f150ee2f9d1d643ea29c1

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

LOG: [lldb/Utility] Add GetDescription(Stream&) to StructureData::*

This patch improves the StructuredData classes to provide a
GetDescription(lldb_private::Stream&) affordance.

This is very convenient compared to the Dump method because this try to
pretty print the structure instead of just serializing it into a JSON.

This patch also updates some parts of lldb (i.e. extended crash info) to
use this new affordance instead of StructuredData::Dump.

Differential Revision: https://reviews.llvm.org/D135547

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/unittests/Utility/Inputs/StructuredData-full.json
lldb/unittests/Utility/Inputs/StructuredData-nested.json

Modified: 
lldb/include/lldb/Core/StructuredDataImpl.h
lldb/include/lldb/Utility/StructuredData.h
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Utility/StructuredData.cpp
lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
lldb/unittests/Utility/CMakeLists.txt
lldb/unittests/Utility/StructuredDataTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/StructuredDataImpl.h 
b/lldb/include/lldb/Core/StructuredDataImpl.h
index e755c53aaa9f6..16dbc5263b285 100644
--- a/lldb/include/lldb/Core/StructuredDataImpl.h
+++ b/lldb/include/lldb/Core/StructuredDataImpl.h
@@ -80,7 +80,7 @@ class StructuredDataImpl {
 error.SetErrorString("No data to describe.");
 return error;
   }
-  m_data_sp->Dump(stream, true);
+  m_data_sp->GetDescription(stream);
   return error;
 }
 // Get the data's description.

diff  --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index 9f6300f4f115b..5420c0dcf8d5a 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -158,6 +158,12 @@ class StructuredData {
   Serialize(jso);
 }
 
+virtual void GetDescription(lldb_private::Stream &s) const {
+  s.IndentMore();
+  Dump(s, false);
+  s.IndentLess();
+}
+
   private:
 lldb::StructuredDataType m_type;
   };
@@ -277,6 +283,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 typedef std::vector collection;
 collection m_items;
@@ -295,6 +303,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 uint64_t m_value;
   };
@@ -312,6 +322,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 double m_value;
   };
@@ -329,6 +341,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 bool m_value;
   };
@@ -345,6 +359,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 std::string m_value;
   };
@@ -524,6 +540,8 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   protected:
 typedef std::map collection;
 collection m_dict;
@@ -538,6 +556,8 @@ class StructuredData {
 bool IsValid() const override { return false; }
 
 void Serialize(llvm::json::OStream &s) const override;
+
+void GetDescription(lldb_private::Stream &s) const override;
   };
 
   class Generic : public Object {
@@ -553,12 +573,15 @@ class StructuredData {
 
 void Serialize(llvm::json::OStream &s) const override;
 
+void GetDescription(lldb_private::Stream &s) const override;
+
   private:
 void *m_object;
   };
 
   static ObjectSP ParseJSON(const std::string &json_text);
   static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error);
+  static bool IsRecordType(const ObjectSP object_sp);
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 28a99ea3d94a5..92544c564e532 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1537,8 +1537,9 @@ class CommandObjectProcessStatus : public 
CommandObjectParsed {
   StructuredData::DictionarySP crash_info_sp = *expected_crash_info;
 
   if

[Lldb-commits] [PATCH] D135482: [lldb/crashlog] Fix the image_regex_uuid to skip null UUID images

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42df155ae628: [lldb/crashlog] Fix the image_regex_uuid to 
skip null UUID images (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135482/new/

https://reviews.llvm.org/D135482

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
@@ -47,3 +47,4 @@
 
 Binary Images:
0x1 -0x2 +a.out (0) <@UUID@> @EXEC@
+   0x0 - 0x ??? (*) 
<----> ???
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -623,7 +623,7 @@
   r'[+]?(.+?)\s+'  # img_name
   r'(?:(' +version+ r')\s+)?'  # img_version
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)' # img_path
+  r'(\?+|/.*)' # img_path
  )
 exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
 exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
@@ -47,3 +47,4 @@
 
 Binary Images:
0x1 -0x2 +a.out (0) <@UUID@> @EXEC@
+   0x0 - 0x ??? (*) <----> ???
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -623,7 +623,7 @@
   r'[+]?(.+?)\s+'  # img_name
   r'(?:(' +version+ r')\s+)?'  # img_version
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)' # img_path
+  r'(\?+|/.*)' # img_path
  )
 exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
 exception_codes_regex = re.compile(r'^Exception Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9060896 - [lldb/Utility] Fix StructuredData::ParseJSONValue for null items

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:52-07:00
New Revision: 90608963d40b4765fc95e039d5100940ad822535

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

LOG: [lldb/Utility] Fix StructuredData::ParseJSONValue for null items

This patch fixes the JSON parser for StructuredData to handle JSON null
entries.

Differential Revision: https://reviews.llvm.org/D135616

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Utility/StructuredData.cpp

Removed: 




diff  --git a/lldb/source/Utility/StructuredData.cpp 
b/lldb/source/Utility/StructuredData.cpp
index fc10fa539e9e5..2e023344f3ddb 100644
--- a/lldb/source/Utility/StructuredData.cpp
+++ b/lldb/source/Utility/StructuredData.cpp
@@ -69,6 +69,9 @@ static StructuredData::ObjectSP ParseJSONValue(json::Value 
&value) {
   if (auto d = value.getAsNumber())
 return std::make_shared(*d);
 
+  if (auto n = value.getAsNull())
+return std::make_shared();
+
   return StructuredData::ObjectSP();
 }
 



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


[Lldb-commits] [lldb] 78d6e1d - [lldb/crashlog] Add support for Application Specific Backtraces & Information

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:53-07:00
New Revision: 78d6e1d1d4b3b5c6bdd779256c915a8ac7148174

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

LOG: [lldb/crashlog] Add support for Application Specific Backtraces & 
Information

For an exception crashlog, the thread backtraces aren't usually very helpful
and instead, developpers look at the "Application Specific Backtrace" that
was generated by `objc_exception_throw`.

LLDB could already parse and symbolicate these Application Specific Backtraces
for regular textual-based crashlog, so this patch adds support to parse them
in JSON crashlogs, and materialize them a HistoryThread extending the
crashed ScriptedThread.

This patch also includes the Application Specific Information messages
as part of the process extended crash information log. To do so, the
ScriptedProcess Python interface has a new GetMetadata method that
returns an arbitrary dictionary with data related to the process.

rdar://93207586

Differential Revision: https://reviews.llvm.org/D126260

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.ips

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.yaml

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/main.m

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test

Modified: 
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
lldb/include/lldb/Target/Process.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 8aaf7c165684a..47250f3b350f1 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -462,6 +462,12 @@ def parse(self):
 self.parse_images(self.data['usedImages'])
 self.parse_main_image(self.data)
 self.parse_threads(self.data['threads'])
+if 'asi' in self.data:
+self.crashlog.asi = self.data['asi']
+if 'asiBacktraces' in self.data:
+self.parse_app_specific_backtraces(self.data['asiBacktraces'])
+if 'lastExceptionBacktrace' in self.data:
+self.crashlog.asb = self.data['lastExceptionBacktrace']
 self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
@@ -573,6 +579,31 @@ def parse_threads(self, json_threads):
 self.crashlog.threads.append(thread)
 idx += 1
 
+def parse_asi_backtrace(self, thread, bt):
+for line in bt.split('\n'):
+frame_match = TextCrashLogParser.frame_regex.search(line)
+if not frame_match:
+print("error: can't parse application specific backtrace.")
+return False
+
+(frame_id, frame_img_name, frame_addr,
+frame_ofs) = frame_match.groups()
+
+thread.add_ident(frame_img_name)
+if frame_img_name not in self.crashlog.idents:
+self.crashlog.idents.append(frame_img_name)
+thread.frames.append(self.crashlog.Frame(int(frame_id), int(
+frame_addr, 0), frame_ofs))
+
+return True
+
+def parse_app_specific_backtraces(self, json_app_specific_bts):
+for idx, backtrace in enumerate(json_app_specific_bts):
+thread = self.crashlog.Thread(idx, True)
+thread.queue = "Application Specific Backtrace"
+if self.parse_asi_backtrace(thread, backtrace):
+self.crashlog.threads.append(thread)
+
 def parse_thread_registers(s

[Lldb-commits] [lldb] 3350d55 - [lldb/Plugins] Use default initializers for StructuredData::*SP (NFC)

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T14:44:53-07:00
New Revision: 3350d5574864442d7c4120af25404762a840da00

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

LOG: [lldb/Plugins] Use default initializers for StructuredData::*SP (NFC)

This patch replaces the ScriptedProcessInterface getters to return
default initializers for StructureData shared pointers instead of
returning a null pointer.

Differential Revision: https://reviews.llvm.org/D137359

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h 
b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
index 164ec9b9dd605..2795c2f487dff 100644
--- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -24,7 +24,7 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
@@ -41,22 +41,22 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
 return {};
   }
 
-  virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
 
   virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual lldb::DataExtractorSP
   ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
-return nullptr;
+return {};
   }
 
-  virtual StructuredData::ArraySP GetLoadedImages() { return nullptr; }
+  virtual StructuredData::ArraySP GetLoadedImages() { return {}; }
 
   virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
 
@@ -66,12 +66,12 @@ class ScriptedProcessInterface : virtual public 
ScriptedInterface {
 return llvm::None;
   }
 
-  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+  virtual StructuredData::DictionarySP GetMetadata() { return {}; }
 
 protected:
   friend class ScriptedThread;
   virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
-return nullptr;
+return {};
   }
 };
 
@@ -81,7 +81,7 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
@@ -92,17 +92,17 @@ class ScriptedThreadInterface : virtual public 
ScriptedInterface {
 
   virtual llvm::Optional GetQueue() { return llvm::None; }
 
-  virtual StructuredData::DictionarySP GetStopReason() { return nullptr; }
+  virtual StructuredData::DictionarySP GetStopReason() { return {}; }
 
-  virtual StructuredData::ArraySP GetStackFrames() { return nullptr; }
+  virtual StructuredData::ArraySP GetStackFrames() { return {}; }
 
-  virtual StructuredData::DictionarySP GetRegisterInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
 
   virtual llvm::Optional GetRegisterContext() {
 return llvm::None;
   }
 
-  virtual StructuredData::ArraySP GetExtendedInfo() { return nullptr; }
+  virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }
 };
 } // namespace lldb_private
 



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


[Lldb-commits] [PATCH] D135616: [lldb/Utility] Fix StructuredData::ParseJSONValue for null items

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90608963d40b: [lldb/Utility] Fix 
StructuredData::ParseJSONValue for null items (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135616/new/

https://reviews.llvm.org/D135616

Files:
  lldb/source/Utility/StructuredData.cpp


Index: lldb/source/Utility/StructuredData.cpp
===
--- lldb/source/Utility/StructuredData.cpp
+++ lldb/source/Utility/StructuredData.cpp
@@ -69,6 +69,9 @@
   if (auto d = value.getAsNumber())
 return std::make_shared(*d);
 
+  if (auto n = value.getAsNull())
+return std::make_shared();
+
   return StructuredData::ObjectSP();
 }
 


Index: lldb/source/Utility/StructuredData.cpp
===
--- lldb/source/Utility/StructuredData.cpp
+++ lldb/source/Utility/StructuredData.cpp
@@ -69,6 +69,9 @@
   if (auto d = value.getAsNumber())
 return std::make_shared(*d);
 
+  if (auto n = value.getAsNull())
+return std::make_shared();
+
   return StructuredData::ObjectSP();
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135547: [lldb/Utility] Add GetDescription(Stream&) to StructureData::*

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe861d053dd43: [lldb/Utility] Add GetDescription(Stream&) 
to StructureData::* (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D135547?vs=472497&id=473040#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135547/new/

https://reviews.llvm.org/D135547

Files:
  lldb/include/lldb/Core/StructuredDataImpl.h
  lldb/include/lldb/Utility/StructuredData.h
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Utility/StructuredData.cpp
  lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/Inputs/StructuredData-full.json
  lldb/unittests/Utility/Inputs/StructuredData-nested.json
  lldb/unittests/Utility/StructuredDataTest.cpp

Index: lldb/unittests/Utility/StructuredDataTest.cpp
===
--- lldb/unittests/Utility/StructuredDataTest.cpp
+++ lldb/unittests/Utility/StructuredDataTest.cpp
@@ -31,6 +31,73 @@
   }
 }
 
+TEST(StructuredDataTest, GetDescriptionEmpty) {
+  Status status;
+  auto object_sp = StructuredData::ParseJSON("{}");
+  ASSERT_NE(nullptr, object_sp);
+
+  StreamString S;
+  object_sp->GetDescription(S);
+  EXPECT_EQ(0, S.GetSize());
+}
+
+TEST(StructuredDataTest, GetDescriptionBasic) {
+  Status status;
+  std::string input = GetInputFilePath("StructuredData-basic.json");
+  auto object_sp = StructuredData::ParseJSONFromFile(FileSpec(input), status);
+  ASSERT_NE(nullptr, object_sp);
+
+  const std::string expected = "[0]: 1\n"
+   "[1]: 2\n"
+   "[2]: 3";
+
+  StreamString S;
+  object_sp->GetDescription(S);
+  EXPECT_EQ(expected, S.GetString());
+}
+
+TEST(StructuredDataTest, GetDescriptionNested) {
+  Status status;
+  std::string input = GetInputFilePath("StructuredData-nested.json");
+  auto object_sp = StructuredData::ParseJSONFromFile(FileSpec(input), status);
+  ASSERT_NE(nullptr, object_sp);
+
+  const std::string expected = "my_dict:\n"
+   "  [0]:\n"
+   "three: 3\n"
+   "two: 2\n"
+   "  [1]:\n"
+   "four:\n"
+   "  val: 4\n"
+   "  [2]: 1";
+
+  StreamString S;
+  object_sp->GetDescription(S);
+  EXPECT_EQ(expected, S.GetString());
+}
+
+TEST(StructuredDataTest, GetDescriptionFull) {
+  Status status;
+  std::string input = GetInputFilePath("StructuredData-full.json");
+  auto object_sp = StructuredData::ParseJSONFromFile(FileSpec(input), status);
+  ASSERT_NE(nullptr, object_sp);
+
+  const std::string expected = "Array:\n"
+   "  [0]: 3.14\n"
+   "  [1]:\n"
+   "key: val\n"
+   "Dictionary:\n"
+   "  FalseBool: False\n"
+   "Integer: 1\n"
+   "Null: NULL\n"
+   "String: value\n"
+   "TrueBool: True";
+
+  StreamString S;
+  object_sp->GetDescription(S);
+  EXPECT_EQ(expected, S.GetString());
+}
+
 TEST(StructuredDataTest, ParseJSONFromFile) {
   Status status;
   auto object_sp = StructuredData::ParseJSONFromFile(
Index: lldb/unittests/Utility/Inputs/StructuredData-nested.json
===
--- /dev/null
+++ lldb/unittests/Utility/Inputs/StructuredData-nested.json
@@ -0,0 +1,14 @@
+{
+  "my_dict": [
+{
+  "three": 3,
+  "two": 2
+},
+{
+  "four": {
+"val": 4
+  }
+},
+1
+  ]
+}
Index: lldb/unittests/Utility/Inputs/StructuredData-full.json
===
--- /dev/null
+++ lldb/unittests/Utility/Inputs/StructuredData-full.json
@@ -0,0 +1,15 @@
+{
+  "Array": [
+3.14,
+{
+  "key": "val"
+}
+  ],
+  "Dictionary": {
+"FalseBool": false
+  },
+  "Integer": 1,
+  "Null": null,
+  "String": "value",
+  "TrueBool": true
+}
Index: lldb/unittests/Utility/CMakeLists.txt
===
--- lldb/unittests/Utility/CMakeLists.txt
+++ lldb/unittests/Utility/CMakeLists.txt
@@ -54,6 +54,10 @@
 Support
   )
 
-add_unittest_inputs(UtilityTests
+set(test_inputs
   StructuredData-basic.json
+  StructuredData-nested.json
+  StructuredData-full.json
   )
+
+add_unittest_inputs(UtilityTests "${test_inputs}")
Index: lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
===
--- lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
+++ lldb/test/API/functionaliti

[Lldb-commits] [PATCH] D126260: [lldb/crashlog] Add support for Application Specific Backtraces & Information

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78d6e1d1d4b3: [lldb/crashlog] Add support for Application 
Specific Backtraces & Information (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126260/new/

https://reviews.llvm.org/D126260

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
  lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.ips
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.yaml
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/main.m
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/app_specific_backtrace_crashlog.test
@@ -0,0 +1,52 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/asi %S/Inputs/application_specific_info/asi.ips' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status --verbose
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT: frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK: Extended Crash Information:
+# CHECK:   Application Specific Information:
+# CHECK-NEXT: CoreFoundation: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'
+# CHECK-NEXT: libc++abi.dylib: terminating with uncaught exception of type NSException
+# CHECK-NEXT: libsystem_c.dylib: abort() called
+
+
+# CHECK: (lldb) thread backtrace --extended true
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT:   * frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK-NEXT: frame #1: 0x0001a08fdceb{{.*}}[artificial]
+# CHECK-NEXT: frame #2: 0x0001a08372c7{{.*}}[artificial]
+# CHECK-NEXT: frame #3: 0x0001a08b7b17{{.*}}[artificial]
+# CHECK-NEXT: frame #4: 0x0001a08a7a0b{{.*}}[artificial]
+# CHECK-NEXT: frame #5: 0x0001a05ab763{{.*}}[artificial]
+# CHECK-NEXT: frame #6: 0x0001a08b6eb3{{.*}}[artificial]
+# CHECK-NEXT: frame #7: 0x0001a08b9c2b{{.*}}[artificial]
+# CHECK-NEXT: frame #8: 0x0001a08b9bd7{{.*}}[artificial]
+# CHECK-NEXT: frame #9: 0x0001a05a3007{{.*}}[artificial]
+# CHECK-NEXT: frame #10: 0x0001a0b3dcc3{{.*}}[artificial]
+# CHECK-NEXT: frame #11: 0x0001a0b46af3{{.*}}[artificial]
+# CHECK-NEXT: frame #12: 0x0001a09a12a3{{.*}}[artificial]
+# CHECK-NEXT: frame #13: 0x0001047e3ecf asi`main{{.*}}[artificial]
+# CHECK-NEXT: frame #14: 0x0001a05d3e4f{{.*}}[artificial]
+
+# CHECK:   thread #4294967295: tid = 0x0001, 0x0001a0a58418{{.*}}, queue = 'Application Specific Backtrace'
+# CHECK-NEXT: frame #0: 0x0001a0a58418{{.*}}
+# CHECK-NEXT: frame #1: 0x0001a05a2ea7{{.*}}
+# CHECK-NEXT: frame #2: 0x0001a0b3dcc3{{.*}}
+# CHECK-NEXT: frame #3: 0x0001a0b46af3{{.*}}
+# CHECK-NEXT: frame #4: 0x0001a09a12a3{{.*}}
+# CHECK-NEXT: frame #5: 0x0001047e3ecf asi`main{{.*}}
+# CHECK-NEXT: frame #6: 0x0001a05d3e4f dyld`start{{.*}}
+
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1: tid = 0x1af8f3, 0x0001

[Lldb-commits] [PATCH] D137359: [lldb/Plugins] Use default initializers for StructuredData::*SP (NFC)

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3350d5574864: [lldb/Plugins] Use default initializers for 
StructuredData::*SP (NFC) (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137359/new/

https://reviews.llvm.org/D137359

Files:
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h


Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -24,7 +24,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
@@ -41,22 +41,22 @@
 return {};
   }
 
-  virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
 
   virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual lldb::DataExtractorSP
   ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
-return nullptr;
+return {};
   }
 
-  virtual StructuredData::ArraySP GetLoadedImages() { return nullptr; }
+  virtual StructuredData::ArraySP GetLoadedImages() { return {}; }
 
   virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
 
@@ -66,12 +66,12 @@
 return llvm::None;
   }
 
-  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+  virtual StructuredData::DictionarySP GetMetadata() { return {}; }
 
 protected:
   friend class ScriptedThread;
   virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
-return nullptr;
+return {};
   }
 };
 
@@ -81,7 +81,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
@@ -92,17 +92,17 @@
 
   virtual llvm::Optional GetQueue() { return llvm::None; }
 
-  virtual StructuredData::DictionarySP GetStopReason() { return nullptr; }
+  virtual StructuredData::DictionarySP GetStopReason() { return {}; }
 
-  virtual StructuredData::ArraySP GetStackFrames() { return nullptr; }
+  virtual StructuredData::ArraySP GetStackFrames() { return {}; }
 
-  virtual StructuredData::DictionarySP GetRegisterInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
 
   virtual llvm::Optional GetRegisterContext() {
 return llvm::None;
   }
 
-  virtual StructuredData::ArraySP GetExtendedInfo() { return nullptr; }
+  virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }
 };
 } // namespace lldb_private
 


Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
===
--- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -24,7 +24,7 @@
   CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp,
  StructuredData::Generic *script_obj = nullptr) override {
-return nullptr;
+return {};
   }
 
   virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
@@ -41,22 +41,22 @@
 return {};
   }
 
-  virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; }
+  virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
 
   virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
-return nullptr;
+return {};
   }
 
   virtual lldb::DataExtractorSP
   ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
-return nullptr;
+return {};
   }
 
-  virtual StructuredData::ArraySP GetLoadedImages() { return nullptr; }
+  virtual StructuredData::ArraySP GetLoadedImages() { return {}; }
 
   virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
 
@@ -66,12 +66,12 @@
 return llvm::None;
   }
 
-  virtual StructuredData::DictionarySP GetMetadata() { return nullptr; }
+  virtual StructuredData::DictionarySP GetMetadata() { return {}; }
 
 protected:
   friend class ScriptedThread;
   virtu

[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread Yubo Hu via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
GeorgeHuyubo marked 2 inline comments as done.
Closed by commit rG0309081e1f4b: Override CalculateFrameVariableError in 
SymbolFileOnDemand (authored by GeorgeHuyubo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137284/new/

https://reviews.llvm.org/D137284

Files:
  lldb/include/lldb/Symbol/SymbolFileOnDemand.h
  lldb/source/Symbol/SymbolFileOnDemand.cpp
  lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py

Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -85,6 +85,40 @@
   'variable "%s" in verify dictionary' % (name))
 self.verify_values(verify_dict[name], variable, varref_dict)
 
+def darwin_dwarf_missing_obj(self, initCommands):
+self.build(debug_info="dwarf")
+program = self.getBuildArtifact("a.out")
+main_obj = self.getBuildArtifact("main.o")
+self.assertTrue(os.path.exists(main_obj))
+# Delete the main.o file that contains the debug info so we force an
+# error when we run to main and try to get variables
+os.unlink(main_obj)
+
+self.create_debug_adaptor()
+self.assertTrue(os.path.exists(program), 'executable must exist')
+
+self.launch(program=program,
+initCommands=initCommands)
+
+functions = ['main']
+breakpoint_ids = self.set_function_breakpoints(functions)
+self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint")
+self.continue_to_breakpoints(breakpoint_ids)
+
+locals = self.vscode.get_local_variables()
+
+verify_locals = {
+'': {
+'equals': {'type': 'const char *'},
+'contains': { 'value': [
+'debug map object file ',
+'main.o" containing debug info does not exist, debug info will not be loaded']
+}
+},
+}
+varref_dict = {}
+self.verify_variables(verify_locals, locals, varref_dict)
+
 @skipIfWindows
 @skipIfRemote
 def test_scopes_variables_setVariable_evaluate(self):
@@ -529,33 +563,16 @@
 changing compiler options and are designed to give better feedback
 to the user.
 '''
-self.build(debug_info="dwarf")
-program = self.getBuildArtifact("a.out")
-main_obj = self.getBuildArtifact("main.o")
-self.assertTrue(os.path.exists(main_obj))
-# Delete the main.o file that contains the debug info so we force an
-# error when we run to main and try to get variables
-os.unlink(main_obj)
-
-self.create_debug_adaptor()
-self.assertTrue(os.path.exists(program), 'executable must exist')
-self.launch(program)
-
-functions = ['main']
-breakpoint_ids = self.set_function_breakpoints(functions)
-self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint")
-self.continue_to_breakpoints(breakpoint_ids)
+self.darwin_dwarf_missing_obj(None)
 
-locals = self.vscode.get_local_variables()
 
-verify_locals = {
-'': {
-'equals': {'type': 'const char *'},
-'contains': { 'value': [
-'debug map object file ',
-'main.o" containing debug info does not exist, debug info will not be loaded']
-}
-},
-}
-varref_dict = {}
-self.verify_variables(verify_locals, locals, varref_dict)
+@no_debug_info_test
+@skipUnlessDarwin
+def test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled(self):
+'''
+Test that if we build a binary with DWARF in .o files and we remove
+the .o file for main.cpp, that we get a variable named ""
+whose value matches the appriopriate error. Test with symbol_ondemand_enabled.
+'''
+initCommands = ['settings set symbols.load-on-demand true']
+self.darwin_dwarf_missing_obj(initCommands)
Index: lldb/source/Symbol/SymbolFileOnDemand.cpp
===
--- lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -274,6 +274,15 @@
   return m_sym_file_impl->ResolveSymbolContext(so_addr, resolve_scope, sc);
 }
 
+Status SymbolFileOnDemand::CalculateFrameVariableError(StackFrame &frame) {
+  if (!m_debug_info_enabled) {
+LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(),
+ __FUNCTION__);
+return Status()

[Lldb-commits] [lldb] 0309081 - Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-03 Thread George Hu via lldb-commits

Author: George Hu
Date: 2022-11-03T15:09:07-07:00
New Revision: 0309081e1f4b564693dd4e4d3c7b1d700780c62b

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

LOG: Override CalculateFrameVariableError in SymbolFileOnDemand

Differential Revision: https://reviews.llvm.org/D137284

Added: 


Modified: 
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py

Removed: 




diff  --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h 
b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index 05708395687f2..a215c7e32b26a 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -117,6 +117,9 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
 lldb::SymbolContextItem resolve_scope,
 lldb_private::SymbolContext &sc) override;
 
+  lldb_private::Status
+  CalculateFrameVariableError(lldb_private::StackFrame &frame) override;
+
   uint32_t ResolveSymbolContext(
   const lldb_private::SourceLocationSpec &src_location_spec,
   lldb::SymbolContextItem resolve_scope,

diff  --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp 
b/lldb/source/Symbol/SymbolFileOnDemand.cpp
index b4c9ed002a8ea..737cb1042ca76 100644
--- a/lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -274,6 +274,15 @@ SymbolFileOnDemand::ResolveSymbolContext(const Address 
&so_addr,
   return m_sym_file_impl->ResolveSymbolContext(so_addr, resolve_scope, sc);
 }
 
+Status SymbolFileOnDemand::CalculateFrameVariableError(StackFrame &frame) {
+  if (!m_debug_info_enabled) {
+LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(),
+ __FUNCTION__);
+return Status();
+  }
+  return m_sym_file_impl->CalculateFrameVariableError(frame);
+}
+
 uint32_t SymbolFileOnDemand::ResolveSymbolContext(
 const SourceLocationSpec &src_location_spec,
 SymbolContextItem resolve_scope, SymbolContextList &sc_list) {

diff  --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 9b9195561606b..a6a7e159169b6 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -85,6 +85,40 @@ def verify_variables(self, verify_dict, variables, 
varref_dict=None):
   'variable "%s" in verify dictionary' % (name))
 self.verify_values(verify_dict[name], variable, varref_dict)
 
+def darwin_dwarf_missing_obj(self, initCommands):
+self.build(debug_info="dwarf")
+program = self.getBuildArtifact("a.out")
+main_obj = self.getBuildArtifact("main.o")
+self.assertTrue(os.path.exists(main_obj))
+# Delete the main.o file that contains the debug info so we force an
+# error when we run to main and try to get variables
+os.unlink(main_obj)
+
+self.create_debug_adaptor()
+self.assertTrue(os.path.exists(program), 'executable must exist')
+
+self.launch(program=program,
+initCommands=initCommands)
+
+functions = ['main']
+breakpoint_ids = self.set_function_breakpoints(functions)
+self.assertEquals(len(breakpoint_ids), len(functions), "expect one 
breakpoint")
+self.continue_to_breakpoints(breakpoint_ids)
+
+locals = self.vscode.get_local_variables()
+
+verify_locals = {
+'': {
+'equals': {'type': 'const char *'},
+'contains': { 'value': [
+'debug map object file ',
+'main.o" containing debug info does not exist, debug info 
will not be loaded']
+}
+},
+}
+varref_dict = {}
+self.verify_variables(verify_locals, locals, varref_dict)
+
 @skipIfWindows
 @skipIfRemote
 def test_scopes_variables_setVariable_evaluate(self):
@@ -529,33 +563,16 @@ def test_darwin_dwarf_missing_obj(self):
 changing compiler options and are designed to give better feedback
 to the user.
 '''
-self.build(debug_info="dwarf")
-program = self.getBuildArtifact("a.out")
-main_obj = self.getBuildArtifact("main.o")
-self.assertTrue(os.path.exists(main_obj))
-# Delete the main.o file that contains the debug info so we force an
-# error when we run to main and try to get variables
-os.unlink(main_obj)
-
-self.create_debug_adaptor()
-self.assertTrue(os.path.exists(program), 'executable must exist'

[Lldb-commits] [PATCH] D137098: [lldb] Support simplified template names when looking up functions

2022-11-03 Thread Arthur Eubanks via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d83a57721de: [lldb] Support simplified template names when 
looking up functions (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137098/new/

https://reviews.llvm.org/D137098

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/cpp/main.cpp

Index: lldb/test/API/functionalities/breakpoint/cpp/main.cpp
===
--- lldb/test/API/functionalities/breakpoint/cpp/main.cpp
+++ lldb/test/API/functionalities/breakpoint/cpp/main.cpp
@@ -94,6 +94,8 @@
 
   template  void operator<<(T t) {}
 };
+
+template  void g() {}
 } // namespace ns
 
 int main (int argc, char const *argv[])
@@ -123,5 +125,8 @@
 f.operator<<(5);
 f.operator<< >({});
 
+ns::g();
+ns::g();
+
 return 0;
 }
Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
===
--- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto ns::Foo::func>()']},
 
@@ -71,6 +84,15 @@
 {'name': 'operator<<', 'loc_names': ['void ns::Foo::operator<<(int)']},
 {'name': 'ns::Foo::operator<<', 'loc_names': ['void ns::Foo::operator<<(int)',
   'void ns::Foo::operator<<>(ns::Foo)']},
+
+{'name': 'g', 'loc_names': []},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()', 'void ns::g()']},
+{'name': 'ns::g', 'loc_names': []},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()', 'void ns::g()']},
 ]
 
 for bp_dict in bp_dicts:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2389,6 +2389,24 @@
   ResolveFunction(die, include_inlines, sc_list);
 return true;
   });
+  // With -gsimple-template-names, a templated type's DW_AT_name will not
+  // contain the template parameters. Try again stripping '<' and anything
+  // after, filtering out entries with template parameters that don't match.
+  {
+const llvm::StringRef name_ref = name.GetStringRef();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+
+  Module::LookupInfo no_tp_lookup_info(lookup_info);
+  no_tp_lookup_info.SetLookupName(ConstString(name_no_template_params));
+  m_index->GetFunctions(no_tp_lookup_info, *this, parent_decl_ctx, [&](DWARFDIE die) {
+if (resolved_dies.insert(die.GetDIE()).second)
+  ResolveFunction(die, include_inlines, sc_list);
+return true;
+  });
+}
+  }
 
   // Return the number of variable that were appended to the list
   const uint32_t num_matches = sc_list.GetSize() - original_size;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3d83a57 - [lldb] Support simplified template names when looking up functions

2022-11-03 Thread Arthur Eubanks via lldb-commits

Author: Arthur Eubanks
Date: 2022-11-03T16:19:15-07:00
New Revision: 3d83a57721def7aad227d68b1e5e0afa6a74a33f

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

LOG: [lldb] Support simplified template names when looking up functions

This makes setting breakpoints work with -gsimple-template-names.

Assume that callers handle false positives. For example, 
`Module::LookupInfo::Prune` removes wrong template instantiations when setting 
a breakpoint.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D137098

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
lldb/test/API/functionalities/breakpoint/cpp/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5d5a47bc0c92c..066fc9f434cae 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2389,6 +2389,24 @@ void SymbolFileDWARF::FindFunctions(const 
Module::LookupInfo &lookup_info,
   ResolveFunction(die, include_inlines, sc_list);
 return true;
   });
+  // With -gsimple-template-names, a templated type's DW_AT_name will not
+  // contain the template parameters. Try again stripping '<' and anything
+  // after, filtering out entries with template parameters that don't match.
+  {
+const llvm::StringRef name_ref = name.GetStringRef();
+auto it = name_ref.find('<');
+if (it != llvm::StringRef::npos) {
+  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
+
+  Module::LookupInfo no_tp_lookup_info(lookup_info);
+  no_tp_lookup_info.SetLookupName(ConstString(name_no_template_params));
+  m_index->GetFunctions(no_tp_lookup_info, *this, parent_decl_ctx, 
[&](DWARFDIE die) {
+if (resolved_dies.insert(die.GetDIE()).second)
+  ResolveFunction(die, include_inlines, sc_list);
+return true;
+  });
+}
+  }
 
   // Return the number of variable that were appended to the list
   const uint32_t num_matches = sc_list.GetSize() - original_size;

diff  --git 
a/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py 
b/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
index 6c86f5016a606..1dedc5d7f9bbd 100644
--- a/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ b/lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -12,7 +12,16 @@ class TestCPPBreakpointLocations(TestBase):
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 def test(self):
-self.build()
+self.do_test(dict())
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@skipIf(compiler=no_match("clang"))
+@skipIf(compiler_version=["<", "15.0"])
+def test_simple_template_names(self):
+self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))
+
+def do_test(self, debug_flags):
+self.build(dictionary=debug_flags)
 self.breakpoint_id_tests()
 
 def verify_breakpoint_locations(self, target, bp_dict):
@@ -57,7 +66,11 @@ def breakpoint_id_tests(self):
 
 # Template cases
 {'name': 'func', 'loc_names': []},
+{'name': 'Foo::func', 'loc_names': []},
+{'name': 'ns::Foo::func', 'loc_names': []},
 {'name': 'func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
+{'name': 'ns::Foo::func', 'loc_names': ['auto 
ns::Foo::func()']},
 {'name': 'func', 'loc_names': ['auto ns::Foo::func()',
'auto 
ns::Foo::func>()']},
 
@@ -71,6 +84,15 @@ def breakpoint_id_tests(self):
 {'name': 'operator<<', 'loc_names': ['void 
ns::Foo::operator<<(int)']},
 {'name': 'ns::Foo::operator<<', 'loc_names': ['void 
ns::Foo::operator<<(int)',
   'void 
ns::Foo::operator<<>(ns::Foo)']},
+
+{'name': 'g', 'loc_names': []},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()']},
+{'name': 'g', 'loc_names': ['void ns::g()', 'void 
ns::g()']},
+{'name': 'ns::g', 'loc_names': []},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()']},
+{'name': 'ns::g', 'loc_names': ['void ns::g()', 'void 
ns::g()']},
 ]
 
 for bp_dict in bp_dicts:

diff  --git a/lldb/te

[Lldb-commits] [PATCH] D134066: [LLDB][NativePDB] Forcefully complete a record type it has incomplete type debug info.

2022-11-03 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 473077.
zequanwu added a comment.

Update to forcefully complete a record type only if it has empty debug info and 
is required to have complete type.

I basically copied RequireCompleteType 

 from dwarf plugin. Calling it when the tag type is one of 1. an element type 
2. an base class 3. a class member. This is the same way that dwarf plugin is 
doing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134066/new/

https://reviews.llvm.org/D134066

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
  lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
  lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
  lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp

Index: lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
@@ -0,0 +1,28 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj -- %p/Inputs/incomplete-tag-type.cpp
+// RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj -- %s
+// RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj /out:%t.exe /pdb:%t.pdb
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe \
+// RUN:   -o "p b" -o "p b_array" -o "p c" -o "exit" | FileCheck %s
+
+// CHECK: (lldb) p b
+// CHECK: (B) $0 = {}
+// CHECK: (lldb) p b_array
+// CHECK: (B[3]) $1 = ([0] = B @ {{.*}}, [1] = B @ {{.*}}, [2] = B @ {{.*}})
+// CHECK: (lldb) p c
+// CHECK: (C) $2 = {}
+
+struct A { int x; A(); };
+struct B : A {};
+struct C {
+  static A static_a;
+  A getA() {}
+};
+
+B b;
+B b_array[3] = {};
+A C::static_a = A();
+C c;
+int main(){}
Index: lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
@@ -0,0 +1,5 @@
+struct A {
+  int x;
+  A();
+};
+A::A() : x(47) {}
Index: lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -92,9 +92,10 @@
   m_ast_builder.GetOrCreateType(PdbTypeSymId(type_idx));
   if (method_qt.isNull())
 return;
-  m_ast_builder.CompleteType(method_qt);
   CompilerType method_ct = m_ast_builder.ToCompilerType(method_qt);
-  lldb::opaque_compiler_type_t derived_opaque_ty = m_derived_ct.GetOpaqueQualType();
+  PdbAstBuilder::RequireCompleteType(method_ct);
+  lldb::opaque_compiler_type_t derived_opaque_ty =
+  m_derived_ct.GetOpaqueQualType();
   auto iter = m_cxx_record_map.find(derived_opaque_ty);
   if (iter != m_cxx_record_map.end()) {
 if (iter->getSecond().contains({name, method_ct})) {
@@ -155,6 +156,7 @@
 return llvm::Error::success();
 
   CompilerType member_ct = m_ast_builder.ToCompilerType(member_type);
+  PdbAstBuilder::RequireCompleteType(member_ct);
 
   lldb::AccessType access =
   TranslateMemberAccess(static_data_member.getAccess());
@@ -253,7 +255,7 @@
   clang::QualType member_qt = m_ast_builder.GetOrCreateType(PdbTypeSymId(ti));
   if (member_qt.isNull())
 return Error::success();
-  m_ast_builder.CompleteType(member_qt);
+  PdbAstBuilder::RequireCompleteType(m_ast_builder.ToCompilerType(member_qt));
   lldb::AccessType access = TranslateMemberAccess(data_member.getAccess());
   size_t field_size =
   bitfield_width ? bitfield_width : GetSizeOfType(ti, m_index.tpi()) * 8;
@@ -310,6 +312,18 @@
 bases.push_back(std::move(ib.second));
 
   TypeSystemClang &clang = m_ast_builder.clang();
+  // Make sure all base classes refer to complete types and not forward
+  // declarations. If we don't do this, clang will crash with an
+  // assertion in the call to clang_type.TransferBaseClasses()
+  for (const auto &base_class : bases) {
+clang::TypeSourceInfo *type_source_info =
+base_class->getTypeSourceInfo();
+if (type_source_info) {
+  PdbAstBuilder::RequireCompleteType(
+  clang.GetType(type_source_info->getType()));
+}
+  }
+
   clang.TransferBaseClasses(m_derived_ct.GetOpaqueQualType(), std::move(bases));
 
   clang.AddMethodOverridesForCXXRecordType(m_derived_ct.GetOpaqueQualType());
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -87,6 +87,7 @@
   ClangASTImporter

[Lldb-commits] [PATCH] D137287: [Test] Fix CHECK typo.

2022-11-03 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D137287#3905474 , @probinson wrote:

> Nice work!
> have you verified that all the modified tests pass? naively it looks like 
> you'd need at least 3 different targets to run them all (windows, 
> webassembly, powerpc)

Those are target independent tests. I'm able to run and pass those tests in my 
linux machine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137287/new/

https://reviews.llvm.org/D137287

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


[Lldb-commits] [PATCH] D137287: [Test] Fix CHECK typo.

2022-11-03 Thread Paul Robinson via Phabricator via lldb-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM, but you'll want to be ready to jump on any bot failures.  That's just the 
nature of these kinds of changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137287/new/

https://reviews.llvm.org/D137287

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


[Lldb-commits] [PATCH] D137003: [lldb-vscode] Send Statistics Dump in terminated event

2022-11-03 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
kusmour marked an inline comment as done.
Closed by commit rGe3ccbae30927: [lldb-vscode] Send Statistics Dump in 
terminated event (authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137003/new/

https://reviews.llvm.org/D137003

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
  lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
  lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -204,7 +204,7 @@
 g_vsc.sent_terminated_event = true;
 g_vsc.RunTerminateCommands();
 // Send a "terminated" event
-llvm::json::Object event(CreateEventObject("terminated"));
+llvm::json::Object event(CreateTerminatedEventObject());
 g_vsc.SendJSON(llvm::json::Value(std::move(event)));
   }
 }
@@ -2949,7 +2949,7 @@
   const uint32_t addr_size = g_vsc.target.GetProcess().GetAddressByteSize();
   lldb::SBValue reg_set = g_vsc.variables.registers.GetValueAtIndex(0);
   const uint32_t num_regs = reg_set.GetNumChildren();
-  for (uint32_t reg_idx=0; reg_idx pairs
+void FilterAndGetValueForKey(const lldb::SBStructuredData data, const char *key,
+ llvm::json::Object &out) {
+  lldb::SBStructuredData value = data.GetValueForKey(key);
+  std::string key_utf8 = llvm::json::fixUTF8(key);
+  if (strcmp(key, "modules") == 0)
+return;
+  switch (value.GetType()) {
+  case lldb::eStructuredDataTypeFloat:
+out.try_emplace(key_utf8, value.GetFloatValue());
+break;
+  case lldb::eStructuredDataTypeInteger:
+out.try_emplace(key_utf8, value.GetIntegerValue());
+break;
+  case lldb::eStructuredDataTypeArray: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+EmplaceSafeString(out, key, contents.GetData());
+  } break;
+  case lldb::eStructuredDataTypeBoolean:
+out.try_emplace(key_utf8, value.GetBooleanValue());
+break;
+  case lldb::eStructuredDataTypeString: {
+// Get the string size before reading
+const size_t str_length = value.GetStringValue(nullptr, 0);
+std::string str(str_length + 1, 0);
+value.GetStringValue(&str[0], str_length);
+EmplaceSafeString(out, key, str);
+  } break;
+  case lldb::eStructuredDataTypeDictionary: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+EmplaceSafeString(out, key, contents.GetData());
+  } break;
+  case lldb::eStructuredDataTypeNull:
+  case lldb::eStructuredDataTypeGeneric:
+  case lldb::eStructuredDataTypeInvalid:
+break;
+  }
+}
+
+void addStatistic(llvm::json::Object &event) {
+  lldb::SBStructuredData statistics = g_vsc.target.GetStatistics();
+  bool is_dictionary =
+  statistics.GetType() == lldb::eStructuredDataTypeDictionary;
+  if (!is_dictionary)
+return;
+  llvm::json::Object stats_body;
+
+  lldb::SBStringList keys;
+  if (!statistics.GetKeys(keys))
+return;
+  for (size_t i = 0; i < keys.GetSize(); i++) {
+const char *key = keys.GetStringAtIndex(i);
+FilterAndGetValueForKey(statistics, key, stats_body);
+  }
+  event.try_emplace("statistics", std::move(stats_body));
+}
+
+llvm::json::Object CreateTerminatedEventObject() {
+  llvm::json::Object event(CreateEventObject("terminated"));
+  addStatistic(event);
+  return event;
+}
+
 std::string JSONToString(const llvm::json::Value &json) {
   std::string data;
   llvm::raw_string_ostream os(data);
Index: lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include "foo.h"
+
+int main(int argc, char const *argv[]) {
+  std::cout << "Hello World!" << std::endl; // main breakpoint 1
+  foo();
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
@@ -0,0 +1,3 @@
+int foo() {
+return 12;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_te

[Lldb-commits] [lldb] e3ccbae - [lldb-vscode] Send Statistics Dump in terminated event

2022-11-03 Thread Wanyi Ye via lldb-commits

Author: Wanyi Ye
Date: 2022-11-03T18:15:38-07:00
New Revision: e3ccbae309273900a42e30b606c15c873d57f1ea

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

LOG: [lldb-vscode] Send Statistics Dump in terminated event

This patch will gather debug info & breakpoint info from the statistics dump 
(from `(SBTarget.GetStatistics())` func) and send to DAP in terminated event.

The statistics content can be huge (especially the `modules`) and dumping in 
full JSON can create delay in the IDE's debugging UI. (For more details, please 
read: 
https://github.com/llvm/llvm-project/commit/7bbd0fba986c241162b77b7e424ad82bc7e17b41
 ). Hence, we will filter out large contents before returning it in terminated 
event.

It will keep all the metadata fields (those starts with "total"). For large 
contents, it uses the opt-out strategy. Currently it only removes the "modules" 
field. This way every time a new top-level field being added, we will be able 
to capture them from DAP log without changing lldb-vscode.

The DAP terminated event should look like
```
{
  "event":"terminated",
  "seq":0,
  "statistics": {
"memory": 
"targets": , // it's a JSON array, breakpoints info included 
in each target
 // pairs
  },
  "type":"event"
}
```

All the info above will be append to statistics field in the terminated event

Test Plan

Debugged a simple hello world program from VSCode. Exit debug session in two 
ways: 1) run to program exit; 2) user initiated debug session end (quit 
debugging before program exit).
Check DAP log and see both debug sessions have statistics returned in 
terminated event.

Here's an example when debugging the test program:

```
{"event":"terminated","seq":0,"statistics":{"memory":"{\"strings\":{\"bytesTotal\":1843200,\"bytesUnused\":897741,\"bytesUsed\":945459}}","targets":"[{\"breakpoints\":[{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"NameMask\":[56],\"Offset\":0,\"SkipPrologue\":true,\"SymbolNames\":[\"foo\"]},\"Type\":\"SymbolName\"},\"Hardware\":false,\"Names\":[\"vscode\"],\"SearchFilter\":{\"Options\":{},\"Type\":\"Unconstrained\"}}},\"id\":1,\"internal\":false,\"numLocations\":1,\"numResolvedLocations\":1,\"resolveTime\":0.002232},{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"Column\":0,\"Exact\":false,\"FileName\":\"/data/users/wanyi/llvm-sand/external/llvm-project/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp\",\"Inlines\":true,\"LineNumber\":5,\"Offset\":0,\"SkipPrologue\":true},\"Type\":\"FileAndLine\"},\"Hardware\":false,\"Names\":[\"vscode\"],\"SearchFilter\":{\"Options\":{},\"Type\":\"Unconstrained\"}}},\"id\":2,\"internal\":false,\"numLocations\":0,\"numResolvedLocations\":0,\"resolveTime\":0.232037999},{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"Language\":\"c\",\"NameMask\":[4,4,4,4,4,4],\"Offset\":0,\"SkipPrologue\":false,\"SymbolNames\":[\"_dl_debug_state\",\"rtld_db_dlactivity\",\"__dl_rtld_db_dlactivity\",\"r_debug_state\",\"_r_debug_state\",\"_rtld_debug_state\"]},\"Type\":\"SymbolName\"},\"Hardware\":false,\"SearchFilter\":{\"Options\":{\"ModuleList\":[\"/usr/lib64/ld-2.28.so\"]},\"Type\":\"Modules\"}}},\"id\":-1,\"internal\":true,\"kindDescription\":\"shared-library-event\",\"numLocations\":1,\"numResolvedLocations\":1,\"resolveTime\":0.00026698}],\"expressionEvaluation\":{\"failures\":0,\"successes\":0},\"firstStopTime\":0.0874589744,\"frameVariable\":{\"failures\":0,\"successes\":0},\"launchOrAttachTime\":0.0529531618,\"moduleIdentifiers\":[94554748126576,94554747837792,94554747149216,139800112130176,139800112161056,139800112206064,139800112340224,139800112509552,139800112236528],\"signals\":[{\"SIGSTOP\":1}],\"sourceMapDeduceCount\":0,\"stopCount\":8,\"targetCreateTime\":0.00057704,\"totalBreakpointResolveTime\":0.234537}]","totalDebugInfoByteSize":1668056,"totalDebugInfoEnabled":3,"totalDebugInfoIndexLoadedFromCache":0,"totalDebugInfoIndexSavedToCache":0,"totalDebugInfoIndexTime":0.0279630002,"totalDebugInfoParseTime":0.343548002,"totalModuleCount":10,"totalModuleCountHasDebugInfo":3,"totalSymbolTableIndexTime":0.056053,"totalSymbolTableParseTime":0.23931,"totalSymbolTableStripped":0,"totalSymbolTablesLoadedFromCache":0,"totalSymbolTablesSavedToCache":0},"type":"event"}
```

Differential Revision: https://reviews.llvm.org/D137003

Added: 
lldb/test/API/tools/lldb-vscode/terminated-event/Makefile

[Lldb-commits] [lldb] de86508 - [LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()

2022-11-03 Thread Weining Lu via lldb-commits

Author: Weining Lu
Date: 2022-11-04T10:26:31+08:00
New Revision: de865087f8c07c742dec3523ec8cbe6895bd57ac

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

LOG: [LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()

This is a simple change, loongarch64 host also supports 32-bit binaries,
so note it.

Without this patch:

```
[loongson@linux build]$ ./tools/lldb/unittests/Host/HostTests | tail -6
[==] 78 tests from 18 test suites ran. (16 ms total)
[  PASSED  ] 77 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] HostTest.GetProcessInfo

 1 FAILED TEST
```

With this patch:

```
[loongson@linux build]$ ./tools/lldb/unittests/Host/HostTests | tail -2
[==] 78 tests from 18 test suites ran. (15 ms total)
[  PASSED  ] 78 tests.
```

Reviewed By: xen0n, MaskRay, DavidSpickett

Differential Revision: https://reviews.llvm.org/D137312

Added: 


Modified: 
lldb/source/Host/common/HostInfoBase.cpp

Removed: 




diff  --git a/lldb/source/Host/common/HostInfoBase.cpp 
b/lldb/source/Host/common/HostInfoBase.cpp
index e8088344422a7..9a7b77c19de1d 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -340,6 +340,7 @@ void HostInfoBase::ComputeHostArchitectureSupport(ArchSpec 
&arch_32,
   case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
   case llvm::Triple::riscv64:
+  case llvm::Triple::loongarch64:
 arch_64.SetTriple(triple);
 arch_32.SetTriple(triple.get32BitArchVariant());
 break;



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


[Lldb-commits] [PATCH] D137312: [LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()

2022-11-03 Thread Lu Weining via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde865087f8c0: [LLDB] [LoongArch] Add loongarch64 case in 
ComputeHostArchitectureSupport() (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137312/new/

https://reviews.llvm.org/D137312

Files:
  lldb/source/Host/common/HostInfoBase.cpp


Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -340,6 +340,7 @@
   case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
   case llvm::Triple::riscv64:
+  case llvm::Triple::loongarch64:
 arch_64.SetTriple(triple);
 arch_32.SetTriple(triple.get32BitArchVariant());
 break;


Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -340,6 +340,7 @@
   case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
   case llvm::Triple::riscv64:
+  case llvm::Triple::loongarch64:
 arch_64.SetTriple(triple);
 arch_32.SetTriple(triple.get32BitArchVariant());
 break;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b3578f3 - Revert "[LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()"

2022-11-03 Thread Weining Lu via lldb-commits

Author: Weining Lu
Date: 2022-11-04T10:38:10+08:00
New Revision: b3578f33c8b0a05070661565af54352fe3381f6d

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

LOG: Revert "[LLDB] [LoongArch] Add loongarch64 case in 
ComputeHostArchitectureSupport()"

This reverts commit de865087f8c07c742dec3523ec8cbe6895bd57ac.

Reason to revert: author name is wrong.

Added: 


Modified: 
lldb/source/Host/common/HostInfoBase.cpp

Removed: 




diff  --git a/lldb/source/Host/common/HostInfoBase.cpp 
b/lldb/source/Host/common/HostInfoBase.cpp
index 9a7b77c19de1d..e8088344422a7 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -340,7 +340,6 @@ void HostInfoBase::ComputeHostArchitectureSupport(ArchSpec 
&arch_32,
   case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
   case llvm::Triple::riscv64:
-  case llvm::Triple::loongarch64:
 arch_64.SetTriple(triple);
 arch_32.SetTriple(triple.get32BitArchVariant());
 break;



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


[Lldb-commits] [lldb] 8cca7f3 - Reland "[LLDB] [LoongArch] Add loongarch64 case in ComputeHostArchitectureSupport()"

2022-11-03 Thread Weining Lu via lldb-commits

Author: Tiezhu Yang
Date: 2022-11-04T10:40:53+08:00
New Revision: 8cca7f3bf741287eb21ce273106244349a03345a

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

LOG: Reland "[LLDB] [LoongArch] Add loongarch64 case in 
ComputeHostArchitectureSupport()"

This is a simple change, loongarch64 host also supports 32-bit binaries,
so note it.

Without this patch:

```
[loongson@linux build]$ ./tools/lldb/unittests/Host/HostTests | tail -6
[==] 78 tests from 18 test suites ran. (16 ms total)
[  PASSED  ] 77 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] HostTest.GetProcessInfo

 1 FAILED TEST
```

With this patch:

```
[loongson@linux build]$ ./tools/lldb/unittests/Host/HostTests | tail -2
[==] 78 tests from 18 test suites ran. (15 ms total)
[  PASSED  ] 78 tests.
```

Reviewed By: SixWeining, xen0n, MaskRay, DavidSpickett

Differential Revision: https://reviews.llvm.org/D137312

Added: 


Modified: 
lldb/source/Host/common/HostInfoBase.cpp

Removed: 




diff  --git a/lldb/source/Host/common/HostInfoBase.cpp 
b/lldb/source/Host/common/HostInfoBase.cpp
index e8088344422a7..9a7b77c19de1d 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -340,6 +340,7 @@ void HostInfoBase::ComputeHostArchitectureSupport(ArchSpec 
&arch_32,
   case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
   case llvm::Triple::riscv64:
+  case llvm::Triple::loongarch64:
 arch_64.SetTriple(triple);
 arch_32.SetTriple(triple.get32BitArchVariant());
 break;



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


[Lldb-commits] [lldb] 902ba8b - [lldb/Interpreter] Open saved transcript in GUI Editor

2022-11-03 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-11-03T23:13:13-07:00
New Revision: 902ba8b0c9b013043aa04dc548be3ec907ef5571

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

LOG: [lldb/Interpreter] Open saved transcript in GUI Editor

This patch will automatically open LLDB's saved transcript file on the
graphical editor if lldb is running under an interactive graphical session.

This can be controlled by a new setting: `interpreter.open-transcript-in-editor`

rdar://92692106

Differential Revision: https://reviews.llvm.org/D137137

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/InterpreterProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 255f50099ebb9..a72800b5409ca 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -559,6 +559,9 @@ class CommandInterpreter : public Broadcaster,
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  bool GetOpenTranscriptInEditor() const;
+  void SetOpenTranscriptInEditor(bool enable);
+
   FileSpec GetSaveSessionDirectory() const;
   void SetSaveSessionDirectory(llvm::StringRef path);
 

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eaad0195c1b74..3d0b61fa7d3c3 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -170,6 +170,17 @@ void CommandInterpreter::SetSaveSessionOnQuit(bool enable) 
{
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetOpenTranscriptInEditor() const {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
   const uint32_t idx = ePropertySaveSessionDirectory;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
@@ -3226,6 +3237,13 @@ bool CommandInterpreter::SaveTranscript(
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
+  if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
+const FileSpec file_spec;
+error = file->GetFileSpec(const_cast(file_spec));
+if (error.Success())
+  Host::OpenFileInExternalEditor(file_spec, 1);
+  }
+
   return true;
 }
 

diff  --git a/lldb/source/Interpreter/InterpreterProperties.td 
b/lldb/source/Interpreter/InterpreterProperties.td
index c0acc044fb7fe..2155ee61ccffb 100644
--- a/lldb/source/Interpreter/InterpreterProperties.td
+++ b/lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,10 @@ let Definition = "interpreter" in {
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, LLDB will open the saved session's transcripts in the 
external editor.">;
   def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"A path where LLDB will save the session's transcripts. This is 
particularly useful when you can't set the session file, for example when using 
`save-session-on-quit`.">;



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


[Lldb-commits] [PATCH] D137137: [lldb/Interpreter] Open saved transcript in GUI Editor

2022-11-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG902ba8b0c9b0: [lldb/Interpreter] Open saved transcript in 
GUI Editor (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137137/new/

https://reviews.llvm.org/D137137

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td


Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,10 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, LLDB will open the saved session's transcripts in the 
external editor.">;
   def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"A path where LLDB will save the session's transcripts. This is 
particularly useful when you can't set the session file, for example when using 
`save-session-on-quit`.">;
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -170,6 +170,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetOpenTranscriptInEditor() const {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
   const uint32_t idx = ePropertySaveSessionDirectory;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
@@ -3226,6 +3237,13 @@
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
+  if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
+const FileSpec file_spec;
+error = file->GetFileSpec(const_cast(file_spec));
+if (error.Success())
+  Host::OpenFileInExternalEditor(file_spec, 1);
+  }
+
   return true;
 }
 
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -559,6 +559,9 @@
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  bool GetOpenTranscriptInEditor() const;
+  void SetOpenTranscriptInEditor(bool enable);
+
   FileSpec GetSaveSessionDirectory() const;
   void SetSaveSessionDirectory(llvm::StringRef path);
 


Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,10 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"If true, LLDB will open the saved session's transcripts in the external editor.">;
   def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"A path where LLDB will save the session's transcripts. This is particularly useful when you can't set the session file, for example when using `save-session-on-quit`.">;
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -170,6 +170,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+bool CommandInterpreter::GetOpenTranscriptInEditor() const {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
+  const uint32_t idx = ePropertyOpenTranscriptInEditor;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
+}
+
 FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
   const uint32_t idx = ePrope