[Lldb-commits] [lldb] fcf4e25 - [LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer

2022-07-22 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-07-22T08:02:07+01:00
New Revision: fcf4e252f4d992cade4bdfe5aed10ff96fa40202

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

LOG: [LLDB][NFC] Create variable for hardcoded alignment/size constants in 
materializer

Added: 


Modified: 
lldb/source/Expression/Materializer.cpp

Removed: 




diff  --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index 965a96b7f909d..8c7e74b6e51e5 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -27,6 +27,14 @@
 
 using namespace lldb_private;
 
+// FIXME: these should be retrieved from the target
+//instead of being hard-coded. Currently we
+//assume that persistent vars are materialized
+//as references, and thus pick the size of a
+//64-bit pointer.
+static constexpr uint32_t g_default_var_alignment = 8;
+static constexpr uint32_t g_default_var_byte_size = 8;
+
 uint32_t Materializer::AddStructMember(Entity &entity) {
   uint32_t size = entity.GetSize();
   uint32_t alignment = entity.GetAlignment();
@@ -54,8 +62,8 @@ class EntityPersistentVariable : public Materializer::Entity {
 m_delegate(delegate) {
 // Hard-coding to maximum size of a pointer since persistent variables are
 // materialized by reference
-m_size = 8;
-m_alignment = 8;
+m_size = g_default_var_byte_size;
+m_alignment = g_default_var_alignment;
   }
 
   void MakeAllocation(IRMemoryMap &map, Status &err) {
@@ -418,8 +426,8 @@ class EntityVariable : public Materializer::Entity {
   : Entity(), m_variable_sp(variable_sp) {
 // Hard-coding to maximum size of a pointer since all variables are
 // materialized by reference
-m_size = 8;
-m_alignment = 8;
+m_size = g_default_var_byte_size;
+m_alignment = g_default_var_alignment;
 m_is_reference =
 m_variable_sp->GetType()->GetForwardCompilerType().IsReferenceType();
   }
@@ -772,8 +780,8 @@ class EntityResultVariable : public Materializer::Entity {
 m_keep_in_memory(keep_in_memory), m_delegate(delegate) {
 // Hard-coding to maximum size of a pointer since all results are
 // materialized by reference
-m_size = 8;
-m_alignment = 8;
+m_size = g_default_var_byte_size;
+m_alignment = g_default_var_alignment;
   }
 
   void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
@@ -1050,8 +1058,8 @@ class EntitySymbol : public Materializer::Entity {
 public:
   EntitySymbol(const Symbol &symbol) : Entity(), m_symbol(symbol) {
 // Hard-coding to maximum size of a symbol
-m_size = 8;
-m_alignment = 8;
+m_size = g_default_var_byte_size;
+m_alignment = g_default_var_alignment;
   }
 
   void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,



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


[Lldb-commits] [lldb] 317c8bf - [LLDB][Expression] Allow instantiation of IR Entity from ValueObject

2022-07-22 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-07-22T08:02:08+01:00
New Revision: 317c8bf84d185c6b4a51a415c0deb7f8af661cb6

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

LOG: [LLDB][Expression] Allow instantiation of IR Entity from ValueObject

This is required in preparation for the follow-up patch which adds
support for evaluating expressions from within C++ lambdas. In such
cases we need to materialize variables which are not part of the
current frame but instead are ivars on a 'this' pointer of the current
frame.

Added: 

lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/Makefile

lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/TestBreakOnLambdaCapture.py

lldb/test/API/functionalities/breakpoint/breakpoint_on_lambda_capture/main.cpp

Modified: 
lldb/include/lldb/Expression/Materializer.h
lldb/include/lldb/lldb-private-types.h
lldb/source/Expression/Materializer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Expression/Materializer.h 
b/lldb/include/lldb/Expression/Materializer.h
index 25cf22a8b5b0b..aae94f86a71e6 100644
--- a/lldb/include/lldb/Expression/Materializer.h
+++ b/lldb/include/lldb/Expression/Materializer.h
@@ -78,6 +78,28 @@ class Materializer {
   AddPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp,
 PersistentVariableDelegate *delegate, Status &err);
   uint32_t AddVariable(lldb::VariableSP &variable_sp, Status &err);
+
+  /// Create entity from supplied ValueObject and count it as a member
+  /// of the materialized struct.
+  ///
+  /// Behaviour is undefined if 'valobj_provider' is empty.
+  ///
+  /// \param[in] name Name of variable to materialize
+  ///
+  /// \param[in] valobj_provider When materializing values multiple
+  ///times, this callback gets used to fetch a fresh
+  ///ValueObject corresponding to the supplied frame.
+  ///This is mainly used for conditional breakpoints
+  ///that re-apply an expression whatever the frame
+  ///happens to be when the breakpoint got hit.
+  ///
+  /// \param[out] err Error status that gets set on error.
+  ///
+  /// \returns Offset in bytes of the member we just added to the
+  ///  materialized struct.
+  uint32_t AddValueObject(ConstString name,
+  ValueObjectProviderTy valobj_provider, Status &err);
+
   uint32_t AddResultVariable(const CompilerType &type, bool is_lvalue,
  bool keep_in_memory,
  PersistentVariableDelegate *delegate, Status 
&err);

diff  --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index 3be7003cd0fb2..1b0d263e2073b 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -106,6 +106,12 @@ struct OptionValidator {
 typedef struct type128 { uint64_t x[2]; } type128;
 typedef struct type256 { uint64_t x[4]; } type256;
 
+/// Functor that returns a ValueObjectSP for a variable given its name
+/// and the StackFrame of interest. Used primarily in the Materializer
+/// to refetch a ValueObject when the ExecutionContextScope changes.
+using ValueObjectProviderTy =
+std::function;
+
 } // namespace lldb_private
 
 #endif // #if defined(__cplusplus)

diff  --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index 8c7e74b6e51e5..946ae10d69c28 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -22,6 +22,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
+#include "lldb/lldb-forward.h"
 
 #include 
 
@@ -420,16 +421,19 @@ uint32_t Materializer::AddPersistentVariable(
   return ret;
 }
 
-class EntityVariable : public Materializer::Entity {
+/// Base class for materialization of Variables and ValueObjects.
+///
+/// Subclasses specify how to obtain the Value which is to be
+/// materialized.
+class EntityVariableBase : public Materializer::Entity {
 public:
-  EntityVariable(lldb::VariableSP &variable_sp)
-  : Entity(), m_variable_sp(variable_sp) {
+  virtual ~EntityVariableBase() = default;
+
+  EntityVariableBase() {
 // Hard-coding to maximum size of a pointer since all variables are
 // materialized by reference
 m_size = g_default_var_byte_size;
 m_alignment = g_default_var_alignment;
-m_is_reference =
-m_variable_sp->GetType()->GetForwardCompilerType().IsReferenceType();
   }
 
   void Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
@@ -441,7 +445,7 @@ class EntityVariable : public Materializer::Entity {
   LLDB_LOGF(log,
 "EntityVariable::Materialize [ad

[Lldb-commits] [lldb] 8184b25 - [LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas

2022-07-22 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-07-22T08:02:09+01:00
New Revision: 8184b252cdab2fbe44f766d6de28b29ebe4c8753

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

LOG: [LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas

This patch adds support for evaluating expressions which reference
a captured `this` from within the context of a C++ lambda expression.
Currently LLDB doesn't provide Clang with enough information to
determine that we're inside a lambda expression and are allowed to
access variables on a captured `this`; instead Clang simply fails
to parse the expression.

There are two problems to solve here:
1. Make sure `clang::Sema` doesn't reject the expression due to an
illegal member access.
2. Materialize all the captured variables/member variables required
to evaluate the expression.

To address (1), we currently import the outer structure's AST context
onto `$__lldb_class`, making the `contextClass` and the `NamingClass`
match, a requirement by `clang::Sema::BuildPossibleImplicitMemberExpr`.

To address (2), we inject all captured variables as locals into the
expression source code.

**Testing**

* Added API test

Added: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.h
lldb/test/API/commands/expression/expr_inside_lambda/Makefile

lldb/test/API/commands/expression/expr_inside_lambda/TestExprInsideLambdas.py
lldb/test/API/commands/expression/expr_inside_lambda/main.cpp

Modified: 
lldb/include/lldb/Expression/UserExpression.h
lldb/source/Expression/UserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 3874a60e06f09..2d62fa37a24c2 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -280,6 +280,23 @@ class UserExpression : public Expression {
   static lldb::addr_t GetObjectPointer(lldb::StackFrameSP frame_sp,
ConstString &object_name, Status &err);
 
+  /// Return ValueObject for a given variable name in the current stack frame
+  ///
+  /// \param[in] frame Current stack frame. When passed a 'nullptr', this
+  ///  function returns an empty ValueObjectSP.
+  ///
+  /// \param[in] object_name Name of the variable in the current stack frame
+  ///for which we want the ValueObjectSP.
+  ///
+  /// \param[out] err Status object which will get set on error.
+  ///
+  /// \returns On success returns a ValueObjectSP corresponding to the variable
+  ///  with 'object_name' in the current 'frame'. Otherwise, returns
+  ///  'nullptr' (and sets the error status parameter 'err').
+  static lldb::ValueObjectSP
+  GetObjectPointerValueObject(lldb::StackFrameSP frame,
+  ConstString const &object_name, Status &err);
+
   /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the
   /// environment.
 

diff  --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index f821603f03e56..186e414e68793 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -98,28 +98,34 @@ bool UserExpression::MatchesContext(ExecutionContext 
&exe_ctx) {
   return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp);
 }
 
-lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,
-  ConstString &object_name,
-  Status &err) {
+lldb::ValueObjectSP UserExpression::GetObjectPointerValueObject(
+lldb::StackFrameSP frame_sp, ConstString const &object_name, Status &err) {
   err.Clear();
 
   if (!frame_sp) {
 err.SetErrorStringWithFormat(
 "Couldn't load '%s' because the context is incomplete",
 object_name.AsCString());
-return LLDB_INVALID_ADDRESS;
+return {};
   }
 
   lldb::VariableSP var_sp;
   lldb::ValueObjectSP valobj_sp;
 
-  valobj_sp = frame_sp->GetValueForVariableExpressionPath(
+  return fra

[Lldb-commits] [PATCH] D128504: debugserver: spawn process in its own process group

2022-07-22 Thread Alessandro Arzilli via Phabricator via lldb-commits
aarzilli added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128504

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


[Lldb-commits] [lldb] 5c39c31 - [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra

2022-07-22 Thread Andy Yankovsky via lldb-commits

Author: Andy Yankovsky
Date: 2022-07-22T09:22:40Z
New Revision: 5c39c31a99525630dfe684fed48292a50fd0c3c9

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

LOG: [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra

DW_OP_skip/DW_OP_bra can move offset to the end of the data, which means that 
this was the last instruction to execute and the interpreter should terminate.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 9e6b21fc25ea3..25f6a46d805b7 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1655,11 +1655,16 @@ bool DWARFExpression::Evaluate(
 case DW_OP_skip: {
   int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
   lldb::offset_t new_offset = offset + skip_offset;
-  if (opcodes.ValidOffset(new_offset))
+  // New offset can point at the end of the data, in this case we should
+  // terminate the DWARF expression evaluation (will happen in the loop
+  // condition).
+  if (new_offset <= opcodes.GetByteSize())
 offset = new_offset;
   else {
 if (error_ptr)
-  error_ptr->SetErrorString("Invalid opcode offset in DW_OP_skip.");
+  error_ptr->SetErrorStringWithFormatv(
+  "Invalid opcode offset in DW_OP_skip: {0}+({1}) > {2}", offset,
+  skip_offset, opcodes.GetByteSize());
 return false;
   }
 } break;
@@ -1684,11 +1689,16 @@ bool DWARFExpression::Evaluate(
 Scalar zero(0);
 if (tmp.ResolveValue(exe_ctx) != zero) {
   lldb::offset_t new_offset = offset + bra_offset;
-  if (opcodes.ValidOffset(new_offset))
+  // New offset can point at the end of the data, in this case we 
should
+  // terminate the DWARF expression evaluation (will happen in the loop
+  // condition).
+  if (new_offset <= opcodes.GetByteSize())
 offset = new_offset;
   else {
 if (error_ptr)
-  error_ptr->SetErrorString("Invalid opcode offset in DW_OP_bra.");
+  error_ptr->SetErrorStringWithFormatv(
+  "Invalid opcode offset in DW_OP_bra: {0}+({1}) > {2}", 
offset,
+  bra_offset, opcodes.GetByteSize());
 return false;
   }
 }

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 5169e5f9a33ec..06f79186bad76 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -131,6 +131,25 @@ TEST(DWARFExpression, DW_OP_const) {
   llvm::HasValue(0x010101010101));
 }
 
+TEST(DWARFExpression, DW_OP_skip) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x42, DW_OP_skip, 0x02, 0x00,
+ DW_OP_const1u, 0xff}),
+   llvm::HasValue(0x42));
+}
+
+TEST(DWARFExpression, DW_OP_bra) {
+  EXPECT_THAT_EXPECTED(
+  // clang-format off
+  Evaluate({
+DW_OP_const1u, 0x42, // push 0x42
+DW_OP_const1u, 0x1,  // push 0x1
+DW_OP_bra, 0x02, 0x00,   // if 0x1 > 0, then skip 0x0002 opcodes
+DW_OP_const1u, 0xff, // push 0xff
+  }),
+  // clang-format on
+  llvm::HasValue(0x42));
+}
+
 TEST(DWARFExpression, DW_OP_convert) {
   /// Auxiliary debug info.
   const char *yamldata = R"(



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


[Lldb-commits] [PATCH] D130285: [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra

2022-07-22 Thread Andy Yankovsky via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c39c31a9952: [lldb] Handle jumping to the end in 
DW_OP_skip/DW_OP_bra (authored by werat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130285

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -131,6 +131,25 @@
   llvm::HasValue(0x010101010101));
 }
 
+TEST(DWARFExpression, DW_OP_skip) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x42, DW_OP_skip, 0x02, 0x00,
+ DW_OP_const1u, 0xff}),
+   llvm::HasValue(0x42));
+}
+
+TEST(DWARFExpression, DW_OP_bra) {
+  EXPECT_THAT_EXPECTED(
+  // clang-format off
+  Evaluate({
+DW_OP_const1u, 0x42, // push 0x42
+DW_OP_const1u, 0x1,  // push 0x1
+DW_OP_bra, 0x02, 0x00,   // if 0x1 > 0, then skip 0x0002 opcodes
+DW_OP_const1u, 0xff, // push 0xff
+  }),
+  // clang-format on
+  llvm::HasValue(0x42));
+}
+
 TEST(DWARFExpression, DW_OP_convert) {
   /// Auxiliary debug info.
   const char *yamldata = R"(
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1655,11 +1655,16 @@
 case DW_OP_skip: {
   int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
   lldb::offset_t new_offset = offset + skip_offset;
-  if (opcodes.ValidOffset(new_offset))
+  // New offset can point at the end of the data, in this case we should
+  // terminate the DWARF expression evaluation (will happen in the loop
+  // condition).
+  if (new_offset <= opcodes.GetByteSize())
 offset = new_offset;
   else {
 if (error_ptr)
-  error_ptr->SetErrorString("Invalid opcode offset in DW_OP_skip.");
+  error_ptr->SetErrorStringWithFormatv(
+  "Invalid opcode offset in DW_OP_skip: {0}+({1}) > {2}", offset,
+  skip_offset, opcodes.GetByteSize());
 return false;
   }
 } break;
@@ -1684,11 +1689,16 @@
 Scalar zero(0);
 if (tmp.ResolveValue(exe_ctx) != zero) {
   lldb::offset_t new_offset = offset + bra_offset;
-  if (opcodes.ValidOffset(new_offset))
+  // New offset can point at the end of the data, in this case we 
should
+  // terminate the DWARF expression evaluation (will happen in the loop
+  // condition).
+  if (new_offset <= opcodes.GetByteSize())
 offset = new_offset;
   else {
 if (error_ptr)
-  error_ptr->SetErrorString("Invalid opcode offset in DW_OP_bra.");
+  error_ptr->SetErrorStringWithFormatv(
+  "Invalid opcode offset in DW_OP_bra: {0}+({1}) > {2}", 
offset,
+  bra_offset, opcodes.GetByteSize());
 return false;
   }
 }


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -131,6 +131,25 @@
   llvm::HasValue(0x010101010101));
 }
 
+TEST(DWARFExpression, DW_OP_skip) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x42, DW_OP_skip, 0x02, 0x00,
+ DW_OP_const1u, 0xff}),
+   llvm::HasValue(0x42));
+}
+
+TEST(DWARFExpression, DW_OP_bra) {
+  EXPECT_THAT_EXPECTED(
+  // clang-format off
+  Evaluate({
+DW_OP_const1u, 0x42, // push 0x42
+DW_OP_const1u, 0x1,  // push 0x1
+DW_OP_bra, 0x02, 0x00,   // if 0x1 > 0, then skip 0x0002 opcodes
+DW_OP_const1u, 0xff, // push 0xff
+  }),
+  // clang-format on
+  llvm::HasValue(0x42));
+}
+
 TEST(DWARFExpression, DW_OP_convert) {
   /// Auxiliary debug info.
   const char *yamldata = R"(
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1655,11 +1655,16 @@
 case DW_OP_skip: {
   int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
   lldb::offset_t new_offset = offset + skip_offset;
-  if (opcodes.ValidOffset(new_offset))
+  // New offset can point at the end of the data, in this case we should
+  // terminate the DWARF expression evaluation (will happen in the loop
+  // condition).
+  if (new_offset <= opcodes.GetByteSize())

[Lldb-commits] [lldb] 1ac12a5 - [lldb][ARM] Invert emulation test assert message

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

Author: David Spickett
Date: 2022-07-22T09:35:30Z
New Revision: 1ac12a517767c0108a6859b723bc1351d8ba2157

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

LOG: [lldb][ARM] Invert emulation test assert message

Previously you got:
AssertionError: False is not True : Emulation test succeeded.

Which is a bit of a head scratcher. The message is used when
the test fails, not when it succeeds.

Added: 


Modified: 
lldb/test/API/arm/emulation/TestEmulations.py

Removed: 




diff  --git a/lldb/test/API/arm/emulation/TestEmulations.py 
b/lldb/test/API/arm/emulation/TestEmulations.py
index 800ac8bf98206..0e30949bc5f48 100644
--- a/lldb/test/API/arm/emulation/TestEmulations.py
+++ b/lldb/test/API/arm/emulation/TestEmulations.py
@@ -49,4 +49,4 @@ def run_a_single_test(self, filename):
 print('\nRunning test ' + os.path.basename(filename))
 print(output)
 
-self.assertTrue(success, 'Emulation test succeeded.')
+self.assertTrue(success, 'Emulation test failed.')



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


[Lldb-commits] [PATCH] D130307: [LLDB][Reliability] Fix register value unpacking

2022-07-22 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

Thanks!

I'm bothered that no test hit this but I deal with that (it's probably because 
no instruction you'd need to emulate uses these registers).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130307

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


[Lldb-commits] [PATCH] D130340: [lldb] [gdb-remote] Refactor killing process and move it to client

2022-07-22 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Refactor the code responsible for sending the "k" packet and move it
into GDBRemoteCommunicationClient::KillProcess() method.  This is part
of refactoring to enable multiprocess support in the client,
and to support using the vKill packet instead.

As part of the refactoring, the following functional changes apply:

- Some redundant logging has been removed, as any failures are returned via 
exit_string anyway.

- SetLastStopPacket() is no longer called.  It is used only to populate the 
thread list, and since the process has just exited and we're terminating the 
process instance, there's really no reason to set it.

- On successful kill, exit_string is set to "killed", to clearly indicate that 
the process has terminated on our request rather than on its own.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D130340

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2406,7 +2406,6 @@
 }
 
 Status ProcessGDBRemote::DoDestroy() {
-  Status error;
   Log *log = GetLog(GDBRLog::Process);
   LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy()");
 
@@ -2416,54 +2415,35 @@
 
   if (m_gdb_comm.IsConnected()) {
 if (m_public_state.GetValue() != eStateAttaching) {
-  StringExtractorGDBRemote response;
-  GDBRemoteCommunication::ScopedTimeout(m_gdb_comm,
-std::chrono::seconds(3));
-
-  if (m_gdb_comm.SendPacketAndWaitForResponse("k", response,
-  GetInterruptTimeout()) ==
-  GDBRemoteCommunication::PacketResult::Success) {
-char packet_cmd = response.GetChar(0);
+  llvm::Expected kill_res = m_gdb_comm.KillProcess(GetID());
 
-if (packet_cmd == 'W' || packet_cmd == 'X') {
+  if (kill_res) {
+exit_status = kill_res.get();
 #if defined(__APPLE__)
-  // For Native processes on Mac OS X, we launch through the Host
-  // Platform, then hand the process off to debugserver, which becomes
-  // the parent process through "PT_ATTACH".  Then when we go to kill
-  // the process on Mac OS X we call ptrace(PT_KILL) to kill it, then
-  // we call waitpid which returns with no error and the correct
-  // status.  But amusingly enough that doesn't seem to actually reap
-  // the process, but instead it is left around as a Zombie.  Probably
-  // the kernel is in the process of switching ownership back to lldb
-  // which was the original parent, and gets confused in the handoff.
-  // Anyway, so call waitpid here to finally reap it.
-  PlatformSP platform_sp(GetTarget().GetPlatform());
-  if (platform_sp && platform_sp->IsHost()) {
-int status;
-::pid_t reap_pid;
-reap_pid = waitpid(GetID(), &status, WNOHANG);
-LLDB_LOGF(log, "Reaped pid: %d, status: %d.\n", reap_pid, status);
-  }
-#endif
-  SetLastStopPacket(response);
-  ClearThreadIDList();
-  exit_status = response.GetHexU8();
-} else {
-  LLDB_LOGF(log,
-"ProcessGDBRemote::DoDestroy - got unexpected response "
-"to k packet: %s",
-response.GetStringRef().data());
-  exit_string.assign("got unexpected response to k packet: ");
-  exit_string.append(std::string(response.GetStringRef()));
+// For Native processes on Mac OS X, we launch through the Host
+// Platform, then hand the process off to debugserver, which becomes
+// the parent process through "PT_ATTACH".  Then when we go to kill
+// the process on Mac OS X we call ptrace(PT_KILL) to kill it, then
+// we call waitpid which returns with no error and the correct
+// status.  But amusingly enough that doesn't seem to actually reap
+// the process, but instead it is left around as a Zombie.  Probably
+// the kernel is in the process of switching ownership back to lldb
+// which was the original parent, and gets confused in the handoff.
+// Anyway, so call waitpid here to finally reap it.
+PlatformSP platform_sp(GetTarget().GetPlatform());
+if (platform_sp && platform_sp->IsHost()) {
+  int status;
+  ::pid_t reap_pid;
+  reap_pid = waitpid(GetID(), &status, WNOHAN

[Lldb-commits] [PATCH] D130341: [lldb] [gdb-remote] Use vKill packet if multiprocess & available

2022-07-22 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Prefer the modern vKill packet over k if the server reports multiprocess
support.  This ensures that when multiple processes are debugged over
a shared connection, only the correct one will be killed.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D130341

Files:
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
@@ -46,3 +46,97 @@
  lldb.eStopReasonSignal)
 self.assertEqual(process.GetThreadByID(0x10204).stop_reason,
  lldb.eStopReasonNone)
+
+def test_kill_no_mp(self):
+class MyResponder(MockGDBServerResponder):
+got_vKill = False
+
+def qfThreadInfo(self):
+return "mp100.100"
+
+def vKill(self, pid):
+self.got_vKill = True
+return "E01"
+
+def k(self):
+return "X01"
+
+self.server.responder = MyResponder()
+target = self.dbg.CreateTarget("")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+process.Kill()
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateExited])
+self.assertPacketLogContains(["k"])
+self.assertFalse(self.server.responder.got_vKill)
+self.assertEqual(process.GetExitStatus(), 1)
+
+def test_kill_mp(self):
+class MyResponder(MockGDBServerResponder):
+got_k = False
+
+def __init__(self, test_case):
+super().__init__()
+self.test_case = test_case
+
+def qSupported(self, client_supported):
+self.test_case.assertIn("multiprocess+", client_supported)
+return "multiprocess+;" + super().qSupported(client_supported)
+
+def qfThreadInfo(self):
+return "mp100.100"
+
+def vKill(self, pid):
+return "OK"
+
+def k(self):
+self.got_k = True
+return "X00"
+
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTarget("")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+process.Kill()
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateExited])
+self.assertPacketLogContains(["vKill;100"])
+self.assertFalse(self.server.responder.got_k)
+self.assertEqual(process.GetExitStatus(),
+ lldbutil.get_signal_number("SIGKILL"))
+
+def test_kill_mp_no_vKill(self):
+class MyResponder(MockGDBServerResponder):
+def __init__(self, test_case):
+super().__init__()
+self.test_case = test_case
+
+def qSupported(self, client_supported):
+self.test_case.assertIn("multiprocess+", client_supported)
+return "multiprocess+;" + super().qSupported(client_supported)
+
+def qC(self):
+return "QC100"
+
+def qfThreadInfo(self):
+return "mp100.100"
+
+def cont(self):
+return "S02"
+
+def k(self):
+return "X01"
+
+self.server.responder = MyResponder(self)
+target = self.dbg.CreateTarget("")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+process.Kill()
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateExited])
+self.assertPacketLogContains(["vKill;100", "k"])
+self.assertEqual(process.GetExitStatus(), 1)
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -4252,8 +4252

[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add Register Info and Context

2022-07-22 Thread Emmmer S via Phabricator via lldb-commits
Emmmer created this revision.
Emmmer added reviewers: labath, DavidSpickett, JDevlieghere, jingham.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, arichardson, mgorny.
Herald added a project: All.
Emmmer requested review of this revision.
Herald added subscribers: lldb-commits, pcwang-thead, eopXD.
Herald added a project: LLDB.

This patch is modified from D128250 , and I 
extracted the code for registers and removed some unnecessary changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130342

Files:
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Process/Linux/CMakeLists.txt
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
  lldb/source/Utility/ArchSpec.cpp

Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -724,6 +724,7 @@
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
   case llvm::Triple::arc:
+  case llvm::Triple::riscv64:
 return false;
   }
 }
@@ -1386,6 +1387,13 @@
 }
 break;
 
+  case ArchSpec::eCore_riscv64:
+if (!enforce_exact_match) {
+  if (core2 == ArchSpec::eCore_riscv64)
+return true;
+}
+break;
+
   default:
 break;
   }
Index: lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
@@ -0,0 +1,238 @@
+//===-- RegisterInfos_riscv64.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifdef DECLARE_REGISTER_INFOS_RISCV64_STRUCT
+
+#include 
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private.h"
+
+#ifndef GPR_OFFSET
+#error GPR_OFFSET must be defined before including this header file
+#endif
+
+#ifndef GPR_OFFSET_NAME
+#error GPR_OFFSET_NAME must be defined before including this header file
+#endif
+
+#ifndef FPR_OFFSET
+#error FPR_OFFSET must be defined before including this header file
+#endif
+
+#ifndef FPR_OFFSET_NAME
+#error FPR_OFFSET_NAME must be defined before including this header file
+#endif
+
+enum {
+  gpr_x0 = 0,
+  gpr_x1,
+  gpr_x2,
+  gpr_x3,
+  gpr_x4,
+  gpr_x5,
+  gpr_x6,
+  gpr_x7,
+  gpr_x8,
+  gpr_x9,
+  gpr_x10,
+  gpr_x11,
+  gpr_x12,
+  gpr_x13,
+  gpr_x14,
+  gpr_x15,
+  gpr_x16,
+  gpr_x17,
+  gpr_x18,
+  gpr_x19,
+  gpr_x20,
+  gpr_x21,
+  gpr_x22,
+  gpr_x23,
+  gpr_x24,
+  gpr_x25,
+  gpr_x26,
+  gpr_x27,
+  gpr_x28,
+  gpr_x29,
+  gpr_x30,
+  gpr_x31,
+  gpr_ra = gpr_x1,
+  gpr_sp = gpr_x2,
+  gpr_fp = gpr_x8,
+
+  gpr_pc = 32,
+
+  fpr_f0 = 33,
+  fpr_f1,
+  fpr_f2,
+  fpr_f3,
+  fpr_f4,
+  fpr_f5,
+  fpr_f6,
+  fpr_f7,
+  fpr_f8,
+  fpr_f9,
+  fpr_f10,
+  fpr_f11,
+  fpr_f12,
+  fpr_f13,
+  fpr_f14,
+  fpr_f15,
+  fpr_f16,
+  fpr_f17,
+  fpr_f18,
+  fpr_f19,
+  fpr_f20,
+  fpr_f21,
+  fpr_f22,
+  fpr_f23,
+  fpr_f24,
+  fpr_f25,
+  fpr_f26,
+  fpr_f27,
+  fpr_f28,
+  fpr_f29,
+  fpr_f30,
+  fpr_f31,
+
+  fpr_fflags,
+  fpr_frm,
+  fpr_fcsr,
+
+  k_num_registers
+};
+
+// Generates register kinds array with DWARF, EH frame and generic kind
+#define MISC_KIND(reg, type, generic_kind) \
+  { reg, reg, generic_kind, LLDB_INVALID_REGNUM, reg }
+
+// Generates register kinds array for registers with only lldb kind
+#define LLDB_KIND(lldb_kind)   \
+  {\
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+LLDB_INVALID_REGNUM, lldb_kind \
+  }
+
+// Generates register kinds array for vector registers
+#define GPR64_KIND(reg, generic_kind) MISC_KIND(reg, gpr, generic_kind)
+
+// FPR re

[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add Register Info and Context

2022-07-22 Thread Emmmer S via Phabricator via lldb-commits
Emmmer updated this revision to Diff 446766.

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

https://reviews.llvm.org/D130342

Files:
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Process/Linux/CMakeLists.txt
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
  lldb/source/Utility/ArchSpec.cpp

Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -724,6 +724,7 @@
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
   case llvm::Triple::arc:
+  case llvm::Triple::riscv64:
 return false;
   }
 }
@@ -1386,6 +1387,13 @@
 }
 break;
 
+  case ArchSpec::eCore_riscv64:
+if (!enforce_exact_match) {
+  if (core2 == ArchSpec::eCore_riscv64)
+return true;
+}
+break;
+
   default:
 break;
   }
Index: lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h
@@ -0,0 +1,238 @@
+//===-- RegisterInfos_riscv64.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifdef DECLARE_REGISTER_INFOS_RISCV64_STRUCT
+
+#include 
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private.h"
+
+#ifndef GPR_OFFSET
+#error GPR_OFFSET must be defined before including this header file
+#endif
+
+#ifndef GPR_OFFSET_NAME
+#error GPR_OFFSET_NAME must be defined before including this header file
+#endif
+
+#ifndef FPR_OFFSET
+#error FPR_OFFSET must be defined before including this header file
+#endif
+
+#ifndef FPR_OFFSET_NAME
+#error FPR_OFFSET_NAME must be defined before including this header file
+#endif
+
+enum {
+  gpr_x0 = 0,
+  gpr_x1,
+  gpr_x2,
+  gpr_x3,
+  gpr_x4,
+  gpr_x5,
+  gpr_x6,
+  gpr_x7,
+  gpr_x8,
+  gpr_x9,
+  gpr_x10,
+  gpr_x11,
+  gpr_x12,
+  gpr_x13,
+  gpr_x14,
+  gpr_x15,
+  gpr_x16,
+  gpr_x17,
+  gpr_x18,
+  gpr_x19,
+  gpr_x20,
+  gpr_x21,
+  gpr_x22,
+  gpr_x23,
+  gpr_x24,
+  gpr_x25,
+  gpr_x26,
+  gpr_x27,
+  gpr_x28,
+  gpr_x29,
+  gpr_x30,
+  gpr_x31,
+  gpr_ra = gpr_x1,
+  gpr_sp = gpr_x2,
+  gpr_fp = gpr_x8,
+
+  gpr_pc = 32,
+
+  fpr_f0 = 33,
+  fpr_f1,
+  fpr_f2,
+  fpr_f3,
+  fpr_f4,
+  fpr_f5,
+  fpr_f6,
+  fpr_f7,
+  fpr_f8,
+  fpr_f9,
+  fpr_f10,
+  fpr_f11,
+  fpr_f12,
+  fpr_f13,
+  fpr_f14,
+  fpr_f15,
+  fpr_f16,
+  fpr_f17,
+  fpr_f18,
+  fpr_f19,
+  fpr_f20,
+  fpr_f21,
+  fpr_f22,
+  fpr_f23,
+  fpr_f24,
+  fpr_f25,
+  fpr_f26,
+  fpr_f27,
+  fpr_f28,
+  fpr_f29,
+  fpr_f30,
+  fpr_f31,
+
+  fpr_fflags,
+  fpr_frm,
+  fpr_fcsr,
+
+  k_num_registers
+};
+
+// Generates register kinds array with DWARF, EH frame and generic kind
+#define MISC_KIND(reg, type, generic_kind) \
+  { reg, reg, generic_kind, LLDB_INVALID_REGNUM, reg }
+
+// Generates register kinds array for registers with only lldb kind
+#define LLDB_KIND(lldb_kind)   \
+  {\
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+LLDB_INVALID_REGNUM, lldb_kind \
+  }
+
+// Generates register kinds array for vector registers
+#define GPR64_KIND(reg, generic_kind) MISC_KIND(reg, gpr, generic_kind)
+
+// FPR register kinds array for vector registers
+#define FPR64_KIND(reg, generic_kind) MISC_KIND(reg, fpr, generic_kind)
+
+#define MISC_FPR_KIND(lldb_kind) LLDB_KIND(lldb_kind)
+
+// Defines a 64-bit general purpose register
+#define DEFINE_GPR64(reg, generic_kind)\
+  {\
+#reg, nullptr, 8, GPR_OFFSET(gpr_##reg), lldb::eEncodingUint,  \
+lldb::eFormatHex, GPR64_KIND(gpr_##reg, generic_kind), nullptr,\
+nullptr\
+  }
+
+// Defines a 64-bit general purpose register
+#def

[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-22 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov added a comment.

In D112374#3666531 , @kimgr wrote:

> From a purely personal perspective, I'd prefer if this landed after the 
> branch for llvm-15.
>
> We try to co-release IWYU shortly after LLVM/Clang are released, to get a 
> public API-compatible release out there. So it would be really nice if we 
> didn't have to spend time working around AST changes while the clock is 
> ticking to get a release out the door.
>
> That said, I know we're just an out-of-tree project and the LLVM project as 
> such doesn't make any promises (and shouldn't have to!). I just thought I'd 
> raise the concern to see if anybody shares it.

So I checked out and played a bit with IWYU sources yesterday. I saw that my 
previous suggestions only fixes one of the six test breakages.

Yeah its a bit messy, I totally understand now why you seem a bit desperate 
about this haha.

Since I am not one to met around in the torture business, I concur to hold.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D130320: Move GetControlFlowKind's logic to DisassemblerLLVMC.cpp

2022-07-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

great! thank you. I'll land this


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

https://reviews.llvm.org/D130320

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


[Lldb-commits] [lldb] 9429b67 - [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-07-22T10:12:31-07:00
New Revision: 9429b67b8e300e638d7828bbcb95585f85c4df4d

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

LOG: [NFC] Improve FileSpec internal APIs and usage in preparation for adding 
caching of resolved/absolute.

The FileSpect APIs allow users to modify instance variables directly by getting 
a non const reference to the directory and filename instance variables. This 
makes it impossibly to control all of the times the FileSpec object is modified 
so we can clear the cache. This patch modifies the APIs of FileSpec so no one 
can modify the directory or filename directly by adding set accessors and by 
removing the get accessors that are non const.

Many clients were using FileSpec::GetCString(...) which returned a unique C 
string from a ConstString'ified version of the result of GetPath() which 
returned a std::string. This caused many locations to use this convenient 
function incorrectly and could cause many strings to be added to the constant 
string pool that didn't need to. Most clients were converted to using 
FileSpec::GetPath().c_str() when possible. Other clients were modified to use 
the newly renamed version of this function which returns an actualy ConstString:
ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const;

This avoids the issue where people were getting an already uniqued "const char 
*" that came from a ConstString only to put the "const char *" back into a 
"ConstString" object. By returning the ConstString instead of a "const char *" 
clients can be more efficient with the result.

The patch:
- Removes the non const GetDirectory() and GetFilename() get accessors
- Adds set accessors to replace the above functions: SetDirectory() and 
SetFilename().
- Adds ClearDirectory() and ClearFilename() to replace usage of the 
FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites
- Fixed all incorrect usage of FileSpec::GetCString() to use 
FileSpec::GetPath().c_str() where appropriate, and updated other call sites 
that wanted a ConstString to use the newly returned ConstString appropriately 
and efficiently.

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

Added: 


Modified: 
lldb/include/lldb/Utility/FileSpec.h
lldb/source/API/SBFileSpec.cpp
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/API/SBReproducer.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Expression/FunctionCaller.cpp
lldb/source/Expression/REPL.cpp
lldb/source/Host/common/FileAction.cpp
lldb/source/Host/common/FileSystem.cpp
lldb/source/Host/common/HostInfoBase.cpp
lldb/source/Host/macosx/objcxx/Host.mm
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Host/posix/FileSystemPosix.cpp
lldb/source/Host/posix/HostInfoPosix.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/source/Target/Trace.cpp
lldb/source/Utility

[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9429b67b8e30: [NFC] Improve FileSpec internal APIs and usage 
in preparation for adding… (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/API/SBFileSpec.cpp
  lldb/source/API/SBLaunchInfo.cpp
  lldb/source/API/SBPlatform.cpp
  lldb/source/API/SBReproducer.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Commands/CommandObjectLog.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Host/common/FileAction.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Host/posix/FileSystemPosix.cpp
  lldb/source/Host/posix/HostInfoPosix.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/source/Target/Trace.cpp
  lldb/source/Utility/FileSpec.cpp
  lldb/tools/lldb-server/lldb-platform.cpp
  lldb/tools/lldb-test/lldb-test.cpp
  lldb/unittests/Target/FindFileTest.cpp
  lldb/unittests/Target/ModuleCacheTest.cpp
  lldb/unittests/Utility/FileSpecTest.cpp

Index: lldb/unittests/Utility/FileSpecTest.cpp
===
--- lldb/unittests/Utility/FileSpecTest.cpp
+++ lldb/unittests/Utility/FileSpecTest.cpp
@@ -22,92 +22,92 @@
 
 TEST(FileSpecTest, FileAndDirectoryComponents) {
   FileSpec fs_posix("/foo/bar", FileSpec::Style::posix);
-  EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
+  EXPECT_STREQ("/foo/bar", fs_posix.GetPath().c_str());
   EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
   EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
 
   FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
-  EXPECT_STREQ("F:\\bar", fs_windows.GetCString());
-  // EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); // It returns
+  EXPECT_STREQ("F:\\bar", fs_windows.GetPath().c_str());
+  // EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetPath().c_str()); // It returns
   // "F:/"
   EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString());
 
   FileSpec fs_posix_root("/", FileSpec::Style::posix);
-  EXPECT_STREQ("/", fs_posix_root.GetCString());
+  EXPECT_STREQ("/", fs_posix_root.GetPath().c_str());
   EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString());
   EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString());
 
   FileSpec fs_net_drive("//net", FileSpec::Style::posix);
-  EXPECT_STREQ("//net", fs_net_drive.GetCString());
+  EXPECT_STREQ("//net", fs_net_drive.GetPath().c_str());
   EXPECT_EQ(nullptr, fs_net_drive.GetDirectory().GetCString());
   EXPECT_STREQ("//net", fs_net_drive.GetFilename().GetCString());
 
   FileSpec fs_net_root("//net/", FileSpec::Style::posix);
-  EXPECT_STREQ("//net/", fs_net_root.GetCString());
+  EXPECT_STREQ("//net/", fs_net_root.GetPath().c_str());
   EXPECT_STREQ("//net", fs_net_root.GetDirectory().GetCString());
   EXPECT_STREQ("/", fs_net_root.GetFilename().GetCString());
 
   FileSpec fs_windows_d

[Lldb-commits] [PATCH] D130307: [LLDB][Reliability] Fix register value unpacking

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Can we add a test for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130307

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

This doesn't build, as far as I can tell: 
http://45.33.8.238/linux/82002/step_4.txt

Please take a look, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

I ran into this build break too - please try to fix or revert!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Looking at the build breakage now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [lldb] f959d81 - Fix buildbot breakage after https://reviews.llvm.org/D130309.

2022-07-22 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-07-22T13:24:26-07:00
New Revision: f959d815f4637890ebbacca379f1c38ab47e4e14

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

LOG: Fix buildbot breakage after https://reviews.llvm.org/D130309.

Added: 


Modified: 
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git a/lldb/source/Host/linux/HostInfoLinux.cpp 
b/lldb/source/Host/linux/HostInfoLinux.cpp
index 1ed203769bd1b..50aa03daaf17b 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -178,7 +178,7 @@ bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec 
&file_spec) {
 bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
   FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
   FileSystem::Instance().Resolve(temp_file);
-  file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
+  file_spec.SetDirectory(temp_file.GetPath());
   return true;
 }
 
@@ -190,9 +190,9 @@ bool HostInfoLinux::ComputeUserPluginsDirectory(FileSpec 
&file_spec) {
   if (xdg_data_home && xdg_data_home[0]) {
 std::string user_plugin_dir(xdg_data_home);
 user_plugin_dir += "/lldb";
-file_spec.GetDirectory().SetCString(user_plugin_dir.c_str());
+file_spec.SetDirectory(user_plugin_dir.c_str());
   } else
-file_spec.GetDirectory().SetCString("~/.local/share/lldb");
+file_spec.SetDirectory("~/.local/share/lldb");
   return true;
 }
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index e7cb154a8dea4..6558993470eee 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -241,7 +241,7 @@ void ScriptInterpreterPython::ComputePythonDir(
   llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 
 #if defined(_WIN32)
-  // This will be injected directly through 
FileSpec.GetDirectory().SetString(),
+  // This will be injected directly through FileSpec.SetDirectory(),
   // so we need to normalize manually.
   std::replace(path.begin(), path.end(), '\\', '/');
 #endif



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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Submitted a fix for the buildbots:

commit f959d815f4637890ebbacca379f1c38ab47e4e14 
 (HEAD -> 
main)
Author: Greg Clayton 
Date:   Fri Jul 22 13:24:04 2022 -0700

  Fix buildbot breakage after https://reviews.llvm.org/D130309.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130396: Cache the value for absolute path in FileSpec.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, yinghuitan.
Herald added a project: All.
clayborg requested review of this revision.
Herald added subscribers: lldb-commits, aheejin.
Herald added a project: LLDB.

Checking if a path is absolute can be expensive and currently the result is not 
cached in the FileSpec object. This patch adds caching and also code to clear 
the cache if the file is modified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130396

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Utility/FileSpec.cpp
  lldb/unittests/Utility/FileSpecTest.cpp

Index: lldb/unittests/Utility/FileSpecTest.cpp
===
--- lldb/unittests/Utility/FileSpecTest.cpp
+++ lldb/unittests/Utility/FileSpecTest.cpp
@@ -450,3 +450,29 @@
   EXPECT_FALSE(FileSpec(""));
   EXPECT_TRUE(FileSpec("/foo/bar"));
 }
+
+
+TEST(FileSpecTest, TestAbsoluteCaching) {
+  // Test that if we modify a path that we recalculate if a path is relative
+  // or absolute correctly. The test below calls set accessors and functions
+  // that change the path and verifies that the FileSpec::IsAbsolute() returns
+  // the correct value.
+  FileSpec file = PosixSpec("/tmp/a");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.ClearDirectory();
+  EXPECT_FALSE(file.IsAbsolute());
+  file.SetDirectory("/tmp");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.SetDirectory(".");
+  EXPECT_FALSE(file.IsAbsolute());
+  file.SetPath("/log.txt");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.RemoveLastPathComponent();
+  EXPECT_TRUE(file.IsAbsolute());
+  file.ClearFilename();
+  EXPECT_FALSE(file.IsAbsolute());
+  file.AppendPathComponent("foo.txt");
+  EXPECT_FALSE(file.IsAbsolute());
+  file.PrependPathComponent("/tmp");
+  EXPECT_TRUE(file.IsAbsolute());
+}
Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -170,9 +170,7 @@
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
 void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
-  m_filename.Clear();
-  m_directory.Clear();
-  m_is_resolved = false;
+  Clear();
   m_style = (style == Style::native) ? GetNativeStyle() : style;
 
   if (pathname.empty())
@@ -259,6 +257,7 @@
 void FileSpec::Clear() {
   m_directory.Clear();
   m_filename.Clear();
+  PathWasModified();
 }
 
 // Compare two FileSpec objects. If "full" is true, then both the directory and
@@ -332,26 +331,32 @@
 
 void FileSpec::SetDirectory(ConstString directory) {
   m_directory = directory;
+  PathWasModified();
 }
 
 void FileSpec::SetDirectory(llvm::StringRef directory) {
   m_directory = ConstString(directory);
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(ConstString filename) {
   m_filename = filename;
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(llvm::StringRef filename) {
   m_filename = ConstString(filename);
+  PathWasModified();
 }
 
 void FileSpec::ClearFilename() {
   m_filename.Clear();
+  PathWasModified();
 }
 
 void FileSpec::ClearDirectory() {
   m_directory.Clear();
+  PathWasModified();
 }
 
 // Extract the directory and path into a fixed buffer. This is needed as the
@@ -488,18 +493,22 @@
 }
 
 bool FileSpec::IsAbsolute() const {
-llvm::SmallString<64> current_path;
-  GetPath(current_path, false);
+  // Check if we have cached if this path is absolute to avoid recalculating.
+  if (m_absolute != Absolute::Calculate)
+return m_absolute == Absolute::Yes;
 
-  // Early return if the path is empty.
-  if (current_path.empty())
-return false;
+  m_absolute = Absolute::No;
 
-  // We consider paths starting with ~ to be absolute.
-  if (current_path[0] == '~')
-return true;
+  llvm::SmallString<64> path;
+  GetPath(path, false);
+
+  if (!path.empty()) {
+// We consider paths starting with ~ to be absolute.
+if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style))
+  m_absolute = Absolute::Yes;
+  }
 
-  return llvm::sys::path::is_absolute(current_path, m_style);
+  return m_absolute == Absolute::Yes;
 }
 
 void FileSpec::MakeAbsolute(const FileSpec &dir) {
Index: lldb/include/lldb/Utility/FileSpec.h
===
--- lldb/include/lldb/Utility/FileSpec.h
+++ lldb/include/lldb/Utility/FileSpec.h
@@ -416,10 +416,24 @@
   // Convenience method for setting the file without changing the style.
   void SetFile(llvm::StringRef path);
 
+  /// Called anytime m_directory or m_filename is changed to clear any cached
+  /// state in this object.
+  void PathWasModified() {
+m_is_resolved = false;
+m_absolute = Absolute::Calculate;
+  }
+
+  enum class Absolute : uint8_t {
+Calculate,
+Yes,
+No
+  };
+
   // Member variables
   ConstString m_directory;///< The uniqued dire

[Lldb-commits] [PATCH] D130045: Implement better path matching in FileSpecList::FindFileIndex(...).

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Submitted the absolute caching stuff in FileSpec with 
https://reviews.llvm.org/D130396. I will rebase this on top of that diff when 
it gets checked in.

I will also revert changes to FindFileIndex, and then add a new 
FindContainedFileIndex(...) with the contents of this patch's FindFileIndex and 
explain that it will allow the specified file to be relative and have it match 
any files those suffix matches, or any file in the file list can be relative 
and as along as the suffix matches the specified file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130045

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


[Lldb-commits] [PATCH] D130396: Cache the value for absolute path in FileSpec.

2022-07-22 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130396

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


[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add Register Info and Context

2022-07-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Utility/ArchSpec.cpp:1390-1395
+  case ArchSpec::eCore_riscv64:
+if (!enforce_exact_match) {
+  if (core2 == ArchSpec::eCore_riscv64)
+return true;
+}
+break;

I don't think this is needed. The case where the two cores are identical is 
already covered by line 1084. This would be for something like `eCore_riscv32` 
if that were a thing. 


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

https://reviews.llvm.org/D130342

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D130309#3672934 , @clayborg wrote:

> Submitted a fix for the buildbots:
>
> commit f959d815f4637890ebbacca379f1c38ab47e4e14 
>  (HEAD 
> -> main)
> Author: Greg Clayton 
> Date:   Fri Jul 22 13:24:04 2022 -0700
>
>   Fix buildbot breakage after https://reviews.llvm.org/D130309.

Still broken for me:

  ../tools/lldb/source/Host/linux/HostInfoLinux.cpp: In static member function 
‘static bool 
lldb_private::HostInfoLinux::ComputeSupportExeDirectory(lldb_private::FileSpec&)’:
  ../tools/lldb/source/Host/linux/HostInfoLinux.cpp:174:64: error: passing 
‘const lldb_private::ConstString’ as ‘this’ argument discards qualifiers 
[-fpermissive]
174 |   file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();
|^
  In file included from ../tools/lldb/include/lldb/Utility/ArchSpec.h:13,
   from ../tools/lldb/include/lldb/Host/HostInfoBase.h:12,
   from 
../tools/lldb/include/lldb/Host/posix/HostInfoPosix.h:12,
   from 
../tools/lldb/include/lldb/Host/linux/HostInfoLinux.h:12,
   from ../tools/lldb/source/Host/linux/HostInfoLinux.cpp:9:
  ../tools/lldb/include/lldb/Utility/ConstString.h:40:7: note:   in call to 
‘constexpr lldb_private::ConstString& 
lldb_private::ConstString::operator=(const lldb_private::ConstString&)’
 40 | class ConstString {
|   ^~~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [lldb] 0bbce7a - Fix buildbot breakage after https://reviews.llvm.org/D130309.

2022-07-22 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-07-22T13:59:06-07:00
New Revision: 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24

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

LOG: Fix buildbot breakage after https://reviews.llvm.org/D130309.

Added: 


Modified: 
lldb/source/Host/linux/HostInfoLinux.cpp

Removed: 




diff  --git a/lldb/source/Host/linux/HostInfoLinux.cpp 
b/lldb/source/Host/linux/HostInfoLinux.cpp
index 50aa03daaf17..0af7a473e1af 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -171,7 +171,7 @@ bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec 
&file_spec) {
   if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) &&
   file_spec.IsAbsolute() && FileSystem::Instance().Exists(file_spec))
 return true;
-  file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();
+  file_spec.SetDirectory(GetProgramFileSpec().GetDirectory());
   return !file_spec.GetDirectory().IsEmpty();
 }
 



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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Another fix for linux:

commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24 
 (HEAD -> 
main, origin/main, origin/HEAD)
Author: Greg Clayton 
Date:   Fri Jul 22 13:59:06 2022 -0700

  Fix buildbot breakage after https://reviews.llvm.org/D130309.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D130309#3673045 , @clayborg wrote:

> Another fix for linux:
>
> commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24 
>  (HEAD 
> -> main, origin/main, origin/HEAD)
> Author: Greg Clayton 
> Date:   Fri Jul 22 13:59:06 2022 -0700
>
>   Fix buildbot breakage after https://reviews.llvm.org/D130309.

Thanks, now it finally built correctly for me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D130309#3673046 , @mstorsjo wrote:

> In D130309#3673045 , @clayborg 
> wrote:
>
>> Another fix for linux:
>>
>> commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24 
>>  (HEAD 
>> -> main, origin/main, origin/HEAD)
>> Author: Greg Clayton 
>> Date:   Fri Jul 22 13:59:06 2022 -0700
>>
>>   Fix buildbot breakage after https://reviews.llvm.org/D130309.
>
> Thanks, now it finally built correctly for me!

Great! Thanks for the heads up on the breakage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [lldb] dabe877 - Cache the value for absolute path in FileSpec.

2022-07-22 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-07-22T14:04:52-07:00
New Revision: dabe877248b85b34878e75d5510339325ee087d0

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

LOG: Cache the value for absolute path in FileSpec.

Checking if a path is absolute can be expensive and currently the result is not 
cached in the FileSpec object. This patch adds caching and also code to clear 
the cache if the file is modified.

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

Added: 


Modified: 
lldb/include/lldb/Utility/FileSpec.h
lldb/source/Utility/FileSpec.cpp
lldb/unittests/Utility/FileSpecTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index a0b01fb085ebe..8492c93fd58a1 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -416,10 +416,24 @@ class FileSpec {
   // Convenience method for setting the file without changing the style.
   void SetFile(llvm::StringRef path);
 
+  /// Called anytime m_directory or m_filename is changed to clear any cached
+  /// state in this object.
+  void PathWasModified() {
+m_is_resolved = false;
+m_absolute = Absolute::Calculate;
+  }
+
+  enum class Absolute : uint8_t {
+Calculate,
+Yes,
+No
+  };
+
   // Member variables
   ConstString m_directory;///< The uniqued directory path
   ConstString m_filename; ///< The uniqued filename path
   mutable bool m_is_resolved = false; ///< True if this path has been resolved.
+  mutable Absolute m_absolute = Absolute::Calculate; ///< Cache absoluteness.
   Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
 };
 

diff  --git a/lldb/source/Utility/FileSpec.cpp 
b/lldb/source/Utility/FileSpec.cpp
index 7646d33264226..48b922970d87e 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -170,9 +170,7 @@ void FileSpec::SetFile(llvm::StringRef pathname) { 
SetFile(pathname, m_style); }
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
 void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
-  m_filename.Clear();
-  m_directory.Clear();
-  m_is_resolved = false;
+  Clear();
   m_style = (style == Style::native) ? GetNativeStyle() : style;
 
   if (pathname.empty())
@@ -259,6 +257,7 @@ Stream &lldb_private::operator<<(Stream &s, const FileSpec 
&f) {
 void FileSpec::Clear() {
   m_directory.Clear();
   m_filename.Clear();
+  PathWasModified();
 }
 
 // Compare two FileSpec objects. If "full" is true, then both the directory and
@@ -332,26 +331,32 @@ FileSpec::Style FileSpec::GetPathStyle() const { return 
m_style; }
 
 void FileSpec::SetDirectory(ConstString directory) {
   m_directory = directory;
+  PathWasModified();
 }
 
 void FileSpec::SetDirectory(llvm::StringRef directory) {
   m_directory = ConstString(directory);
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(ConstString filename) {
   m_filename = filename;
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(llvm::StringRef filename) {
   m_filename = ConstString(filename);
+  PathWasModified();
 }
 
 void FileSpec::ClearFilename() {
   m_filename.Clear();
+  PathWasModified();
 }
 
 void FileSpec::ClearDirectory() {
   m_directory.Clear();
+  PathWasModified();
 }
 
 // Extract the directory and path into a fixed buffer. This is needed as the
@@ -488,18 +493,22 @@ bool FileSpec::IsRelative() const {
 }
 
 bool FileSpec::IsAbsolute() const {
-llvm::SmallString<64> current_path;
-  GetPath(current_path, false);
+  // Check if we have cached if this path is absolute to avoid recalculating.
+  if (m_absolute != Absolute::Calculate)
+return m_absolute == Absolute::Yes;
 
-  // Early return if the path is empty.
-  if (current_path.empty())
-return false;
+  m_absolute = Absolute::No;
 
-  // We consider paths starting with ~ to be absolute.
-  if (current_path[0] == '~')
-return true;
+  llvm::SmallString<64> path;
+  GetPath(path, false);
+
+  if (!path.empty()) {
+// We consider paths starting with ~ to be absolute.
+if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style))
+  m_absolute = Absolute::Yes;
+  }
 
-  return llvm::sys::path::is_absolute(current_path, m_style);
+  return m_absolute == Absolute::Yes;
 }
 
 void FileSpec::MakeAbsolute(const FileSpec &dir) {

diff  --git a/lldb/unittests/Utility/FileSpecTest.cpp 
b/lldb/unittests/Utility/FileSpecTest.cpp
index 9260262d8b674..0249dd5a98a4d 100644
--- a/lldb/unittests/Utility/FileSpecTest.cpp
+++ b/lldb/unittests/Utility/FileSpecTest.cpp
@@ -450,3 +450,29 @@ TEST(FileSpecTest, OperatorBool) {
   EXPECT_FALSE(FileSpec(""));
   EXPECT_TRUE(FileSpec("/foo/bar"));
 }
+
+

[Lldb-commits] [PATCH] D130396: Cache the value for absolute path in FileSpec.

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdabe877248b8: Cache the value for absolute path in FileSpec. 
(authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130396

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Utility/FileSpec.cpp
  lldb/unittests/Utility/FileSpecTest.cpp

Index: lldb/unittests/Utility/FileSpecTest.cpp
===
--- lldb/unittests/Utility/FileSpecTest.cpp
+++ lldb/unittests/Utility/FileSpecTest.cpp
@@ -450,3 +450,29 @@
   EXPECT_FALSE(FileSpec(""));
   EXPECT_TRUE(FileSpec("/foo/bar"));
 }
+
+
+TEST(FileSpecTest, TestAbsoluteCaching) {
+  // Test that if we modify a path that we recalculate if a path is relative
+  // or absolute correctly. The test below calls set accessors and functions
+  // that change the path and verifies that the FileSpec::IsAbsolute() returns
+  // the correct value.
+  FileSpec file = PosixSpec("/tmp/a");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.ClearDirectory();
+  EXPECT_FALSE(file.IsAbsolute());
+  file.SetDirectory("/tmp");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.SetDirectory(".");
+  EXPECT_FALSE(file.IsAbsolute());
+  file.SetPath("/log.txt");
+  EXPECT_TRUE(file.IsAbsolute());
+  file.RemoveLastPathComponent();
+  EXPECT_TRUE(file.IsAbsolute());
+  file.ClearFilename();
+  EXPECT_FALSE(file.IsAbsolute());
+  file.AppendPathComponent("foo.txt");
+  EXPECT_FALSE(file.IsAbsolute());
+  file.PrependPathComponent("/tmp");
+  EXPECT_TRUE(file.IsAbsolute());
+}
Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -170,9 +170,7 @@
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
 void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
-  m_filename.Clear();
-  m_directory.Clear();
-  m_is_resolved = false;
+  Clear();
   m_style = (style == Style::native) ? GetNativeStyle() : style;
 
   if (pathname.empty())
@@ -259,6 +257,7 @@
 void FileSpec::Clear() {
   m_directory.Clear();
   m_filename.Clear();
+  PathWasModified();
 }
 
 // Compare two FileSpec objects. If "full" is true, then both the directory and
@@ -332,26 +331,32 @@
 
 void FileSpec::SetDirectory(ConstString directory) {
   m_directory = directory;
+  PathWasModified();
 }
 
 void FileSpec::SetDirectory(llvm::StringRef directory) {
   m_directory = ConstString(directory);
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(ConstString filename) {
   m_filename = filename;
+  PathWasModified();
 }
 
 void FileSpec::SetFilename(llvm::StringRef filename) {
   m_filename = ConstString(filename);
+  PathWasModified();
 }
 
 void FileSpec::ClearFilename() {
   m_filename.Clear();
+  PathWasModified();
 }
 
 void FileSpec::ClearDirectory() {
   m_directory.Clear();
+  PathWasModified();
 }
 
 // Extract the directory and path into a fixed buffer. This is needed as the
@@ -488,18 +493,22 @@
 }
 
 bool FileSpec::IsAbsolute() const {
-llvm::SmallString<64> current_path;
-  GetPath(current_path, false);
+  // Check if we have cached if this path is absolute to avoid recalculating.
+  if (m_absolute != Absolute::Calculate)
+return m_absolute == Absolute::Yes;
 
-  // Early return if the path is empty.
-  if (current_path.empty())
-return false;
+  m_absolute = Absolute::No;
 
-  // We consider paths starting with ~ to be absolute.
-  if (current_path[0] == '~')
-return true;
+  llvm::SmallString<64> path;
+  GetPath(path, false);
+
+  if (!path.empty()) {
+// We consider paths starting with ~ to be absolute.
+if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style))
+  m_absolute = Absolute::Yes;
+  }
 
-  return llvm::sys::path::is_absolute(current_path, m_style);
+  return m_absolute == Absolute::Yes;
 }
 
 void FileSpec::MakeAbsolute(const FileSpec &dir) {
Index: lldb/include/lldb/Utility/FileSpec.h
===
--- lldb/include/lldb/Utility/FileSpec.h
+++ lldb/include/lldb/Utility/FileSpec.h
@@ -416,10 +416,24 @@
   // Convenience method for setting the file without changing the style.
   void SetFile(llvm::StringRef path);
 
+  /// Called anytime m_directory or m_filename is changed to clear any cached
+  /// state in this object.
+  void PathWasModified() {
+m_is_resolved = false;
+m_absolute = Absolute::Calculate;
+  }
+
+  enum class Absolute : uint8_t {
+Calculate,
+Yes,
+No
+  };
+
   // Member variables
   ConstString m_directory;///< The uniqued directory path
   ConstString m_filename; ///< The uniqued filename path
   mutable bool m_is_resolved = false; ///< True if this path has been resolved.
+  mutable Absolute m_absolute = 

[Lldb-commits] [lldb] b797834 - [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-22 Thread Chelsea Cassanova via lldb-commits

Author: Chelsea Cassanova
Date: 2022-07-22T17:32:00-04:00
New Revision: b797834748f1954950880bf50fb78abedd4494e6

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

LOG: [lldb/Fuzzer] Add fuzzer for expression evaluator

This commit adds a fuzzer for LLDB's expression evaluator.
The fuzzer takes a different approach than the current fuzzers
present, and uses an approach that is currently being used for
clang fuzzers.

Instead of fuzzing the evaluator with randomly mutated
characters, protobufs are used to generate a subset of C++. This
is then converted to valid C++ code and sent to the expression
evaluator. In addition, libprotobuf_mutator is used to mutate
the fuzzer's inputs from valid C++ code to valid C++ code, rather
than mutating from valid code to total nonsense.

Differential revision: https://reviews.llvm.org/D129377

Added: 
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Modified: 
clang/cmake/modules/ProtobufMutator.cmake
clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
lldb/tools/lldb-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/ProtobufMutator.cmake 
b/clang/cmake/modules/ProtobufMutator.cmake
index 15fe95ed6e8e9..071f11bc343de 100644
--- a/clang/cmake/modules/ProtobufMutator.cmake
+++ b/clang/cmake/modules/ProtobufMutator.cmake
@@ -1,5 +1,9 @@
 include(ExternalProject)
-set(PBM_PREFIX protobuf_mutator)
+
+if (NOT PBM_PREFIX)
+  set (PBM_PREFIX protobuf_mutator)
+endif()
+
 set(PBM_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PBM_PREFIX}/src/${PBM_PREFIX})
 set(PBM_LIB_PATH ${PBM_PATH}-build/src/libprotobuf-mutator.a)
 set(PBM_FUZZ_LIB_PATH 
${PBM_PATH}-build/src/libfuzzer/libprotobuf-mutator-libfuzzer.a)

diff  --git a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
index 6d62421d9a69a..469b88cb7de29 100644
--- a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
@@ -11,3 +11,5 @@ add_clang_library(clangHandleCXX
   clangSerialization
   clangTooling
   )
+
+target_include_directories(clangHandleCXX PUBLIC .)

diff  --git a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
index 339959b81af0c..45f51c9d8b54d 100644
--- a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
@@ -14,6 +14,8 @@ add_clang_library(clangLoopProtoToCXX loop_proto_to_cxx.cpp
   DEPENDS clangCXXLoopProto
   LINK_LIBS clangCXXLoopProto ${PROTOBUF_LIBRARIES}
   )
+target_include_directories(clangProtoToCXX PUBLIC .)
+target_include_directories(clangLoopProtoToCXX PUBLIC .)
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)
 add_clang_executable(clang-loop-proto-to-cxx loop_proto_to_cxx_main.cpp)

diff  --git a/lldb/tools/lldb-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/CMakeLists.txt
index 867a41961c13c..4c081a9de53e2 100644
--- a/lldb/tools/lldb-fuzzer/CMakeLists.txt
+++ b/lldb/tools/lldb-fuzzer/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(lldb-commandinterpreter-fuzzer)
+add_subdirectory(lldb-expression-fuzzer)
 add_subdirectory(lldb-target-fuzzer)
 add_subdirectory(utils)

diff  --git a/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
new file mode 100644
index 0..40606f10cc711
--- /dev/null
+++ b/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
@@ -0,0 +1,57 @@
+if(CLANG_ENABLE_PROTO_FUZZER)
+  set(LLVM_LINK_COMPONENTS
+Support
+)
+
+  add_llvm_fuzzer(lldb-expression-fuzzer
+EXCLUDE_FROM_ALL
+lldb-expression-fuzzer.cpp
+)
+
+  if(TARGET lldb-expression-fuzzer)
+target_include_directories(lldb-expression-fuzzer PRIVATE ..)
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer
 PRIVATE ..)
+
+set(CLANG_CMAKE_MODULE_PATH
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
+
+set(CMAKE_MODULE_PATH
+  ${CMAKE_MODULE_PATH}
+  ${CLANG_CMAKE_MODULE_PATH})
+
+
+set (PBM_PREFIX lldb_protobuf_mutator)
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+target_link_libraries(lldb-expression-fuzzer
+  PRIVATE
+  ${ProtobufMutator_LIBRARIES}
+  ${LLVM_LIB_FUZZING_ENGINE}
+  clangHandleCXX
+  clangCXXProto
+  clangProtoToCXX
+  liblldb
+   

[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-22 Thread Chelsea Cassanova via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb797834748f1: [lldb/Fuzzer] Add fuzzer for expression 
evaluator (authored by cassanova).

Changed prior to commit:
  https://reviews.llvm.org/D129377?vs=444761&id=446982#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

Files:
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  lldb/tools/lldb-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
@@ -0,0 +1,73 @@
+//===-- lldb-expression-fuzzer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// \file
+// This file is a fuzzer for LLDB's expression evaluator. It uses protobufs
+// and the libprotobuf-mutator to create valid C-like inputs for the
+// expression evaluator.
+//
+//===-===//
+
+#include 
+
+#include "cxx_proto.pb.h"
+#include "handle_cxx.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBTarget.h"
+#include "proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+using namespace lldb;
+using namespace llvm;
+using namespace clang_fuzzer;
+
+char **originalargv;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  SBDebugger::Initialize();
+
+  // The path for a simple compiled program is needed to create a
+  // target for the debugger and that path is passed in through argv
+  originalargv = *argv;
+  return 0;
+}
+
+DEFINE_BINARY_PROTO_FUZZER(const clang_fuzzer::Function &input) {
+  auto input_string = clang_fuzzer::FunctionToString(input);
+
+  // Get the second argument from argv and strip the '--' from it.
+  // This will be used as the path for the object file to create a target from
+  std::string raw_path = originalargv[2];
+  StringRef obj_path = raw_path.erase(0, 2);
+
+  // Create a debugger and a target
+  SBDebugger debugger = SBDebugger::Create(false);
+  SBTarget target = debugger.CreateTarget(obj_path.str().c_str());
+
+  // Create a breakpoint on the only line in the program
+  SBBreakpoint breakpoint = target.BreakpointCreateByLocation(obj_path.str().c_str(), 1);
+
+  // Create launch info and error for launching the process
+  SBLaunchInfo launch_info = target.GetLaunchInfo();
+  SBError error;
+
+  // Launch the process and evaluate the fuzzer's input data
+  // as an expression
+  SBProcess process = target.Launch(launch_info, error);
+  target.EvaluateExpression(input_string.c_str());
+
+  debugger.DeleteTarget(target);
+  SBDebugger::Destroy(debugger);
+  SBModule::GarbageCollectAllocatedModules();
+}
Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
@@ -0,0 +1,57 @@
+if(CLANG_ENABLE_PROTO_FUZZER)
+  set(LLVM_LINK_COMPONENTS
+Support
+)
+
+  add_llvm_fuzzer(lldb-expression-fuzzer
+EXCLUDE_FROM_ALL
+lldb-expression-fuzzer.cpp
+)
+
+  if(TARGET lldb-expression-fuzzer)
+target_include_directories(lldb-expression-fuzzer PRIVATE ..)
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer PRIVATE ..)
+
+set(CLANG_CMAKE_MODULE_PATH
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
+
+set(CMAKE_MODULE_PATH
+  ${CMAKE_MODULE_PATH}
+  ${CLANG_CMAKE_MODULE_PATH})
+
+
+set (PBM_PREFIX lldb_protobuf_mutator)
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+target_link_libraries(lldb-expression-fuzzer
+  PRIVATE
+  ${ProtobufMutator_LIBRARIES}
+  ${LLVM_LIB_FUZZING_ENGINE}
+  clangHandleCXX
+  clangCXXProto
+  clangProtoToCXX
+  liblldb
+  )
+
+add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
+  COMMAND ${CMAKE_COMMAND} -E make_directory 

[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

This broke building of Clang, when it's set up by symlinking 
`llvm-project/clang` into `llvm-project/llvm/tools`. In that case, cmake 
configure errors out like this:

  -- Configuring done 
  CMake Error in tools/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt:
Target "clangHandleCXX" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
   
  
"/home/martin/code/llvm-project/llvm/tools/clang/tools/clang-fuzzer/handle-cxx/."
 
  
which is prefixed in the source directory.

See e.g. 
https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
 for some discussion on the issue.

Can we revert this commit until this has been sorted out?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

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


[Lldb-commits] [PATCH] D130045: Implement better path matching in FileSpecList::FindFileIndex(...).

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg abandoned this revision.
clayborg added a comment.

Abandoning since I am going to add FileSpecList::FindCompatibleIndex(...) which 
doesn't match the original description of this patch. I will submit a new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130045

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


[Lldb-commits] [PATCH] D130401: Implement better path matching in FileSpecList::FindCompatibleIndex(...).

2022-07-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, jingham, yinghuitan.
Herald added subscribers: arphaman, mgorny.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

Currently a FileSpecList::FindFileIndex(...) will only match the specified 
FileSpec if:

- it has filename and directory and both match exactly
- if has a filename only and any filename in the list matches

Because of this, we modify our breakpoint resolving so it can handle relative 
paths by doing some extra code that removes the directory from the FileSpec 
when searching if the path is relative.

This patch is intended to fix breakpoints so they work as users expect them to 
by adding the following features:

- allow matches to relative paths in the file list to match as long as the 
relative path is at the end of the specified path at valid directory delimiters
- allow matches to paths to match if the specified path is relative and shorter 
than the file paths in the list

This allows us to remove the extra logic from BreakpointResolverFileLine.cpp 
that added support for setting breakpoints with relative paths.

This means we can still set breakpoints with relative paths when the debug info 
contains full paths. We add the ability to set breakpoints with full paths when 
the debug info contains relative paths.

Debug info contains "./a/b/c/main.cpp", the following will set breakpoints 
successfully:

- /build/a/b/c/main.cpp
- a/b/c/main.cpp
- b/c/main.cpp
- c/main.cpp
- main.cpp
- ./c/main.cpp
- ./a/b/c/main.cpp
- ./b/c/main.cpp
- ./main.cpp

This also ensures that we won't match partial directory names, if a relative 
path is in the list or is used for the match, things must match at the 
directory level.

The breakpoint resolving code will now use the new 
FileSpecList::FindCompatibleIndex(...) function to allow this fuzzy matching to 
work for breakpoints.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130401

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Core/FileSpecList.h
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Core/FileSpecList.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Utility/FileSpec.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/relative.yaml
  lldb/unittests/Core/CMakeLists.txt
  lldb/unittests/Core/FileSpecListTest.cpp

Index: lldb/unittests/Core/FileSpecListTest.cpp
===
--- /dev/null
+++ lldb/unittests/Core/FileSpecListTest.cpp
@@ -0,0 +1,76 @@
+//===-- FileSpecListTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Core/FileSpecList.h"
+
+using namespace lldb_private;
+
+static FileSpec PosixSpec(llvm::StringRef path) {
+  return FileSpec(path, FileSpec::Style::posix);
+}
+
+// static FileSpec WindowsSpec(llvm::StringRef path) {
+//   return FileSpec(path, FileSpec::Style::windows);
+// }
+
+TEST(FileSpecListTest, RelativePathMatches) {
+
+  const FileSpec fullpath = PosixSpec("/build/src/main.cpp");
+  const FileSpec relative = PosixSpec("./src/main.cpp");
+  const FileSpec basename = PosixSpec("./main.cpp");
+  const FileSpec full_wrong = PosixSpec("/other/wrong/main.cpp");
+  const FileSpec rel_wrong = PosixSpec("./wrong/main.cpp");
+  // Make sure these don't match "src/main.cpp" as we want to match full
+  // directories only
+  const FileSpec rel2_wrong = PosixSpec("asrc/main.cpp");
+  const FileSpec rel3_wrong = PosixSpec("rc/main.cpp");
+
+  FileSpecList files;
+  files.Append(fullpath);
+  files.Append(relative);
+  files.Append(basename);
+  files.Append(full_wrong);
+  files.Append(rel_wrong);
+  files.Append(rel2_wrong);
+  files.Append(rel3_wrong);
+
+  // Make sure the full path only matches the first entry
+  EXPECT_EQ((size_t)0, files.FindCompatibleIndex(0, fullpath, /*full=*/true));
+  EXPECT_EQ((size_t)1, files.FindCompatibleIndex(1, fullpath, /*full=*/true));
+  EXPECT_EQ((size_t)2, files.FindCompatibleIndex(2, fullpath, /*full=*/true));
+  EXPECT_EQ((size_t)UINT32_MAX,
+files.FindCompatibleIndex(3, fullpath, /*full=*/true));
+  // Make sure the relative path matches the all of the entries that contain
+  // the relative path
+  EXPECT_EQ((size_t)0, files.FindCompatibleIndex(0, relative, /*full=*/true));
+  EXPECT_EQ((size_t)1, files.FindCompatibleIndex(1, relative, /*full=*/t

[Lldb-commits] [lldb] d959324 - Revert "[lldb/Fuzzer] Add fuzzer for expression evaluator"

2022-07-22 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-07-22T15:24:40-07:00
New Revision: d959324e1efec12c3924c17b7d90db0b37eb84c3

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

LOG: Revert "[lldb/Fuzzer] Add fuzzer for expression evaluator"

This reverts commit b797834748f1954950880bf50fb78abedd4494e6, since it
breaks building Clang: https://reviews.llvm.org/D129377

Added: 


Modified: 
clang/cmake/modules/ProtobufMutator.cmake
clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
lldb/tools/lldb-fuzzer/CMakeLists.txt

Removed: 
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp



diff  --git a/clang/cmake/modules/ProtobufMutator.cmake 
b/clang/cmake/modules/ProtobufMutator.cmake
index 071f11bc343de..15fe95ed6e8e9 100644
--- a/clang/cmake/modules/ProtobufMutator.cmake
+++ b/clang/cmake/modules/ProtobufMutator.cmake
@@ -1,9 +1,5 @@
 include(ExternalProject)
-
-if (NOT PBM_PREFIX)
-  set (PBM_PREFIX protobuf_mutator)
-endif()
-
+set(PBM_PREFIX protobuf_mutator)
 set(PBM_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PBM_PREFIX}/src/${PBM_PREFIX})
 set(PBM_LIB_PATH ${PBM_PATH}-build/src/libprotobuf-mutator.a)
 set(PBM_FUZZ_LIB_PATH 
${PBM_PATH}-build/src/libfuzzer/libprotobuf-mutator-libfuzzer.a)

diff  --git a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
index 469b88cb7de29..6d62421d9a69a 100644
--- a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
@@ -11,5 +11,3 @@ add_clang_library(clangHandleCXX
   clangSerialization
   clangTooling
   )
-
-target_include_directories(clangHandleCXX PUBLIC .)

diff  --git a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
index 45f51c9d8b54d..339959b81af0c 100644
--- a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
@@ -14,8 +14,6 @@ add_clang_library(clangLoopProtoToCXX loop_proto_to_cxx.cpp
   DEPENDS clangCXXLoopProto
   LINK_LIBS clangCXXLoopProto ${PROTOBUF_LIBRARIES}
   )
-target_include_directories(clangProtoToCXX PUBLIC .)
-target_include_directories(clangLoopProtoToCXX PUBLIC .)
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)
 add_clang_executable(clang-loop-proto-to-cxx loop_proto_to_cxx_main.cpp)

diff  --git a/lldb/tools/lldb-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/CMakeLists.txt
index 4c081a9de53e2..867a41961c13c 100644
--- a/lldb/tools/lldb-fuzzer/CMakeLists.txt
+++ b/lldb/tools/lldb-fuzzer/CMakeLists.txt
@@ -1,4 +1,3 @@
 add_subdirectory(lldb-commandinterpreter-fuzzer)
-add_subdirectory(lldb-expression-fuzzer)
 add_subdirectory(lldb-target-fuzzer)
 add_subdirectory(utils)

diff  --git a/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
deleted file mode 100644
index 40606f10cc711..0
--- a/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-if(CLANG_ENABLE_PROTO_FUZZER)
-  set(LLVM_LINK_COMPONENTS
-Support
-)
-
-  add_llvm_fuzzer(lldb-expression-fuzzer
-EXCLUDE_FROM_ALL
-lldb-expression-fuzzer.cpp
-)
-
-  if(TARGET lldb-expression-fuzzer)
-target_include_directories(lldb-expression-fuzzer PRIVATE ..)
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer
 PRIVATE ..)
-
-set(CLANG_CMAKE_MODULE_PATH
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
-
-set(CMAKE_MODULE_PATH
-  ${CMAKE_MODULE_PATH}
-  ${CLANG_CMAKE_MODULE_PATH})
-
-
-set (PBM_PREFIX lldb_protobuf_mutator)
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-target_link_libraries(lldb-expression-fuzzer
-  PRIVATE
-  ${ProtobufMutator_LIBRARIES}
-  ${LLVM_LIB_FUZZING_ENGINE}
-  clangHandleCXX
-  clangCXXProto
-  clangProtoToCXX
-  liblldb
-  )
-
-add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
-  COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts
-  # Create and compile a simple C program using the command line. This is
-  # needed because LLDB's expression evaluator needs a legitmate target
-  # instead of a dummy target
-  COMMAND echo 'int main (int argc, char** argv) { return 0\; }' | clang 
-o main.out -xc -
-  )

[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-22 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D129377#3673204 , @mstorsjo wrote:

> This broke building of Clang, when it's set up by symlinking 
> `llvm-project/clang` into `llvm-project/llvm/tools`. In that case, cmake 
> configure errors out like this:
>
>   -- Configuring done 
>   CMake Error in tools/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt:
> Target "clangHandleCXX" INTERFACE_INCLUDE_DIRECTORIES property contains
> path:
>
>   
> "/home/martin/code/llvm-project/llvm/tools/clang/tools/clang-fuzzer/handle-cxx/."
>  
>   
> which is prefixed in the source directory.
>
> See e.g. 
> https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
>  for some discussion on the issue.
>
> Can we revert this commit until this has been sorted out?

@mstorsjo I reverted Chelsea's patch in b797834748f1 
, since 
she's offline now. Do you have a link to a bot failure that would help us 
investigate the issue ?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

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


[Lldb-commits] [lldb] 3b8a1cc - [lldb] Disable TestGuiExpandThreadsTree

2022-07-22 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2022-07-22T16:00:51-07:00
New Revision: 3b8a1cc38ab72afe6889f3c1fff7c3deb8ac26ec

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

LOG: [lldb] Disable TestGuiExpandThreadsTree

Added: 


Modified: 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py

Removed: 




diff  --git 
a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
index 099bf3bb2ac1a..00a5d2673bfc3 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -16,39 +16,60 @@ class TestGuiExpandThreadsTree(PExpectTest):
 @skipIfAsan
 @skipIfCursesSupportMissing
 @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
+@skipIf(bugnumber="rdar://97460266")
 def test_gui(self):
 self.build()
 
+print(1)
 self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
+print(2)
 self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", 
"address ="])
+print(3)
 self.expect("run", substrs=["stop reason ="])
 
 escape_key = chr(27).encode()
 
 # Start the GUI and close the welcome window.
+print(4)
 self.child.sendline("gui")
+print(5)
 self.child.send(escape_key)
+print(6)
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
+
+print(7)
 self.child.expect_exact("#0: break_here")
 
 # Exit GUI.
+
+print(8)
 self.child.send(escape_key)
+print(9)
 self.expect_prompt()
 
 # Select the main thread.
+print(10)
 self.child.sendline("thread select 1")
 
 # Start the GUI.
+print(11)
 self.child.sendline("gui")
+print(12)
 self.child.expect_exact("Threads")
 
 # The main thread should be expanded.
+
+print(13)
 self.child.expect("#\d+: main")
 
 # Quit the GUI
+print(14)
 self.child.send(escape_key)
 
+print(15)
 self.expect_prompt()
+
+print(16)
 self.quit()



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


[Lldb-commits] [lldb] c18304e - [lldb] Remote accidental logs left in TestGuiExpandThreadsTree

2022-07-22 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2022-07-22T16:06:49-07:00
New Revision: c18304e60067b904941fbcfb3ca1649798b242f6

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

LOG: [lldb] Remote accidental logs left in TestGuiExpandThreadsTree

Added: 


Modified: 
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py

Removed: 




diff  --git 
a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
index 00a5d2673bfc..2dfdd6865cd9 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -20,56 +20,36 @@ class TestGuiExpandThreadsTree(PExpectTest):
 def test_gui(self):
 self.build()
 
-print(1)
 self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
-print(2)
 self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", 
"address ="])
-print(3)
 self.expect("run", substrs=["stop reason ="])
 
 escape_key = chr(27).encode()
 
 # Start the GUI and close the welcome window.
-print(4)
 self.child.sendline("gui")
-print(5)
 self.child.send(escape_key)
-print(6)
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
-
-print(7)
 self.child.expect_exact("#0: break_here")
 
 # Exit GUI.
-
-print(8)
 self.child.send(escape_key)
-print(9)
 self.expect_prompt()
 
 # Select the main thread.
-print(10)
 self.child.sendline("thread select 1")
 
 # Start the GUI.
-print(11)
 self.child.sendline("gui")
-print(12)
 self.child.expect_exact("Threads")
 
 # The main thread should be expanded.
-
-print(13)
 self.child.expect("#\d+: main")
 
 # Quit the GUI
-print(14)
 self.child.send(escape_key)
 
-print(15)
 self.expect_prompt()
-
-print(16)
 self.quit()



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


[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

Still broken on windows for me: http://45.33.8.238/win/62911/step_4.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130403: Use the range-based overload of llvm::sort where possible

2022-07-22 Thread Dmitri Gribenko via Phabricator via lldb-commits
gribozavr created this revision.
Herald added subscribers: carlosgalvezp, cishida, cmtice, usaxena95, kadircet, 
arphaman, mgrang.
Herald added a reviewer: jhenderson.
Herald added a reviewer: aaron.ballman.
Herald added a reviewer: ributzka.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, lldb-commits, MaskRay.
Herald added projects: clang, LLDB, LLVM, clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130403

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clangd/index/StdLib.cpp
  clang/include/clang/Basic/Attr.td
  clang/lib/Driver/Multilib.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Symbol/ArmUnwindInfo.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/source/Utility/Timer.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/unittests/ADT/SmallPtrSetTest.cpp
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -125,9 +125,9 @@
   Sym->isReexported() ? Reexports.emplace_back(std::move(temp))
   : Exports.emplace_back(std::move(temp));
   }
-  llvm::sort(Exports.begin(), Exports.end());
-  llvm::sort(Reexports.begin(), Reexports.end());
-  llvm::sort(Undefineds.begin(), Undefineds.end());
+  llvm::sort(Exports);
+  llvm::sort(Reexports);
+  llvm::sort(Undefineds);
 
   static ExportedSymbol ExpectedExportedSymbols[] = {
   {SymbolKind::GlobalSymbol, "_symA", false, false},
@@ -296,9 +296,9 @@
   Sym->isReexported() ? Reexports.emplace_back(std::move(Temp))
   : Exports.emplace_back(std::move(Temp));
   }
-  llvm::sort(Exports.begin(), Exports.end());
-  llvm::sort(Reexports.begin(), Reexports.end());
-  llvm::sort(Undefineds.begin(), Undefineds.end());
+  llvm::sort(Exports);
+  llvm::sort(Reexports);
+  llvm::sort(Undefineds);
 
   static ExportedSymbol ExpectedExportedSymbols[] = {
   {SymbolKind::GlobalSymbol, "_symA", false, false},
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -111,7 +111,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
@@ -203,7 +203,7 @@
 Sym->isWeakDefined(),
 Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
@@ -228,7 +228,7 @@
 Sym->isWeakDefined(),
 Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   ExportedSymbolSeq DocumentSymbols{
   {SymbolKind::GlobalSymbol, "_sym5", false, false},
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -103,7 +103,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined(), Sym->isThreadLocalValue()});
   }
-  llvm::sort(Exports.begin(), Exports.end());
+  llvm::sort(Exports);
 
   EXPECT_EQ(sizeof(TBDv2Symbols) / sizeof(ExportedSymbol), Exports.size());
   EXPECT_TRUE(
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV1Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV1Tests.cpp
@@ -102,7 +102,7 @@
 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
Sym->isWeakDefined()

[Lldb-commits] [PATCH] D130309: [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.

2022-07-22 Thread Shoaib Meenai via Phabricator via lldb-commits
smeenai added a comment.

In D130309#3673365 , @thakis wrote:

> Still broken on windows for me: http://45.33.8.238/win/62911/step_4.txt

Seeing the same errors here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130309

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


[Lldb-commits] [PATCH] D130320: Move GetControlFlowKind's logic to DisassemblerLLVMC.cpp

2022-07-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Just one more change and good to go




Comment at: lldb/include/lldb/Core/Disassembler.h:87
+  virtual lldb::InstructionControlFlowKind
+  GetControlFlowKind(const ExecutionContext *exe_ctx) = 0;
 

could add a default implementation here? 

 {
return lldb::eInstructionControlFlowKindUnknown;
  }

that way you won't break any other class that extends Instruction.


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

https://reviews.llvm.org/D130320

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


[Lldb-commits] [PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D129377#3673237 , @mib wrote:

> In D129377#3673204 , @mstorsjo 
> wrote:
>
>> This broke building of Clang, when it's set up by symlinking 
>> `llvm-project/clang` into `llvm-project/llvm/tools`. In that case, cmake 
>> configure errors out like this:
>>
>>   -- Configuring done 
>>   CMake Error in tools/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt:
>> Target "clangHandleCXX" INTERFACE_INCLUDE_DIRECTORIES property contains
>> path:
>>
>>   
>> "/home/martin/code/llvm-project/llvm/tools/clang/tools/clang-fuzzer/handle-cxx/."
>>  
>>   
>> which is prefixed in the source directory.
>>
>> See e.g. 
>> https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
>>  for some discussion on the issue.
>>
>> Can we revert this commit until this has been sorted out?
>
> @mstorsjo I reverted Chelsea's patch in b797834748f1 
> , since 
> she's offline now. Do you have a link to a bot failure that would help us 
> investigate the issue ?
>
> Thanks!

Thanks!

It’s not on a public buildbot but only in my local continuous builds 
unfortunately - but I’ll have look at the issue myself today - I was running 
out of time yesterday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

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