[Lldb-commits] [lldb] e87b8e4 - [lldb] Log the actual expression result in UserExpression::Evaluate

2021-02-11 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-11T16:15:01+01:00
New Revision: e87b8e4498df3bc1fcb751dfa24816ecf1ac02bd

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

LOG: [lldb] Log the actual expression result in UserExpression::Evaluate

This used to be a LLDB_LOGF call that used the printf %s syntax.
0ab109d43d9d8389fe686ee8df4a82634f246b55 changed it to LLDB_LOG but didn't
update this format string to use formatv's syntax so this just printed '%s'.

Added: 


Modified: 
lldb/source/Expression/UserExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index 5beed4657b37..c6a288a30b17 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -362,7 +362,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
   LLDB_LOG(log,
"== [UserExpression::Evaluate] Execution completed "
-   "normally with result %s ==",
+   "normally with result {0} ==",
result_valobj_sp->GetValueAsCString());
 } else {
   LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "



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


[Lldb-commits] [PATCH] D96458: [LLDB] Add support for Arm64/Linux dynamic register sets

2021-02-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:454
 bool NativeRegisterContextLinux_arm64::IsSVE(unsigned reg) const {
-  if (GetRegisterInfo().GetRegisterSetFromRegisterIndex(reg) ==
-  RegisterInfoPOSIX_arm64::SVERegSet)
+  if (GetRegisterInfo().IsSVEReg(reg))
 return true;

`return GetRegisterInfo().IsSVEReg(reg)` ?



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:1120
+  GetRegisterInfo().ConfigureVectorLength(vq);
   m_sve_ptrace_payload.resize(SVE_PT_SIZE(vq, SVE_PT_REGS_SVE));
 }

I spent a good few minutes getting my head around this logic but tell me if I 
missed something. (a comment explaining it would be great)

* If we don't have a cached sve header and we don't know that SVE is disabled...
* Try to read the SVE header
* if it succeeded and we're doing this read for the first time, setup register 
infos
* otherwise it failed so SVE must be disabled
* if it succeeded (first time or otherwise) query the vector length (this is 
the bit that tripped me up trying to think how you'd refactor it)
* if we did have a cached sve header, we'd already know the config, no point 
reading it again
* if it's disabled, then it's disabled, same thing.

I think that means you're missing the corner case where we have SVEState::Full 
say, but then the header fails to read. Is that possible on a real system 
though? I guess not.

And vector length can change at runtime, correct?



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp:43
 bool RegisterContextPOSIX_arm64::IsSVE(unsigned reg) const {
-  if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg) ==
-  RegisterInfoPOSIX_arm64::SVERegSet)
+  if (m_register_info_up->IsSVEReg(reg))
 return true;

`return m_register_info_up->IsSVEReg(reg);` ?



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:243
+  for (const auto ®set_range : m_per_regset_regnum_range) {
+if (reg_index >= regset_range.second.first &&
+reg_index <= regset_range.second.second)

Should the last condition be  ARM64_REGS_CONFIG_SVE) {

Comments here would really help. 



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h:93
+
+  uint32_t ConfigureVectorLength(uint32_t mode);
 

Just curious, is "mode" the term we use for the SVE length? I guess because 
it's going to be some multiples of 128 isn't it, not an arbitrary bit length.


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

https://reviews.llvm.org/D96458

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


[Lldb-commits] [PATCH] D96459: [LLDB] Pull AuxVec info into NativeRegisterContextLinux_arm64

2021-02-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:104
+
+  return 0;
+}

Do I understand correctly that this will be filled in in a further patch? So 
right now it's only returning 0 because it's not hooked up yet.
For the sake of clean patches I'd rather it just returned 0, then put the rest 
of the work in the follow up.


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

https://reviews.llvm.org/D96459

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


[Lldb-commits] [PATCH] D94307: [lldb] Don't emit a warning when using Objective-C getters in expressions

2021-02-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19b4d3ce27d5: [lldb] Don't emit a warning when using 
Objective-C getters in expressions (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D94307?vs=315389&id=323018#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94307

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
  
lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
  lldb/test/API/lang/objc/warnings-in-expr-parser/main.m


Index: lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
===
--- /dev/null
+++ lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
@@ -0,0 +1,15 @@
+#include 
+
+@interface MyClass : NSObject
+@property int m;
+@end
+
+@implementation MyClass {
+}
+@end
+
+int main() {
+  MyClass *m = [[MyClass alloc] init];
+  m.m;
+  return 0; // break here
+}
Index: 
lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
===
--- /dev/null
+++ 
lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
@@ -0,0 +1,23 @@
+"""
+Test the warnings that LLDB emits when parsing Objective-C expressions.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@no_debug_info_test
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))
+
+# Don't warn about not using the result of getters. This is perfectly
+# fine in the expression parser and LLDB shouldn't warn the user about 
that.
+result = self.frame().EvaluateExpression("m.m; 
unknown_var_to_cause_an_error")
+self.assertNotIn("getters should not", str(result.GetError()))
Index: lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -framework Foundation
+CFLAGS_EXTRAS := -fobjc-arc
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -343,6 +343,7 @@
   const std::vector groupsToIgnore = {
   "unused-value",
   "odr",
+  "unused-getter-return-value",
   };
   for (const char *group : groupsToIgnore) {
 compiler.getDiagnostics().setSeverityForGroup(


Index: lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
===
--- /dev/null
+++ lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
@@ -0,0 +1,15 @@
+#include 
+
+@interface MyClass : NSObject
+@property int m;
+@end
+
+@implementation MyClass {
+}
+@end
+
+int main() {
+  MyClass *m = [[MyClass alloc] init];
+  m.m;
+  return 0; // break here
+}
Index: lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
===
--- /dev/null
+++ lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
@@ -0,0 +1,23 @@
+"""
+Test the warnings that LLDB emits when parsing Objective-C expressions.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@no_debug_info_test
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+# Don't warn about not using the result of getters. This is perfectly
+# fine in the expression parser and LLDB shouldn't warn the user about that.
+result = self.frame().EvaluateExpression("m.m; unknown_var_to_cause_an_error")
+self.assertNotIn("getters should not", str(result.GetError()))
Index: lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -framework Foundation
+CFLAGS_EXTRAS := -fobjc-arc
+
+include Makefile.rules
Index: lldb/source

[Lldb-commits] [lldb] 19b4d3c - [lldb] Don't emit a warning when using Objective-C getters in expressions

2021-02-11 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-11T16:48:41+01:00
New Revision: 19b4d3ce27d5c8ed19bf08cdceb4c03608d2c66d

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

LOG: [lldb] Don't emit a warning when using Objective-C getters in expressions

Clang emits a warning when accessing an Objective-C getter but not using the 
result.
This gets triggered when just trying to print a getter value in the expression 
parser (where
Clang just sees a normal expression like `obj.getter` while parsing).

This patch just disables the warning in the expression parser (similar to what 
we do with
the C++ equivalent of just accessing a member variable but not doing anything 
with it).

Reviewed By: kastiglione

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

Added: 
lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile

lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
lldb/test/API/lang/objc/warnings-in-expr-parser/main.m

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 7644a5e1423e..0f3d36cec937 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -343,6 +343,7 @@ static void SetupDefaultClangDiagnostics(CompilerInstance 
&compiler) {
   const std::vector groupsToIgnore = {
   "unused-value",
   "odr",
+  "unused-getter-return-value",
   };
   for (const char *group : groupsToIgnore) {
 compiler.getDiagnostics().setSeverityForGroup(

diff  --git a/lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile 
b/lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
new file mode 100644
index ..2f74200fd6f1
--- /dev/null
+++ b/lldb/test/API/lang/objc/warnings-in-expr-parser/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -framework Foundation
+CFLAGS_EXTRAS := -fobjc-arc
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
 
b/lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
new file mode 100644
index ..b0b52cbdab76
--- /dev/null
+++ 
b/lldb/test/API/lang/objc/warnings-in-expr-parser/TestObjCWarningsInExprParser.py
@@ -0,0 +1,23 @@
+"""
+Test the warnings that LLDB emits when parsing Objective-C expressions.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@no_debug_info_test
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))
+
+# Don't warn about not using the result of getters. This is perfectly
+# fine in the expression parser and LLDB shouldn't warn the user about 
that.
+result = self.frame().EvaluateExpression("m.m; 
unknown_var_to_cause_an_error")
+self.assertNotIn("getters should not", str(result.GetError()))

diff  --git a/lldb/test/API/lang/objc/warnings-in-expr-parser/main.m 
b/lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
new file mode 100644
index ..8d7193304e54
--- /dev/null
+++ b/lldb/test/API/lang/objc/warnings-in-expr-parser/main.m
@@ -0,0 +1,15 @@
+#include 
+
+@interface MyClass : NSObject
+@property int m;
+@end
+
+@implementation MyClass {
+}
+@end
+
+int main() {
+  MyClass *m = [[MyClass alloc] init];
+  m.m;
+  return 0; // break here
+}



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


[Lldb-commits] [lldb] 71536fd - [lldb] Fix that running a top level expression without a process fails with a cryptic error

2021-02-11 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-11T17:07:11+01:00
New Revision: 71536fd031084b25ffc9ad0a26c8471a68f5ad7c

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

LOG: [lldb] Fix that running a top level expression without a process fails 
with a cryptic error

Right now when running `expr --top-level -- void foo() {}`, LLDB just prints a 
cryptic
`error: Couldn't find $__lldb_expr() in the module` error. The reason for that 
is
that if we don't have a running process, we try to set our execution policy to 
always use the
IR interpreter (ExecutionPolicyNever) which works even without a process. 
However
that code didn't consider the special ExecutionPolicyTopLevel which we use for
top-level expressions. By changing the execution policy to ExecutionPolicyNever,
LLDB thinks we're actually trying to interpret a normal expression inside our
`$__lldb_expr` function and then fails when looking for it.

This just adds an exception for top-level expressions to that code and a bunch 
of tests.

Reviewed By: shafik

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

Added: 


Modified: 
lldb/source/Expression/UserExpression.cpp

lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py

Removed: 




diff  --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index c6a288a30b17..25931b1232b4 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -187,7 +187,12 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 }
   }
 
-  if (process == nullptr || !process->CanJIT())
+  // Explicitly force the IR interpreter to evaluate the expression when the
+  // there is no process that supports running the expression for us. Don't
+  // change the execution policy if we have the special top-level policy that
+  // doesn't contain any expression and there is nothing to interpret.
+  if (execution_policy != eExecutionPolicyTopLevel &&
+  (process == nullptr || !process->CanJIT()))
 execution_policy = eExecutionPolicyNever;
 
   // We need to set the expression execution thread here, turns out parse can

diff  --git 
a/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
 
b/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
index 6abdb226be29..60a005f10280 100644
--- 
a/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
+++ 
b/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
@@ -31,3 +31,8 @@ def test_failing_init(self):
 # FIXME: This error message is not even remotely helpful.
 self.expect("expr -p -- struct Foo2 { Foo2() { do_abort(); } }; Foo2 
f;", error=True,
 substrs=["error: couldn't run static initializer:"])
+
+def test_without_process(self):
+""" Test a static initializer without a running process. """
+self.expect("expr -p -- int i = 0; struct Foo3 { Foo3() { ++i; } }; 
Foo3 f;", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])

diff  --git a/lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py 
b/lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
index 4e1a3779cfc3..92707eabec0c 100644
--- a/lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
+++ b/lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
@@ -91,3 +91,14 @@ def test_top_level_expressions(self):
 self.assertEqual(
 resultFromCode,
 resultFromTopLevel.GetValueAsUnsigned())
+
+def test_top_level_expression_without_target(self):
+self.expect("expr --top-level -- void func() {}", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
+
+# FIXME: This doesn't actually generate any code, so LLDB should 
probably
+# allow these expressions.
+self.expect("expr --top-level -- template struct StructT { 
T m; };", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
+self.expect("expr --top-level -- struct Struct { int i; };", 
error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])

diff  --git a/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py 
b/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
index 395ba30b5454..97670ec263e5 100644
--- a/lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
+++ b/lldb/test/API/lang/cpp/elaborated

[Lldb-commits] [PATCH] D91723: [lldb] Fix that running a top level expression without a process fails with a cryptic error

2021-02-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71536fd03108: [lldb] Fix that running a top level expression 
without a process fails with a… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91723

Files:
  lldb/source/Expression/UserExpression.cpp
  
lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
  lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
  lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py


Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -34,7 +34,7 @@
 # Declare a template that can actually be instantiated.
 # FIXME: The error message here is incorrect.
 self.expect("expr --top-level -- template struct $V {};",
-error=True, substrs=["Couldn't find $__lldb_expr() in the 
module"])
+error=True, substrs=["Top-level code needs to be inserted 
into a runnable target"])
 result = self.expect_expr("$V<::Struct> s; s",
   result_type="$V< ::Struct>")
 self.assertEqual(result.GetTypeName(), "$V")
Index: lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
===
--- lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
+++ lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
@@ -91,3 +91,14 @@
 self.assertEqual(
 resultFromCode,
 resultFromTopLevel.GetValueAsUnsigned())
+
+def test_top_level_expression_without_target(self):
+self.expect("expr --top-level -- void func() {}", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
+
+# FIXME: This doesn't actually generate any code, so LLDB should 
probably
+# allow these expressions.
+self.expect("expr --top-level -- template struct StructT { 
T m; };", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
+self.expect("expr --top-level -- struct Struct { int i; };", 
error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
Index: 
lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
===
--- 
lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
+++ 
lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
@@ -31,3 +31,8 @@
 # FIXME: This error message is not even remotely helpful.
 self.expect("expr -p -- struct Foo2 { Foo2() { do_abort(); } }; Foo2 
f;", error=True,
 substrs=["error: couldn't run static initializer:"])
+
+def test_without_process(self):
+""" Test a static initializer without a running process. """
+self.expect("expr -p -- int i = 0; struct Foo3 { Foo3() { ++i; } }; 
Foo3 f;", error=True,
+substrs=["Top-level code needs to be inserted into a 
runnable target"])
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -187,7 +187,12 @@
 }
   }
 
-  if (process == nullptr || !process->CanJIT())
+  // Explicitly force the IR interpreter to evaluate the expression when the
+  // there is no process that supports running the expression for us. Don't
+  // change the execution policy if we have the special top-level policy that
+  // doesn't contain any expression and there is nothing to interpret.
+  if (execution_policy != eExecutionPolicyTopLevel &&
+  (process == nullptr || !process->CanJIT()))
 execution_policy = eExecutionPolicyNever;
 
   // We need to set the expression execution thread here, turns out parse can


Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -34,7 +34,7 @@
 # Declare a template that can actually be instantiated.
 # FIXME: The error message here is incorrect.
 self.expect("expr --top-level -- template struct $V {};",
-error=True, substrs=["Couldn't find $__lldb_expr() in the module"])
+error=True, substrs=["Top-level code need

[Lldb-commits] [PATCH] D96463: [LLDB] Arm64/Linux test case for MTE and Pointer Authentication regset

2021-02-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added inline comments.



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:35
+
+p_value_bytes = ['0xff', '0x55', '0x11', '0x01', '0x00']
+for i in range(16):

Can you explain the logic for the values here?



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:39
+' '.join(p_value_bytes[i % 5] for _ in range(p_reg_size)) + '}'
+self.expect("register read " + 'p%i' % (i), substrs=[p_regs_value])
+

You don't need the brackets around i for `% (i)`.



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:49
+
+for i in range(32):
+self.runCmd('register write ' + 'z%i' %

Is it slightly more strict if we have one loop that reads then writes?
```
for i in range(32):
   write
   read
```

Since we write the same value, if you write them all then read them all you 
aren't totally sure that each one is lined up right. Then again I'm sure you've 
tested sve register writes elsewhere.

Anyway, a single loop for each would be a bit neater.



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:111
+
+if not self.isAArch64SVE() and sve_regset_available:
+self.fail(

If you move all this code from after the for, into the for loop, you could skip 
having the bools per register set.



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c:14
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");

(I'm not familiar with SVE assembly but anyway..)

Is the .b/.h/.s etc. pattern specific or does it not matter?



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c:31-32
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");

Same here, is the p0/p5/p10/p15 pattern affecting values used in the test or 
just for fun? (which isn't a bad thing)



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c:68
+  unsigned int mte_is_enabled = 0;
+  unsigned int pauth_is_enabled = 0;
+

This appears to be defined but not set.



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c:73
+
+  if (hwcap & HWCAP_SVE) // check if SVE is present
+set_sve_registers();

Should there be a `#ifndef HWCAP_SVE` above too?



Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c:82
+  if (hwcap2 & HWCAP2_MTE)
+mte_is_enabled = 1;
+

Would be neat to do these vars like:
```
unsigned int mte_is_enabled = hwcap2 & HWCAP2_MTE;
```


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

https://reviews.llvm.org/D96463

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


[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-11 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It looks like this change resulted in a failing test on the Windows LLDB bot:

http://lab.llvm.org:8011/#/builders/83/builds/3602

It seems like one of the tests is trying to re-use the same log names within a 
single run and they are still being used by the previous instance from the same 
test run. Can you have a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

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


[Lldb-commits] [lldb] ed98676 - Support multi-configuration generators correctly in several config files

2021-02-11 Thread Stella Stamenova via lldb-commits

Author: Stella Stamenova
Date: 2021-02-11T09:32:20-08:00
New Revision: ed98676fa4833bb80632fc7c9db10c3328d78485

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

LOG: Support multi-configuration generators correctly in several config files

Multi-configuration generators (such as Visual Studio and Xcode) allow the 
specification of a build flavor at build time instead of config time, so the 
lit configuration files need to support that - and they do for the most part. 
There are several places that had one of two issues (or both!):

1) Paths had %(build_mode)s set up, but then not configured, resulting in 
values that would not work correctly e.g. 
D:/llvm-build/%(build_mode)s/bin/dsymutil.exe
2) Paths did not have %(build_mode)s set up, but instead contained 
$(Configuration) (which is the value for Visual Studio at configuration time, 
for Xcode they would have had the equivalent) e.g. 
"D:/llvm-build/$(Configuration)/lib".

This seems to indicate that we still have a lot of fragility in the 
configurations, but also that a number of these paths are never used (at least 
on Windows) since the errors appear to have been there a while.

This patch fixes the configurations and it has been tested with Ninja and 
Visual Studio to generate the correct paths. We should consider removing some 
of these settings altogether.

Reviewed By: JDevlieghere, mehdi_amini

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

Added: 


Modified: 
clang/test/Unit/lit.site.cfg.py.in
lld/test/CMakeLists.txt
lld/test/Unit/lit.site.cfg.py.in
lld/test/lit.site.cfg.py.in
lldb/test/API/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/CMakeLists.txt
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in
mlir/examples/standalone/test/lit.site.cfg.py.in
mlir/integration_test/lit.site.cfg.py.in
mlir/test/Unit/lit.site.cfg.py.in
mlir/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index ad5e6d0c8b2a..3edab4473dc4 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -19,6 +19,7 @@ try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.shlibdir = config.shlibdir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index ce0bcaa9203d..b2543901b757 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -1,8 +1,11 @@
-set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
-set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
-set(LLVM_BUILD_MODE "%(build_mode)s")
-set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
-set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
+if (CMAKE_CFG_INTDIR STREQUAL ".")
+  set(LLVM_BUILD_MODE ".")
+else ()
+  set(LLVM_BUILD_MODE "%(build_mode)s")
+endif ()
+
+string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLD_LIBS_DIR 
"${LLVM_LIBRARY_OUTPUT_INTDIR}")
+string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLD_TOOLS_DIR 
"${LLVM_RUNTIME_OUTPUT_INTDIR}")
 
 llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_ZLIB

diff  --git a/lld/test/Unit/lit.site.cfg.py.in 
b/lld/test/Unit/lit.site.cfg.py.in
index d96e20f11d0a..65d9f9d85935 100644
--- a/lld/test/Unit/lit.site.cfg.py.in
+++ b/lld/test/Unit/lit.site.cfg.py.in
@@ -8,8 +8,8 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_src_root = "@LLD_SOURCE_DIR@"
-config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
-config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
+config.lld_libs_dir = "@LLD_LIBS_DIR@"
+config.lld_tools_dir = "@LLD_TOOLS_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 
@@ -19,6 +19,8 @@ try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.lld_libs_dir = config.lld_libs_dir % lit_config.params
+config.lld_tools_dir = config.lld_tools_dir % lit_config.params
 except KeyError as e:
 key, = e.args
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index a4e00b9dac93..a140284e0ded 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -9,8 +9,8 @@ config.llvm_tool

[Lldb-commits] [PATCH] D96194: Defer the decision whether to use the CU or TU index until after reading the unit header.

2021-02-11 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:808-809
 
+  if (cu_index && (header.m_unit_type == llvm::dwarf::DW_UT_compile ||
+   header.m_unit_type == llvm::dwarf::DW_UT_split_compile)) {
+header.m_index_entry = cu_index->getFromOffset(header.m_offset);

labath wrote:
> I guess this could be `header.IsTypeUnit()` (and `!header.IsTypeUnit())`)...
But `!header.IsTypeUnit` would also treat DW_UT_partial and DW_UT_skeleton as 
compile units, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96194

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


[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-11 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D96202#2557365 , @stella.stamenova 
wrote:

> It looks like this change resulted in a failing test on the Windows LLDB bot:
>
> http://lab.llvm.org:8011/#/builders/83/builds/3602
>
> It seems like one of the tests is trying to re-use the same log names within 
> a single run and they are still being used by the previous instance from the 
> same test run. Can you have a look?

I don't understand yet what is going on, but it does seem like this patch is to 
blame. I'll revert while I try to understand this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

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


[Lldb-commits] [lldb] 3cad308 - Revert "[lldb/test] Automatically find debug servers to test"

2021-02-11 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-02-11T20:26:05+01:00
New Revision: 3cad308ce5d9eb2cc52f43ccef68f3d2b12f2a32

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

LOG: Revert "[lldb/test] Automatically find debug servers to test"

The commit 7df4eaaa937332c0617aa665080533966e2c98a0 appears to
break the windows bot. Revert while I investigate.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
lldb/test/API/CMakeLists.txt
lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
lldb/test/API/lit.site.cfg.py.in
lldb/utils/lldb-dotest/CMakeLists.txt
lldb/utils/lldb-dotest/lldb-dotest.in

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 945b3f0c20a4..62508a144972 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -366,6 +366,12 @@ def parseOptionsAndInitTestdirs():
 args.executable)
 sys.exit(-1)
 
+if args.server and args.out_of_tree_debugserver:
+logging.warning('Both --server and --out-of-tree-debugserver are set')
+
+if args.server and not args.out_of_tree_debugserver:
+os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
+
 if args.excluded:
 for excl_file in args.excluded:
 parseExclusion(excl_file)

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index af45205ae3ed..4774ce352fc2 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -100,6 +100,10 @@ def create_parser():
 '--executable',
 metavar='executable-path',
 help='The path to the lldb executable')
+group.add_argument(
+'--server',
+metavar='server-path',
+help='The path to the debug server executable to use')
 group.add_argument(
 '--out-of-tree-debugserver',
 dest='out_of_tree_debugserver',

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index eba6f322db9b..07136108b2a4 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -15,12 +15,54 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import configuration
 from textwrap import dedent
-import shutil
 
-def _get_support_exe(basename):
-support_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir)
+def _get_debug_monitor_from_lldb(lldb_exe, debug_monitor_basename):
+"""Return the debug monitor exe path given the lldb exe path.
 
-return shutil.which(basename, path=support_dir.GetDirectory())
+This method attempts to construct a valid debug monitor exe name
+from a given lldb exe name.  It will return None if the synthesized
+debug monitor name is not found to exist.
+
+The debug monitor exe path is synthesized by taking the directory
+of the lldb exe, and replacing the portion of the base name that
+matches "lldb" (case insensitive) and replacing with the value of
+debug_monitor_basename.
+
+Args:
+lldb_exe: the path to an lldb executable.
+
+debug_monitor_basename: the base name portion of the debug monitor
+that will replace 'lldb'.
+
+Returns:
+A path to the debug monitor exe if it is found to exist; otherwise,
+returns None.
+
+"""
+if not lldb_exe:
+return None
+
+exe_dir = os.path.dirname(lldb_exe)
+exe_base = os.path.basename(lldb_exe)
+
+# we'll rebuild the filename by replacing lldb with
+# the debug monitor basename, keeping any prefix or suffix in place.
+regex = re.compile(r"lldb", re.IGNORECASE)
+new_base = regex.sub(debug_monitor_basename, exe_base)
+
+debug_monitor_exe = os.path.join(exe_dir, new_base)
+if os.path.exists(debug_monitor_exe):
+return debug_monitor_exe
+
+new_base = regex.sub(
+'LLDB.framework/Versions/A/Resources/' +
+debug_monitor_basename,
+exe_base)
+debug_monitor_exe = os.path.join(exe_dir, new_base)
+if os.path.exists(debug_monitor_exe):
+return debug_monitor_exe
+
+return None
 
 
 def get_lldb_server_exe():
@@ -30,8 +72,11 @@ def get_lldb_server_exe():
 A path to the lldb-server exe if it is found to exist; otherwise,
 returns None.
 """
+if "LLDB_DEBUGSERVER_PATH

[Lldb-commits] [PATCH] D93951: [vscode] Improve runInTerminal and support linux

2021-02-11 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added inline comments.



Comment at: lldb/tools/lldb-vscode/FifoFiles.cpp:9
+
+#if !defined(WIN32)
+#include 

mstorsjo wrote:
> stella.stamenova wrote:
> > Also, this is no good. It works if you are targeting windows on windows, 
> > but not if you are targeting something else and building on windows. There 
> > are a few different ways this is done in LLVM/clang and they are generally 
> > not based on defined(WIN32). Here are a couple of examples:
> > 
> > From llvm\lib\Support\Path.cpp:
> > 
> > ```
> > #if !defined(_MSC_VER) && !defined(__MINGW32__)
> > ```
> > 
> > From clang\lib\Driver\Driver.cpp:
> > 
> > ```
> > #if LLVM_ON_UNIX
> > ```
> > 
> > From llvm\lib\Support\ErrorHandling.cpp:
> > 
> > ```
> > #if defined(HAVE_UNISTD_H)
> > ```
> > 
> > I suggest browsing through the code and finding the most appropriate way to 
> > manage your includes. In the mean time, this is breaking our internal 
> > builds that run on Windows but do not target Windows.
> @stella.stamenova `defined(WIN32)` shouldn't be used (as that isn't 
> predefined by the compiler), but `defined(_WIN32)` should be just fine (and 
> is used a lot within LLDB already, 176 occurrances). If cross compiling on 
> windows, targeting another os, neither of them should be defined, so it 
> should be just fine, no?
> 
> Or is this a case of cygwin, where the lines are blurred even more?
> 
> Does the current main branch work fine for you?
`defined(_WIN32)` is fine for us, since we build on Windows (and not cygwin). I 
have not tried the lldb-vscode build on cygwin, so that may or may not work 
with the current setup.

In general, there are too many ways in LLVM to achieve the same 
excludes/includes right now and the lack of unity is only creating issues and 
confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93951

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


[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, teemperor, shafik.
Herald added a subscriber: emaste.
aprantl requested review of this revision.

The comment for ValueType claims that all values <1 are errors, but not all 
switch statements take this into account. This patch introduces an explicit 
Error case and deletes all `default:` cases, so we get warned about incomplete 
switch coverage.


https://reviews.llvm.org/D96537

Files:
  lldb/include/lldb/Core/Value.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectChild.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectConstResultImpl.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/DataFormatters/TypeFormat.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
  lldb/source/Target/ABI.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -34,9 +34,9 @@
 return status.ToError();
 
   switch (result.GetValueType()) {
-  case Value::eValueTypeScalar:
+  case Value::ValueType::Scalar:
 return result.GetScalar();
-  case Value::eValueTypeHostAddress: {
+  case Value::ValueType::HostAddress: {
 // Convert small buffers to scalars to simplify the tests.
 DataBufferHeap &buf = result.GetBuffer();
 if (buf.GetByteSize() <= 8) {
Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -191,7 +191,7 @@
 
 for (int arg_index = 0; arg_index < num_args; ++arg_index) {
   Value value;
-  value.SetValueType(Value::eValueTypeScalar);
+  value.SetValueType(Value::ValueType::Scalar);
   value.SetCompilerType(intptr_type);
   value_list.PushValue(value);
 }
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -1521,7 +1521,7 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
 Value cfa_val = Scalar(m_cfa);
-cfa_val.SetValueType(Value::eValueTypeLoadAddress);
+cfa_val.SetValueType(Value::ValueType::LoadAddress);
 Value result;
 Status error;
 if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -120,11 +120,11 @@
 const Value &result_value = live_valobj_sp->GetValue();
 
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:
   // we don't do anything with these for now
   break;
-case Value::eValueTypeScalar:
+case Value::ValueType::Scalar:
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsFreezeDried;
   expr_variable_sp->m_flags |=
@@ -132,7 +132,7 @@
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVNeedsAllocation;
  

[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 323119.
aprantl added a comment.

Phabricator got really confused by the diff context. Reposting without context.


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

https://reviews.llvm.org/D96537

Files:
  lldb/include/lldb/Core/Value.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectChild.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectConstResultImpl.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/DataFormatters/TypeFormat.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
  lldb/source/Target/ABI.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -34,9 +34,9 @@
 return status.ToError();
 
   switch (result.GetValueType()) {
-  case Value::eValueTypeScalar:
+  case Value::ValueType::Scalar:
 return result.GetScalar();
-  case Value::eValueTypeHostAddress: {
+  case Value::ValueType::HostAddress: {
 // Convert small buffers to scalars to simplify the tests.
 DataBufferHeap &buf = result.GetBuffer();
 if (buf.GetByteSize() <= 8) {
Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -191,7 +191,7 @@
 
 for (int arg_index = 0; arg_index < num_args; ++arg_index) {
   Value value;
-  value.SetValueType(Value::eValueTypeScalar);
+  value.SetValueType(Value::ValueType::Scalar);
   value.SetCompilerType(intptr_type);
   value_list.PushValue(value);
 }
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -1521,7 +1521,7 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
 Value cfa_val = Scalar(m_cfa);
-cfa_val.SetValueType(Value::eValueTypeLoadAddress);
+cfa_val.SetValueType(Value::ValueType::LoadAddress);
 Value result;
 Status error;
 if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -120,11 +120,11 @@
 const Value &result_value = live_valobj_sp->GetValue();
 
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:
   // we don't do anything with these for now
   break;
-case Value::eValueTypeScalar:
+case Value::ValueType::Scalar:
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsFreezeDried;
   expr_variable_sp->m_flags |=
@@ -132,7 +132,7 @@
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVNeedsAllocation;
   break;
-case Value::eValueTypeLoadAddress:
+case Value::ValueType::LoadAddress:
   expr_variable_sp->m_live_sp = live_valobj_sp;
   expr_variable_sp->m_flags |=
   ExpressionVa

[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 323120.

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

https://reviews.llvm.org/D96537

Files:
  lldb/include/lldb/Core/Value.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectChild.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectConstResultImpl.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/DataFormatters/TypeFormat.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
  lldb/source/Target/ABI.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -34,9 +34,9 @@
 return status.ToError();
 
   switch (result.GetValueType()) {
-  case Value::eValueTypeScalar:
+  case Value::ValueType::Scalar:
 return result.GetScalar();
-  case Value::eValueTypeHostAddress: {
+  case Value::ValueType::HostAddress: {
 // Convert small buffers to scalars to simplify the tests.
 DataBufferHeap &buf = result.GetBuffer();
 if (buf.GetByteSize() <= 8) {
Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -191,7 +191,7 @@
 
 for (int arg_index = 0; arg_index < num_args; ++arg_index) {
   Value value;
-  value.SetValueType(Value::eValueTypeScalar);
+  value.SetValueType(Value::ValueType::Scalar);
   value.SetCompilerType(intptr_type);
   value_list.PushValue(value);
 }
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -1521,7 +1521,7 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
 Value cfa_val = Scalar(m_cfa);
-cfa_val.SetValueType(Value::eValueTypeLoadAddress);
+cfa_val.SetValueType(Value::ValueType::LoadAddress);
 Value result;
 Status error;
 if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -120,11 +120,11 @@
 const Value &result_value = live_valobj_sp->GetValue();
 
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:
   // we don't do anything with these for now
   break;
-case Value::eValueTypeScalar:
+case Value::ValueType::Scalar:
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsFreezeDried;
   expr_variable_sp->m_flags |=
@@ -132,7 +132,7 @@
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVNeedsAllocation;
   break;
-case Value::eValueTypeLoadAddress:
+case Value::ValueType::LoadAddress:
   expr_variable_sp->m_live_sp = live_valobj_sp;
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsProgramReference;
Index: lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler

[Lldb-commits] [PATCH] D96539: [lldb] Add step target to ThreadPlanStepInRange constructor

2021-02-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`QueueThreadPlanForStepInRange` accepts a `step_into_target`, but the 
constructor for
`ThreadPlanStepInRange` has not. Instead, the caller would optionally call
`SetStepInTarget()`.

This change adds `step_into_target` as a constructor argument. This simplifies
construction of `ThreadPlanSP`, by avoiding a subsequent downcast and 
conditional
assignment. This constructor is already used in downstream repos.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96539

Files:
  lldb/include/lldb/Target/ThreadPlanStepInRange.h
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanStepInRange.cpp


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info)
 : ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
   "Step Range stepping in", thread, range, 
addr_context,
   stop_others),
   ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
-  m_virtual_step(false) {
+  m_virtual_step(false), m_step_into_target(step_into_target) {
   SetCallbacks();
   SetFlagsToDefault();
   SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1289,16 +1289,10 @@
 lldb::RunMode stop_other_threads, Status &status,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info) {
-  ThreadPlanSP thread_plan_sp(
-  new ThreadPlanStepInRange(*this, range, addr_context, stop_other_threads,
-step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info));
-  ThreadPlanStepInRange *plan =
-  static_cast(thread_plan_sp.get());
-
-  if (step_in_target)
-plan->SetStepInTarget(step_in_target);
-
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepInRange(
+  *this, range, addr_context, step_in_target, stop_other_threads,
+  step_in_avoids_code_without_debug_info,
+  step_out_avoids_code_without_debug_info));
   status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
   return thread_plan_sp;
 }
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -397,8 +397,8 @@
   // We create a ThreadPlan to keep stepping through using the address 
range
   // of the current function.
   ret_plan_sp = std::make_shared(
-  thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
-  eLazyBoolYes);
+  thread, range_of_curr_func, sc, nullptr, eOnlyThisThread,
+  eLazyBoolYes, eLazyBoolYes);
   return ret_plan_sp;
 }
   }
Index: lldb/include/lldb/Target/ThreadPlanStepInRange.h
===
--- lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -22,7 +22,7 @@
 public:
   ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
 const SymbolContext &addr_context,
-lldb::RunMode stop_others,
+const char *step_into_target, lldb::RunMode 
stop_others,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
@@ -34,10 +34,6 @@
 
   void SetAvoidRegexp(const char *name);
 
-  void SetStepInTarget(const char *target) {
-m_step_into_target.SetCString(target);
-  }
-
   static void SetDefaultFlagValue(uint32_t new_value);
 
   bool IsVirtualStep() override;


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange:

[Lldb-commits] [lldb] 876e771 - [lldb] Disable x86-multithread-write.test with reproducers

2021-02-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-02-11T13:17:30-08:00
New Revision: 876e7714dc73e651c5841af1b38b54fa350b6331

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

LOG: [lldb] Disable x86-multithread-write.test with reproducers

This test is failing on GreenDragon. Disabling it until I have bandwidth
to investigate why the register values are different during replay.

Added: 


Modified: 
lldb/test/Shell/Register/x86-multithread-write.test

Removed: 




diff  --git a/lldb/test/Shell/Register/x86-multithread-write.test 
b/lldb/test/Shell/Register/x86-multithread-write.test
index cc02b323c726..30273a6609dc 100644
--- a/lldb/test/Shell/Register/x86-multithread-write.test
+++ b/lldb/test/Shell/Register/x86-multithread-write.test
@@ -1,6 +1,7 @@
 # XFAIL: system-windows
 # REQUIRES: native && (target-x86 || target-x86_64)
 # UNSUPPORTED: system-debugserver
+# UNSUPPORTED: lldb-repro
 # RUN: %clangxx_host %p/Inputs/x86-multithread-write.cpp -o %t -pthread
 # RUN: %lldb -b -s %s %t | FileCheck %s
 



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


[Lldb-commits] [PATCH] D96539: [lldb] Add step target to ThreadPlanStepInRange constructor

2021-02-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 323127.
kastiglione added a comment.
Herald added a subscriber: JDevlieghere.

Improved wording in summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96539

Files:
  lldb/include/lldb/Target/ThreadPlanStepInRange.h
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanStepInRange.cpp


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info)
 : ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
   "Step Range stepping in", thread, range, 
addr_context,
   stop_others),
   ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
-  m_virtual_step(false) {
+  m_virtual_step(false), m_step_into_target(step_into_target) {
   SetCallbacks();
   SetFlagsToDefault();
   SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1289,16 +1289,10 @@
 lldb::RunMode stop_other_threads, Status &status,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info) {
-  ThreadPlanSP thread_plan_sp(
-  new ThreadPlanStepInRange(*this, range, addr_context, stop_other_threads,
-step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info));
-  ThreadPlanStepInRange *plan =
-  static_cast(thread_plan_sp.get());
-
-  if (step_in_target)
-plan->SetStepInTarget(step_in_target);
-
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepInRange(
+  *this, range, addr_context, step_in_target, stop_other_threads,
+  step_in_avoids_code_without_debug_info,
+  step_out_avoids_code_without_debug_info));
   status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
   return thread_plan_sp;
 }
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -397,8 +397,8 @@
   // We create a ThreadPlan to keep stepping through using the address 
range
   // of the current function.
   ret_plan_sp = std::make_shared(
-  thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
-  eLazyBoolYes);
+  thread, range_of_curr_func, sc, nullptr, eOnlyThisThread,
+  eLazyBoolYes, eLazyBoolYes);
   return ret_plan_sp;
 }
   }
Index: lldb/include/lldb/Target/ThreadPlanStepInRange.h
===
--- lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -22,7 +22,7 @@
 public:
   ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
 const SymbolContext &addr_context,
-lldb::RunMode stop_others,
+const char *step_into_target, lldb::RunMode 
stop_others,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
@@ -34,10 +34,6 @@
 
   void SetAvoidRegexp(const char *name);
 
-  void SetStepInTarget(const char *target) {
-m_step_into_target.SetCString(target);
-  }
-
   static void SetDefaultFlagValue(uint32_t new_value);
 
   bool IsVirtualStep() override;


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_deb

[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 323135.
aprantl added a comment.

Found two more uncovered cases. Drive-by fix of two error messages.


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

https://reviews.llvm.org/D96537

Files:
  lldb/include/lldb/Core/Value.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectChild.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectConstResultImpl.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/DataFormatters/TypeFormat.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
  lldb/source/Target/ABI.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -34,9 +34,9 @@
 return status.ToError();
 
   switch (result.GetValueType()) {
-  case Value::eValueTypeScalar:
+  case Value::ValueType::Scalar:
 return result.GetScalar();
-  case Value::eValueTypeHostAddress: {
+  case Value::ValueType::HostAddress: {
 // Convert small buffers to scalars to simplify the tests.
 DataBufferHeap &buf = result.GetBuffer();
 if (buf.GetByteSize() <= 8) {
Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -191,7 +191,7 @@
 
 for (int arg_index = 0; arg_index < num_args; ++arg_index) {
   Value value;
-  value.SetValueType(Value::eValueTypeScalar);
+  value.SetValueType(Value::ValueType::Scalar);
   value.SetCompilerType(intptr_type);
   value_list.PushValue(value);
 }
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -1521,7 +1521,7 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
 Value cfa_val = Scalar(m_cfa);
-cfa_val.SetValueType(Value::eValueTypeLoadAddress);
+cfa_val.SetValueType(Value::ValueType::LoadAddress);
 Value result;
 Status error;
 if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -120,11 +120,11 @@
 const Value &result_value = live_valobj_sp->GetValue();
 
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:
   // we don't do anything with these for now
   break;
-case Value::eValueTypeScalar:
+case Value::ValueType::Scalar:
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsFreezeDried;
   expr_variable_sp->m_flags |=
@@ -132,7 +132,7 @@
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVNeedsAllocation;
   break;
-case Value::eValueTypeLoadAddress:
+case Value::ValueType::LoadAddress:
   expr_variable_sp->m_live_sp = live_valobj_sp;
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIs

[Lldb-commits] [PATCH] D96548: [lldb] [Process/FreeBSDRemote] Introduce aarch64 hw break/watchpoint support [WIP]

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, emaste, labath.
Herald added subscribers: omjavaid, danielkiss, kristof.beyls, arichardson.
mgorny requested review of this revision.

Split out the common base of Linux hardware breakpoint/watchpoint
support for AArch64 into a Utility class, and use it to implement
the matching support on FreeBSD.


https://reviews.llvm.org/D96548

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
  
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h

Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h
@@ -0,0 +1,77 @@
+//===-- NativeRegisterContextBreakWatchpoint_arm64.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
+//
+//===--===//
+
+#ifndef lldb_NativeRegisterContextBreakWatchpoint_arm64_h
+#define lldb_NativeRegisterContextBreakWatchpoint_arm64_h
+
+#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
+
+#include 
+
+namespace lldb_private {
+
+class NativeRegisterContextBreakWatchpoint_arm64
+: public virtual NativeRegisterContextRegisterInfo {
+public:
+  uint32_t NumSupportedHardwareBreakpoints() override = 0;
+
+  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+
+  Status ClearAllHardwareBreakpoints() override;
+
+  Status GetHardwareBreakHitIndex(uint32_t &bp_index,
+  lldb::addr_t trap_addr) override;
+
+  uint32_t NumSupportedHardwareWatchpoints() override = 0;
+
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags) override;
+
+  bool ClearHardwareWatchpoint(uint32_t hw_index) override;
+
+  Status ClearAllHardwareWatchpoints() override;
+
+  Status GetWatchpointHitIndex(uint32_t &wp_index,
+   lldb::addr_t trap_addr) override;
+
+  lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
+
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
+
+  uint32_t GetWatchpointSize(uint32_t wp_index);
+
+  bool WatchpointIsEnabled(uint32_t wp_index);
+
+  // Debug register type select
+  enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
+
+protected:
+  // Debug register info for hardware breakpoints and watchpoints management.
+  struct DREG {
+lldb::addr_t address;  // Breakpoint/watchpoint address value.
+lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception
+   // occurred.
+lldb::addr_t real_addr; // Address value that should cause target to stop.
+uint32_t control;   // Breakpoint/watchpoint control value.
+  };
+
+  std::array m_hbr_regs; // hardware breakpoints
+  std::array m_hwp_regs; // hardware watchpoints
+
+  uint32_t m_max_hbp_supported;
+  uint32_t m_max_hwp_supported;
+
+  virtual llvm::Error ReadHardwareDebugInfo() = 0;
+  virtual llvm::Error WriteHardwareDebugRegs(DREGType hwbType) = 0;
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef lldb_NativeRegisterContextBreakWatchpoint_arm64_h
Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
@@ -0,0 +1,439 @@
+//===-- NativeRegisterContextBreakWatchpoint_arm64.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 "NativeRegisterContextBreakWatchpoint_arm64.h"
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
+
+using namespace lldb_private;
+
+uint32_t NativeRegisterContextBreakWatchpoint_arm64::SetHardwareBreakpoint(
+lldb::addr_t addr, size_t size) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LI

[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

This LGTM module the unrelated changes in that one file. A third pair of eyes 
probably won't hurt, so I'll give the others a change to look over this before 
I accept, but otherwise I'll just accept tomorrow.

(Btw, if you intend to cherry-pick this into swift/main for some reason then 
please let me know as this probably will cause a bunch of conflicts with the 
temporarily reverted patch from Pavel).




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:38
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"

The changes in this whole file seem like an accidental commit slipped in.


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

https://reviews.llvm.org/D96537

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


[Lldb-commits] [PATCH] D96548: [lldb] [Process/FreeBSDRemote] Introduce aarch64 hw break/watchpoint support [WIP]

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

@labath, the Linux/common part is working here. FreeBSD is still pending 
further kernel changes, so I'm not going to commit it until all the kernel 
patches are committed, and then I'll add appropriate `#if`s.

In the meantime, please review the utility part. This is roughly the Linux 
code, minus the two functions to read/write dbregs, and… I've just realized 
that getters for number of break/watchpoints can be made common now. So another 
update incoming soon. In any case, the only real change in the code is using 
`llvm::Error` in new API.


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

https://reviews.llvm.org/D96548

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


[Lldb-commits] [PATCH] D96549: Support dereferencing a DWARF scalar stack value

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: vsk, JDevlieghere, jasonmolenda.
Herald added a subscriber: lxfind.
aprantl requested review of this revision.

Swift async functions receive function arguments inside a heap-allocated data 
structure, similar to how ObjC block captures or C++ coroutine arguments are 
implement. In DWARF they are described relative to an entry value that produces 
a pointer into that heap object. At typical location looks like

`DW_OP_entry_value [ DW_OP_reg14 ] DW_OP_deref DW_OP_plus_uconst 32 DW_OP_deref`

This allows the unwinder (which has special ABI knowledge to restore the 
contents of r14) to push the base address onto the stack thus allowing the 
deref/offset operations to continue. The result of the entry value is a scalar, 
because DW_OP_reg14 is a register location — as it should be since we want to 
restore the pointer value contained in r14 at the beginning of the function and 
not the historical memory contents it was pointing to. The entry value should 
restore the address, which is still valid, not the contents at function entry.

To make this work, we need to allow LLDB to dereference Scalar stack results 
like load addresses, which is what this patch does. Unfortunately it is 
difficult to test this in isolation, since the DWARFExpression unit test 
doesn't have a process. Are there any situations where we shouldn't allow 
Scalars to be dereferences? Could they ever hold a File- or Hostaddress? I 
don't think so.


https://reviews.llvm.org/D96549

Files:
  lldb/source/Expression/DWARFExpression.cpp


Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1067,6 +1067,7 @@
 stack.back().SetValueType(Value::ValueType::LoadAddress);
 // Fall through to load address code below...
   } LLVM_FALLTHROUGH;
+  case Value::ValueType::Scalar:
   case Value::ValueType::LoadAddress:
 if (exe_ctx) {
   if (process) {
@@ -1099,7 +1100,6 @@
 }
 break;
 
-  case Value::ValueType::Scalar:
   case Value::ValueType::Invalid:
 if (error_ptr)
   error_ptr->SetErrorString("Invalid value type for DW_OP_deref.\n");
@@ -1170,6 +1170,7 @@
 stack.back().GetScalar() = ptr;
 stack.back().ClearContext();
   } break;
+  case Value::ValueType::Scalar:
   case Value::ValueType::LoadAddress:
 if (exe_ctx) {
   if (process) {
@@ -1221,7 +1222,6 @@
 }
 break;
 
-  case Value::ValueType::Scalar:
   case Value::ValueType::FileAddress:
   case Value::ValueType::Invalid:
 if (error_ptr)


Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1067,6 +1067,7 @@
 stack.back().SetValueType(Value::ValueType::LoadAddress);
 // Fall through to load address code below...
   } LLVM_FALLTHROUGH;
+  case Value::ValueType::Scalar:
   case Value::ValueType::LoadAddress:
 if (exe_ctx) {
   if (process) {
@@ -1099,7 +1100,6 @@
 }
 break;
 
-  case Value::ValueType::Scalar:
   case Value::ValueType::Invalid:
 if (error_ptr)
   error_ptr->SetErrorString("Invalid value type for DW_OP_deref.\n");
@@ -1170,6 +1170,7 @@
 stack.back().GetScalar() = ptr;
 stack.back().ClearContext();
   } break;
+  case Value::ValueType::Scalar:
   case Value::ValueType::LoadAddress:
 if (exe_ctx) {
   if (process) {
@@ -1221,7 +1222,6 @@
 }
 break;
 
-  case Value::ValueType::Scalar:
   case Value::ValueType::FileAddress:
   case Value::ValueType::Invalid:
 if (error_ptr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96550: Fix LLDB_LOG calls to use correct formatting

2021-02-11 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added a reviewer: teemperor.
shafik requested review of this revision.

It looks like a previous change switched these from `LLDB_LOGF` but did not 
update the format strings.


https://reviews.llvm.org/D96550

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -350,7 +350,7 @@
   if (!var)
 return false;
 
-  LLDB_LOG(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
+  LLDB_LOG(log, "Adding value for (NamedDecl*){0} [{1} - {2}] to the 
structure",
decl, name, var->GetName());
 
   // We know entity->m_parser_vars is valid because we used a parser variable
@@ -752,7 +752,7 @@
 MaybeRegisterFunctionBody(parser_function_decl);
   }
 
-  LLDB_LOG(log, "  CEDM::FEVD Found persistent decl %s", name);
+  LLDB_LOG(log, "  CEDM::FEVD Found persistent decl {0}", name);
 
   context.AddNamedDecl(parser_named_decl);
 }
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1570,10 +1570,10 @@
 
   if (log) {
 LLDB_LOG(log, "LRT returned:");
-LLDB_LOG(log, "LRT   Original = (RecordDecl*)%p",
+LLDB_LOG(log, "LRT   Original = (RecordDecl*){0}",
  static_cast(origin_record.decl));
-LLDB_LOG(log, "LRT   Size = %" PRId64, size);
-LLDB_LOG(log, "LRT   Alignment = %" PRId64, alignment);
+LLDB_LOG(log, "LRT   Size = {0}", size);
+LLDB_LOG(log, "LRT   Alignment = {0}", alignment);
 LLDB_LOG(log, "LRT   Fields:");
 for (RecordDecl::field_iterator fi = record->field_begin(),
 fe = record->field_end();


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -350,7 +350,7 @@
   if (!var)
 return false;
 
-  LLDB_LOG(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
+  LLDB_LOG(log, "Adding value for (NamedDecl*){0} [{1} - {2}] to the structure",
decl, name, var->GetName());
 
   // We know entity->m_parser_vars is valid because we used a parser variable
@@ -752,7 +752,7 @@
 MaybeRegisterFunctionBody(parser_function_decl);
   }
 
-  LLDB_LOG(log, "  CEDM::FEVD Found persistent decl %s", name);
+  LLDB_LOG(log, "  CEDM::FEVD Found persistent decl {0}", name);
 
   context.AddNamedDecl(parser_named_decl);
 }
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1570,10 +1570,10 @@
 
   if (log) {
 LLDB_LOG(log, "LRT returned:");
-LLDB_LOG(log, "LRT   Original = (RecordDecl*)%p",
+LLDB_LOG(log, "LRT   Original = (RecordDecl*){0}",
  static_cast(origin_record.decl));
-LLDB_LOG(log, "LRT   Size = %" PRId64, size);
-LLDB_LOG(log, "LRT   Alignment = %" PRId64, alignment);
+LLDB_LOG(log, "LRT   Size = {0}", size);
+LLDB_LOG(log, "LRT   Alignment = {0}", alignment);
 LLDB_LOG(log, "LRT   Fields:");
 for (RecordDecl::field_iterator fi = record->field_begin(),
 fe = record->field_end();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96548: [lldb] [Process/FreeBSDRemote] Introduce aarch64 hw break/watchpoint support [WIP]

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 323150.
mgorny added a comment.

Move `NumSupportedHardwareBreakpoints` and `NumSupportedHardwareWatchpoints` 
into the shared code.


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

https://reviews.llvm.org/D96548

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
  
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h

Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.h
@@ -0,0 +1,77 @@
+//===-- NativeRegisterContextBreakWatchpoint_arm64.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
+//
+//===--===//
+
+#ifndef lldb_NativeRegisterContextBreakWatchpoint_arm64_h
+#define lldb_NativeRegisterContextBreakWatchpoint_arm64_h
+
+#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
+
+#include 
+
+namespace lldb_private {
+
+class NativeRegisterContextBreakWatchpoint_arm64
+: public virtual NativeRegisterContextRegisterInfo {
+public:
+  uint32_t NumSupportedHardwareBreakpoints() override;
+
+  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+
+  Status ClearAllHardwareBreakpoints() override;
+
+  Status GetHardwareBreakHitIndex(uint32_t &bp_index,
+  lldb::addr_t trap_addr) override;
+
+  uint32_t NumSupportedHardwareWatchpoints() override;
+
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags) override;
+
+  bool ClearHardwareWatchpoint(uint32_t hw_index) override;
+
+  Status ClearAllHardwareWatchpoints() override;
+
+  Status GetWatchpointHitIndex(uint32_t &wp_index,
+   lldb::addr_t trap_addr) override;
+
+  lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
+
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
+
+  uint32_t GetWatchpointSize(uint32_t wp_index);
+
+  bool WatchpointIsEnabled(uint32_t wp_index);
+
+  // Debug register type select
+  enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
+
+protected:
+  // Debug register info for hardware breakpoints and watchpoints management.
+  struct DREG {
+lldb::addr_t address;  // Breakpoint/watchpoint address value.
+lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception
+   // occurred.
+lldb::addr_t real_addr; // Address value that should cause target to stop.
+uint32_t control;   // Breakpoint/watchpoint control value.
+  };
+
+  std::array m_hbr_regs; // hardware breakpoints
+  std::array m_hwp_regs; // hardware watchpoints
+
+  uint32_t m_max_hbp_supported;
+  uint32_t m_max_hwp_supported;
+
+  virtual llvm::Error ReadHardwareDebugInfo() = 0;
+  virtual llvm::Error WriteHardwareDebugRegs(DREGType hwbType) = 0;
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef lldb_NativeRegisterContextBreakWatchpoint_arm64_h
Index: lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp
@@ -0,0 +1,466 @@
+//===-- NativeRegisterContextBreakWatchpoint_arm64.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 "NativeRegisterContextBreakWatchpoint_arm64.h"
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
+
+using namespace lldb_private;
+
+uint32_t
+NativeRegisterContextBreakWatchpoint_arm64::NumSupportedHardwareBreakpoints() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  llvm::Error error = ReadHardwareDebugInfo();
+  if (error) {
+auto err_msg = llvm::toString(std::move(error));
+LLDB_LOG(log, "f

[Lldb-commits] [PATCH] D96539: [lldb] Add step target to ThreadPlanStepInRange constructor

2021-02-11 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

I must have thought there would be a case where you wouldn't be able to figure 
out the target right when you made the plan, but since that possibility never 
arose, this simplification is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96539

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


[Lldb-commits] [PATCH] D96194: Defer the decision whether to use the CU or TU index until after reading the unit header.

2021-02-11 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe updated this revision to Diff 323166.
jgorbe added a comment.

Moved index handling to DWARFUnit.cpp as suggested by Pavel.


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

https://reviews.llvm.org/D96194

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/dwarf5_tu_index_abbrev_offset.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5_tu_index_abbrev_offset.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5_tu_index_abbrev_offset.s
@@ -0,0 +1,323 @@
+## This test checks that lldb uses the abbrev_offset from .debug_tu_index when
+## reading TUs in the .debug_info section of a DWARF v5 DWP.
+##
+## The assembly here is, essentially, slightly hand-reduced output from
+## `clang -gsplit-dwarf -gdwarf-5 -fdebug-types-section`, with a manually-added
+## .debug_cu_index and a .debug_tu_index to create a DWP, and a twist: abbrevs
+## from the TU are listed *AFTER* abbrevs from the CU so that they don't begin
+## at offset 0.
+
+# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %t --defsym MAIN=1
+# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %t.dwp
+# RUN: %lldb %t -o "image lookup -t t1" -b | FileCheck %s
+# CHECK: struct t1
+
+.ifdef MAIN
+## Main file
+	.text
+	.globl	main# -- Begin function main
+main:   # @main
+.Lfunc_begin0:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	xorl	%eax, %eax
+	popq	%rbp
+	retq
+.Lfunc_end0:
+# -- End function
+	.section	.debug_abbrev,"",@progbits
+	.byte	1   # Abbreviation Code
+	.byte	74  # DW_TAG_skeleton_unit
+	.byte	0   # DW_CHILDREN_no
+	.byte	118 # DW_AT_dwo_name
+	.byte	8   # DW_FORM_string
+	.byte	17  # DW_AT_low_pc
+	.byte	27  # DW_FORM_addrx
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	115 # DW_AT_addr_base
+	.byte	23  # DW_FORM_sec_offset
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	0   # EOM(3)
+
+
+	.section	.debug_info,"",@progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	5 # DWARF version number
+	.byte	4   # DWARF Unit Type
+	.byte	8   # Address Size (in bytes)
+	.long	.debug_abbrev   # Offset Into Abbrev. Section
+	.quad	-8218585293556409984# dwo_id
+	.byte	1   # Abbrev [1] 0x14:0x14 DW_TAG_skeleton_unit
+	.asciz "hello.dwo"# DW_AT_dwo_name
+	.byte	0   # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0   # DW_AT_high_pc
+	.long	.Laddr_table_base0  # DW_AT_addr_base
+.Ldebug_info_end0:
+
+
+	.section	.debug_addr,"",@progbits
+	.long	.Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+	.short	5   # DWARF version number
+	.byte	8   # Address size
+	.byte	0   # Segment selector size
+.Laddr_table_base0:
+	.quad	.Lfunc_begin0
+.Ldebug_addr_end0:
+
+
+.else
+## DWP file
+	.section	.debug_info.dwo,"e",@progbits
+	.long	.Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
+.Ldebug_info_dwo_start0:
+	.short	5   # DWARF version number
+	.byte	6   # DWARF Unit Type
+	.byte	8   # Address Size (in bytes)
+	.long	0   # Offset Into Abbrev. Section
+	.quad	-4149699470930386446# Type Signature
+	.long	31  # Type DIE Offset
+	.byte	1   # Abbrev [1] 0x18:0xe DW_TAG_type_unit
+	.short	33  # DW_AT_language
+	.long	0   # DW_AT_stmt_list
+	.byte	2   # Abbrev [2] 0x1f:0x6 DW_TAG_structure_type
+	.byte	5   # DW_AT_calling_convention
+	.byte	3   # DW_AT_name
+	.byte	1   # DW_AT_byte_size
+	.byte	0   # DW_AT_decl_file
+	.byte	1   # DW_AT_decl_line
+	.byte	0   # End Of Children Mark
+.Ldebug_info_dwo_end0:
+	.long	.Ldebug_info_dwo_end1-.Ldebug_info_dwo_start1 # Length of Unit
+.Ldebug_info_dwo_start1:
+	.short	5  

[Lldb-commits] [lldb] a5ab1dc - [lldb] Add step target to ThreadPlanStepInRange constructor

2021-02-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2021-02-11T14:57:20-08:00
New Revision: a5ab1dc4ad2c02510e363b4dd3c267f9eaf11516

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

LOG: [lldb] Add step target to ThreadPlanStepInRange constructor

`QueueThreadPlanForStepInRange` accepts a `step_into_target`, but the 
constructor for
`ThreadPlanStepInRange` does not. Instead, a caller would optionally call
`SetStepInTarget()` in a separate statement.

This change adds `step_into_target` as a constructor argument. This simplifies
construction of `ThreadPlanSP`, by avoiding a subsequent downcast and 
conditional
assignment. This constructor is already used in downstream repos.

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

Added: 


Modified: 
lldb/include/lldb/Target/ThreadPlanStepInRange.h
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadPlanStepInRange.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h 
b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
index a26b0fb87b3a..f9ef87942a7c 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -22,7 +22,7 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
 public:
   ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
 const SymbolContext &addr_context,
-lldb::RunMode stop_others,
+const char *step_into_target, lldb::RunMode 
stop_others,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
@@ -34,10 +34,6 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
 
   void SetAvoidRegexp(const char *name);
 
-  void SetStepInTarget(const char *target) {
-m_step_into_target.SetCString(target);
-  }
-
   static void SetDefaultFlagValue(uint32_t new_value);
 
   bool IsVirtualStep() override;

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 24ab9cc5f238..02d9bff9eee3 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -397,8 +397,8 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread 
&thread,
   // We create a ThreadPlan to keep stepping through using the address 
range
   // of the current function.
   ret_plan_sp = std::make_shared(
-  thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
-  eLazyBoolYes);
+  thread, range_of_curr_func, sc, nullptr, eOnlyThisThread,
+  eLazyBoolYes, eLazyBoolYes);
   return ret_plan_sp;
 }
   }

diff  --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 049e458d8b19..660d5f8908b3 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1289,16 +1289,10 @@ ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
 lldb::RunMode stop_other_threads, Status &status,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info) {
-  ThreadPlanSP thread_plan_sp(
-  new ThreadPlanStepInRange(*this, range, addr_context, stop_other_threads,
-step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info));
-  ThreadPlanStepInRange *plan =
-  static_cast(thread_plan_sp.get());
-
-  if (step_in_target)
-plan->SetStepInTarget(step_in_target);
-
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepInRange(
+  *this, range, addr_context, step_in_target, stop_other_threads,
+  step_in_avoids_code_without_debug_info,
+  step_out_avoids_code_without_debug_info));
   status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
   return thread_plan_sp;
 }

diff  --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index a03bd93ac638..64ae0d7787d2 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@ uint32_t ThreadPlanStepInRange::s_default_flag_values =
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_de

[Lldb-commits] [PATCH] D96539: [lldb] Add step target to ThreadPlanStepInRange constructor

2021-02-11 Thread Dave Lee via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5ab1dc4ad2c: [lldb] Add step target to 
ThreadPlanStepInRange constructor (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96539

Files:
  lldb/include/lldb/Target/ThreadPlanStepInRange.h
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanStepInRange.cpp


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info)
 : ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
   "Step Range stepping in", thread, range, 
addr_context,
   stop_others),
   ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
-  m_virtual_step(false) {
+  m_virtual_step(false), m_step_into_target(step_into_target) {
   SetCallbacks();
   SetFlagsToDefault();
   SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1289,16 +1289,10 @@
 lldb::RunMode stop_other_threads, Status &status,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info) {
-  ThreadPlanSP thread_plan_sp(
-  new ThreadPlanStepInRange(*this, range, addr_context, stop_other_threads,
-step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info));
-  ThreadPlanStepInRange *plan =
-  static_cast(thread_plan_sp.get());
-
-  if (step_in_target)
-plan->SetStepInTarget(step_in_target);
-
+  ThreadPlanSP thread_plan_sp(new ThreadPlanStepInRange(
+  *this, range, addr_context, step_in_target, stop_other_threads,
+  step_in_avoids_code_without_debug_info,
+  step_out_avoids_code_without_debug_info));
   status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
   return thread_plan_sp;
 }
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -397,8 +397,8 @@
   // We create a ThreadPlan to keep stepping through using the address 
range
   // of the current function.
   ret_plan_sp = std::make_shared(
-  thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
-  eLazyBoolYes);
+  thread, range_of_curr_func, sc, nullptr, eOnlyThisThread,
+  eLazyBoolYes, eLazyBoolYes);
   return ret_plan_sp;
 }
   }
Index: lldb/include/lldb/Target/ThreadPlanStepInRange.h
===
--- lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -22,7 +22,7 @@
 public:
   ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
 const SymbolContext &addr_context,
-lldb::RunMode stop_others,
+const char *step_into_target, lldb::RunMode 
stop_others,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
@@ -34,10 +34,6 @@
 
   void SetAvoidRegexp(const char *name);
 
-  void SetStepInTarget(const char *target) {
-m_step_into_target.SetCString(target);
-  }
-
   static void SetDefaultFlagValue(uint32_t new_value);
 
   bool IsVirtualStep() override;


Index: lldb/source/Target/ThreadPlanStepInRange.cpp
===
--- lldb/source/Target/ThreadPlanStepInRange.cpp
+++ lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -33,14 +33,14 @@
 
 ThreadPlanStepInRange::ThreadPlanStepInRange(
 Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
+const SymbolContext &addr_context, const char *step_into_target,
+lldb::RunMode stop_ot

[Lldb-commits] [lldb] c314f5e - ObjectFileELF: Test whether reloc_header is non-null instead of asserting.

2021-02-11 Thread Peter Collingbourne via lldb-commits

Author: Peter Collingbourne
Date: 2021-02-11T15:05:18-08:00
New Revision: c314f5ede8249ef20fff1de45c2c31156b1950d4

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

LOG: ObjectFileELF: Test whether reloc_header is non-null instead of asserting.

It is possible for the GetSectionHeaderByIndex lookup to fail because
the previous FindSectionContainingFileAddress lookup found a segment
instead of a section. This is possible if the binary does not have
a PLT (which means that lld will in some circumstances set DT_JMPREL
to 0, which is typically an address that is part of the ELF headers
and not in a section) and may also be possible if the section headers
have been stripped. To handle this possibility, replace the assert
with an if.

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

Added: 
lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml

Modified: 
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index cad9ce218b10..df0586367832 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2770,14 +2770,14 @@ Symtab *ObjectFileELF::GetSymtab() {
 user_id_t reloc_id = reloc_section->GetID();
 const ELFSectionHeaderInfo *reloc_header =
 GetSectionHeaderByIndex(reloc_id);
-assert(reloc_header);
+if (reloc_header) {
+  if (m_symtab_up == nullptr)
+m_symtab_up =
+std::make_unique(reloc_section->GetObjectFile());
 
-if (m_symtab_up == nullptr)
-  m_symtab_up =
-  std::make_unique(reloc_section->GetObjectFile());
-
-ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header,
-   reloc_id);
+  ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header,
+ reloc_id);
+}
   }
 }
 

diff  --git a/lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml 
b/lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml
new file mode 100644
index ..ae151ba8cdc1
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml
@@ -0,0 +1,148 @@
+# RUN: yaml2obj %s -o %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: _DYNAMIC
+# CHECK: _start
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_DYN
+  Machine: EM_X86_64
+  Entry:   0x1000
+ProgramHeaders:
+  - Type:PT_PHDR
+Flags:   [ PF_R ]
+VAddr:   0x40
+Align:   0x8
+  - Type:PT_LOAD
+Flags:   [ PF_R ]
+FirstSec:.dynsym
+LastSec: .dynstr
+Align:   0x1000
+  - Type:PT_LOAD
+Flags:   [ PF_X, PF_R ]
+FirstSec:.text
+LastSec: .text
+VAddr:   0x1000
+Align:   0x1000
+  - Type:PT_LOAD
+Flags:   [ PF_W, PF_R ]
+FirstSec:.data
+LastSec: .bss
+VAddr:   0x2000
+Align:   0x1000
+  - Type:PT_DYNAMIC
+Flags:   [ PF_W, PF_R ]
+FirstSec:.data
+LastSec: .dynamic
+VAddr:   0x2000
+Align:   0x8
+  - Type:PT_GNU_RELRO
+Flags:   [ PF_R ]
+FirstSec:.data
+LastSec: .bss
+VAddr:   0x2000
+  - Type:PT_GNU_STACK
+Flags:   [ PF_W, PF_R ]
+Align:   0x0
+Sections:
+  - Name:.dynsym
+Type:SHT_DYNSYM
+Flags:   [ SHF_ALLOC ]
+Address: 0x1C8
+Link:.dynstr
+AddressAlign:0x8
+EntSize: 0x18
+  - Name:.gnu.hash
+Type:SHT_GNU_HASH
+Flags:   [ SHF_ALLOC ]
+Address: 0x1F8
+Link:.dynsym
+AddressAlign:0x8
+Header:
+  SymNdx:  0x1
+  Shift2:  0x6
+BloomFilter: [ 0x40100 ]
+HashBuckets: [ 0x1 ]
+HashValues:  [ 0xEDDB6233 ]
+  - Name:.hash
+Type:SHT_HASH
+Flags:   [ SHF_ALLOC ]
+Address: 0x218
+Link:.dynsym
+AddressAlign:0x4
+Bucket:  [ 1, 0 ]
+Chain:   [ 0, 0 ]
+  - Name:.dynstr
+Type:SHT_STRTAB
+Flags:   [ SHF_ALLOC ]
+Address: 0x230
+AddressAlign:0x1
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x1000
+AddressA

[Lldb-commits] [PATCH] D93438: ObjectFileELF: Test whether reloc_header is non-null instead of asserting.

2021-02-11 Thread Peter Collingbourne via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc314f5ede824: ObjectFileELF: Test whether reloc_header is 
non-null instead of asserting. (authored by pcc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93438

Files:
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml

Index: lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/ELF/null-jmprel.yaml
@@ -0,0 +1,148 @@
+# RUN: yaml2obj %s -o %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: _DYNAMIC
+# CHECK: _start
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_DYN
+  Machine: EM_X86_64
+  Entry:   0x1000
+ProgramHeaders:
+  - Type:PT_PHDR
+Flags:   [ PF_R ]
+VAddr:   0x40
+Align:   0x8
+  - Type:PT_LOAD
+Flags:   [ PF_R ]
+FirstSec:.dynsym
+LastSec: .dynstr
+Align:   0x1000
+  - Type:PT_LOAD
+Flags:   [ PF_X, PF_R ]
+FirstSec:.text
+LastSec: .text
+VAddr:   0x1000
+Align:   0x1000
+  - Type:PT_LOAD
+Flags:   [ PF_W, PF_R ]
+FirstSec:.data
+LastSec: .bss
+VAddr:   0x2000
+Align:   0x1000
+  - Type:PT_DYNAMIC
+Flags:   [ PF_W, PF_R ]
+FirstSec:.data
+LastSec: .dynamic
+VAddr:   0x2000
+Align:   0x8
+  - Type:PT_GNU_RELRO
+Flags:   [ PF_R ]
+FirstSec:.data
+LastSec: .bss
+VAddr:   0x2000
+  - Type:PT_GNU_STACK
+Flags:   [ PF_W, PF_R ]
+Align:   0x0
+Sections:
+  - Name:.dynsym
+Type:SHT_DYNSYM
+Flags:   [ SHF_ALLOC ]
+Address: 0x1C8
+Link:.dynstr
+AddressAlign:0x8
+EntSize: 0x18
+  - Name:.gnu.hash
+Type:SHT_GNU_HASH
+Flags:   [ SHF_ALLOC ]
+Address: 0x1F8
+Link:.dynsym
+AddressAlign:0x8
+Header:
+  SymNdx:  0x1
+  Shift2:  0x6
+BloomFilter: [ 0x40100 ]
+HashBuckets: [ 0x1 ]
+HashValues:  [ 0xEDDB6233 ]
+  - Name:.hash
+Type:SHT_HASH
+Flags:   [ SHF_ALLOC ]
+Address: 0x218
+Link:.dynsym
+AddressAlign:0x4
+Bucket:  [ 1, 0 ]
+Chain:   [ 0, 0 ]
+  - Name:.dynstr
+Type:SHT_STRTAB
+Flags:   [ SHF_ALLOC ]
+Address: 0x230
+AddressAlign:0x1
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x1000
+AddressAlign:0x1
+Offset:  0x1000
+Content: C3
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x2000
+AddressAlign:0x1
+Offset:  0x2000
+  - Name:.dynamic
+Type:SHT_DYNAMIC
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x2000
+Link:.dynstr
+AddressAlign:0x8
+Entries:
+  - Tag: DT_SYMTAB
+Value:   0x1C8
+  - Tag: DT_SYMENT
+Value:   0x18
+  - Tag: DT_STRTAB
+Value:   0x230
+  - Tag: DT_STRSZ
+Value:   0x8
+  - Tag: DT_GNU_HASH
+Value:   0x1F8
+  - Tag: DT_HASH
+Value:   0x218
+  - Tag: DT_JMPREL
+Value:   0x0
+  - Tag: DT_PLTRELSZ
+Value:   0x0
+  - Tag: DT_NULL
+Value:   0x0
+  - Name:.bss
+Type:SHT_NOBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x3000
+AddressAlign:0x1
+  - Name:.comment
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x1
+EntSize: 0x1
+Content: 4C696E6B65723A204C4C4420372E302E3000
+Symbols:
+  - Name:_DYNAMIC
+Section: .dynamic
+Value:   0x2000
+Other:   [ STV_HIDDEN ]
+  - Name:_start
+Type:STT_FUNC
+Section: .text
+Binding: STB_GLOBAL
+Value:   0x1000
+DynamicSymbols:
+  - Name:_st

[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 323176.
aprantl added a comment.

Upload the correct patch this time!? Hopefully?


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

https://reviews.llvm.org/D96537

Files:
  lldb/include/lldb/Core/Value.h
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/source/Core/Value.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectChild.cpp
  lldb/source/Core/ValueObjectConstResult.cpp
  lldb/source/Core/ValueObjectConstResultImpl.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectVariable.cpp
  lldb/source/DataFormatters/TypeFormat.cpp
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
  lldb/source/Target/ABI.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -34,9 +34,9 @@
 return status.ToError();
 
   switch (result.GetValueType()) {
-  case Value::eValueTypeScalar:
+  case Value::ValueType::Scalar:
 return result.GetScalar();
-  case Value::eValueTypeHostAddress: {
+  case Value::ValueType::HostAddress: {
 // Convert small buffers to scalars to simplify the tests.
 DataBufferHeap &buf = result.GetBuffer();
 if (buf.GetByteSize() <= 8) {
Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -191,7 +191,7 @@
 
 for (int arg_index = 0; arg_index < num_args; ++arg_index) {
   Value value;
-  value.SetValueType(Value::eValueTypeScalar);
+  value.SetValueType(Value::ValueType::Scalar);
   value.SetCompilerType(intptr_type);
   value_list.PushValue(value);
 }
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -1521,7 +1521,7 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
 Value cfa_val = Scalar(m_cfa);
-cfa_val.SetValueType(Value::eValueTypeLoadAddress);
+cfa_val.SetValueType(Value::ValueType::LoadAddress);
 Value result;
 Status error;
 if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -120,11 +120,11 @@
 const Value &result_value = live_valobj_sp->GetValue();
 
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:
   // we don't do anything with these for now
   break;
-case Value::eValueTypeScalar:
+case Value::ValueType::Scalar:
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsFreezeDried;
   expr_variable_sp->m_flags |=
@@ -132,7 +132,7 @@
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVNeedsAllocation;
   break;
-case Value::eValueTypeLoadAddress:
+case Value::ValueType::LoadAddress:
   expr_variable_sp->m_live_sp = live_valobj_sp;
   expr_variable_sp->m_flags |=
   ExpressionVariable::EVIsProgramReference;
In

[Lldb-commits] [PATCH] D96555: [lldb] Remove the legacy FreeBSD plugin

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

@labath, any clue if I'm missing some no-longer-necessary code? I feel like I 
was supposed to also remove something responsible for launching/attaching 
processes in the old mode.


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

https://reviews.llvm.org/D96555

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


[Lldb-commits] [PATCH] D96557: [lldb] Rename FreeBSDRemote to FreeBSD (NFC)

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: emaste, krytarowski, labath.
Herald added subscribers: atanasyan, nemanjai.
mgorny requested review of this revision.

https://reviews.llvm.org/D96557

Files:
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSD/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_arm64.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -40,7 +40,7 @@
 #if defined(__linux__)
 #include "Plugins/Process/Linux/NativeProcessLinux.h"
 #elif defined(__FreeBSD__)
-#include "Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h"
+#include "Plugins/Process/FreeBSD/NativeProcessFreeBSD.h"
 #elif defined(__NetBSD__)
 #include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
 #elif defined(_WIN32)
Index: lldb/tools/lldb-server/CMakeLists.txt
===
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -10,7 +10,7 @@
 endif()
 
 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  list(APPEND LLDB_PLUGINS lldbPluginProcessFreeBSDRemote)
+  list(APPEND LLDB_PLUGINS lldbPluginProcessFreeBSD)
 endif()
 
 if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
Index: lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
@@ -11,7 +11,7 @@
 
 #include "lldb/Host/common/NativeThreadProtocol.h"
 
-#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+#include "Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h"
 
 #include 
 #include 
Index: lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h
===
--- lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h
+++ lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h
@@ -20,7 +20,7 @@
 
 #include 
 
-#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+#include "Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h"
 #include "Plugins/Process/Utility/RegisterContext_x86.h"
 #include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
 #include "Plugins/Process/Utility/lldb

[Lldb-commits] [PATCH] D96558: [lldb] [Process/FreeBSDRemote] Ensure that errors are always handled

2021-02-11 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.

Ensure that the llvm::Error instances are always considered handled
by moving the respective code out of LLDB_LOG.  Apparently the latter
may result in the error not being processed if the respective log
channels are not enabled.


https://reviews.llvm.org/D96558

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -213,8 +213,9 @@
   llvm::Error error = t.CopyWatchpointsFrom(
   static_cast(*GetCurrentThread()));
   if (error) {
+auto error_msg = llvm::toString(std::move(error));
 LLDB_LOG(log, "failed to copy watchpoints to new thread {0}: {1}",
- info.pl_lwpid, llvm::toString(std::move(error)));
+ info.pl_lwpid, error_msg);
 SetState(StateType::eStateInvalid);
 return;
   }


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -213,8 +213,9 @@
   llvm::Error error = t.CopyWatchpointsFrom(
   static_cast(*GetCurrentThread()));
   if (error) {
+auto error_msg = llvm::toString(std::move(error));
 LLDB_LOG(log, "failed to copy watchpoints to new thread {0}: {1}",
- info.pl_lwpid, llvm::toString(std::move(error)));
+ info.pl_lwpid, error_msg);
 SetState(StateType::eStateInvalid);
 return;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96549: Support dereferencing a DWARF scalar stack value

2021-02-11 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

The logic change seems reasonable to me. Any chance we can provide a mock 
memory in the DwarfExpression unit test, or check in assembly for a program 
that uses such an entry value expression?


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

https://reviews.llvm.org/D96549

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


[Lldb-commits] [PATCH] D96537: Make the error condition in Value::ValueType explicit (NFC)

2021-02-11 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Core/Value.cpp:321
+  case ValueType::Invalid:
+break;
+  case ValueType::Scalar: {

Would it make sense to also do an `error.SetErrorString(...`? 



Comment at: lldb/source/Core/Value.cpp:574
 switch (m_value_type) {
-case eValueTypeScalar: // raw scalar value
+case ValueType::Invalid:
+case ValueType::Scalar: // raw scalar value

In the invalid case does `m_value` have some initial value i.e. it is not 
uninitialized. 



Comment at: lldb/source/Core/Value.cpp:629
   };
-  return "???";
 }

I love the `"???"`



Comment at: lldb/source/Core/ValueObject.cpp:339
   switch (value_type) {
-  case Value::eValueTypeScalar:
-if (value.GetContextType() == Value::eContextTypeRegisterInfo) {
+  case Value::ValueType::Scalar:
+if (value.GetContextType() == Value::ContextType::RegisterInfo) {

No handing for `ValueType::Invalid` here?



Comment at: lldb/source/Core/ValueObject.cpp:855
   switch (value_type) {
-  case Value::eValueTypeScalar: {
+  case Value::ValueType::Scalar: {
 Status set_error =

No handling for `ValueType::Invalid` here?

Same for some code below as well.



Comment at: lldb/source/Core/ValueObjectConstResult.cpp:148
   m_value.GetScalar().GetData(m_data, addr_byte_size);
-  // m_value.SetValueType(Value::eValueTypeHostAddress);
+  // m_value.SetValueType(Value::ValueType::HostAddress);
   switch (address_type) {

dead code?



Comment at: lldb/source/Core/ValueObjectVariable.cpp:200
+  case Value::ValueType::Invalid:
+break;
+  case Value::ValueType::Scalar:

Does `m_error.SetErrorString` make sense here?



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp:1668
 
-  // parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType,
+  // parser_vars->m_lldb_value.SetContext(Value::ContextType::ClangType,
   // user_type.GetOpaqueQualType());

Dead code?



Comment at: lldb/source/Target/ABI.cpp:123
 switch (result_value.GetValueType()) {
-case Value::eValueTypeHostAddress:
-case Value::eValueTypeFileAddress:
+case Value::ValueType::HostAddress:
+case Value::ValueType::FileAddress:

No handling for `ValueType::Invalid` here?


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

https://reviews.llvm.org/D96537

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


[Lldb-commits] [PATCH] D96549: Support dereferencing a DWARF scalar stack value

2021-02-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I think this makes sense. From a DWARF perspective this is sound, all the 
standard says is that the popped value must have an integral type.


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

https://reviews.llvm.org/D96549

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


[Lldb-commits] [lldb] 4d3a061 - [lldb] Fix 'r' and 'run' aliases on Apple Silicon

2021-02-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-02-11T20:23:53-08:00
New Revision: 4d3a061c32ee5c4fb88be389a4dd7fd71fc9fa9c

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

LOG: [lldb] Fix 'r' and 'run' aliases on Apple Silicon

The 'r' and 'run' aliases were different based on the target
architecture. I suspect the intention was to disable shell expansion on
embedded devices. This fixes TestCustomShell.test on AS.

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/test/Shell/Host/TestCustomShell.test

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index a7afa1034762..f0a6baa3b9ad 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -417,24 +417,20 @@ void CommandInterpreter::Initialize() {
   cmd_obj_sp = GetCommandSPExact("process launch");
   if (cmd_obj_sp) {
 alias_arguments_vector_sp = std::make_shared();
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#if defined(__APPLE__)
+#if defined(TARGET_OS_IPHONE)
 AddAlias("r", cmd_obj_sp, "--");
 AddAlias("run", cmd_obj_sp, "--");
 #else
-#if defined(__APPLE__)
-std::string shell_option;
-shell_option.append("--shell-expand-args");
-shell_option.append(" true");
-shell_option.append(" --");
 AddAlias("r", cmd_obj_sp, "--shell-expand-args true --");
 AddAlias("run", cmd_obj_sp, "--shell-expand-args true --");
+#endif
 #else
 StreamString defaultshell;
 defaultshell.Printf("--shell=%s --",
 HostInfo::GetDefaultShell().GetPath().c_str());
 AddAlias("r", cmd_obj_sp, defaultshell.GetString());
 AddAlias("run", cmd_obj_sp, defaultshell.GetString());
-#endif
 #endif
   }
 

diff  --git a/lldb/test/Shell/Host/TestCustomShell.test 
b/lldb/test/Shell/Host/TestCustomShell.test
index 75114c554493..1823d094ea7a 100644
--- a/lldb/test/Shell/Host/TestCustomShell.test
+++ b/lldb/test/Shell/Host/TestCustomShell.test
@@ -1,7 +1,5 @@
-# This test applies to POSIX.
-# UNSUPPORTED: system-windows
-
 # FIXME: ShellExpandArguments is unimplemented on the following targets.
+# UNSUPPORTED: system-windows
 # UNSUPPORTED: system-linux
 # XFAIL: system-freebsd
 # XFAIL: system-netbsd



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


[Lldb-commits] [lldb] 732534e - [lldb] s/TARGET_OS_EMBEDDED/TARGET_OS_IPHONE/

2021-02-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-02-11T20:40:59-08:00
New Revision: 732534ed64284b7ec6dde98e7b0ff779fce6b3d4

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

LOG: [lldb] s/TARGET_OS_EMBEDDED/TARGET_OS_IPHONE/

TARGET_OS_EMBEDDED is deprecated, use TARGET_OS_IPHONE and/or
TARGET_OS_SIMULATOR instead.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 5e06792e0fbf..0376e46720c0 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -138,7 +138,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   size_t framework_pos = raw_path.find("LLDB.framework");
   if (framework_pos != std::string::npos) {
 framework_pos += strlen("LLDB.framework");
-#if TARGET_OS_EMBEDDED
+#if TARGET_OS_IPHONE
 // Shallow bundle
 raw_path.resize(framework_pos);
 #else

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 463a2a52f5df..548e21ad9aea 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2578,7 +2578,7 @@ size_t ObjectFileMachO::ParseSymtab() {
   typedef std::set IndirectSymbols;
   IndirectSymbols indirect_symbol_names;
 
-#if defined(__APPLE__) && TARGET_OS_EMBEDDED
+#if TARGET_OS_IPHONE
 
   // Some recent builds of the dyld_shared_cache (hereafter: DSC) have been
   // optimized by moving LOCAL symbols out of the memory mapped portion of



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


[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-11 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py:75-79
-if "LLDB_DEBUGSERVER_PATH" in os.environ:
-return os.environ["LLDB_DEBUGSERVER_PATH"]
 
-return _get_debug_monitor_from_lldb(
-lldbtest_config.lldbExec, "lldb-server")

rupprecht wrote:
> labath wrote:
> > rupprecht wrote:
> > > labath wrote:
> > > > @rupprecht : I'm adding you mainly because my last attempt to change 
> > > > this function broke some google integration stuff.
> > > Thanks, patching this in now! (Sorry for the delay, I was out a couple 
> > > days)
> > Sure, np. Let me know how it works out.
> Everything I've tried to throw this against seems to be working. I'm not sure 
> exactly what the problem was before though. Seems fine to land and I can take 
> a closer look if something fails later. Thanks for the heads up!
Thanks for checking it out.

The previous patch simply removed the LLDB_DEBUGSERVER_PATH thingy, and left 
the original logic logic in place (which was calculating the lldb server 
location based on realpath(3) of the lldb binary, which does not work well 
inside google).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

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


[Lldb-commits] [lldb] 7df4eaa - [lldb/test] Automatically find debug servers to test

2021-02-11 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-02-11T14:43:53+01:00
New Revision: 7df4eaaa937332c0617aa665080533966e2c98a0

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

LOG: [lldb/test] Automatically find debug servers to test

Our test configuration logic assumes that the tests can be run either
with debugserver or with lldb-server. This is not entirely correct,
since lldb server has two "personalities" (platform server and debug
server) and debugserver is only a replacement for the latter.

A consequence of this is that it's not possible to test the platform
behavior of lldb-server on macos, as it is not possible to get a hold of
the lldb-server binary.

One solution to that would be to duplicate the server configuration
logic to be able to specify both executables. However, that seems
excessively redundant.

A well-behaved lldb should be able to find the debug server on its own,
and testing lldb with a different (lldb-|debug)server does not seem very
useful (even in the out-of-tree debugserver setup, we copy the server
into the build tree to make it appear "real").

Therefore, this patch deletes the configuration altogether and changes
the low-level server retrieval functions to be able to both lldb-server
and debugserver paths. They do this by consulting the "support
executable" directory of the lldb under test.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
lldb/test/API/CMakeLists.txt
lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
lldb/test/API/lit.site.cfg.py.in
lldb/utils/lldb-dotest/CMakeLists.txt
lldb/utils/lldb-dotest/lldb-dotest.in

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 62508a144972..945b3f0c20a4 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -366,12 +366,6 @@ def parseOptionsAndInitTestdirs():
 args.executable)
 sys.exit(-1)
 
-if args.server and args.out_of_tree_debugserver:
-logging.warning('Both --server and --out-of-tree-debugserver are set')
-
-if args.server and not args.out_of_tree_debugserver:
-os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
-
 if args.excluded:
 for excl_file in args.excluded:
 parseExclusion(excl_file)

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 4774ce352fc2..af45205ae3ed 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -100,10 +100,6 @@ def create_parser():
 '--executable',
 metavar='executable-path',
 help='The path to the lldb executable')
-group.add_argument(
-'--server',
-metavar='server-path',
-help='The path to the debug server executable to use')
 group.add_argument(
 '--out-of-tree-debugserver',
 dest='out_of_tree_debugserver',

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 07136108b2a4..eba6f322db9b 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -15,54 +15,12 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import configuration
 from textwrap import dedent
+import shutil
 
-def _get_debug_monitor_from_lldb(lldb_exe, debug_monitor_basename):
-"""Return the debug monitor exe path given the lldb exe path.
+def _get_support_exe(basename):
+support_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir)
 
-This method attempts to construct a valid debug monitor exe name
-from a given lldb exe name.  It will return None if the synthesized
-debug monitor name is not found to exist.
-
-The debug monitor exe path is synthesized by taking the directory
-of the lldb exe, and replacing the portion of the base name that
-matches "lldb" (case insensitive) and replacing with the value of
-debug_monitor_basename.
-
-Args:
-lldb_exe: the path to an lldb executable.
-
-debug_monitor_basename: the base name portion of the debug monitor
-that will replace 'lldb'.
-
-Returns:
-A path to the debug monitor exe if it is found to exist; otherwise,
-returns None.
-
-"""
-if not lldb_exe:
-   

[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-11 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7df4eaaa9373: [lldb/test] Automatically find debug servers 
to test (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
  lldb/test/API/CMakeLists.txt
  lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
  lldb/test/API/lit.site.cfg.py.in
  lldb/utils/lldb-dotest/CMakeLists.txt
  lldb/utils/lldb-dotest/lldb-dotest.in

Index: lldb/utils/lldb-dotest/lldb-dotest.in
===
--- lldb/utils/lldb-dotest/lldb-dotest.in
+++ lldb/utils/lldb-dotest/lldb-dotest.in
@@ -8,7 +8,6 @@
 executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@'
 compiler = '@LLDB_TEST_COMPILER_CONFIGURED@'
 dsymutil = '@LLDB_TEST_DSYMUTIL_CONFIGURED@'
-server = '@LLDB_TEST_SERVER_CONFIGURED@'
 lldb_build_dir = '@LLDB_TEST_BUILD_DIRECTORY_CONFIGURED@'
 lldb_build_intel_pt = "@LLDB_BUILD_INTEL_PT@"
 lldb_framework_dir = "@LLDB_FRAMEWORK_DIR_CONFIGURED@"
@@ -28,8 +27,6 @@
 cmd.extend(['--dsymutil', dsymutil])
 cmd.extend(['--lldb-libs-dir', lldb_libs_dir])
 cmd.extend(['--llvm-tools-dir', llvm_tools_dir])
-if server:
-cmd.extend(['--server', server])
 if lldb_framework_dir:
 cmd.extend(['--framework', lldb_framework_dir])
 if lldb_build_intel_pt == "1":
Index: lldb/utils/lldb-dotest/CMakeLists.txt
===
--- lldb/utils/lldb-dotest/CMakeLists.txt
+++ lldb/utils/lldb-dotest/CMakeLists.txt
@@ -19,7 +19,6 @@
   LLDB_TEST_EXECUTABLE
   LLDB_TEST_COMPILER
   LLDB_TEST_DSYMUTIL
-  LLDB_TEST_SERVER
   LLDB_LIBS_DIR
   LLVM_TOOLS_DIR
   )
Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -29,7 +29,6 @@
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = '@LLDB_TEST_COMPILER@'
 config.dsymutil = '@LLDB_TEST_DSYMUTIL@'
-config.server = '@LLDB_TEST_SERVER@'
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
@@ -55,7 +54,6 @@
 config.lldb_executable = config.lldb_executable % lit_config.params
 config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
 config.test_compiler = config.test_compiler % lit_config.params
-config.server = config.server % lit_config.params
 config.lldb_framework_dir = config.lldb_framework_dir % lit_config.params
 config.dotest_args_str = config.dotest_args_str % lit_config.params
 except KeyError as e:
Index: lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
===
--- lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
+++ lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
@@ -3,6 +3,7 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+from lldbgdbserverutils import get_debugserver_exe
 
 import os
 import platform
@@ -28,7 +29,7 @@
 TIMEOUT = 2
 
 def no_debugserver(self):
-if os.getenv('LLDB_DEBUGSERVER_PATH') is None:
+if get_debugserver_exe() is None:
 return 'no debugserver'
 return None
 
@@ -88,7 +89,7 @@
 shutil.move(exe, exe_sdk_path)
 
 # Attach to it with debugserver.
-debugserver = os.getenv('LLDB_DEBUGSERVER_PATH')
+debugserver = get_debugserver_exe()
 debugserver_args = [
 'localhost:{}'.format(self.PORT), '--attach={}'.format(pid)
 ]
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -108,18 +108,8 @@
 message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}")
 list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 add_lldb_test_dependency(debugserver)
-  elseif(TARGET debugserver)
-set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver)
-message(STATUS "LLDB Tests use just-built debugserver: ${debugserver_path}")
-set(LLDB_TEST_SERVER ${debugserver_path})
-add_lldb_test_dependency(debugserver)
-  elseif(TARGET lldb-server)
-set(lldb_server_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-server)
-message(STATUS "LLDB Tests use just-built lldb-server: ${lldb_server_path}")
-set(LLDB_TEST_SERVER ${lldb_server_path})
-add_lldb_test_dependency(lldb-server)
   else()
-message(WARNING "LLDB Tests enabled, bu

[Lldb-commits] [PATCH] D96460: [LLDB] Arm64/Linux Add MTE and Pointer Authentication registers

2021-02-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:79
 
+  m_mte_ctrl_reg = 0;
+

Should m_pac_mask also be initialised or is it already?



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:120
+  uint32_t result = 0;
+  if (*auxv_at_hwcap & HWCAP_PACA)
+result |= ARM64_REGS_CONFIG_PAUTH;

I think this should be more defensive:
```
if (auxv_at_hwcap && (*auxv_at_hwcap & HWCAP_PACA))
```

Otherwise you'll deference an invalid optional, which might work if its storage 
happens to be zeroed but it's not intended use.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:126
+
+  if (*auxv_at_hwcap2 & HWCAP2_MTE)
+result |= ARM64_REGS_CONFIG_MTE;

Same here, auxv_at_hwcap2 could be llvm::None.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:531
 
+bool NativeRegisterContextLinux_arm64::IsPAuth(unsigned reg) const {
+  if (GetRegisterInfo().IsPAuthReg(reg))

Can you simplify these?
```
return GetRegisterInfo().IsPAuthReg(reg);
```

(the others could do that too, but obviously we're ignoring those ones here)



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:1100
   m_sve_header_is_valid = false;
+  m_pac_mask_is_valid = false;
 

I think `m_mte_ctrl_is_valid` is missing here.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:1198
+
+  if (m_mte_ctrl_is_valid)
+return error;

Just to confirm I understand this logic.

If `m_mte_ctrl_is_valid` would mean that our cached value of the register is 
valid. So if something tries to read a new copy of it we fail because they 
should have used the cached version?

Then if `m_mte_ctrl_is_valid` is false, our cache is out of date so we do the 
read.

Seems odd to error on asking for a read of a value that is cached but then 
again I don't know the surrounding code too well. If that pattern is already 
established no point disturbing it now.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp:1216
+
+  error = ReadMTEControl();
+  if (error.Fail())

This is a sanity check that we didn't ask to write this register on a system 
that doesn't have it?



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h:182
+
+  void *GetMTEControl() { return &m_pac_mask; }
+

This looks like a mistake.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:320
+  uint32_t pa_regnum = m_dynamic_reg_infos.size();
+  for (uint32_t i = 0; i < 2; i++) {
+pauth_regnum_collection.push_back(pa_regnum + i);

Can you get this 2 from some list somewhere in this class? E.g. 
PauthRegs.Size(). Or add a comment if not.

g_register_infos_pauth perhaps?



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:324
+m_dynamic_reg_infos[pa_regnum + i].byte_offset =
+m_dynamic_reg_infos[pa_regnum + i - 1].byte_offset +
+m_dynamic_reg_infos[pa_regnum + i - 1].byte_size;

Is it possible at this point that `m_dynamic_reg_infos.size()` is 0 making 
`m_dynamic_reg_infos[pa_regnum + i - 1]` into `m_dynamic_reg_infos[0 + 0 - 1]` ?

I guess this could happen if SVE wasn't present but maybe you already account 
for that.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:326
+m_dynamic_reg_infos[pa_regnum + i - 1].byte_size;
+m_dynamic_reg_infos[pa_regnum + i].kinds[4] = pa_regnum + i;
+  }

Please comment what the [4] is getting.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:330
+  m_dynamic_reg_sets.push_back(g_reg_set_pauth_arm64);
+  m_dynamic_reg_sets[m_dynamic_reg_sets.size() - 1].registers =
+  pauth_regnum_collection.data();

You could simplify this with back 
(https://www.cplusplus.com/reference/vector/vector/back/) assuming this is a 
vector-ish type.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:336
+  uint32_t mte_regnum = m_dynamic_reg_infos.size();
+  for (uint32_t i = 0; i < 1; i++) {
+m_mte_regnum_collection.push_back(mte_regnum + i);

Same as above

Given that there's only one MTE register you could also remove the for since 
we'll only ever have i==0. If we want to be nice and handle future expansion 
some MTERegs.size() would be preferred.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp:434
+bool RegisterInfoPOSIX_arm64::IsPAuthReg(unsigned re

[Lldb-commits] [PATCH] D95710: [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch

2021-02-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 322995.
mib marked 2 inline comments as done.
mib added a comment.

Address @JDevlieghere comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95710

Files:
  lldb/include/lldb/Host/ProcessLaunchInfo.h
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandOptionsProcessLaunch.cpp
  lldb/source/Commands/CommandOptionsProcessLaunch.h
  lldb/source/Host/common/ProcessLaunchInfo.cpp

Index: lldb/source/Host/common/ProcessLaunchInfo.cpp
===
--- lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -32,7 +32,8 @@
 : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
   m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
   m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
-  m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {}
+  m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(),
+  m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {}
 
 ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
  const FileSpec &stdout_file_spec,
@@ -42,7 +43,8 @@
 : ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags),
   m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
   m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
-  m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {
+  m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(),
+  m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {
   if (stdin_file_spec) {
 FileAction file_action;
 const bool read = true;
@@ -171,6 +173,8 @@
   m_resume_count = 0;
   m_listener_sp.reset();
   m_hijack_listener_sp.reset();
+  m_scripted_process_class_name.clear();
+  m_scripted_process_dictionary_sp.reset();
 }
 
 void ProcessLaunchInfo::SetMonitorProcessCallback(
Index: lldb/source/Commands/CommandOptionsProcessLaunch.h
===
--- lldb/source/Commands/CommandOptionsProcessLaunch.h
+++ lldb/source/Commands/CommandOptionsProcessLaunch.h
@@ -1,4 +1,4 @@
-//===-- CommandOptionsProcessLaunch.h -===//
+//===-- CommandOptionsProcessLaunch.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.
@@ -16,9 +16,9 @@
 
 // CommandOptionsProcessLaunch
 
-class CommandOptionsProcessLaunch : public lldb_private::Options {
+class CommandOptionsProcessLaunch : public lldb_private::OptionGroup {
 public:
-  CommandOptionsProcessLaunch() : lldb_private::Options() {
+  CommandOptionsProcessLaunch() : lldb_private::OptionGroup() {
 // Keep default values of all options in one place: OptionParsingStarting
 // ()
 OptionParsingStarting(nullptr);
Index: lldb/source/Commands/CommandOptionsProcessLaunch.cpp
===
--- lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -30,7 +30,7 @@
 uint32_t option_idx, llvm::StringRef option_arg,
 ExecutionContext *execution_context) {
   Status error;
-  const int short_option = m_getopt_table[option_idx].val;
+  const int short_option = g_process_launch_options[option_idx].short_option;
 
   switch (short_option) {
   case 's': // Stop at program entry point
Index: lldb/source/Commands/CommandObjectProcess.cpp
===
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
 #include "lldb/Interpreter/Options.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -108,7 +109,12 @@
 interpreter, "process launch",
 "Launch the executable in the debugger.", nullptr,
 eCommandRequiresTarget, "restart"),
-m_options() {
+m_options(), m_class_options("scripted process"), m_all_options() {
+m_all_options.Append(&m_options);
+m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2,
+ LLDB_OPT_SET_1);
+m_all_options.Finalize();
+
 CommandArgumentEntry arg;
 CommandArgumentData run_args_arg;
 
@@ -135,7 +141,7 @@
 request, nullptr);
   }
 
-  Options *GetOptions() override { retur

[Lldb-commits] [PATCH] D95711: [lldb/Interpreter] Add ScriptInterpreter Wrapper for ScriptedProcess

2021-02-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 322997.
mib marked 4 inline comments as done.
mib added a comment.
Herald added a subscriber: mgorny.

Address @JDevlieghere feedbacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95711

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/include/lldb/API/SBData.h
  lldb/include/lldb/API/SBThreadPlan.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Interpreter/CMakeLists.txt
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Interpreter/ScriptedProcessInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -153,6 +153,14 @@
   return 0;
 }
 
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data) {
+  return nullptr;
+}
+
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data) {
+  return nullptr;
+}
+
 extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data) {
   return nullptr;
 }
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -0,0 +1,63 @@
+//===-- ScriptedProcessPythonInterface.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
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
+
+#include "lldb/Host/Config.h"
+
+#if LLDB_ENABLE_PYTHON
+
+#include "lldb/Interpreter/ScriptedProcessInterface.h"
+
+namespace lldb_private {
+class ScriptInterpreterPythonImpl;
+class ScriptedProcessPythonInterface : public ScriptedProcessInterface {
+public:
+  ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter)
+  : ScriptedProcessInterface(), m_interpreter(interpreter) {}
+
+  StructuredData::GenericSP
+  CreatePluginObject(const llvm::StringRef class_name, lldb::TargetSP target_sp,
+ StructuredData::DictionarySP args_sp) override;
+
+  Status Launch() override;
+
+  size_t GetNumMemoryRegions() override;
+
+  lldb::MemoryRegionInfoSP GetMemoryRegionAtIndex(size_t index) override;
+
+  size_t GetNumThreads() override;
+
+  lldb::ThreadSP GetThreadAtIndex(size_t index) override;
+
+  StructuredData::DictionarySP GetRegisterForThread() override;
+
+  lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address,
+Status &error) override;
+
+  StructuredData::DictionarySP GetLoadedImages() override;
+
+  lldb::pid_t GetProcessID() override;
+
+  bool CanDebug() override;
+
+  bool IsAlive() override;
+
+protected:
+  size_t GetGenericInteger(llvm::StringRef method_name);
+
+private:
+  // The lifetime is managed by the ScriptInterpreter
+  ScriptInterpreterPythonImpl &m_interpreter;
+  StructuredData::GenericSP m_object_instance_sp;
+};
+} // namespace lldb_private
+
+#endif // LLDB_ENABLE_PYTHON
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -0,0 +1,292 @@
+//===-- ScriptedProcessPythonInterface.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
+//
+//===--===//
+
+#i