[Lldb-commits] [PATCH] D135031: [lldb] [llgs] Move client-server communication into a separate thread (WIP)

2022-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D135031#3833661 , @labath wrote:

> I think we should get some measurements (e.g. from the `process plugin packet 
> speed-test` cmd) of the overhead of this approach. The latency/RTT of the 
> connection is very important for some users, and I fear that all of this ping 
> pong could significantly regress that.

Hmm, it seems that I'm seeing half the speed of the original. Not sure how much 
of a deal that is.

Before:

  Testing sending 1000 packets of various sizes:
  qSpeedTest(send=  0, recv=  0) in 0,032515690 s for  30754,38 
packets/s (0,032515 ms per packet) with standard deviation of 0,002605 ms
  qSpeedTest(send=  0, recv=  4) in 0,034152463 s for  29280,46 
packets/s (0,034152 ms per packet) with standard deviation of 0,002709 ms
  qSpeedTest(send=  0, recv=  8) in 0,036265273 s for  27574,59 
packets/s (0,036265 ms per packet) with standard deviation of 0,001512 ms
  qSpeedTest(send=  0, recv= 16) in 0,023616176 s for  42343,86 
packets/s (0,023616 ms per packet) with standard deviation of 0,008221 ms
  qSpeedTest(send=  0, recv= 32) in 0,019671151 s for  50835,86 
packets/s (0,019671 ms per packet) with standard deviation of 0,000691 ms
  qSpeedTest(send=  0, recv= 64) in 0,019893631 s for  50267,34 
packets/s (0,019893 ms per packet) with standard deviation of 0,000811 ms
  qSpeedTest(send=  0, recv=128) in 0,020450350 s for  48898,92 
packets/s (0,020450 ms per packet) with standard deviation of 0,001330 ms
  qSpeedTest(send=  0, recv=256) in 0,021703819 s for  46074,84 
packets/s (0,021703 ms per packet) with standard deviation of 0,001262 ms
  qSpeedTest(send=  0, recv=512) in 0,023610808 s for  42353,48 
packets/s (0,023610 ms per packet) with standard deviation of 0,001446 ms
  qSpeedTest(send=  0, recv=   1024) in 0,027390972 s for  36508,38 
packets/s (0,027390 ms per packet) with standard deviation of 0,002319 ms
  qSpeedTest(send=  4, recv=  0) in 0,018693436 s for  53494,71 
packets/s (0,018693 ms per packet) with standard deviation of 0,001463 ms
  qSpeedTest(send=  4, recv=  4) in 0,018819677 s for  53135,88 
packets/s (0,018819 ms per packet) with standard deviation of 0,001217 ms
  qSpeedTest(send=  4, recv=  8) in 0,020369085 s for  49094,01 
packets/s (0,020369 ms per packet) with standard deviation of 0,001513 ms
  qSpeedTest(send=  4, recv= 16) in 0,020784404 s for  48113,00 
packets/s (0,020784 ms per packet) with standard deviation of 0,002064 ms
  qSpeedTest(send=  4, recv= 32) in 0,020945720 s for  47742,45 
packets/s (0,020945 ms per packet) with standard deviation of 0,002698 ms
  qSpeedTest(send=  4, recv= 64) in 0,023253340 s for  43004,57 
packets/s (0,023253 ms per packet) with standard deviation of 0,002361 ms
  qSpeedTest(send=  4, recv=128) in 0,022991221 s for  43494,86 
packets/s (0,022991 ms per packet) with standard deviation of 0,002397 ms
  qSpeedTest(send=  4, recv=256) in 0,024546532 s for  40738,95 
packets/s (0,024546 ms per packet) with standard deviation of 0,001291 ms
  qSpeedTest(send=  4, recv=512) in 0,026892496 s for  37185,09 
packets/s (0,026892 ms per packet) with standard deviation of 0,001912 ms
  qSpeedTest(send=  4, recv=   1024) in 0,031360906 s for  31886,83 
packets/s (0,031360 ms per packet) with standard deviation of 0,003003 ms
  qSpeedTest(send=  8, recv=  0) in 0,020722076 s for  48257,71 
packets/s (0,020722 ms per packet) with standard deviation of 0,002566 ms
  qSpeedTest(send=  8, recv=  4) in 0,022102837 s for  45243,06 
packets/s (0,022102 ms per packet) with standard deviation of 0,001933 ms
  qSpeedTest(send=  8, recv=  8) in 0,021921420 s for  45617,48 
packets/s (0,021921 ms per packet) with standard deviation of 0,001025 ms
  qSpeedTest(send=  8, recv= 16) in 0,019039322 s for  52522,88 
packets/s (0,019039 ms per packet) with standard deviation of 0,002766 ms
  qSpeedTest(send=  8, recv= 32) in 0,019113524 s for  52318,98 
packets/s (0,019113 ms per packet) with standard deviation of 0,003287 ms
  qSpeedTest(send=  8, recv= 64) in 0,018969281 s for  52716,81 
packets/s (0,018969 ms per packet) with standard deviation of 0,000611 ms
  qSpeedTest(send=  8, recv=128) in 0,019544501 s for  51165,29 
packets/s (0,019544 ms per packet) with standard deviation of 0,000706 ms
  qSpeedTest(send=  8, recv=256) in 0,020592488 s for  48561,40 
packets/s (0,020592 ms per packet) with standard deviation of 0,000887 ms
  qSpeedTest(send=  8, recv=512) in 0,022484412 s for  44475,26 
packets/s (0,022484 ms per packet) with standard deviation of 0,000715 ms
  qSpeedTest(send=  8, recv=   1024) in 0,023713522 s for  42170,04 
packets/s (0,023713 ms per packet) with standard deviation of 0,003766 ms
  qSpeedTest(send= 16, recv=  0) in 0

[Lldb-commits] [lldb] 3c2275a - [LLDB] Add missing space in help for frame-format-unique setting

2022-10-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-10-07T08:42:35Z
New Revision: 3c2275a6073cdab5ae883104527b974ec9c9fa6d

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

LOG: [LLDB] Add missing space in help for frame-format-unique setting

Added: 


Modified: 
lldb/source/Core/CoreProperties.td

Removed: 




diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index f3d6855fd8065..b8b2a881160a0 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -178,7 +178,7 @@ let Definition = "debugger" in {
   def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
 Global,
 DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
-Desc<"The default frame format string to use when displaying stack 
frameinformation for threads from thread backtrace unique.">;
+Desc<"The default frame format string to use when displaying stack frame 
information for threads from thread backtrace unique.">;
   def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
 Global,
 DefaultFalse,



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


[Lldb-commits] [lldb] 02c1c93 - [LLDB] Fix printing a static bool struct member when using "image lookup -t"

2022-10-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-10-07T09:02:59Z
New Revision: 02c1c939486f247dc80866477eaab193c634d1e2

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

LOG: [LLDB] Fix printing a static bool struct member when using "image lookup 
-t"

Fixes #58135

Somehow lldb was able to print the member on its own but when we try
to print the whole type found by "image lookup -t" lldb would crash.

This is because we'd encoded the initial value of the member as an integer.
Which isn't the end of the world because bool is integral for C++.
However, clang has a special AST node to handle literal bool and it
expected us to use that instead.

This adds a new codepath to handle static bool which uses cxxBoolLiteralExpr
and we get the member printed as you'd expect.

For testing I added a struct with just the bool because trying to print
all of "A" crashes as well. Presumably because one of the other member's
types isn't handled properly either.

So for now I just added the bool case, we can merge it with A later.

Reviewed By: aeubanks

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

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index aefd19d0a8595..f0443fceb28d0 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -121,6 +121,8 @@ class CompilerType {
 
   bool IsIntegerOrEnumerationType(bool &is_signed) const;
 
+  bool IsBooleanType() const;
+
   bool IsPolymorphicClass() const;
 
   /// \param target_typeCan pass nullptr.

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 57bdfa5b626ab..63f9495ad916d 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -178,6 +178,8 @@ class TypeSystem : public PluginInterface {
 return false;
   }
 
+  virtual bool IsBooleanType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0;
 
   virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 25f2a37cbab5d..988dc0236652a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2720,6 +2720,7 @@ void DWARFASTParserClang::ParseSingleMember(
   // TODO: Support float/double static members as well.
   if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
 return;
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
@@ -2728,7 +2729,13 @@ void DWARFASTParserClang::ParseSingleMember(
v->getQualifiedNameAsString());
 return;
   }
-  TypeSystemClang::SetIntegerInitializerForVariable(v, 
*const_value_or_err);
+
+  if (ct.IsBooleanType())
+TypeSystemClang::SetBoolInitializerForVariable(
+v, !const_value_or_err->isZero());
+  else
+TypeSystemClang::SetIntegerInitializerForVariable(v,
+  *const_value_or_err);
 }
 return;
   }

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4adf653b6c508..b2779d6dd10aa 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3224,6 +3224,20 @@ bool 
TypeSystemClang::IsIntegerType(lldb::opaque_compiler_type_t type,
   return false;
 }
 
+bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
+  if (!type)
+return false;
+
+  clang::QualType qual_type(GetCanonicalQualType(type));
+  const clang::BuiltinType *builtin_type =
+  
llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
+
+  if (!builtin_type)
+return false;
+
+  return builtin_type->isBooleanType();
+}
+
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool &is_signed) {
   if (type) {
@@ -7574,6 +

[Lldb-commits] [PATCH] D135169: [LLDB] Fix printing a static bool struct member when using "image lookup -t"

2022-10-07 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02c1c939486f: [LLDB] Fix printing a static bool struct 
member when using "image lookup -t" (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135169

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,8 +79,13 @@
   ScopedEnum::scoped_enum_case1;
 };
 
+struct StaticBoolStruct {
+  static const bool value = false;
+};
+
 int main() {
   A a;
+  StaticBoolStruct sbs;
 
   auto char_max = A::char_max;
   auto uchar_max = A::uchar_max;
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,6 +32,11 @@
 # Test a bool member.
 self.expect_expr("A::bool_val", result_value="true")
 
+# Test a bool member when printing the struct it is a member of.
+# TODO: replace this with printing struct A, once doing so doesn't crash lldb.
+self.expect("image lookup -t StaticBoolStruct",
+substrs=["static const bool value = false;"])
+
 # Test that minimum and maximum values for each data type are right.
 self.expect_expr("A::char_max == char_max", result_value="true")
 self.expect_expr("A::uchar_max == uchar_max", result_value="true")
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -154,6 +154,12 @@
   return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
 }
 
+bool CompilerType::IsBooleanType() const {
+  if (IsValid())
+return m_type_system->IsBooleanType(m_type);
+  return false;
+}
+
 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
   if (IsValid()) {
 return m_type_system->IsPointerType(m_type, pointee_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -592,6 +592,8 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
+  bool IsBooleanType(lldb::opaque_compiler_type_t type) override;
+
   bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
 
   static bool IsObjCClassType(const CompilerType &type);
@@ -860,6 +862,8 @@
   static void SetIntegerInitializerForVariable(clang::VarDecl *var,
const llvm::APInt &init_value);
 
+  static void SetBoolInitializerForVariable(clang::VarDecl *var, bool value);
+
   /// Initializes a variable with a floating point value.
   /// \param var The variable to initialize. Must not already have an
   ///initializer and must have a floating point type.
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3224,6 +3224,20 @@
   return false;
 }
 
+bool TypeSystemClang::IsBooleanType(lldb::opaque_compiler_type_t type) {
+  if (!type)
+return false;
+
+  clang::QualType qual_type(GetCanonicalQualType(type));
+  const clang::BuiltinType *builtin_type =
+  llvm::dyn_cast(qual_type->getCanonicalTypeInternal());
+
+  if (!builtin_type)
+return false;
+
+  return builtin_type->isBooleanType();
+}
+
 bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 bool &is_signed) {
   if (type) {
@@ -7574,6 +7588,18 @@
   return var_decl;
 }
 
+void TypeSystemClang::SetBoolInitializerForVariable(VarDecl *var, bool value) {
+  assert(!var->hasInit() && "variable already initialized");
+
+  QualType qt = var->getType();
+  assert(qt->isSpecificBuiltinType(BuiltinType::Bool

[Lldb-commits] [PATCH] D135170: [LLDB] Fix crash when printing a struct with a static signed char member

2022-10-07 Thread David Spickett 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 rG5a9e21305803: [LLDB] Fix crash when printing a struct with a 
static signed char member (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135170

Files:
  clang/lib/AST/StmtPrinter.cpp
  
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,13 +79,8 @@
   ScopedEnum::scoped_enum_case1;
 };
 
-struct StaticBoolStruct {
-  static const bool value = false;
-};
-
 int main() {
   A a;
-  StaticBoolStruct sbs;
 
   auto char_max = A::char_max;
   auto uchar_max = A::uchar_max;
Index: 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,11 +32,6 @@
 # Test a bool member.
 self.expect_expr("A::bool_val", result_value="true")
 
-# Test a bool member when printing the struct it is a member of.
-# TODO: replace this with printing struct A, once doing so doesn't 
crash lldb.
-self.expect("image lookup -t StaticBoolStruct",
-substrs=["static const bool value = false;"])
-
 # Test that minimum and maximum values for each data type are right.
 self.expect_expr("A::char_max == char_max", result_value="true")
 self.expect_expr("A::uchar_max == uchar_max", result_value="true")
@@ -88,6 +83,10 @@
 self.expect_expr("const int *i = &A::int_val_with_address; *i",
  result_value="2")
 
+# Printing the whole type takes a slightly different code path. Check 
that
+# it does not crash.
+self.expect("image lookup -t A")
+
 # dsymutil strips the debug info for classes that only have const static
 # data members without a definition namespace scope.
 @expectedFailureAll(debug_info=["dsym"])
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1280,6 +1280,7 @@
   case BuiltinType::Char_S:
   case BuiltinType::Char_U:OS << "i8"; break;
   case BuiltinType::UChar: OS << "Ui8"; break;
+  case BuiltinType::SChar: OS << "i8"; break;
   case BuiltinType::Short: OS << "i16"; break;
   case BuiltinType::UShort:OS << "Ui16"; break;
   case BuiltinType::Int:   break; // no suffix.


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,13 +79,8 @@
   ScopedEnum::scoped_enum_case1;
 };
 
-struct StaticBoolStruct {
-  static const bool value = false;
-};
-
 int main() {
   A a;
-  StaticBoolStruct sbs;
 
   auto char_max = A::char_max;
   auto uchar_max = A::uchar_max;
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
===
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,11 +32,6 @@
 # Test a bool member.
 self.expect_expr("A::bool_val", result_value="true")
 
-# Test a bool member when printing the struct it is a member of.
-# TODO: replace this with printing struct A, once doing so doesn't crash lldb.
-self.expect("image lookup -t StaticBoolStruct",
-substrs=["static const bool value = false;"])
-
 # Test that minimum and maximum values for each data type are right.
 self.expect_expr("A::char_max == char_max", result_value="true")
 self.expect_expr("A::uchar_max == uchar_max", result_value="true")
@@ -88,6 +83,10 @@
 self.expect_expr("const int *i = &A::int_val_with_address; *i",
  result_value="2")
 
+# Printing the whole type takes a slightly different code path. Check that
+# it does not crash.
+self.expect("image lookup -t A")
+
 # dsymutil strips the debug info for classes that only have const static
 # data members without a definition na

[Lldb-commits] [lldb] 5a9e213 - [LLDB] Fix crash when printing a struct with a static signed char member

2022-10-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-10-07T09:11:15Z
New Revision: 5a9e21305803336dc359f72014849845b1a7e173

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

LOG: [LLDB] Fix crash when printing a struct with a static signed char member

As with static bool for whatever reason printing them on their own
worked fine but wasn't handled when you printed the whole type.

I don't see a good way to test this from clang's side so our existing
tests will have to do.

We can now print all of the struct "A", so there's no need for a separate
one for static bool testing. I've not checked the output, just that it
succeeds. This saves us having to handle different min/max between systems.

Depends on D135169

Reviewed By: aeubanks, shafik

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

Added: 


Modified: 
clang/lib/AST/StmtPrinter.cpp

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Removed: 




diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 03b71a7ec9416..fabffbd323648 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1280,6 +1280,7 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral 
*Node) {
   case BuiltinType::Char_S:
   case BuiltinType::Char_U:OS << "i8"; break;
   case BuiltinType::UChar: OS << "Ui8"; break;
+  case BuiltinType::SChar: OS << "i8"; break;
   case BuiltinType::Short: OS << "i16"; break;
   case BuiltinType::UShort:OS << "Ui16"; break;
   case BuiltinType::Int:   break; // no suffix.

diff  --git 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index 0482007d48147..5252247191383 100644
--- 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,11 +32,6 @@ def test(self):
 # Test a bool member.
 self.expect_expr("A::bool_val", result_value="true")
 
-# Test a bool member when printing the struct it is a member of.
-# TODO: replace this with printing struct A, once doing so doesn't 
crash lldb.
-self.expect("image lookup -t StaticBoolStruct",
-substrs=["static const bool value = false;"])
-
 # Test that minimum and maximum values for each data type are right.
 self.expect_expr("A::char_max == char_max", result_value="true")
 self.expect_expr("A::uchar_max == uchar_max", result_value="true")
@@ -88,6 +83,10 @@ def test(self):
 self.expect_expr("const int *i = &A::int_val_with_address; *i",
  result_value="2")
 
+# Printing the whole type takes a slightly 
diff erent code path. Check that
+# it does not crash.
+self.expect("image lookup -t A")
+
 # dsymutil strips the debug info for classes that only have const static
 # data members without a definition namespace scope.
 @expectedFailureAll(debug_info=["dsym"])

diff  --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp 
b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
index d078076b99dc8..977e12295760a 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,13 +79,8 @@ struct ClassWithEnumAlias {
   ScopedEnum::scoped_enum_case1;
 };
 
-struct StaticBoolStruct {
-  static const bool value = false;
-};
-
 int main() {
   A a;
-  StaticBoolStruct sbs;
 
   auto char_max = A::char_max;
   auto uchar_max = A::uchar_max;



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


[Lldb-commits] [PATCH] D134873: [LLDB] Add "frame select" as equivalent of GDB's "frame" command

2022-10-07 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68ab7accc72b: [LLDB] Add "frame select" as 
equivalent of GDB's "frame" command (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134873

Files:
  lldb/docs/use/map.rst


Index: lldb/docs/use/map.rst
===
--- lldb/docs/use/map.rst
+++ lldb/docs/use/map.rst
@@ -410,6 +410,20 @@

  
 
+ 
+   Show the current frame and 
source line.
+ 
+ 
+   
+  (gdb) frame
+   
+   
+  (lldb) frame select
+  (lldb) f
+  (lldb) process status
+   
+ 
+
   

 


Index: lldb/docs/use/map.rst
===
--- lldb/docs/use/map.rst
+++ lldb/docs/use/map.rst
@@ -410,6 +410,20 @@

  
 
+ 
+   Show the current frame and source line.
+ 
+ 
+   
+  (gdb) frame
+   
+   
+  (lldb) frame select
+  (lldb) f
+  (lldb) process status
+   
+ 
+
   

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


[Lldb-commits] [lldb] 68ab7ac - [LLDB] Add "frame select" as equivalent of GDB's "frame" command

2022-10-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-10-07T09:30:05Z
New Revision: 68ab7accc72bffe4d27a1b2ee50105c7ffda54cf

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

LOG: [LLDB] Add "frame select" as equivalent of GDB's "frame" command

This is useful for answering the question "where am I?" and is surprisingly
difficult to figure out without just doing another step command.

Reviewed By: awarzynski

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

Added: 


Modified: 
lldb/docs/use/map.rst

Removed: 




diff  --git a/lldb/docs/use/map.rst b/lldb/docs/use/map.rst
index 569649a0b2a59..0447b24a88aed 100644
--- a/lldb/docs/use/map.rst
+++ b/lldb/docs/use/map.rst
@@ -410,6 +410,20 @@ Execution Commands

  
 
+ 
+   Show the current frame and 
source line.
+ 
+ 
+   
+  (gdb) frame
+   
+   
+  (lldb) frame select
+  (lldb) f
+  (lldb) process status
+   
+ 
+
   

 



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


[Lldb-commits] [PATCH] D132734: [lldb] Fix member access in GetExpressionPath

2022-10-07 Thread Tonko Sabolčec via Phabricator via lldb-commits
tonkosi updated this revision to Diff 466043.
tonkosi edited the summary of this revision.
tonkosi added a comment.

Fixed the issue of printing unnecessary parenthesis, which broke API tests on 
macOS.

Improved use of parenthesis to produce outputs such as `(*ptr).member` instead 
of `(*(ptr)).member`.


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

https://reviews.llvm.org/D132734

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
  lldb/test/API/python_api/expression_path/Makefile
  lldb/test/API/python_api/expression_path/TestExpressionPath.py
  lldb/test/API/python_api/expression_path/main.cpp

Index: lldb/test/API/python_api/expression_path/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/expression_path/main.cpp
@@ -0,0 +1,34 @@
+struct StructA {
+  int x;
+  int y;
+};
+
+struct StructB {
+  int x;
+  StructA &a_ref;
+  StructA *&a_ptr_ref;
+};
+
+struct StructC : public StructB {
+  int y;
+
+  StructC(int x, StructA &a_ref, StructA *&a_ref_ptr, int y)
+  : StructB{x, a_ref, a_ref_ptr}, y(y) {}
+};
+
+int main() {
+  StructA a{1, 2};
+  StructA *a_ptr = &a;
+
+  StructB b{3, a, a_ptr};
+  StructB *b_ptr = &b;
+  StructB &b_ref = b;
+  StructB *&b_ptr_ref = b_ptr;
+
+  StructC c(4, a, a_ptr, 5);
+  StructC *c_ptr = &c;
+  StructC &c_ref = c;
+  StructC *&c_ptr_ref = c_ptr;
+
+  return 0; // Set breakpoint here
+}
\ No newline at end of file
Index: lldb/test/API/python_api/expression_path/TestExpressionPath.py
===
--- /dev/null
+++ lldb/test/API/python_api/expression_path/TestExpressionPath.py
@@ -0,0 +1,119 @@
+"""Test that SBFrame::GetExpressionPath construct valid expressions"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class SBValueGetExpressionPathTest(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def path(self, value):
+"""Constructs the expression path given the SBValue"""
+if not value:
+return None
+stream = lldb.SBStream()
+if not value.GetExpressionPath(stream):
+return None
+return stream.GetData()
+
+def test_expression_path(self):
+"""Test that SBFrame::GetExpressionPath construct valid expressions"""
+self.build()
+self.setTearDownCleanup()
+
+exe = self.getBuildArtifact("a.out")
+
+# Create the target
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Set the breakpoints
+breakpoint = target.BreakpointCreateBySourceRegex(
+'Set breakpoint here', lldb.SBFileSpec("main.cpp"))
+self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
+
+# Launch the process, and do not stop at the entry point.
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Frame #0 should be at our breakpoint.
+threads = lldbutil.get_threads_stopped_at_breakpoint(
+process, breakpoint)
+
+self.assertEquals(len(threads), 1)
+self.thread = threads[0]
+self.frame = self.thread.frames[0]
+self.assertTrue(self.frame, "Frame 0 is valid.")
+
+# Find "b" variables in frame
+b = self.frame.FindVariable("b")
+bp = self.frame.FindVariable("b_ptr")
+br = self.frame.FindVariable("b_ref")
+bpr = self.frame.FindVariable("b_ptr_ref")
+# Check expression paths
+self.assertEqual(self.path(b), "b")
+self.assertEqual(self.path(bp), "b_ptr")
+self.assertEqual(self.path(br), "b_ref")
+self.assertEqual(self.path(bpr), "b_ptr_ref")
+
+# Dereference "b" pointers
+bp_deref = bp.Dereference()
+bpr_deref = bpr.Dereference()  # a pointer
+bpr_deref2 = bpr_deref.Dereference()  # two Dereference() calls to get object
+# Check expression paths
+self.assertEqual(self.path(bp_deref), "*b_ptr")
+self.assertEqual(self.path(bpr_deref), "b_ptr_ref")
+self.assertEqual(self.path(bpr_deref2), "*b_ptr_ref")
+
+# Access "b" members and check expression paths
+self.assertEqual(self.path(b.GetChildMemberWithName("x")), "b.x")
+self.assertEqual(self.path(bp.GetChildMemberWithName("x")), "b_ptr->x")
+self.assertEqual(self.path(br.GetChildMemberWithName("x")), "b_ref.x")
+self.assertEqual(self.path(bp_deref.GetChildMemberWithName("x")), "(*b_ptr).x")
+self.assertEqual(self.path(bpr_deref.GetChildMemberWithName("x")), "b_ptr_ref->x")
+self.assertEqual(self.path(bpr_deref2.GetChildMemberWithNa

[Lldb-commits] [PATCH] D132734: [lldb] Fix member access in GetExpressionPath

2022-10-07 Thread Tonko Sabolčec via Phabricator via lldb-commits
tonkosi added a comment.

Hi, I fixed the issue causing macOS tests to fail, but I don't have a macOS 
machine to verify it actually works. I'd be grateful if someone could check 
that part.

I also decided to further reduce number of parenthesis in output (e.g. 
`(*(ptr)).member` isn't ideal), but now I realize that the previous `*(a.b.c)` 
might be more clear than `*a.b.c`. Let me know if I should revert that part.


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

https://reviews.llvm.org/D132734

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


[Lldb-commits] [PATCH] D135461: [LLDB] Fix crash when printing a struct with a static wchar_t member

2022-10-07 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
aeubanks added a reviewer: DavidSpickett.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Similar to D135170 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135461

Files:
  clang/lib/AST/StmtPrinter.cpp
  lldb/test/API/lang/cpp/const_static_integral_member/main.cpp


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -35,6 +35,7 @@
   const static auto longlong_max = std::numeric_limits::max();
   const static auto ulonglong_max =
   std::numeric_limits::max();
+  const static auto wchar_max = std::numeric_limits::max();
 
   const static auto char_min = std::numeric_limits::min();
   const static auto uchar_min = std::numeric_limits::min();
@@ -45,6 +46,7 @@
   const static auto longlong_min = std::numeric_limits::min();
   const static auto ulonglong_min =
   std::numeric_limits::min();
+  const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1293,6 +1293,9 @@
 break; // no suffix.
   case BuiltinType::UInt128:
 break; // no suffix.
+  case BuiltinType::WChar_S:
+  case BuiltinType::WChar_U:
+break; // no suffix.
   }
 }
 


Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
===
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -35,6 +35,7 @@
   const static auto longlong_max = std::numeric_limits::max();
   const static auto ulonglong_max =
   std::numeric_limits::max();
+  const static auto wchar_max = std::numeric_limits::max();
 
   const static auto char_min = std::numeric_limits::min();
   const static auto uchar_min = std::numeric_limits::min();
@@ -45,6 +46,7 @@
   const static auto longlong_min = std::numeric_limits::min();
   const static auto ulonglong_min =
   std::numeric_limits::min();
+  const static auto wchar_min = std::numeric_limits::min();
 
   const static Enum enum_val = enum_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1293,6 +1293,9 @@
 break; // no suffix.
   case BuiltinType::UInt128:
 break; // no suffix.
+  case BuiltinType::WChar_S:
+  case BuiltinType::WChar_U:
+break; // no suffix.
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2022-10-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, kastiglione.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

`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

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135482

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -655,6 +655,7 @@
   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/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -655,6 +655,7 @@
   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] [PATCH] D135482: [lldb/crashlog] Fix the image_regex_uuid to skip null UUID images

2022-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Can we add a test for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135482

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


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

2022-10-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 466213.
mib added a comment.

- Add test
- Remove extra line


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
@@ -654,7 +654,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
@@ -654,7 +654,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] [PATCH] D135482: [lldb/crashlog] Fix the image_regex_uuid to skip null UUID images

2022-10-07 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.
This revision is now accepted and ready to land.

lgtm now


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

https://reviews.llvm.org/D135482

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