[Lldb-commits] [PATCH] D76964: Fix an issue where the IgnoreName function was not allowing "Class" to be looked up inside a namespace or other class.

2020-04-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

LGTM minus some stylistic changes.




Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:582
+static const ConstString Class_name("Class");
+if (name == id_name || name == Class_name) {
+  // Only disallow using "id" and "Class" if we are searching from the root

aprantl wrote:
> For these tiny strings a StringRef `==` comparison is going to be more 
> efficient than constructing and storing a pointer to a ConstString.
There is no need for StringRef as ConstString allows direct comparison against 
string literals, so this works and is much faster: `name == "id" || name == 
"Class"`



Comment at: lldb/test/API/commands/expression/ignore/TestIgnoreName.py:6
+
+Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
+"""

Left over from the original test case (TestCallUserAnonTypedef.py)



Comment at: lldb/test/API/commands/expression/ignore/TestIgnoreName.py:32
+   add_dependent_modules, error)
+self.assertTrue(error.Success(), "Make sure our target got created")
+expr_result = target.EvaluateExpression("a::Class a; a")

I don't think we usually check the error, but only if target is valid in any 
other test. So this whole test can just be this (at least after D77197 has 
landed):
```
lang=python
def test(self): 
"""Test that we can evaluate an expression that finds something inside  
   a namespace that uses an Objective C keyword.
""" 
self.build()
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))  
self.assertTrue(target, VALID_TARGET)   
self.expect_expr("a::Class x; x", result_type="a::Class")   
```



Comment at: lldb/test/API/commands/expression/ignore/main.cpp:7
+int main(int argc, char **argv)
+{
+  a::Class c;

I think new test files should follow LLVM code style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76964



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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It might be worth mentioning though that the title of the patch is somewhat 
misleading -- I believe the `CXX` in `CXXFunctionSummaryFormat` refers to the 
language the formatter is implemented in, not the language of the type itself. 
So this patch affects all types whose formatters are implemented as c++ 
functions, not all c++ pointers in the target program.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D77153#1952952 , @friss wrote:

> I haven't tested the libstdc++ part, would be great if someone could confirm 
> this works.


This doesn't work work for libstdc++ (I get ``), presumably because the code uses the simple `StringSummaryFormat` 
(`new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p}")`) 
instead of `CXXFunctionSummaryFormat` However, it doesn't make the situation 
any worse either, so you can just drop the libstdc++ test changes and carry on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-04-01 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D75750#1954086 , @clayborg wrote:

> Another idea for the SymbolServers: be able to specify a source repository 
> (git, svn etc) and hash or revision ID. The symbol server can grab the source 
> from the repo and cache is locally for display.


When you talk about it FYI I use "build-id" to "GIT hash" mapping text file 
during build to retrieve source files later according to binary's build-id. But 
it expects you do not strip symbols from the binaries as otherwise one cannot 
rebuild the binaries later ("reproducible build" problem - dependency on 
versions of system packages being updated in the meantime). 
https://www.jankratochvil.net/t/BUILDID-git-checkout
`debuginfod` solves this better although with higher storage requirements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [lldb] 15f34ff - [lldb] Allow expect_expr without a running target

2020-04-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-04-01T09:39:24+02:00
New Revision: 15f34ff2d8976f9211c6112531355ed5e2a92ea0

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

LOG: [lldb] Allow expect_expr without a running target

Summary:
If we don't have a current frame then we can still run many expressions
as long as we have an active target. With this patch `expect_expr` directly
calls the target's EvaluateExpression function when there is no current frame.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 966d460ea13d..5058594505f5 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2414,9 +2414,12 @@ def expect_expr(
 
 # Set the usual default options for normal expressions.
 options.SetIgnoreBreakpoints(True)
-options.SetLanguage(frame.GuessLanguage())
 
-eval_result = frame.EvaluateExpression(expr, options)
+if self.frame().IsValid():
+  options.SetLanguage(frame.GuessLanguage())
+  eval_result = self.frame().EvaluateExpression(expr, options)
+else:
+  eval_result = self.target().EvaluateExpression(expr, options)
 
 if not eval_result.GetError().Success():
 self.assertTrue(eval_result.GetError().Success(),

diff  --git 
a/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py 
b/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
index 31478884ad7d..55ba2717c013 100644
--- a/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
+++ b/lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
@@ -17,24 +17,10 @@ class ExprCommandCallBuiltinFunction(TestBase):
 # Builtins are expanded by Clang, so debug info shouldn't matter.
 NO_DEBUG_INFO_TESTCASE = True
 
-def setUp(self):
-TestBase.setUp(self)
-# Find the line number to break for main.c.
-self.line = line_number(
-'main.cpp',
-'// Please test these expressions while stopped at this line:')
-
 def test(self):
 self.build()
 
-# Set breakpoint in main and run exe
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=-1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-# Test 
diff erent builtin functions.
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 
 self.expect_expr("__builtin_isinf(0.0f)", result_type="int", 
result_value="0")
 self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", 
result_value="0")



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


[Lldb-commits] [PATCH] D77197: [lldb] Allow expect_expr without a running target

2020-04-01 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15f34ff2d897: [lldb] Allow expect_expr without a running 
target (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/D77197/new/

https://reviews.llvm.org/D77197

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py


Index: 
lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
===
--- lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
+++ lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
@@ -17,24 +17,10 @@
 # Builtins are expanded by Clang, so debug info shouldn't matter.
 NO_DEBUG_INFO_TESTCASE = True
 
-def setUp(self):
-TestBase.setUp(self)
-# Find the line number to break for main.c.
-self.line = line_number(
-'main.cpp',
-'// Please test these expressions while stopped at this line:')
-
 def test(self):
 self.build()
 
-# Set breakpoint in main and run exe
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=-1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-# Test different builtin functions.
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 
 self.expect_expr("__builtin_isinf(0.0f)", result_type="int", 
result_value="0")
 self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", 
result_value="0")
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2414,9 +2414,12 @@
 
 # Set the usual default options for normal expressions.
 options.SetIgnoreBreakpoints(True)
-options.SetLanguage(frame.GuessLanguage())
 
-eval_result = frame.EvaluateExpression(expr, options)
+if self.frame().IsValid():
+  options.SetLanguage(frame.GuessLanguage())
+  eval_result = self.frame().EvaluateExpression(expr, options)
+else:
+  eval_result = self.target().EvaluateExpression(expr, options)
 
 if not eval_result.GetError().Success():
 self.assertTrue(eval_result.GetError().Success(),


Index: lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
===
--- lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
+++ lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
@@ -17,24 +17,10 @@
 # Builtins are expanded by Clang, so debug info shouldn't matter.
 NO_DEBUG_INFO_TESTCASE = True
 
-def setUp(self):
-TestBase.setUp(self)
-# Find the line number to break for main.c.
-self.line = line_number(
-'main.cpp',
-'// Please test these expressions while stopped at this line:')
-
 def test(self):
 self.build()
 
-# Set breakpoint in main and run exe
-self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-# Test different builtin functions.
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 
 self.expect_expr("__builtin_isinf(0.0f)", result_type="int", result_value="0")
 self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", result_value="0")
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2414,9 +2414,12 @@
 
 # Set the usual default options for normal expressions.
 options.SetIgnoreBreakpoints(True)
-options.SetLanguage(frame.GuessLanguage())
 
-eval_result = frame.EvaluateExpression(expr, options)
+if self.frame().IsValid():
+  options.SetLanguage(frame.GuessLanguage())
+  eval_result = self.frame().EvaluateExpression(expr, options)
+else:
+  eval_result = self.target().EvaluateExpression(expr, options)
 
 if not eval_result.GetError().Success():
 self.assertTrue(eval_result.GetError().Success(),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
h

[Lldb-commits] [lldb] fa1b602 - [lldb][NFC] Modernize TestCallUserAnonTypedef

2020-04-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-04-01T10:06:59+02:00
New Revision: fa1b602ee6c3bd3dc245cbafe7534be5381e71e7

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

LOG: [lldb][NFC] Modernize TestCallUserAnonTypedef

Added: 


Modified: 

lldb/test/API/commands/expression/anonymous-struct/TestCallUserAnonTypedef.py
lldb/test/API/commands/expression/anonymous-struct/main.cpp

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/anonymous-struct/TestCallUserAnonTypedef.py 
b/lldb/test/API/commands/expression/anonymous-struct/TestCallUserAnonTypedef.py
index b6e035752896..1a4e16610042 100644
--- 
a/lldb/test/API/commands/expression/anonymous-struct/TestCallUserAnonTypedef.py
+++ 
b/lldb/test/API/commands/expression/anonymous-struct/TestCallUserAnonTypedef.py
@@ -6,22 +6,15 @@
 Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790
 """
 
-
 import lldb
 
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class TestExprLookupAnonStructTypedef(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-TestBase.setUp(self)
-# Find the breakpoint
-self.line = line_number('main.cpp', '// lldb testsuite break')
-
 @expectedFailureAll(
 oslist=['linux'],
 archs=['arm'],
@@ -29,16 +22,5 @@ def setUp(self):
 def test(self):
 """Test typedeffed untagged struct arguments for function call 
expressions"""
 self.build()
-
-self.runCmd("file "+self.getBuildArtifact("a.out"),
-CURRENT_EXECUTABLE_SET)
-lldbutil.run_break_set_by_file_and_line(
-self,
-"main.cpp",
-self.line,
-num_expected_locations=-1,
-loc_exact=True
-)
-
-self.runCmd("run", RUN_SUCCEEDED)
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
 self.expect_expr("multiply(&s)", result_type="double", 
result_value="1")

diff  --git a/lldb/test/API/commands/expression/anonymous-struct/main.cpp 
b/lldb/test/API/commands/expression/anonymous-struct/main.cpp
index 5b170c5f943a..d6366e787152 100644
--- a/lldb/test/API/commands/expression/anonymous-struct/main.cpp
+++ b/lldb/test/API/commands/expression/anonymous-struct/main.cpp
@@ -1,26 +1,17 @@
-#include 
-
 typedef struct {
-float f;
-int i;
+  float f;
+  int i;
 } my_untagged_struct;
 
-double multiply(my_untagged_struct *s)
-{
-return s->f * s->i;
-}
+double multiply(my_untagged_struct *s) { return s->f * s->i; }
 
-double multiply(my_untagged_struct *s, int x)
-{
-return multiply(s) * x;
-}
+double multiply(my_untagged_struct *s, int x) { return multiply(s) * x; }
 
-int main(int argc, char **argv)
-{
-my_untagged_struct s = {
-.f = (float)argc,
-.i = argc,
-};
-// lldb testsuite break
-return !(multiply(&s, argc) == pow(argc, 3));
+int main(int argc, char **argv) {
+  my_untagged_struct s = {
+  .f = (float)argc,
+  .i = argc,
+  };
+  // break here
+  return multiply(&s, argc) > 0;
 }



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


[Lldb-commits] [lldb] edb0efc - [lldb][NFC] Modernize call-function tests

2020-04-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-04-01T10:17:42+02:00
New Revision: edb0efca1e73ec5f791d9fe8c28f7c4c85a61c43

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

LOG: [lldb][NFC] Modernize call-function tests

Added: 


Modified: 
lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py

lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py
lldb/test/API/commands/expression/call-function/main.cpp

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py 
b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
index 261e702fa59a..f94bcae34cf9 100644
--- 
a/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
+++ 
b/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py
@@ -2,26 +2,15 @@
 Test calling std::String member functions.
 """
 
-
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class ExprCommandCallFunctionTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break for main.c.
-self.line = line_number(
-'main.cpp',
-'// Please test these expressions while stopped at this line:')
-
 @expectedFailureAll(
 compiler="icc",
 bugnumber="llvm.org/pr14437, fails with ICC 13.1")
@@ -29,15 +18,7 @@ def setUp(self):
 def test_with(self):
 """Test calling std::String member function."""
 self.build()
-self.runCmd("file " + self.getBuildArtifact("a.out"),
-CURRENT_EXECUTABLE_SET)
-
-# Some versions of GCC encode two locations for the 'return' statement
-# in main.cpp
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=-1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
 
 self.expect("print str",
 substrs=['Hello world'])

diff  --git 
a/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py 
b/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py
index 0f0f1a54e31c..1191176aa706 100644
--- a/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py
+++ b/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py
@@ -2,13 +2,10 @@
 Test calling a function, stopping in the call, continue and gather the result 
on stop.
 """
 
-
-
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class ExprCommandCallStopContinueTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
@@ -17,27 +14,16 @@ def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line number to break for main.c.
-self.line = line_number(
-'main.cpp',
-'// Please test these expressions while stopped at this line:')
-self.func_line = line_number('main.cpp', '{5, "five"}')
 
 def test(self):
 """Test gathering result from interrupted function call."""
 self.build()
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-
-# Some versions of GCC encode two locations for the 'return' statement
-# in main.cpp
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=-1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
 
 lldbutil.run_break_set_by_file_and_line(
 self,
 "main.cpp",
-self.func_line,
+line_number('main.cpp', '{5, "five"}'),
 num_expected_locations=-1,
 loc_exact=True)
 

diff  --git 
a/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py
 
b/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py
index 98cd0f24f36c..edaa76174b47 100644
--- 
a/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py
+++ 
b/lldb/test/API/commands/expression/call-function/TestCallUserDefinedFunction.py
@@ -7,36 +7,19 @@
 
 """
 
-
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class 

[Lldb-commits] [lldb] 48a5bda - [lldb][NFC] Modernize TestXValuePrinting

2020-04-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-04-01T10:20:52+02:00
New Revision: 48a5bdafba5e51244de627a50574d48c87a5249d

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

LOG: [lldb][NFC] Modernize TestXValuePrinting

Added: 


Modified: 
lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py

Removed: 




diff  --git a/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py 
b/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py
index 3a394d781f0a..f5122b84839a 100644
--- a/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py
+++ b/lldb/test/API/commands/expression/xvalue/TestXValuePrinting.py
@@ -1,36 +1,15 @@
-
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class ExprXValuePrintingTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-self.main_source = "main.cpp"
-self.main_source_spec = lldb.SBFileSpec(self.main_source)
-
-def do_test(self, dictionary=None):
-"""Printing an xvalue should work."""
-self.build(dictionary=dictionary)
-
-(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
-  '// Break here', 
self.main_source_spec)
-frame = thread.GetFrameAtIndex(0)
-
-value = frame.EvaluateExpression("foo().data")
-self.assertTrue(value.IsValid())
-self.assertTrue(value.GetError().Success())
-self.assertEqual(value.GetValueAsSigned(), 1234)
-
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
 def test(self):
-self.do_test()
-
+"""Printing an xvalue should work."""
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', 
lldb.SBFileSpec("main.cpp"))
+self.expect_expr("foo().data", result_value="1234")



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


[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I don't think that spreading this out over host and platform is convoluted. In 
fact, I was going to propose something like that myself. However, it does bring 
us back to the question of the "linux" sdk.

A couple of comments ago you said:

> The "Linux" SDK is a placeholder of sorts when debugging a Swift-on-Linux 
> server application (e.g., something like https://www.kitura.io/) from 
> *within* Xcode that points to a directory that contains the Swift 
> resources/stdlib cross-compiled for Linux.

When you say "cross-compiled", I am imagining that the resulting binary will be 
a regular linux elf file, and it's triple will be detected as `***-linux`. So, 
`Platform::GetPlatformForArchitecture(GetArchitecture(), nullptr)` will return 
PlatformLinux, and the subsequent `GetSDKPath` will return blank, whereas I am 
expecting that you would want it to return `HostInfoMacOSX::GetXcodeSDK(linux)` 
(if running on macos).

So, if all of this is true, and we want this interface to reside on the 
Platform class, then I think the implementation of `GetSDKPath` needs to be 
spread out over the individual platform classes, which would delegate to the 
appropriate host api. E.g. `PlatformLinux::GetSDKPath` (with no arguments) 
would be implemented via `HostInfo::GetXcodeSDK(linux)`, 
`PlatformRemoteAppleWatch::GetSDKPath` as `HostInfo::GetXcodeSDK(watchos)`, etc.

This would give us maximum flexibility. For instance one could implement 
`HostInfoLinux::GetXcodeSDK` to locate the xcode sdk through some other 
mechanism, and then cross-debugging mac binaries would work too. Or, one could 
implement `PlatformXXX::GetSDKPath` to download the sdk from the remote system 
somehow if it is not found on the host, and then we would be able to debug on 
any host. However, I found all of these scenarios fairly unlikely, which is why 
I said that going straight for the host seems fine. The interface is still 
sensible -- we just say that the host system has to provide the sdks for any of 
the listed platforms. And if the host doesn't provide that, tough luck. That 
setup can always be generalized if we have a need for it.

In D76471#1954045 , @JDevlieghere 
wrote:

> I think the current separation makes a lot of sense, but I don't like that 
> `XcodeSDK` class is part of Utility. I understand the need from a layering 
> perspective and I don't really have a better idea, but maybe someone else 
> does?


We could move it up to Host, and have it be next to the `HostInfo::GetXcodeSDK` 
function which returns it. Would that look any better?


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

https://reviews.llvm.org/D76471



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


[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath requested changes to this revision.
labath added a comment.
This revision now requires changes to proceed.

Thanks for the updates and for writing the test. The code looks fine to me, the 
"request changes" is for making sure the test follows best practices and is 
portable.




Comment at: lldb/test/API/tools/lldb-vscode/breakpoint/Makefile:10-17
+# The following shared library will be used to test breakpoints under dynamic 
loading
+libother.so:  other-copy.c
+   $(CC) $(CFLAGS) -fpic -o other.o -c other-copy.c
+   $(CC) $(CFLAGS) -shared -o libother.so other.o
+
+a.out: main-copy.cpp libother.so
+   echo $(CXXFLAGS) > ./flags

This is not the right way to build binaries --  it will fail on macos for 
instance.
If we were not dlopening, you should set CXX_SOURCES, and DYLIB_C_SOURCES and 
let the normal rules do build for you, but for dlopen you need to do something 
a tad more complicated and invoke a submake with the right arguments you can 
look at `functionalities/load_unload/Makefile` for an example of how to do that.

I don't think we currently have a test which uses both shared libraries, and 
relocated sources files, so it's possible that this may fail for some reason. 
But if that's the case, then I want to understand what's the problem first (so 
we can try to fix it).



Comment at: 
lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py:32-33
+
+new_main_folder = os.path.join(os.path.dirname(source_folder), 
'moved_main')
+new_other_folder = os.path.join(os.path.dirname(source_folder), 
'moved_other')
+

If I follow this correctly this will escape from the build folder for this test 
(two `dirname`s). Can you stay within the confines of the build folder?

Among other things, then you won't need to `rmtree` these things as the build 
folder is automatically cleaned before each test.



Comment at: 
lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py:229-230
breakpoint, like 'conditions' and 'hitCondition' settings.'''
-source_basename = 'main.cpp'
-source_path = os.path.join(os.getcwd(), source_basename)
+source_basename = 'main-copy.cpp'
+source_path = self.getBuildArtifact(source_basename)
 loop_line = line_number('main.cpp', '// break loop')

maybe move these into the `setUp` function?



Comment at: lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp:19
 int main(int argc, char const *argv[]) {
+  void *handle = dlopen("libother.so", RTLD_NOW);
+  int (*foo)(int) = (int (*)(int))dlsym(handle, "foo");

Looking at the other dlopen tests (e.g., 
`functionalities/load_unload/main.cpp`), it looks like you'll need to ifdef the 
correct library name here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968



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


[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It seems somewhat odd for a command to return error (one of the effects of that 
for instance is to abort processing of batch scripts), but still perform some 
changes. It might be more appropriate to call those warnings. However, 
reporting warnings from here would require some plumbing, and the new behavior 
is definitely more reasonable than the old one, so I don't think this patch 
should be blocked on that.




Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:73
 changed = true;
+idx++;
   } else {

does this actually change anything?



Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:113-114
 } else {
   error.SetErrorStringWithFormat(
   "the replacement path doesn't exist: \"%s\"", replace_path);
 }

If there are multiple non-existing paths, this will just return the last one 
right? We should list all of them.



Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:146
 changed = true;
+idx++;
   } else {

does this change anything?



Comment at: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py:45
+src_map_cmd = 'settings set target.source-map . "%s" . "%s"' % 
(src_dir + "invalid_path", src_dir)
 self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)

It would be good to follow this up with a `settings show`, both to 
test/document the expected final value of the setting, and also to catch any 
issues early.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186



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


[Lldb-commits] [lldb] 0ec88d0 - [lldb] Inherit host environment when running shell commands

2020-04-01 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-04-01T11:20:13+02:00
New Revision: 0ec88d031ad5abcd78068a8377494ec84ea6a1e1

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

LOG: [lldb] Inherit host environment when running shell commands

Summary:
On most hosts we were running shell commands with an empty environment.
The only exception was windows, which was inheriting the host enviroment
mostly by accident.

Running the commands in an empty environment does not sound like a
sensible default, so this patch changes Host::RunShellCommand to inherit
the host environment.  This impacts both commands run via
SBPlatform::Run (in case of host platforms), as well as the "platform
shell" CLI command.

Reviewers: jingham, friss

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
lldb/test/API/python_api/sbplatform/Makefile
lldb/test/API/python_api/sbplatform/TestSBPlatform.py
lldb/test/API/python_api/sbplatform/main.cpp

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

Removed: 




diff  --git a/lldb/source/Host/common/Host.cpp 
b/lldb/source/Host/common/Host.cpp
index b2485393cd6a..8a6af3881a0f 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -501,6 +501,8 @@ Status Host::RunShellCommand(const Args &args, const 
FileSpec &working_dir,
 launch_info.SetArguments(args, first_arg_is_executable);
   }
 
+  launch_info.GetEnvironment() = Host::GetEnvironment();
+
   if (working_dir)
 launch_info.SetWorkingDirectory(working_dir);
   llvm::SmallString<64> output_file_path;

diff  --git a/lldb/test/API/python_api/sbplatform/Makefile 
b/lldb/test/API/python_api/sbplatform/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/python_api/sbplatform/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git a/lldb/test/API/python_api/sbplatform/TestSBPlatform.py 
b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py
new file mode 100644
index ..4735f6ea3b49
--- /dev/null
+++ b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -0,0 +1,22 @@
+"""Test the SBPlatform APIs."""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class SBPlatformAPICase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(['pyapi'])
+def test_run(self):
+self.build()
+plat = lldb.SBPlatform.GetHostPlatform()
+
+os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run"
+def cleanup():
+del os.environ["MY_TEST_ENV_VAR"]
+self.addTearDownHook(cleanup)
+cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))
+self.assertTrue(plat.Run(cmd).Success())
+self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", 
cmd.GetOutput())

diff  --git a/lldb/test/API/python_api/sbplatform/main.cpp 
b/lldb/test/API/python_api/sbplatform/main.cpp
new file mode 100644
index ..9f2aca26ab8d
--- /dev/null
+++ b/lldb/test/API/python_api/sbplatform/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include 
+
+int main() {
+  printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR"));
+
+  return 0;
+}



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


[Lldb-commits] [lldb] aa786b8 - [lldb] [PECOFF] Only use PECallFrameInfo on the one supported architecture

2020-04-01 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2020-04-01T12:39:21+03:00
New Revision: aa786b881fc89a2a9883bff77912f2053126f95b

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

LOG: [lldb] [PECOFF] Only use PECallFrameInfo on the one supported architecture

The RuntimeFunction struct, which PECallFrameInfo interprets, has a
different layout and differnet semantics on all architectures.

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

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 38b4472f50a7..385b291df709 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -782,6 +782,9 @@ std::unique_ptr 
ObjectFilePECOFF::CreateCallFrameInfo() {
   if (!data_dir_exception.vmaddr)
 return {};
 
+  if (m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
+return {};
+
   return std::make_unique(*this, data_dir_exception.vmaddr,
data_dir_exception.vmsize);
 }



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-04-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Ok, no more complaints from my side. LGTM




Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1256
+  name,
+  parent_desc ? const_cast(parent_desc->getModuleOrNull())
+  : nullptr,

aprantl wrote:
> here ^^
True, it seems we can't fix that. Also the ExternalASTSource uses non-const 
modules, so I guess that's fine then.


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

https://reviews.llvm.org/D75488



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


[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py:50-54
+"rand", # We expect to see a reference to the rand function
+# within the last instructions
+hex(fun_start_adddress),  # We expect to have seen the first
+  # instruction of 'fun'
+"at main.cpp:21" # We expect to see the exit condition of

wallace wrote:
> labath wrote:
> > labath wrote:
> > > clayborg wrote:
> > > > can we guarantee we will see any of these on a fully loaded machine 
> > > > running many tests simultaneously? Maybe we need to settle for the 
> > > > header of the output only to know that it tried to display something?
> > > better avoid referencing functions from the system library... makes the 
> > > test more hermetic
> > What exactly is the case you're worried about? I'm not very familiar with 
> > how all this works, but I would think that the kernel trace buffer for this 
> > is application specific, and is automatically switched off when the os 
> > schedules a different process (anything else would be a security breach). 
> > If that is true, then we should have pretty good control over what goes 
> > into the buffer, and we can ensure that it is: (a) big enough; and/or (b) 
> > application does not execute too much code and overflows it (not calling 
> > rand would help us get a reasonable upper bound on that).
> > 
> > (Nonetheless it would be good to run some stress tests to verify this is 
> > stable.)
> This is how it works: by default Intel PT has to be enabled on each logical 
> CPU, where it traces everything, regardless of which thread if running. The 
> kernel has the ability to switch Intel PT on and off on each logical CPU 
> whenever there's a thread context switch, and this kind of filtering is what 
> this LLDB plugin is using.
> 
> For some context, that kind of filtering is expensive because of the constant 
> enabling/disabling of Intel PT and could incur in up to 5% total CPU cost 
> according to Intel. Another drawback of this approach is that threads spawned 
> by an already traced thread are not traced by default. The user has to enable 
> filtered tracing explicitly for these threads.
> 
> A faster approach is to enable Intel PT on all CPUs without filtering. That 
> leads to a ~2% total CPU cost according to some tests some colleagues and I 
> ran. However, this needs having a secondary trace of context switches to be 
> able to attribute Intel PT packets to individual threads. We are not 
> following that approach in this plugin because of the added complexity. 
> However, I plan to make this plugin flexible enough to be able to load Intel 
> PT traces collected by other mechanisms which can do global tracing correctly.
> 
> Lastly, the PT Trace unit in the cpu writes PT packets on memory without 
> interrupting the CPU itself nor the kernel. The only case in which packets 
> couldn't be written is when the BUS is completely full. However, this is 
> extremely rare and the CPU would retry later.
> 
> -
> That being said, I see no reason why the trace wouldn't be collected at that 
> point. Just in case I'll add a 0.1 ms wait time for the CPU to have enough 
> time to send all the packets, which should be more than enough.
Ok, that sounds good to me, though I'd be very surprised if 100ms makes any 
difference -- I've seen flaky tests with much bigger delays. 



Comment at: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp:2-8
+
+ 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
+
+===--===//
+//

wallace wrote:
> labath wrote:
> > We're not putting license headers on tests.
> > 
> > (Do these get automatically created by some IDEs or something? Can they be 
> > configured not to do that?)
> I just copy pasted it from another test
Which one? I don't see any test like that in the lldb repo. Was it from the 
swift fork or something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107



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


[Lldb-commits] [PATCH] D77000: [LLDB] [PECOFF] Only use PECallFrameInfo on the one supported architecture

2020-04-01 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa786b881fc8: [lldb] [PECOFF] Only use PECallFrameInfo on 
the one supported architecture (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77000

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -782,6 +782,9 @@
   if (!data_dir_exception.vmaddr)
 return {};
 
+  if (m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
+return {};
+
   return std::make_unique(*this, data_dir_exception.vmaddr,
data_dir_exception.vmsize);
 }


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -782,6 +782,9 @@
   if (!data_dir_exception.vmaddr)
 return {};
 
+  if (m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
+return {};
+
   return std::make_unique(*this, data_dir_exception.vmaddr,
data_dir_exception.vmsize);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77123: [lldb] Inherit host environment when running shell commands

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ec88d031ad5: [lldb] Inherit host environment when running 
shell commands (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77123

Files:
  lldb/source/Host/common/Host.cpp
  lldb/test/API/python_api/sbplatform/Makefile
  lldb/test/API/python_api/sbplatform/TestSBPlatform.py
  lldb/test/API/python_api/sbplatform/main.cpp


Index: lldb/test/API/python_api/sbplatform/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include 
+
+int main() {
+  printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR"));
+
+  return 0;
+}
Index: lldb/test/API/python_api/sbplatform/TestSBPlatform.py
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -0,0 +1,22 @@
+"""Test the SBPlatform APIs."""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class SBPlatformAPICase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(['pyapi'])
+def test_run(self):
+self.build()
+plat = lldb.SBPlatform.GetHostPlatform()
+
+os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run"
+def cleanup():
+del os.environ["MY_TEST_ENV_VAR"]
+self.addTearDownHook(cleanup)
+cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))
+self.assertTrue(plat.Run(cmd).Success())
+self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", 
cmd.GetOutput())
Index: lldb/test/API/python_api/sbplatform/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -501,6 +501,8 @@
 launch_info.SetArguments(args, first_arg_is_executable);
   }
 
+  launch_info.GetEnvironment() = Host::GetEnvironment();
+
   if (working_dir)
 launch_info.SetWorkingDirectory(working_dir);
   llvm::SmallString<64> output_file_path;


Index: lldb/test/API/python_api/sbplatform/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include 
+
+int main() {
+  printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR"));
+
+  return 0;
+}
Index: lldb/test/API/python_api/sbplatform/TestSBPlatform.py
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -0,0 +1,22 @@
+"""Test the SBPlatform APIs."""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class SBPlatformAPICase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(['pyapi'])
+def test_run(self):
+self.build()
+plat = lldb.SBPlatform.GetHostPlatform()
+
+os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run"
+def cleanup():
+del os.environ["MY_TEST_ENV_VAR"]
+self.addTearDownHook(cleanup)
+cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))
+self.assertTrue(plat.Run(cmd).Success())
+self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", cmd.GetOutput())
Index: lldb/test/API/python_api/sbplatform/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -501,6 +501,8 @@
 launch_info.SetArguments(args, first_arg_is_executable);
   }
 
+  launch_info.GetEnvironment() = Host::GetEnvironment();
+
   if (working_dir)
 launch_info.SetWorkingDirectory(working_dir);
   llvm::SmallString<64> output_file_path;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D75750#1953924 , @clayborg wrote:

> The main issue is that the symbol vendors currently are ELF, macOS and WASM. 
> Right now we have one SymbolVendor for a triple, but I can see a SymbolVendor 
> wanting to use multiple symbol servers to get information: one for the OS 
> binaries (debuginfod or DebugSymbols.framework at Apple) and one for the 
> current application with company specific symbol servers. At Apple, they can 
> download any symbols for macOS, iOS, watchOS and tvOS OSes and applications. 
> At Facebook we can download symbols for android, linux and iOS. Linux distros 
> might have ways to download symbols for their OS stuff, which might work 
> along side debuginfod? Also windows has the ability to download symbols.
>
> So it might be good to have the SymbolVendors use one or more SymbolServer 
> plug-ins.


I don't believe we have anything that would require all modules in a given 
target (or whatever) to use the same symbol vendor type. Each module gets its 
own instance of the object, which is obtained and manipulated through the 
generic interface. It is true that our current symbol vendors key off of the 
triple (more like object file type, really), so all modules ale likely to have 
the same vendor, but nothing really requires it to be that way. The symbol 
vendors get a ModuleSP, and they can use any information there to determine 
whether they are relevant. So if we had multiple symbol vendors interested in 
say elf files, we would just ask each of them in turn whether they can handle 
this module, and the first one would "win".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [PATCH] D76806: Remove m_last_file_sp from SourceManager

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I think this is fine now. Jim, do you have any more thoughts on this patchset?




Comment at: 
lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py:40
+# Make sure source file is bigger than 16K to trigger memory mapping
+self.assertTrue(os.stat(src).st_size > (4*4096))
+

self.assertGreater


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76806



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-04-01 Thread James Henderson via Phabricator via lldb-commits
jhenderson accepted this revision.
jhenderson added a comment.

Nothing else from me, thanks.


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Thanks for doing this. This looks fine to me. @dblaikie, @jhenderson, do you 
have any additional comments?




Comment at: llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:38-39
+  if (IndexVersion == 5) {
+assert(Kind >= DW_SECT_INFO && Kind <= DW_SECT_RNGLISTS &&
+   Kind != DW_SECT_EXT_TYPES);
+return static_cast(Kind);

maybe a small helper like `isKnownSectionKind` ?


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

https://reviews.llvm.org/D75929



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


[Lldb-commits] [lldb] 9beba42 - [lldb][NFC] Modernize TestExprChar

2020-04-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-04-01T13:24:21+02:00
New Revision: 9beba4245a77ae75db874146036b77fb76398e4c

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

LOG: [lldb][NFC] Modernize TestExprChar

Added: 


Modified: 
lldb/test/API/commands/expression/char/TestExprsChar.py

Removed: 




diff  --git a/lldb/test/API/commands/expression/char/TestExprsChar.py 
b/lldb/test/API/commands/expression/char/TestExprsChar.py
index f1fa78053846..a1a4568aa92e 100644
--- a/lldb/test/API/commands/expression/char/TestExprsChar.py
+++ b/lldb/test/API/commands/expression/char/TestExprsChar.py
@@ -1,44 +1,21 @@
-
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class ExprCharTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-self.main_source = "main.cpp"
-self.main_source_spec = lldb.SBFileSpec(self.main_source)
-
 def do_test(self, dictionary=None):
 """These basic expression commands should work as expected."""
 self.build(dictionary=dictionary)
 
-(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
-  '// Break here', 
self.main_source_spec)
-frame = thread.GetFrameAtIndex(0)
-
-value = frame.EvaluateExpression("foo(c)")
-self.assertTrue(value.IsValid())
-self.assertTrue(value.GetError().Success())
-self.assertEqual(value.GetValueAsSigned(0), 1)
-
-value = frame.EvaluateExpression("foo(sc)")
-self.assertTrue(value.IsValid())
-self.assertTrue(value.GetError().Success())
-self.assertEqual(value.GetValueAsSigned(0), 2)
+lldbutil.run_to_source_breakpoint(self, '// Break here', 
lldb.SBFileSpec("main.cpp"))
 
-value = frame.EvaluateExpression("foo(uc)")
-self.assertTrue(value.IsValid())
-self.assertTrue(value.GetError().Success())
-self.assertEqual(value.GetValueAsSigned(0), 3)
+self.expect_expr("foo(c)", result_value="1")
+self.expect_expr("foo(sc)", result_value="2")
+self.expect_expr("foo(uc)", result_value="3")
 
 def test_default_char(self):
 self.do_test()



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


[Lldb-commits] [PATCH] D72251: [RFC] Support SVE registers access on AArch64 Linux

2020-04-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid abandoned this revision.
omjavaid added a comment.
Herald added a subscriber: danielkiss.

Abandoned in favor of following patches and more to come as suggested by labath 
in separate patches.

https://reviews.llvm.org/D77047

https://reviews.llvm.org/D77045

https://reviews.llvm.org/D77044

https://reviews.llvm.org/D77043


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

https://reviews.llvm.org/D72251



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


[Lldb-commits] [lldb] c9d1588 - Silent failing TestWatchpointCount.py aarch64/linux

2020-04-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-04-01T16:31:37+05:00
New Revision: c9d15880542ef483470ee33dbd055b68396d4537

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

LOG: Silent failing TestWatchpointCount.py aarch64/linux

Skip TestWatchpointCount.py for aarch64-linux to fix lldb aarch64 linux 
buildbot.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/

Added: 


Modified: 
lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py

Removed: 




diff  --git 
a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py 
b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
index 18667e913a94..9ad21522b4aa 100644
--- a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
+++ b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
@@ -10,6 +10,7 @@ class TestWatchpointCount(TestBase):
 def setUp(self):
 TestBase.setUp(self)
 
+@skipIf(oslist=["linux"], archs=["aarch64"])
 def test_watchpoint_count(self):
 self.build()
 (_, process, thread, _) = lldbutil.run_to_source_breakpoint(self, 
"patatino", lldb.SBFileSpec("main.c"))



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


[Lldb-commits] [PATCH] D77043: Fix process gdb-remote usage of value_regs/invalidate_regs

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a reviewer: jasonmolenda.
labath added a comment.

I am still thinking this over, but for now I have two comments. First, could 
you re-upload the diff with full context (e.g. `git show -U`). That would 
make it a lot easier to review this.
Second, would it be possible to change the meaning of the `invalidate_regs` and 
`value_regs` lists so that they do the right thing even in your case (instead 
of introducing a new number)? We already have too many numbering schemes to 
begin with, and introducing a new one is definitely something I'd like to avoid 
(in particular when the number is stored as `eRegisterKindLLDB` on the server 
side, but then becomes `eRegisterKindProcessPlugin` on the other end).


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

https://reviews.llvm.org/D77043



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


[Lldb-commits] [PATCH] D73206: Pass `CompileUnit *` along `DWARFDIE` for DWZ

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The internal representation of DebugNames and Apple indexes is fixed by the 
relevant (pseudo-)standards, so we can't really change it. The question is how 
to efficiently (and cleanly) convert from the internal representation to some 
common thing. The conversion from AppleIndex to DIERef is trivial (which is not 
surprising as it was the first and the overall design was optimized for that). 
With debug_names, the situation gets more tricky. The internal representation 
of debug_names uses CU-relative DIE offsets, but DIERef wants an absolute 
offset. That means the index has to do more work to produce the common 
representation. And it needs to do that for all results, even though a lot of 
the index users are really interested only in a single entry. With the switch 
to user_id_t, _all_ indexes would have to do some extra work to encode it, only 
for their users to have to immediately decode it back.  Having a 
iterator/callback based api would allow us to minimize the impact of that, as 
it would only need to happen for the entries that are really used. And /I 
think/ we could make it interface returns DWARFDies directly, and each index 
converts to that using the most direct approach available.

Another aspect is that is seems fundamentally wrong to use an representation 
which requires knowledge of multiple SymbolFiles when dealing with entities 
which are statically know to come from a single file (here, I mean 
SymbolFileDWARFDebugMap -- I'm glossing over SymbolFileDWARFDwos as those 
aren't really standalone files, and I hope that class will go away soon).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73206



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


[Lldb-commits] [PATCH] D77045: Add invalidate list to primary regs in arm64 register infos

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This sounds like it could use a test case.




Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h:593-594
 
+#define STRINGIZE2(x) #x
+#define STRINGIZE(x) STRINGIZE2(x)
+

What's up with the indirection?


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

https://reviews.llvm.org/D77045



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


[Lldb-commits] [PATCH] D77047: AArch64 SVE register infos and ptrace support

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

> There is no physical hardware currently available to test SVE and we make use 
> of QEMU for the purpose of testing this feature.

Are these registers presented in core files in any way? Would it be possible to 
at least test the `RegisterInfoPOSIX_arm64.h` changes that way?


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

https://reviews.llvm.org/D77047



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


[Lldb-commits] [PATCH] D72251: [RFC] Support SVE registers access on AArch64 Linux

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for splitting this up.


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

https://reviews.llvm.org/D72251



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


[Lldb-commits] [PATCH] D77044: Extend max register size to accommodate AArch64 SVE vector regs

2020-04-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Sounds fairly noncontroversial. I don't think we have too many of these objects 
floating around, but if it turns out we do, we could switch to a SmallVector to 
optimize for the common case of smaller registers.




Comment at: lldb/include/lldb/Utility/RegisterValue.h:264
  // register for any supported target.
-uint8_t length;
+uint32_t length;
 lldb::ByteOrder byte_order;

how about we stick to uint16_t here ?



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:2051
   // Parse out the value.
-  uint8_t reg_bytes[32]; // big enough to support up to 256 bit ymmN register
+  uint8_t reg_bytes[256]; // big enough to support up to 256 byte AArch64 SVE
+  // registers

danielkiss wrote:
> Could we use the kMaxRegisterByteSize here? 
An excellent idea.


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

https://reviews.llvm.org/D77044



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-04-01 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro added a comment.

In D77108#1952818 , @aprantl wrote:

> For the future, a clean solution would be extending the macros in Dwarf.def 
> to list the stack effects in the definitions of the DW_OP_*, for example
>
>   // opcode, name, version, vendor, in, out
>   HANDLE_DW_OP(0x12, dup, 2, DWARF, 1, 2)
>
>
> and then we could write a static verifier that ensures that the stack effects 
> of an entire expression is sound. (And we could check this in LLVM, already, 
> too).


`DW_OP_entry_value` may be requiring a special handling as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-04-01 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 254207.
ikudrin marked an inline comment as done.
ikudrin added a comment.

Thanks, @jhenderson, @labath!

- Added a helper function `isKnownV5SectionID()`.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of 

[Lldb-commits] [PATCH] D76806: Remove m_last_file_sp from SourceManager

2020-04-01 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 254241.
emrekultursay marked an inline comment as done.
emrekultursay added a comment.

use assertGreater instead of assertTrue(x>y)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76806

Files:
  lldb/include/lldb/Core/SourceManager.h
  lldb/source/Core/SourceManager.cpp
  lldb/test/API/commands/settings/use_source_cache/Makefile
  lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
  lldb/test/API/commands/settings/use_source_cache/main.cpp

Index: lldb/test/API/commands/settings/use_source_cache/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/settings/use_source_cache/main.cpp
@@ -0,0 +1,619 @@
+// This file should be large enough that LLDB decides to load it
+// using memory mapping. See:
+//   ⁠llvm/lib/Support/MemoryBuffer.cp:shouldUseMmap()
+
+#include 
+
+int calc(int x0, int x1, int x2);
+
+int
+main(int argc, char const *argv[])
+{
+  fprintf(stderr, "Hello, world => %d\n", calc(0, 1, 2));
+  return 0;
+}
+
+
+// The name of this function is used in tests to set breakpoints by name.
+int calc(int x0, int x1, int x2) {
+  int x3 = x2 * x1 + x0;
+  int x4 = x3 * x2 + x1;
+  int x5 = x4 * x3 + x2;
+  int x6 = x5 * x4 + x3;
+  int x7 = x6 * x5 + x4;
+  int x8 = x7 * x6 + x5;
+  int x9 = x8 * x7 + x6;
+  int x10 = x9 * x8 + x7;
+  int x11 = x10 * x9 + x8;
+  int x12 = x11 * x10 + x9;
+  int x13 = x12 * x11 + x10;
+  int x14 = x13 * x12 + x11;
+  int x15 = x14 * x13 + x12;
+  int x16 = x15 * x14 + x13;
+  int x17 = x16 * x15 + x14;
+  int x18 = x17 * x16 + x15;
+  int x19 = x18 * x17 + x16;
+  int x20 = x19 * x18 + x17;  
+  int x21 = x20 * x19 + x18;
+  int x22 = x21 * x20 + x19;
+  int x23 = x22 * x21 + x20;
+  int x24 = x23 * x22 + x21;
+  int x25 = x24 * x23 + x22;
+  int x26 = x25 * x24 + x23;
+  int x27 = x26 * x25 + x24;
+  int x28 = x27 * x26 + x25;
+  int x29 = x28 * x27 + x26;
+  int x30 = x29 * x28 + x27;
+  int x31 = x30 * x29 + x28;
+  int x32 = x31 * x30 + x29;
+  int x33 = x32 * x31 + x30;
+  int x34 = x33 * x32 + x31;
+  int x35 = x34 * x33 + x32;
+  int x36 = x35 * x34 + x33;
+  int x37 = x36 * x35 + x34;
+  int x38 = x37 * x36 + x35;
+  int x39 = x38 * x37 + x36;
+  int x40 = x39 * x38 + x37;
+  int x41 = x40 * x39 + x38;
+  int x42 = x41 * x40 + x39;
+  int x43 = x42 * x41 + x40;
+  int x44 = x43 * x42 + x41;
+  int x45 = x44 * x43 + x42;
+  int x46 = x45 * x44 + x43;
+  int x47 = x46 * x45 + x44;
+  int x48 = x47 * x46 + x45;
+  int x49 = x48 * x47 + x46;
+  int x50 = x49 * x48 + x47;
+  int x51 = x50 * x49 + x48;
+  int x52 = x51 * x50 + x49;
+  int x53 = x52 * x51 + x50;
+  int x54 = x53 * x52 + x51;
+  int x55 = x54 * x53 + x52;
+  int x56 = x55 * x54 + x53;
+  int x57 = x56 * x55 + x54;
+  int x58 = x57 * x56 + x55;
+  int x59 = x58 * x57 + x56;
+  int x60 = x59 * x58 + x57;
+  int x61 = x60 * x59 + x58;
+  int x62 = x61 * x60 + x59;
+  int x63 = x62 * x61 + x60;
+  int x64 = x63 * x62 + x61;
+  int x65 = x64 * x63 + x62;
+  int x66 = x65 * x64 + x63;
+  int x67 = x66 * x65 + x64;
+  int x68 = x67 * x66 + x65;
+  int x69 = x68 * x67 + x66;
+  int x70 = x69 * x68 + x67;
+  int x71 = x70 * x69 + x68;
+  int x72 = x71 * x70 + x69;
+  int x73 = x72 * x71 + x70;
+  int x74 = x73 * x72 + x71;
+  int x75 = x74 * x73 + x72;
+  int x76 = x75 * x74 + x73;
+  int x77 = x76 * x75 + x74;
+  int x78 = x77 * x76 + x75;
+  int x79 = x78 * x77 + x76;
+  int x80 = x79 * x78 + x77;
+  int x81 = x80 * x79 + x78;
+  int x82 = x81 * x80 + x79;
+  int x83 = x82 * x81 + x80;
+  int x84 = x83 * x82 + x81;
+  int x85 = x84 * x83 + x82;
+  int x86 = x85 * x84 + x83;
+  int x87 = x86 * x85 + x84;
+  int x88 = x87 * x86 + x85;
+  int x89 = x88 * x87 + x86;
+  int x90 = x89 * x88 + x87;
+  int x91 = x90 * x89 + x88;
+  int x92 = x91 * x90 + x89;
+  int x93 = x92 * x91 + x90;
+  int x94 = x93 * x92 + x91;
+  int x95 = x94 * x93 + x92;
+  int x96 = x95 * x94 + x93;
+  int x97 = x96 * x95 + x94;
+  int x98 = x97 * x96 + x95;
+  int x99 = x98 * x97 + x96;
+  int x100 = x99 * x98 + x97;
+  int x101 = x100 * x99 + x98;
+  int x102 = x101 * x100 + x99;
+  int x103 = x102 * x101 + x100;
+  int x104 = x103 * x102 + x101;
+  int x105 = x104 * x103 + x102;
+  int x106 = x105 * x104 + x103;
+  int x107 = x106 * x105 + x104;
+  int x108 = x107 * x106 + x105;
+  int x109 = x108 * x107 + x106;
+  int x110 = x109 * x108 + x107;
+  int x111 = x110 * x109 + x108;
+  int x112 = x111 * x110 + x109;
+  int x113 = x112 * x111 + x110;
+  int x114 = x113 * x112 + x111;
+  int x115 = x114 * x113 + x112;
+  int x116 = x115 * x114 + x113;
+  int x117 = x116 * x115 + x114;
+  int x118 = x117 * x116 + x115;
+  int x119 = x118 * x117 + x116;
+  int x120 = x119 * x118 + x117;
+  int x121 = x120 * x119 + x118;
+  int x122 = x121 * x120 + x119;
+  int x123 = x122 * x121 + x120;
+  int x124 = x123 * x122 + x121;
+  int x125 = x

[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-04-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked an inline comment as done.
wallace added inline comments.



Comment at: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp:2-8
+
+ 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
+
+===--===//
+//

labath wrote:
> wallace wrote:
> > labath wrote:
> > > We're not putting license headers on tests.
> > > 
> > > (Do these get automatically created by some IDEs or something? Can they 
> > > be configured not to do that?)
> > I just copy pasted it from another test
> Which one? I don't see any test like that in the lldb repo. Was it from the 
> swift fork or something?
I copied it from here 
https://github.com/llvm/llvm-project/blob/master/lldb/tools/intel-features/intel-mpx/test/main.cpp
I'll remove the header from that file as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107



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


[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked 4 inline comments as done.
wallace added inline comments.



Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:73
 changed = true;
+idx++;
   } else {

labath wrote:
> does this actually change anything?
Indeed. It's used in line 70 as the index to replace in the replace operation



Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:113-114
 } else {
   error.SetErrorStringWithFormat(
   "the replacement path doesn't exist: \"%s\"", replace_path);
 }

labath wrote:
> If there are multiple non-existing paths, this will just return the last one 
> right? We should list all of them.
good catch



Comment at: lldb/source/Interpreter/OptionValuePathMappings.cpp:146
 changed = true;
+idx++;
   } else {

labath wrote:
> does this change anything?
Same as above, it's used in line 144



Comment at: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py:45
+src_map_cmd = 'settings set target.source-map . "%s" . "%s"' % 
(src_dir + "invalid_path", src_dir)
 self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)

labath wrote:
> It would be good to follow this up with a `settings show`, both to 
> test/document the expected final value of the setting, and also to catch any 
> issues early.
good one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186



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


[Lldb-commits] [PATCH] D76806: Remove m_last_file_sp from SourceManager

2020-04-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

There was one missing use of GetLastFile (as opposed to doing it by hand.)

Getting the default file is not used in any performance critical way that I'm 
aware of.  It's mostly used for "break set -l" with no "-f" and list with no 
arguments and commands of that sort.  So the extra lookup to get the FileSP 
from the source manager instead of caching it directly should not cause 
problems.  And if you asked not to cache, you've already decided to pay the 
cost for that.

LGTM with that trivial fix.




Comment at: lldb/source/Core/SourceManager.cpp:175-176
 
-  if (m_last_file_sp.get()) {
+  FileSP last_file_sp(GetFile(m_last_file_spec));
+  if (last_file_sp.get()) {
 const uint32_t end_line = start_line + count - 1;

labath wrote:
> `if(FileSP last_file_sp = GetLastFile())`
Doesn't look like this got converted to GetLastFile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76806



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


[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254268.
wallace added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186

Files:
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Index: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
===
--- lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
+++ lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
@@ -1,6 +1,7 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
+import os
 
 
 class TestTargetSourceMap(TestBase):
@@ -10,6 +11,21 @@
 @no_debug_info_test
 def test_source_map(self):
 """Test target.source-map' functionality."""
+
+def assertBreakpointWithSourceMap(src_path):
+# Set a breakpoint after we remap source and verify that it succeeds
+bp = target.BreakpointCreateByLocation(src_path, 2)
+self.assertEquals(bp.GetNumLocations(), 1,
+"make sure breakpoint was resolved with map")
+
+# Now make sure that we can actually FIND the source file using this
+# remapping:
+retval = lldb.SBCommandReturnObject()
+self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
+self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
+self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
+self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
+
 # Set the target soure map to map "./" to the current test directory
 src_dir = self.getSourceDir()
 src_path = os.path.join(src_dir, "main.c")
@@ -25,19 +41,68 @@
 bp = target.BreakpointCreateByLocation(src_path, 2)
 self.assertEquals(bp.GetNumLocations(), 0,
 "make sure no breakpoints were resolved without map")
-src_map_cmd = 'settings set target.source-map . "%s"' % (src_dir)
-self.dbg.HandleCommand(src_map_cmd)
 
-# Set a breakpoint after we remap source and verify that it succeeds
-bp = target.BreakpointCreateByLocation(src_path, 2)
-self.assertEquals(bp.GetNumLocations(), 1,
-"make sure breakpoint was resolved with map")
-
-# Now make sure that we can actually FIND the source file using this
-# remapping:
-retval = lldb.SBCommandReturnObject()
-self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
-self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
-self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
-self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
+invalid_path = src_dir + "invalid_path"
+invalid_path2 = src_dir + "invalid_path2"
+
+# We make sure the error message contains all the invalid paths
+self.expect(
+'settings set target.source-map . "%s" . "%s" . "%s"' % (invalid_path, src_dir, invalid_path2),
+substrs=[
+'the replacement path doesn\'t exist: "%s"' % (invalid_path),
+'the replacement path doesn\'t exist: "%s"' % (invalid_path2),
+],
+error=True,
+)
+self.expect(
+'settings show target.source-map',
+substrs=['[0] "." -> "%s"' % (src_dir)],
+)
+assertBreakpointWithSourceMap(src_path)
+
+# Index 0 is the valid mapping, and modifying it to an invalid one should have no effect
+self.expect(
+'settings replace target.source-map 0 . "%s"' % (invalid_path),
+substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
+error=True,
+)
+self.expect(
+'settings show target.source-map',
+substrs=['[0] "." -> "%s"' % (src_dir)]
+)
+assertBreakpointWithSourceMap(src_path)
+
+# Let's clear and add the mapping in with insert-after
+self.runCmd('settings remove target.source-map 0')
+self.expect(
+'settings show target.source-map',
+endstr="target.source-map (path-map) =\n",
+)
 
+# We add a valid but useless mapping so that we can use insert-after
+another_valid_path = os.path.dirname(src_dir)
+self.runCmd('settings set target.source-map . "%s"' % (another_valid_path))
+
+self.expect(
+'settings replace target.source-map 0 . "%s"' % (invalid_path),
+substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
+error=T

[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-04-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254280.
wallace marked 2 inline comments as done.
wallace added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint/Makefile
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
  lldb/test/API/tools/lldb-vscode/breakpoint/other.c
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -418,7 +418,16 @@
   bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
 auto bp_event = CreateEventObject("breakpoint");
 llvm::json::Object body;
-body.try_emplace("breakpoint", CreateBreakpoint(bp));
+// As VSCode already knows the path of this breakpoint, we don't
+// need to send it back as part of a "changed" event. This
+// prevent us from sending to VSCode paths that should be source
+// mapped. Note that CreateBreakpoint doesn't apply source mapping.
+// Besides, the current implementation of VSCode ignores the
+// "source" element of breakpoint events.
+llvm::json::Value source_bp = CreateBreakpoint(bp);
+source_bp.getAsObject()->erase("source");
+
+body.try_emplace("breakpoint", source_bp);
 body.try_emplace("reason", "changed");
 bp_event.try_emplace("body", std::move(body));
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
@@ -1364,13 +1373,13 @@
 llvm::sys::fs::set_current_path(debuggerRoot.data());
   }
 
-  SetSourceMapFromArguments(*arguments);
-
   // Run any initialize LLDB commands the user specified in the launch.json.
   // This is run before target is created, so commands can't do anything with
   // the targets - preRunCommands are run with the target.
   g_vsc.RunInitCommands();
 
+  SetSourceMapFromArguments(*arguments);
+
   lldb::SBError status;
   g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
   if (status.Fail()) {
@@ -1748,13 +1757,14 @@
 const auto &existing_bp = existing_source_bps->second.find(src_bp.line);
 if (existing_bp != existing_source_bps->second.end()) {
   existing_bp->second.UpdateBreakpoint(src_bp);
-  AppendBreakpoint(existing_bp->second.bp, response_breakpoints);
+  AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
+   src_bp.line);
   continue;
 }
   }
   // At this point the breakpoint is new
   src_bp.SetBreakpoint(path.data());
-  AppendBreakpoint(src_bp.bp, response_breakpoints);
+  AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
   g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
 }
   }
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -184,28 +184,58 @@
 void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object,
 llvm::StringRef key);
 
-/// Converts \a bp to a JSON value and appends all locations to the
+/// Converts \a bp to a JSON value and appends the first valid location to the
 /// \a breakpoints array.
 ///
 /// \param[in] bp
-/// A LLDB breakpoint object which will get all locations extracted
-/// and converted into a JSON objects in the \a breakpoints array
+/// A LLDB breakpoint object which will get the first valid location
+/// extracted and converted into a JSON object in the \a breakpoints array
 ///
 /// \param[in] breakpoints
 /// A JSON array that will get a llvm::json::Value for \a bp
 /// appended to it.
-void AppendBreakpoint(lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints);
+///
+/// \param[in] request_path
+/// An optional source path to use when creating the "Source" object of this
+/// breakpoint. If not specified, the "Source" object is created from the
+/// breakpoint's address' LineEntry. It is useful to ensure the same source
+/// paths provided by the setBreakpoints request are returned to the IDE.
+///
+/// \param[in] request_line
+/// An optional line to use when creating the "Breakpoint" object to append.
+/// It is used if the breakpoint has no valid locations.
+/// It is useful to ensure the same line
+/// provided by the setBreakpoints requ

[Lldb-commits] [lldb] 30350c2 - [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-04-01T13:01:40-07:00
New Revision: 30350c254106ce25b16b13f05e713ceb2b15ce09

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

LOG: [source maps] Ensure all valid source maps are added instead of failing 
with the first invalid one

Summary:
Several lldb-vscode users have noticed that when a source map rule is invalid 
(because a folder doesn't exist anymore), the rest of the source maps from 
their configurations are not applied.
This happens because lldb-vscode executes a single "settings set 
target.source-map" command with all the source maps and LLDB processes them one 
by one until one fails.

Instead of doing this, we can process in LLDB all the source map rules and 
apply the valid ones instead of failing fast.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Interpreter/OptionValuePathMappings.cpp
lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Removed: 




diff  --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp 
b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index ebff5c4dca3e..2784279579f0 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -61,7 +61,7 @@ Status 
OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
 count);
   } else {
 bool changed = false;
-for (size_t i = 1; i < argc; i += 2, ++idx) {
+for (size_t i = 1; i < argc; i += 2) {
   const char *orginal_path = args.GetArgumentAtIndex(i);
   const char *replace_path = args.GetArgumentAtIndex(i + 1);
   if (VerifyPathExists(replace_path)) {
@@ -70,9 +70,13 @@ Status 
OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
 if (!m_path_mappings.Replace(a, b, idx, m_notify_changes))
   m_path_mappings.Append(a, b, m_notify_changes);
 changed = true;
+idx++;
   } else {
+std::string previousError =
+error.Fail() ? std::string(error.AsCString()) + "\n" : "";
 error.SetErrorStringWithFormat(
-"the replacement path doesn't exist: \"%s\"", replace_path);
+"%sthe replacement path doesn't exist: \"%s\"",
+previousError.c_str(), replace_path);
 break;
   }
 }
@@ -109,9 +113,11 @@ Status 
OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
   m_value_was_set = true;
   changed = true;
 } else {
+  std::string previousError =
+  error.Fail() ? std::string(error.AsCString()) + "\n" : "";
   error.SetErrorStringWithFormat(
-  "the replacement path doesn't exist: \"%s\"", replace_path);
-  break;
+  "%sthe replacement path doesn't exist: \"%s\"",
+  previousError.c_str(), replace_path);
 }
   }
   if (changed)
@@ -135,7 +141,7 @@ Status 
OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
 bool changed = false;
 if (op == eVarSetOperationInsertAfter)
   ++idx;
-for (size_t i = 1; i < argc; i += 2, ++idx) {
+for (size_t i = 1; i < argc; i += 2) {
   const char *orginal_path = args.GetArgumentAtIndex(i);
   const char *replace_path = args.GetArgumentAtIndex(i + 1);
   if (VerifyPathExists(replace_path)) {
@@ -143,9 +149,13 @@ Status 
OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
 ConstString b(replace_path);
 m_path_mappings.Insert(a, b, idx, m_notify_changes);
 changed = true;
+idx++;
   } else {
+std::string previousError =
+error.Fail() ? std::string(error.AsCString()) + "\n" : "";
 error.SetErrorStringWithFormat(
-"the replacement path doesn't exist: \"%s\"", replace_path);
+"%sthe replacement path doesn't exist: \"%s\"",
+previousError.c_str(), replace_path);
 break;
   }
 }

diff  --git a/lldb/test/API/functionalities/source-map/TestTargetSourceMap.py 
b/lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
index ac03d80023e4..c9800e6f199e 100644
--- a/lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
+++ b/lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
@@ -1,6 +1,7 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
+import os
 
 
 class TestTargetSourceMap(TestBase):
@@ -10,6 +11,21 @@ class TestTargetSourceMap(Test

[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG30350c254106: [source maps] Ensure all valid source maps are 
added instead of failing with… (authored by Walter Erquinigo 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186

Files:
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Index: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
===
--- lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
+++ lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
@@ -1,6 +1,7 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
+import os
 
 
 class TestTargetSourceMap(TestBase):
@@ -10,6 +11,21 @@
 @no_debug_info_test
 def test_source_map(self):
 """Test target.source-map' functionality."""
+
+def assertBreakpointWithSourceMap(src_path):
+# Set a breakpoint after we remap source and verify that it succeeds
+bp = target.BreakpointCreateByLocation(src_path, 2)
+self.assertEquals(bp.GetNumLocations(), 1,
+"make sure breakpoint was resolved with map")
+
+# Now make sure that we can actually FIND the source file using this
+# remapping:
+retval = lldb.SBCommandReturnObject()
+self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
+self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
+self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
+self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
+
 # Set the target soure map to map "./" to the current test directory
 src_dir = self.getSourceDir()
 src_path = os.path.join(src_dir, "main.c")
@@ -25,19 +41,68 @@
 bp = target.BreakpointCreateByLocation(src_path, 2)
 self.assertEquals(bp.GetNumLocations(), 0,
 "make sure no breakpoints were resolved without map")
-src_map_cmd = 'settings set target.source-map . "%s"' % (src_dir)
-self.dbg.HandleCommand(src_map_cmd)
 
-# Set a breakpoint after we remap source and verify that it succeeds
-bp = target.BreakpointCreateByLocation(src_path, 2)
-self.assertEquals(bp.GetNumLocations(), 1,
-"make sure breakpoint was resolved with map")
-
-# Now make sure that we can actually FIND the source file using this
-# remapping:
-retval = lldb.SBCommandReturnObject()
-self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
-self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
-self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
-self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
+invalid_path = src_dir + "invalid_path"
+invalid_path2 = src_dir + "invalid_path2"
+
+# We make sure the error message contains all the invalid paths
+self.expect(
+'settings set target.source-map . "%s" . "%s" . "%s"' % (invalid_path, src_dir, invalid_path2),
+substrs=[
+'the replacement path doesn\'t exist: "%s"' % (invalid_path),
+'the replacement path doesn\'t exist: "%s"' % (invalid_path2),
+],
+error=True,
+)
+self.expect(
+'settings show target.source-map',
+substrs=['[0] "." -> "%s"' % (src_dir)],
+)
+assertBreakpointWithSourceMap(src_path)
+
+# Index 0 is the valid mapping, and modifying it to an invalid one should have no effect
+self.expect(
+'settings replace target.source-map 0 . "%s"' % (invalid_path),
+substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
+error=True,
+)
+self.expect(
+'settings show target.source-map',
+substrs=['[0] "." -> "%s"' % (src_dir)]
+)
+assertBreakpointWithSourceMap(src_path)
+
+# Let's clear and add the mapping in with insert-after
+self.runCmd('settings remove target.source-map 0')
+self.expect(
+'settings show target.source-map',
+endstr="target.source-map (path-map) =\n",
+)
 
+# We add a valid but useless mapping so that we can use insert-after
+another_valid_path = os.path.dirname(src_dir)
+self.runCmd('settings set target.source-map . "%s"' % (another_valid_path))
+
+self.expect(
+'settings replace target.s

[Lldb-commits] [lldb] f1242ec - [intel-pt] Implement a basic test case

2020-04-01 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-04-01T13:19:15-07:00
New Revision: f1242ec54306c5fbdc9a907e936be899a0ad21ee

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

LOG: [intel-pt] Implement a basic test case

Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
lldb/test/API/tools/intel-features/intel-pt/test/Makefile
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
lldb/test/API/tools/intel-features/intel-pt/test/main.cpp

Modified: 
lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Removed: 




diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
new file mode 100644
index ..29bcf3de696a
--- /dev/null
+++ 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,59 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets 
to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for 
loop')) 
+])
+
+self.runCmd("processor-trace stop")

diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
new file mode 100644
index ..ea826a2ac0c6
--- /dev/null
+++ b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+using namespace std;
+
+int fun(int a) { return a * a + 1; }
+
+int main() {
+  int z = 0;
+  for (int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}

diff  --git a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp 
b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
index 8db1c0f82d66..5e409a269fa4 100644
--- a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@ class ProcessorTraceStart : public 
lldb::SBCommandPluginInterface {
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@ class ProcessorTraceInfo : public 
lldb::SBCommandPluginI

[Lldb-commits] [lldb] 8ba8a4a - Revert "[intel-pt] Implement a basic test case"

2020-04-01 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-04-01T13:27:30-07:00
New Revision: 8ba8a4a14d417abd4a104c0f8b5ec289ed0a1b16

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

LOG: Revert "[intel-pt] Implement a basic test case"

This reverts commit f1242ec54306c5fbdc9a907e936be899a0ad21ee.

Added: 


Modified: 
lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Removed: 
lldb/test/API/tools/intel-features/intel-pt/test/Makefile
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
lldb/test/API/tools/intel-features/intel-pt/test/main.cpp



diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
deleted file mode 100644
index 8b20bcb0..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
deleted file mode 100644
index 29bcf3de696a..
--- 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
+++ /dev/null
@@ -1,59 +0,0 @@
-from __future__ import print_function
-
-import os
-import lldb
-import time
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestIntelPTSimpleBinary(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-@skipIf(oslist=no_match(['linux']))
-@skipIf(archs=no_match(['i386', 'x86_64']))
-@skipIfRemote
-def test_basic_flow(self):
-"""Test collection, decoding, and dumping instructions"""
-lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
-lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
-plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
-if not os.path.isfile(plugin_file):
-self.skipTest("features plugin missing.")
-
-self.build()
-
-self.runCmd("plugin load " + plugin_file)
-
-exe = self.getBuildArtifact("a.out")
-lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
-# We start tracing from main
-self.runCmd("processor-trace start all")
-
-# We check the trace after the for loop
-self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
-self.runCmd("c")
-
-# We wait a little bit to ensure the processor has send the PT packets 
to
-# the memory
-time.sleep(.1)
-
-# We find the start address of the 'fun' function for a later check
-target = self.dbg.GetSelectedTarget()
-fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
-.GetStartAddress().GetLoadAddress(target)
-
-# We print the last instructions
-self.expect("processor-trace show-instr-log -c 100",
-patterns=[
-# We expect to have seen the first instruction of 'fun'
-hex(fun_start_adddress),  
-# We expect to see the exit condition of the for loop
-"at main.cpp:" + str(line_number('main.cpp', '// Break for 
loop')) 
-])
-
-self.runCmd("processor-trace stop")

diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
deleted file mode 100644
index ea826a2ac0c6..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include 
-
-using namespace std;
-
-int fun(int a) { return a * a + 1; }
-
-int main() {
-  int z = 0;
-  for (int i = 0; i < 1; i++) { // Break for loop
-z += fun(z);
-  }
-
-  return 0; // Break 1
-}

diff  --git a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp 
b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
index 5e409a269fa4..8db1c0f82d66 100644
--- a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,7 +191,6 @@ class ProcessorTraceStart : public 
lldb::SBCommandPluginInterface {
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
-result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -291,7 +290,6 @@ class ProcessorTraceInfo : public 
lldb::SBCommandPluginInterface {
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
-result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -430,7 +428,6 @@ class ProcessorTraceShowInstrLog : public 
lldb::SBCommandPluginInterfac

[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D77186#1955451 , @wallace wrote:

> address comments


@wallace labath made comments after the differential had been approved. So it 
looks like he may have further questions. It was probably better waiting for an 
explicit ack instead of being in a haste.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186



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


[Lldb-commits] [PATCH] D76806: Remove m_last_file_sp from SourceManager

2020-04-01 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 254292.
emrekultursay added a comment.

Fix missing use of GetLastFile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76806

Files:
  lldb/include/lldb/Core/SourceManager.h
  lldb/source/Core/SourceManager.cpp
  lldb/test/API/commands/settings/use_source_cache/Makefile
  lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
  lldb/test/API/commands/settings/use_source_cache/main.cpp

Index: lldb/test/API/commands/settings/use_source_cache/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/settings/use_source_cache/main.cpp
@@ -0,0 +1,619 @@
+// This file should be large enough that LLDB decides to load it
+// using memory mapping. See:
+//   ⁠llvm/lib/Support/MemoryBuffer.cp:shouldUseMmap()
+
+#include 
+
+int calc(int x0, int x1, int x2);
+
+int
+main(int argc, char const *argv[])
+{
+  fprintf(stderr, "Hello, world => %d\n", calc(0, 1, 2));
+  return 0;
+}
+
+
+// The name of this function is used in tests to set breakpoints by name.
+int calc(int x0, int x1, int x2) {
+  int x3 = x2 * x1 + x0;
+  int x4 = x3 * x2 + x1;
+  int x5 = x4 * x3 + x2;
+  int x6 = x5 * x4 + x3;
+  int x7 = x6 * x5 + x4;
+  int x8 = x7 * x6 + x5;
+  int x9 = x8 * x7 + x6;
+  int x10 = x9 * x8 + x7;
+  int x11 = x10 * x9 + x8;
+  int x12 = x11 * x10 + x9;
+  int x13 = x12 * x11 + x10;
+  int x14 = x13 * x12 + x11;
+  int x15 = x14 * x13 + x12;
+  int x16 = x15 * x14 + x13;
+  int x17 = x16 * x15 + x14;
+  int x18 = x17 * x16 + x15;
+  int x19 = x18 * x17 + x16;
+  int x20 = x19 * x18 + x17;  
+  int x21 = x20 * x19 + x18;
+  int x22 = x21 * x20 + x19;
+  int x23 = x22 * x21 + x20;
+  int x24 = x23 * x22 + x21;
+  int x25 = x24 * x23 + x22;
+  int x26 = x25 * x24 + x23;
+  int x27 = x26 * x25 + x24;
+  int x28 = x27 * x26 + x25;
+  int x29 = x28 * x27 + x26;
+  int x30 = x29 * x28 + x27;
+  int x31 = x30 * x29 + x28;
+  int x32 = x31 * x30 + x29;
+  int x33 = x32 * x31 + x30;
+  int x34 = x33 * x32 + x31;
+  int x35 = x34 * x33 + x32;
+  int x36 = x35 * x34 + x33;
+  int x37 = x36 * x35 + x34;
+  int x38 = x37 * x36 + x35;
+  int x39 = x38 * x37 + x36;
+  int x40 = x39 * x38 + x37;
+  int x41 = x40 * x39 + x38;
+  int x42 = x41 * x40 + x39;
+  int x43 = x42 * x41 + x40;
+  int x44 = x43 * x42 + x41;
+  int x45 = x44 * x43 + x42;
+  int x46 = x45 * x44 + x43;
+  int x47 = x46 * x45 + x44;
+  int x48 = x47 * x46 + x45;
+  int x49 = x48 * x47 + x46;
+  int x50 = x49 * x48 + x47;
+  int x51 = x50 * x49 + x48;
+  int x52 = x51 * x50 + x49;
+  int x53 = x52 * x51 + x50;
+  int x54 = x53 * x52 + x51;
+  int x55 = x54 * x53 + x52;
+  int x56 = x55 * x54 + x53;
+  int x57 = x56 * x55 + x54;
+  int x58 = x57 * x56 + x55;
+  int x59 = x58 * x57 + x56;
+  int x60 = x59 * x58 + x57;
+  int x61 = x60 * x59 + x58;
+  int x62 = x61 * x60 + x59;
+  int x63 = x62 * x61 + x60;
+  int x64 = x63 * x62 + x61;
+  int x65 = x64 * x63 + x62;
+  int x66 = x65 * x64 + x63;
+  int x67 = x66 * x65 + x64;
+  int x68 = x67 * x66 + x65;
+  int x69 = x68 * x67 + x66;
+  int x70 = x69 * x68 + x67;
+  int x71 = x70 * x69 + x68;
+  int x72 = x71 * x70 + x69;
+  int x73 = x72 * x71 + x70;
+  int x74 = x73 * x72 + x71;
+  int x75 = x74 * x73 + x72;
+  int x76 = x75 * x74 + x73;
+  int x77 = x76 * x75 + x74;
+  int x78 = x77 * x76 + x75;
+  int x79 = x78 * x77 + x76;
+  int x80 = x79 * x78 + x77;
+  int x81 = x80 * x79 + x78;
+  int x82 = x81 * x80 + x79;
+  int x83 = x82 * x81 + x80;
+  int x84 = x83 * x82 + x81;
+  int x85 = x84 * x83 + x82;
+  int x86 = x85 * x84 + x83;
+  int x87 = x86 * x85 + x84;
+  int x88 = x87 * x86 + x85;
+  int x89 = x88 * x87 + x86;
+  int x90 = x89 * x88 + x87;
+  int x91 = x90 * x89 + x88;
+  int x92 = x91 * x90 + x89;
+  int x93 = x92 * x91 + x90;
+  int x94 = x93 * x92 + x91;
+  int x95 = x94 * x93 + x92;
+  int x96 = x95 * x94 + x93;
+  int x97 = x96 * x95 + x94;
+  int x98 = x97 * x96 + x95;
+  int x99 = x98 * x97 + x96;
+  int x100 = x99 * x98 + x97;
+  int x101 = x100 * x99 + x98;
+  int x102 = x101 * x100 + x99;
+  int x103 = x102 * x101 + x100;
+  int x104 = x103 * x102 + x101;
+  int x105 = x104 * x103 + x102;
+  int x106 = x105 * x104 + x103;
+  int x107 = x106 * x105 + x104;
+  int x108 = x107 * x106 + x105;
+  int x109 = x108 * x107 + x106;
+  int x110 = x109 * x108 + x107;
+  int x111 = x110 * x109 + x108;
+  int x112 = x111 * x110 + x109;
+  int x113 = x112 * x111 + x110;
+  int x114 = x113 * x112 + x111;
+  int x115 = x114 * x113 + x112;
+  int x116 = x115 * x114 + x113;
+  int x117 = x116 * x115 + x114;
+  int x118 = x117 * x116 + x115;
+  int x119 = x118 * x117 + x116;
+  int x120 = x119 * x118 + x117;
+  int x121 = x120 * x119 + x118;
+  int x122 = x121 * x120 + x119;
+  int x123 = x122 * x121 + x120;
+  int x124 = x123 * x122 + x121;
+  int x125 = x124 * x123 + x122;
+  int x126 = x125 * x124 + x123;
+  int x1

[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-04-01 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1242ec54306: [intel-pt] Implement a basic test case 
(authored by Walter Erquinigo ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107

Files:
  lldb/test/API/tools/intel-features/intel-pt/test/Makefile
  lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
  lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
  lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -428,6 +430,7 @@
   }
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -480,6 +483,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
Index: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+using namespace std;
+
+int fun(int a) { return a * a + 1; }
+
+int main() {
+  int z = 0;
+  for (int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}
Index: lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,59 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) 
+])
+
+self.runCmd("processor-trace stop")
Index: lldb/test/API/tools/intel-features/intel-pt/test/Makefile
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77241: update eArgTypeScriptLang description to mention lua

2020-04-01 Thread Ed Maste via Phabricator via lldb-commits
emaste created this revision.
emaste added a reviewer: JDevlieghere.

`--script-language python` and `--script-language lua` are now valid

I went with lowercase to match the args


https://reviews.llvm.org/D77241

Files:
  lldb/source/Interpreter/CommandObject.cpp


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1091,7 +1091,7 @@
 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Arguments to be passed to the target program when it starts 
executing." },
 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Help text goes here." },
 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to 
use to run scripted commands with regard to LLDB event system." },
-{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  Currently only Python is valid." },
+{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  python and lua are valid." },
 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Any word of interest for search purposes." },
 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { 
nullptr, false }, "An Objective-C selector name." },
 { eArgTypeSettingIndex, "setting-index", 
CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a 
settings variable that is an array (try 'settings list' to see all the possible 
settings variables and their types)." },


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1091,7 +1091,7 @@
 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
-{ eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands.  Currently only Python is valid." },
+{ eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands.  python and lua are valid." },
 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "Any word of interest for search purposes." },
 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." },
 { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c911cc6 - [intel-pt] Implement a basic test case

2020-04-01 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-04-01T13:44:03-07:00
New Revision: c911cc6c49394909a335c8d7baffcfd8bdcc424b

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

LOG: [intel-pt] Implement a basic test case

Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
lldb/test/API/tools/intel-features/intel-pt/test/Makefile
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
lldb/test/API/tools/intel-features/intel-pt/test/main.cpp

Modified: 
lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Removed: 




diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
new file mode 100644
index ..9bbae290a7d0
--- /dev/null
+++ 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,60 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+return
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets 
to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for 
loop')) 
+])
+
+self.runCmd("processor-trace stop")

diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
new file mode 100644
index ..ea826a2ac0c6
--- /dev/null
+++ b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+using namespace std;
+
+int fun(int a) { return a * a + 1; }
+
+int main() {
+  int z = 0;
+  for (int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}

diff  --git a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp 
b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
index 8db1c0f82d66..5e409a269fa4 100644
--- a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@ class ProcessorTraceStart : public 
lldb::SBCommandPluginInterface {
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@ class ProcessorTraceInfo : public 
ll

[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-04-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Thanks for the heads up. I think I got a false impression of how comments after 
accept vs requesting changes work in this repo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186



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


[Lldb-commits] [lldb] 064c634 - Revert "[intel-pt] Implement a basic test case"

2020-04-01 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-04-01T14:08:19-07:00
New Revision: 064c634ef3d44e7b50db86ec0d1f64e718b6dfe4

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

LOG: Revert "[intel-pt] Implement a basic test case"

This reverts commit c911cc6c49394909a335c8d7baffcfd8bdcc424b.

Added: 


Modified: 
lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Removed: 
lldb/test/API/tools/intel-features/intel-pt/test/Makefile
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
lldb/test/API/tools/intel-features/intel-pt/test/main.cpp



diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
deleted file mode 100644
index 8b20bcb0..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
deleted file mode 100644
index 9bbae290a7d0..
--- 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
+++ /dev/null
@@ -1,60 +0,0 @@
-from __future__ import print_function
-
-import os
-import lldb
-import time
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestIntelPTSimpleBinary(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-@skipIf(oslist=no_match(['linux']))
-@skipIf(archs=no_match(['i386', 'x86_64']))
-@skipIfRemote
-def test_basic_flow(self):
-"""Test collection, decoding, and dumping instructions"""
-lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
-lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
-plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
-if not os.path.isfile(plugin_file):
-self.skipTest("features plugin missing.")
-return
-
-self.build()
-
-self.runCmd("plugin load " + plugin_file)
-
-exe = self.getBuildArtifact("a.out")
-lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
-# We start tracing from main
-self.runCmd("processor-trace start all")
-
-# We check the trace after the for loop
-self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
-self.runCmd("c")
-
-# We wait a little bit to ensure the processor has send the PT packets 
to
-# the memory
-time.sleep(.1)
-
-# We find the start address of the 'fun' function for a later check
-target = self.dbg.GetSelectedTarget()
-fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
-.GetStartAddress().GetLoadAddress(target)
-
-# We print the last instructions
-self.expect("processor-trace show-instr-log -c 100",
-patterns=[
-# We expect to have seen the first instruction of 'fun'
-hex(fun_start_adddress),  
-# We expect to see the exit condition of the for loop
-"at main.cpp:" + str(line_number('main.cpp', '// Break for 
loop')) 
-])
-
-self.runCmd("processor-trace stop")

diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
deleted file mode 100644
index ea826a2ac0c6..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include 
-
-using namespace std;
-
-int fun(int a) { return a * a + 1; }
-
-int main() {
-  int z = 0;
-  for (int i = 0; i < 1; i++) { // Break for loop
-z += fun(z);
-  }
-
-  return 0; // Break 1
-}

diff  --git a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp 
b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
index 5e409a269fa4..8db1c0f82d66 100644
--- a/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ b/lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,7 +191,6 @@ class ProcessorTraceStart : public 
lldb::SBCommandPluginInterface {
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
-result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -291,7 +290,6 @@ class ProcessorTraceInfo : public 
lldb::SBCommandPluginInterface {
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
-result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -430,7 +428,6 @@ class ProcessorTraceShowInstrLog : public 
lldb::SBC

[Lldb-commits] [PATCH] D77241: update eArgTypeScriptLang description to mention lua

2020-04-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Interpreter/CommandObject.cpp:1094
 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to 
use to run scripted commands with regard to LLDB event system." },
-{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  Currently only Python is valid." },
+{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  python and lua are valid." },
 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Any word of interest for search purposes." },

Maybe we can rephrase it as "Supported languages are python and lua"? 


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

https://reviews.llvm.org/D77241



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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-04-01 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

In D77153#1954154 , @labath wrote:

> It might be worth mentioning though that the title of the patch is somewhat 
> misleading -- I believe the `CXX` in `CXXFunctionSummaryFormat` refers to the 
> language the formatter is implemented in, not the language of the type 
> itself. So this patch affects all types whose formatters are implemented as 
> c++ functions, not all c++ pointers in the target program.


Wow, thanks for pointing this out. It should have clicked when I saw 
`ScriptSummaryFormat` besides it, but I was indeed completely confused. Let me 
rework this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [lldb] f203100 - Reapply: [Host.mm] Check for the right macro instead of inlining it

2020-04-01 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-04-01T15:23:07-07:00
New Revision: f203100ebe22bf97a4268a562cdbef22d14db915

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

LOG: Reapply: [Host.mm] Check for the right macro instead of inlining it

Previously, this was reverted in bf65f19b becuase it checked whether
TARGET_OS_EMBEDDED is defined, but that macro is always defined.

Update the condition to check that TARGET_OS_OSX is true.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index eba3060f8ec6..045ba7f3671f 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -9,13 +9,9 @@
 #include "lldb/Host/Host.h"
 
 #include 
+#include 
 
-// On device doesn't have supporty for XPC.
-#if defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__))
-#define NO_XPC_SERVICES 1
-#endif
-
-#if !defined(NO_XPC_SERVICES)
+#if TARGET_OS_OSX
 #define __XPC_PRIVATE_H__
 #include 
 
@@ -135,6 +131,8 @@
   return false;
 }
 
+#if TARGET_OS_OSX
+
 static void *AcceptPIDFromInferior(void *arg) {
   const char *connect_url = (const char *)arg;
   ConnectionFileDescriptor file_conn;
@@ -153,8 +151,6 @@
   return NULL;
 }
 
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
-
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
 "   activate\n"
 "  do script \"/bin/bash -c '%s';exit\"\n"
@@ -307,13 +303,13 @@ repeat with the_window in (get windows)\n\
   return error;
 }
 
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // TARGET_OS_OSX
 
 bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
 uint32_t line_no) {
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#if !TARGET_OS_OSX
   return false;
-#else
+#else // !TARGET_OS_OSX
   // We attach this to an 'odoc' event to specify a particular selection
   typedef struct {
 int16_t reserved0; // must be zero
@@ -404,7 +400,7 @@ repeat with the_window in (get windows)\n\
   }
 
   return true;
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // TARGET_OS_OSX
 }
 
 Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); }
@@ -689,7 +685,7 @@ static bool 
GetMacOSXProcessUserAndGroup(ProcessInstanceInfo &process_info) {
   return false;
 }
 
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
 static void PackageXPCArguments(xpc_object_t message, const char *prefix,
 const Args &args) {
   size_t count = args.GetArgumentCount();
@@ -841,7 +837,7 @@ static short GetPosixspawnFlags(const ProcessLaunchInfo 
&launch_info) {
 static Status LaunchProcessXPC(const char *exe_path,
ProcessLaunchInfo &launch_info,
lldb::pid_t &pid) {
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
   Status error = getXPCAuthorization(launch_info);
   if (error.Fail())
 return error;
@@ -1194,7 +1190,7 @@ static Status LaunchProcessPosixSpawn(const char 
*exe_path,
 static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) {
   bool result = false;
 
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
   bool launchingAsRoot = launch_info.GetUserID() == 0;
   bool currentUserIsRoot = HostInfo::GetEffectiveUserID() == 0;
 
@@ -1226,7 +1222,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo 
&launch_info) {
   }
 
   if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#if TARGET_OS_OSX
 return LaunchInNewTerminalWithAppleScript(exe_spec.GetPath().c_str(),
   launch_info);
 #else



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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-04-01 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

I was checking whether there is a way to catch null pointer before a type 
summary is even chosen. And found out that such logic exists, but only for 
Objective-C. Languages have a `IsNilReference()` virtual method that can tell 
whether a `ValueObject` is a nil reference. It's only implemented for 
ObjectiveC and value objects that test positive for this method are displayed 
as "nil" is the generic code of `ValueObjectPrinter.cpp`. I can see a few 
options:

- I can rework the patch to affect only the libc++ string formatter which was 
the issue I was trying to solve in the first place
- I can implement `IsNilReference()` for C++ and change `ValueObjectPrinter` to 
print C++ "nil references" as "nullptr".
- I do the above and add another customization point in the Language plugins 
which tells `ValueObjectPrinter` out to display "nil" references, so that 
there's no Language specific code in `ValueObjectPrinter`.

A few additional questions come to mind though:

- Was the intent if `IsNilReference()` to be Objective-C specific in the first 
place?
- Should we do the same thing for C and NULL?
- C, C++ and Objective-C(++) being highly intermingled, would something like 
this even do the right thing in all cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-04-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 254326.

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

https://reviews.llvm.org/D76471

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Host/HostInfoBase.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Utility/XcodeSDK.h
  lldb/source/Core/Module.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/XcodeSDK.cpp
  lldb/unittests/Platform/PlatformDarwinTest.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/XcodeSDKTest.cpp

Index: lldb/unittests/Utility/XcodeSDKTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -0,0 +1,84 @@
+//===-- XcodeSDKTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/XcodeSDK.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+using namespace lldb_private;
+
+TEST(XcodeSDKTest, ParseTest) {
+  EXPECT_EQ(XcodeSDK::GetAnyMacOS().GetType(), XcodeSDK::MacOSX);
+  EXPECT_EQ(XcodeSDK("MacOSX.sdk").GetType(), XcodeSDK::MacOSX);
+  EXPECT_EQ(XcodeSDK("iPhoneSimulator.sdk").GetType(), XcodeSDK::iPhoneSimulator);
+  EXPECT_EQ(XcodeSDK("iPhoneOS.sdk").GetType(), XcodeSDK::iPhoneOS);
+  EXPECT_EQ(XcodeSDK("AppleTVSimulator.sdk").GetType(), XcodeSDK::AppleTVSimulator);
+  EXPECT_EQ(XcodeSDK("AppleTVOS.sdk").GetType(), XcodeSDK::AppleTVOS);
+  EXPECT_EQ(XcodeSDK("WatchSimulator.sdk").GetType(), XcodeSDK::WatchSimulator);
+  EXPECT_EQ(XcodeSDK("WatchOS.sdk").GetType(), XcodeSDK::watchOS);
+  EXPECT_EQ(XcodeSDK("Linux.sdk").GetType(), XcodeSDK::Linux);
+  EXPECT_EQ(XcodeSDK("MacOSX.sdk").GetVersion(), llvm::VersionTuple());
+  EXPECT_EQ(XcodeSDK("MacOSX10.9.sdk").GetVersion(), llvm::VersionTuple(10, 9));
+  EXPECT_EQ(XcodeSDK("MacOSX10.15.4.sdk").GetVersion(), llvm::VersionTuple(10, 15));
+}
+
+TEST(XcodeSDKTest, MergeTest) {
+  XcodeSDK sdk("MacOSX.sdk");
+  sdk.Merge(XcodeSDK("WatchOS.sdk"));
+  // This doesn't make any particular sense and shouldn't happen in practice, we
+  // just want to guarantee a well-defined behavior when choosing one
+  // SDK to fit all CUs in an lldb::Module.
+  // -> The higher number wins.
+  EXPECT_EQ(sdk.GetType(), XcodeSDK::watchOS);
+  sdk.Merge(XcodeSDK("WatchOS1.1.sdk"));
+  EXPECT_EQ(sdk.GetVersion(), llvm::VersionTuple(1, 1));
+  sdk.Merge(XcodeSDK("WatchOS2.0.sdk"));
+  EXPECT_EQ(sdk.GetVersion(), llvm::VersionTuple(2, 0));
+}
+
+TEST(XcodeSDKTest, SDKSupportsModules) {
+  std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/";
+  EXPECT_TRUE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::iPhoneSimulator,
+  FileSpec(
+  base +
+  "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk")));
+  EXPECT_FALSE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::iPhoneSimulator,
+  FileSpec(
+  base +
+  "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk")));
+  EXPECT_TRUE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::MacOSX,
+  FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk")));
+  EXPECT_FALSE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::MacOSX,
+  FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")));
+}
+
+TEST(XcodeSDKTest, GetSDKNameForType) {
+  EXPECT_EQ("macosx", XcodeSDK::GetSDKNameForType(XcodeSDK::Type::MacOSX));
+  EXPECT_EQ("iphonesimulator",
+XcodeSDK::GetSDKNameForType(XcodeSDK::Type::iPhoneSimulator));
+  EXPECT_EQ("iphoneos", XcodeSDK::GetSDKNameForType(XcodeSDK::Type::iPhoneOS));
+  EXPECT_EQ("appletvsimulator",
+XcodeSDK::GetSDKNameForType(XcodeSDK::Type::AppleTVSimulator));
+  EXPECT_EQ("appletvos",
+XcodeSDK::GetSDKNameForType(XcodeSDK::Type::AppleTVOS));
+  EXPECT_EQ("watchsimulator",
+XcodeSDK::GetSDKNameForType(XcodeSDK::Type::WatchSimulator));
+  EXPECT_EQ("watchos", XcodeSDK::GetSD

[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-04-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D76471#1954205 , @labath wrote:

> I don't think that spreading this out over host and platform is convoluted. 
> In fact, I was going to propose something like that myself. However, it does 
> bring us back to the question of the "linux" sdk.
>
> A couple of comments ago you said:
>
> > The "Linux" SDK is a placeholder of sorts when debugging a Swift-on-Linux 
> > server application (e.g., something like https://www.kitura.io/) from 
> > *within* Xcode that points to a directory that contains the Swift 
> > resources/stdlib cross-compiled for Linux.
>
> When you say "cross-compiled", I am imagining that the resulting binary will 
> be a regular linux elf file, and it's triple will be detected as `***-linux`. 
> So, `Platform::GetPlatformForArchitecture(GetArchitecture(), nullptr)` will 
> return PlatformLinux, and the subsequent `GetSDKPath` will return blank, 
> whereas I am expecting that you would want it to return 
> `HostInfoMacOSX::GetXcodeSDK(linux)` (if running on macos).
>
> So, if all of this is true, and we want this interface to reside on the 
> Platform class, then I think the implementation of `GetSDKPath` needs to be 
> spread out over the individual platform classes, which would delegate to the 
> appropriate host api. E.g. `PlatformLinux::GetSDKPath` (with no arguments) 
> would be implemented via `HostInfo::GetXcodeSDK(linux)`, 
> `PlatformRemoteAppleWatch::GetSDKPath` as `HostInfo::GetXcodeSDK(watchos)`, 
> etc.
>
> This would give us maximum flexibility. For instance one could implement 
> `HostInfoLinux::GetXcodeSDK` to locate the xcode sdk through some other 
> mechanism, and then cross-debugging mac binaries would work too. Or, one 
> could implement `PlatformXXX::GetSDKPath` to download the sdk from the remote 
> system somehow if it is not found on the host, and then we would be able to 
> debug on any host. However, I found all of these scenarios fairly unlikely, 
> which is why I said that going straight for the host seems fine. The 
> interface is still sensible -- we just say that the host system has to 
> provide the sdks for any of the listed platforms. And if the host doesn't 
> provide that, tough luck. That setup can always be generalized if we have a 
> need for it.


Great! I think the current version of the patch reflects all of that, with only 
one difference — something that I actually overlooked in the previous version. 
We now have Platform that provides the interface to provide an SDK, and will 
forward the question to Host. Each Host can define its own mechanisms for doing 
so. So far I have only provided an implementation for macOS, which runs 
`xcrun`. What I can't do is remove the SDK parameter from the interface in 
platform, because Xcode may contain differently versioned SDKs (e.g., a 
MacOSX10.14.sdk and a MacOSX10.15.sdk) plus some wrinkles that are only 
relevant when you are developing the OS itself. That said, even without 
removing the SDK parameter from GetSDKPath(), we can still implement 
HostInfoLinux::GetXcodeSDK() for hypothetical Linux -> macOS cross-debugger you 
mentioned above, so I don't think the extra parameter tarnishes the design.

> In D76471#1954045 , @JDevlieghere 
> wrote:
> 
>> I think the current separation makes a lot of sense, but I don't like that 
>> XcodeSDK class is part of Utility. I understand the need from a layering 
>> perspective and I don't really have a better idea, but maybe someone else 
>> does?
> 
> We could move it up to Host, and have it be next to the HostInfo::GetXcodeSDK 
> function which returns it. Would that look any better?

In a way XcodeSDK is like Triple or ArchSpec, so I've started to feel less bad 
about putting it into Utility, where ArchSpec lives.


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

https://reviews.llvm.org/D76471



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


[Lldb-commits] [PATCH] D76964: Fix an issue where the IgnoreName function was not allowing "Class" to be looked up inside a namespace or other class.

2020-04-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 254352.
clayborg added a comment.

Fixed patch reviewer suggestions and added a test for "id".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76964

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/test/API/commands/expression/ignore/Makefile
  lldb/test/API/commands/expression/ignore/TestIgnoreName.py
  lldb/test/API/commands/expression/ignore/main.cpp

Index: lldb/test/API/commands/expression/ignore/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/ignore/main.cpp
@@ -0,0 +1,12 @@
+namespace a {
+  struct Class {
+  };
+  struct id {
+  };
+}
+
+int main(int argc, char **argv) {
+  a::Class c;
+  a::id i;
+  return 0;
+}
Index: lldb/test/API/commands/expression/ignore/TestIgnoreName.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/ignore/TestIgnoreName.py
@@ -0,0 +1,33 @@
+"""
+Test calling user an expression that uses an Objective C keyword "id" or
+"Class" when this identifier is inside of a namespace, class or structure.
+ClangASTSource::FindExternalVisibleDecls(...) might try to find one of these
+keywords inside of a non root decl context and this should succeed.
+"""
+
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIgnoreName(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+"""Test that we can evaluate an expression that finds something inside
+   a namespace that uses an Objective C keyword.
+"""
+self.build()
+exe_path = self.getBuildArtifact("a.out")
+error = lldb.SBError()
+triple = None
+platform = None
+add_dependent_modules = False
+target = self.dbg.CreateTarget(exe_path, triple, platform,
+   add_dependent_modules, error)
+self.assertTrue(target, VALID_TARGET)
+self.expect_expr("a::Class x; x", result_type="a::Class")
+self.expect_expr("a::id i; i", result_type="a::id")
Index: lldb/test/API/commands/expression/ignore/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/ignore/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1321,7 +1321,7 @@
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
   const ConstString name(context.m_decl_name.getAsString().c_str());
-  if (IgnoreName(name, false))
+  if (IgnoreName(name, namespace_decl, false))
 return;
 
   // Only look for functions by name out in our symbols if the function doesn't
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -325,13 +325,19 @@
   /// \param[in] name
   /// The name to be considered.
   ///
+  /// \param[in] namespace_decl
+  /// The namespace decl that this name is being searched. This can be
+  /// invalid if we are searching the root namespace.
+  ///
   /// \param[in] ignore_all_dollar_names
   /// True if $-names of all sorts should be ignored.
   ///
   /// \return
   /// True if the name is one of a class of names that are ignored by
   /// global lookup for performance reasons.
-  bool IgnoreName(const ConstString name, bool ignore_all_dollar_names);
+  bool IgnoreName(const ConstString name,
+  const CompilerDeclContext &namespace_decl,
+  bool ignore_all_dollar_names);
 
 public:
   /// Copies a single Decl into the parser's AST context.
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -574,13 +574,21 @@
 }
 
 bool ClangASTSource::IgnoreName(const ConstString name,
+const CompilerDeclContext &namespace_decl,
 bool ignore_all_dollar_names) {
-  static const ConstString id_name("id");
-  static const ConstString Class_name("Class");
-
-  i

[Lldb-commits] [PATCH] D77241: update eArgTypeScriptLang description to mention lua

2020-04-01 Thread Ed Maste via Phabricator via lldb-commits
emaste updated this revision to Diff 254369.
emaste added a comment.

reword


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

https://reviews.llvm.org/D77241

Files:
  lldb/source/Interpreter/CommandObject.cpp


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1091,7 +1091,7 @@
 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Arguments to be passed to the target program when it starts 
executing." },
 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Help text goes here." },
 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to 
use to run scripted commands with regard to LLDB event system." },
-{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  Currently only Python is valid." },
+{ eArgTypeScriptLang, "script-language", 
CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language 
to be used for script-based commands.  Supported languages are python and lua." 
},
 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { 
nullptr, false }, "Any word of interest for search purposes." },
 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { 
nullptr, false }, "An Objective-C selector name." },
 { eArgTypeSettingIndex, "setting-index", 
CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a 
settings variable that is an array (try 'settings list' to see all the possible 
settings variables and their types)." },


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1091,7 +1091,7 @@
 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
-{ eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands.  Currently only Python is valid." },
+{ eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands.  Supported languages are python and lua." },
 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "Any word of interest for search purposes." },
 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." },
 { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76814: Preserve ThreadPlanStacks for unreported threads

2020-04-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 254372.
jingham added a comment.

Add a variable backing the std::condition_variable in the source for the 
stepping test to catch spurious wakeups.

AssertTrue -> AssertIn in the ThreadPlanList test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76814

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Thread.h
  lldb/include/lldb/Target/ThreadPlan.h
  lldb/include/lldb/Target/ThreadPlanStack.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetProperties.td
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadList.cpp
  lldb/source/Target/ThreadPlan.cpp
  lldb/source/Target/ThreadPlanStack.cpp
  lldb/source/Target/ThreadPlanStepOut.cpp
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/Makefile
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/main.cpp
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/operating_system.py
  lldb/test/API/functionalities/thread_plan/Makefile
  lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
  lldb/test/API/functionalities/thread_plan/main.c

Index: lldb/test/API/functionalities/thread_plan/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/thread_plan/main.c
@@ -0,0 +1,16 @@
+#include 
+
+void
+call_me(int value) {
+  printf("called with %d\n", value); // Set another here.
+}
+
+int
+main(int argc, char **argv)
+{
+  call_me(argc); // Set a breakpoint here.
+  printf("This just spaces the two calls\n");
+  call_me(argc); // Run here to step over again.
+  printf("More spacing\n");
+  return 0; // Make sure we get here on last continue
+}
Index: lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
===
--- /dev/null
+++ lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
@@ -0,0 +1,164 @@
+"""
+Test that thread plan listing, and deleting works.
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestThreadPlanCommands(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_thread_plan_actions(self):
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.c")
+self.thread_plan_test()
+
+def check_list_output(self, command, active_plans = [], completed_plans = [], discarded_plans = []):
+# Check the "thread plan list" output against a list of active & completed and discarded plans.
+# If all three check arrays are empty, that means the command is expected to fail. 
+
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+
+num_active = len(active_plans)
+num_completed = len(completed_plans)
+num_discarded = len(discarded_plans)
+
+interp.HandleCommand(command, result)
+if self.TraceOn():
+print("Command: %s"%(command))
+print(result.GetOutput())
+
+if num_active == 0 and num_completed == 0 and num_discarded == 0:
+self.assertFalse(result.Succeeded(), "command: '%s' succeeded when it should have failed: '%s'"%
+ (command, result.GetError()))
+return
+
+self.assertTrue(result.Succeeded(), "command: '%s' failed: '%s'"%(command, result.GetError()))
+result_arr = result.GetOutput().splitlines()
+num_results = len(result_arr)
+
+# Match the expected number of elements.
+# Adjust the count for the number of header lines we aren't matching:
+fudge = 0
+
+if num_completed == 0 and num_discarded == 0:
+# The fudge is 3: Thread header, Active Plan header and base plan
+fudge = 3
+elif num_completed == 0 or num_discarded == 0:
+# The fudge is 4: The above plus either the Completed or Discarded Plan header:
+fudge = 4
+else:
+# The fudge is 5 since we have both headers:
+fudge = 5
+
+self.assertEqual(num_results, num_active + num_completed + num_discarded + fudge,
+ "Too many elements in match arrays")
+
+# Now iterate through the results array and pick out the results.
+result_idx = 0
+self.assertIn("thread #", result_arr[result_idx], "Found thread header") ; result_idx += 1
+self.assertIn("Active plan stack", result_arr[result_idx], "Found active header") ; result_idx += 1
+self.assertIn("Element 0: Bas

[Lldb-commits] [lldb] 4354dfb - Preserve the owning module information from DWARF in the synthesized AST

2020-04-01 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-04-01T17:46:02-07:00
New Revision: 4354dfbdf5c8510a7ddff10ae67a28e16cf7cc79

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

LOG: Preserve the owning module information from DWARF in the synthesized AST

Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
sets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

rdar://problem/59634380

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

Added: 
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm

Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/source/Symbol/Type.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
lldb/unittests/Symbol/TestTypeSystemClang.cpp
lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 0d1b00a1b26c..b0a7953190f8 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -242,8 +242,10 @@ class CompilerType {
   /// Create a typedef to this type using "name" as the name of the typedef 
this
   /// type is valid and the type system supports typedefs, else return an
   /// invalid type.
+  /// \param payload   The typesystem-specific \p lldb::Type payload.
   CompilerType CreateTypedef(const char *name,
- const CompilerDeclContext &decl_ctx) const;
+ const CompilerDeclContext &decl_ctx,
+ uint32_t payload) const;
 
   /// If the current object represents a typedef type, get the underlying type
   CompilerType GetTypedefedType() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index a84b9a1c441c..ba2bbfaf4650 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -259,9 +259,12 @@ class TypeSystem : public PluginInterface {
 
   virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
 
+  /// \param opaque_payload  The m_payload field of Type, which may
+  /// carry TypeSystem-specific extra information.
   virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
  const char *name,
- const CompilerDeclContext &decl_ctx);
+ const CompilerDeclContext &decl_ctx,
+ uint32_t opaque_payload);
 
   // Exploring the type
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 4b3e237dc62c..e552f4389a1f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -18,6 +18,7 @@
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 #include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 
@@ -1003,6 +1004,20 @@ static void MaybeCompleteReturnType(ClangASTImporter 
&importer,
   importer.CompleteTagDecl(rd);
 }
 
+/// Recreate a module with its par

[Lldb-commits] [PATCH] D76814: Preserve ThreadPlanStacks for unreported threads

2020-04-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham marked 5 inline comments as done.
jingham added inline comments.



Comment at: lldb/source/Target/TargetProperties.td:183
 Desc<"A path to a python OS plug-in module file that contains a 
OperatingSystemPlugIn class.">;
+  def PluginReportsAllThreads: Property<"plugin-reports-all-threads", 
"Boolean">,
+Global,

labath wrote:
> jingham wrote:
> > labath wrote:
> > > jingham wrote:
> > > > labath wrote:
> > > > > If this is relevant only for os plugins, then it would be good to 
> > > > > reflect that in the name as well.
> > > > I thought about that.  In the future a regular Process plugin might 
> > > > decide it was too expensive to report all threads as well.  There's 
> > > > nothing in this patch that wouldn't "just work" with that case as well. 
> > > >  Leaving the OS out was meant to indicate this was about how the 
> > > > Process plugin OR any of its helpers (e.g. the OS Plugin) produces 
> > > > threads.
> > > Well, I am hoping that if we ever extend this support to the regular 
> > > process plugins, we will implement it in a way where the plugin itself 
> > > can tell us whether it is operating/supporting this mode (which I guess 
> > > would involve a new gdb-remote packet and some specification of what 
> > > exactly should happen when it gets sent), instead of relying on the user 
> > > to set this correctly.
> > > 
> > > I mean, in an ideal world this is I would want to happen with the python 
> > > plugins as well, but it seems that we are stuck with some existing 
> > > plugins which already do that. However, I wouldn't want to plan on the 
> > > same thing happening again. :)
> > Right, I put this in mostly to help backwards compatibility.  For instance, 
> > another OS Plugin I know about handles some older cooperative threading 
> > scheme.  That one does report all threads on each stop.  I didn't want to 
> > force them to do anything to keep their plugin working as well as it did 
> > before.  That's also why I set the default to true here.
> > 
> > Even when we have plugins that actually support not reporting all threads, 
> > you could imagine somebody having a Process plugin that supports both modes 
> > - particularly early in the development of its support for this feature, 
> > and in some corner cases the "doesn't report all threads" mode has some 
> > subtle problem.  Having this setting will allow people to get the slower 
> > but more assuredly correct behavior till it works 100% reliably.  So I 
> > still think the setting has some value.
> > 
> > But I agree, going forward there should be some kind of handshake between 
> > the ThreadPlanStackMap and the Process Plugin, either a "I've reported all 
> > threads now" which could trigger a prune, or a "Is TID X still alive" which 
> > the generic code could use to balance the cost of keeping outdated stacks 
> > alive against when we want to ask about all threads.
> All of this sounds fine, and I wouldn't mind having a setting like that, even 
> after the support for partial thread lists is considered "stable". However, 
> that sounds like a different setting to me -- that's like a directive to the 
> process plugin about how it should behave, whereas this setting is more like 
> a statement of fact about what the plugin does.
> 
> The setting could be later repurposed to do both, but it's not clear to me 
> whether that is useful. Like, since we already support plugin-specific 
> settings, the plugin which decides to implement both modes of operation could 
> expose that as a custom setting. That way, one wouldn't get the impression 
> that this setting applies to any process plugin...
Okay.  I don't want to have to design that right now.  

Since this is just a workaround for the fact that the extant OS plugins don't 
have a way to tell me this fact, I'll go back to using this just for OS 
plugins.  In that case, I think I should move it to experimental.  Once we add 
an API to the various plugins to advertise how they work, it won't be needed.  
The benefit of experimental settings is that their absence doesn't cause the 
"settings set" to raise an error, so people can leave this in their lldbinit's 
and it won't cause problems once we use it.

Now I just have to figure out how experimental settings work in the new 
tablegen way of doing properties...



Comment at: 
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/main.cpp:40
+  std::thread thread_1(thread_func);
+  g_cv.wait(main_lock);
+  g_value = 1;

labath wrote:
> spurious wake up danger here too
g_value had a different purpose and using it more widely as the variable 
backing the condition_variable was awkward, so I added an explicit condition 
variable.



Comment at: 
lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py:23
+
+def check_list_output(self, command, active_plans = [], completed_plans = 
[], discarded_plan

[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-04-01 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4354dfbdf5c8: Preserve the owning module information from 
DWARF in the synthesized AST (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D75488?vs=254027&id=254383#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75488

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
  lldb/unittests/Symbol/TestTypeSystemClang.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Index: lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
===
--- lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
+++ lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
@@ -28,8 +28,8 @@
 
 inline CompilerType createRecord(TypeSystemClang &ast, llvm::StringRef name) {
   return ast.CreateRecordType(ast.getASTContext().getTranslationUnitDecl(),
-  lldb::AccessType::eAccessPublic, name, 0,
-  lldb::LanguageType::eLanguageTypeC);
+  OptionalClangModuleID(), lldb::AccessType::eAccessPublic, name,
+  0, lldb::LanguageType::eLanguageTypeC);
 }
 
 /// Create a record with the given name and a field with the given type
Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/Declaration.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "gtest/gtest.h"
 
@@ -257,9 +258,10 @@
   CompilerType basic_compiler_type = ast.GetBasicType(basic_type);
   EXPECT_TRUE(basic_compiler_type.IsValid());
 
-  CompilerType enum_type =
-  ast.CreateEnumerationType("my_enum", ast.GetTranslationUnitDecl(),
-Declaration(), basic_compiler_type, scoped);
+  CompilerType enum_type = ast.CreateEnumerationType(
+  "my_enum", ast.GetTranslationUnitDecl(), OptionalClangModuleID(), Declaration(),
+  basic_compiler_type, scoped);
+
   CompilerType t = ast.GetEnumerationIntegerType(enum_type);
   // Check that the type we put in at the start is found again.
   EXPECT_EQ(basic_compiler_type.GetTypeName(), t.GetTypeName());
@@ -267,14 +269,38 @@
   }
 }
 
+TEST_F(TestTypeSystemClang, TestOwningModule) {
+  TypeSystemClang ast("module_ast", HostInfo::GetTargetTriple());
+  CompilerType basic_compiler_type = ast.GetBasicType(BasicType::eBasicTypeInt);
+  CompilerType enum_type = ast.CreateEnumerationType(
+  "my_enum", ast.GetTranslationUnitDecl(), OptionalClangModuleID(100), Declaration(),
+  basic_compiler_type, false);
+  auto *ed = TypeSystemClang::GetAsEnumDecl(enum_type);
+  EXPECT_FALSE(!ed);
+  EXPECT_EQ(ed->getOwningModuleID(), 100u);
+
+  CompilerType record_type = ast.CreateRecordType(
+  nullptr, OptionalClangModuleID(200), lldb::eAccessPublic, "FooRecord",
+  clang::TTK_Struct, lldb::eLanguageTypeC_plus_plus, nullptr);
+  auto *rd = TypeSystemClang::GetAsRecordDecl(record_type);
+  EXPECT_FALSE(!rd);
+  EXPECT_EQ(rd->getOwningModuleID(), 200u);
+
+  CompilerType class_type = ast.CreateObjCClass(
+  "objc_class", ast.GetTranslationUnitDecl(), OptionalClangModuleID(300), false, false);
+  auto *cd = TypeSystemClang::GetAsObjCInterfaceDecl(class_type);
+  EXPECT_FALSE(!cd

[Lldb-commits] [lldb] 32672b8 - Revert "Preserve the owning module information from DWARF in the synthesized AST"

2020-04-01 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-04-01T18:58:11-07:00
New Revision: 32672b877dc1e05bc4489f2f4598f5472bc60576

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

LOG: Revert "Preserve the owning module information from DWARF in the 
synthesized AST"

This reverts commit 4354dfbdf5c8510a7ddff10ae67a28e16cf7cc79 while 
investigating bot fallout.

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/source/Symbol/Type.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
lldb/unittests/Symbol/TestTypeSystemClang.cpp
lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Removed: 
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm



diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index b0a7953190f8..0d1b00a1b26c 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -242,10 +242,8 @@ class CompilerType {
   /// Create a typedef to this type using "name" as the name of the typedef 
this
   /// type is valid and the type system supports typedefs, else return an
   /// invalid type.
-  /// \param payload   The typesystem-specific \p lldb::Type payload.
   CompilerType CreateTypedef(const char *name,
- const CompilerDeclContext &decl_ctx,
- uint32_t payload) const;
+ const CompilerDeclContext &decl_ctx) const;
 
   /// If the current object represents a typedef type, get the underlying type
   CompilerType GetTypedefedType() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index ba2bbfaf4650..a84b9a1c441c 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -259,12 +259,9 @@ class TypeSystem : public PluginInterface {
 
   virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
 
-  /// \param opaque_payload  The m_payload field of Type, which may
-  /// carry TypeSystem-specific extra information.
   virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
  const char *name,
- const CompilerDeclContext &decl_ctx,
- uint32_t opaque_payload);
+ const CompilerDeclContext &decl_ctx);
 
   // Exploring the type
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index e552f4389a1f..4b3e237dc62c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -18,7 +18,6 @@
 
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 #include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
-#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 
@@ -1004,20 +1003,6 @@ static void MaybeCompleteReturnType(ClangASTImporter 
&importer,
   importer.CompleteTagDecl(rd);
 }
 
-/// Recreate a module with its parents in \p to_source and return its id.
-static OptionalClangModuleID RemapModule(OptionalClangModuleID from_id,
-ClangExternalASTSourceCallbacks &from_source,
-ClangExternalASTSourceCallbacks &to_source) {
-  if (!from_id.HasValue())
-return {};

[Lldb-commits] [lldb] af1b7d0 - Correct copy-pasteo in lua script language description

2020-04-01 Thread Ed Maste via lldb-commits

Author: Ed Maste
Date: 2020-04-02T00:12:24-04:00
New Revision: af1b7d06d9e45c7e20540aa3bf81f1be5befaa0f

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

LOG: Correct copy-pasteo in lua script language description

Added: 


Modified: 
lldb/source/Commands/CommandObjectWatchpointCommand.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp 
b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index d86f4a35c5eb..11bf88de2fea 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -39,7 +39,7 @@ static constexpr OptionEnumValueElement 
g_script_option_enumeration[] = {
 {
 eScriptLanguageLua,
 "lua",
-"Commands are in the Python language.",
+"Commands are in the Lua language.",
 },
 {
 eSortOrderByName,



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


[Lldb-commits] [PATCH] D77241: update eArgTypeScriptLang description to mention lua

2020-04-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


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

https://reviews.llvm.org/D77241



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


[Lldb-commits] [PATCH] D77287: Windows: add very basic support for `DoLoadImage`

2020-04-01 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd created this revision.
compnerd added reviewers: JDevlieghere, xiaobai.
compnerd added a project: LLDB.

Add some very basic support for `DoLoadImage` and `UnloadImage` for Windows.  
This was previously not implemented and would result in a failure at runtime 
that is hard to detect.

This implementation is extremely limited but serves as a starting point for 
proper support for loading a library.  Ideally, the user input would be 
converted from UTF-8 to UTF-16.  This requires additional heap allocations and 
conversion logic.  Error recovery there requires additional allocations both 
from the local heap and the global heap.

This support enables the use of LLDB's Swift REPL on Windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77287

Files:
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h

Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.h
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -49,6 +49,15 @@
 
   lldb_private::Status DisconnectRemote() override;
 
+  uint32_t DoLoadImage(lldb_private::Process *process,
+   const lldb_private::FileSpec &remote_file,
+   const std::vector *paths,
+   lldb_private::Status &error,
+   lldb_private::FileSpec *loaded_path) override;
+
+  lldb_private::Status UnloadImage(lldb_private::Process *process,
+   uint32_t image_token) override;
+
   lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
@@ -73,6 +82,10 @@
 
 private:
   DISALLOW_COPY_AND_ASSIGN(PlatformWindows);
+
+  lldb_private::Status EvaluateLoaderExpression(lldb_private::Process *process,
+const char *expression,
+lldb::ValueObjectSP &value);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
===
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -16,11 +16,13 @@
 
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/BreakpointSite.h"
+#include "lldb/Expression/UserExpression.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Status.h"
 
@@ -306,6 +308,112 @@
   return error;
 }
 
+Status PlatformWindows::EvaluateLoaderExpression(Process *process,
+ const char *expression,
+ ValueObjectSP &value) {
+  // FIXME(compnerd) `-fdeclspec` is not passed to the clang instance?
+  static const char kLoaderDecls[] =
+  R"(
+  // libloaderapi.h
+
+  // WINBASEAPI BOOL WINAPI FreeModule(HMODULE);
+  extern "C" /* __declspec(dllimport) */ BOOL __stdcall FreeModule(void *hLibModule);
+
+  // WINBASEAPI HMODULE WINAPI LoadLibraryA(LPCSTR);
+  extern "C" /* __declspec(dllimport) */ void * __stdcall LoadLibraryA(const char *);
+)";
+
+  if (DynamicLoader *loader = process->GetDynamicLoader()) {
+Status result = loader->CanLoadImage();
+if (result.Fail())
+  return result;
+  }
+
+  ThreadSP thread = process->GetThreadList().GetExpressionExecutionThread();
+  if (!thread)
+return Status("selected thread is invalid");
+
+  StackFrameSP frame = thread->GetStackFrameAtIndex(0);
+  if (!frame)
+return Status("frame 0 is invalid");
+
+  ExecutionContext context;
+  frame->CalculateExecutionContext(context);
+
+  EvaluateExpressionOptions options;
+  options.SetUnwindOnError(true);
+  options.SetIgnoreBreakpoints(true);
+  options.SetExecutionPolicy(eExecutionPolicyAlways);
+  options.SetLanguage(eLanguageTypeC_plus_plus);
+  // LoadLibrary{A,W}/FreeLibrary cannot raise exceptions which we can handle.
+  // They may potentially throw SEH exceptions which we do not know how to
+  // handle currently.
+  options.SetTrapExceptions(false);
+  options.SetTimeout(process->GetUtilityExpressionTimeout());
+
+  Status error;
+  ExpressionResults result =
+  UserExpression::Evaluate(context, options, expression, kLoaderDecls,
+   value, error);
+  if (result != eExpressionCompleted)
+return error;
+
+  if (value->GetError().Fail())
+return value->GetError();
+
+  return Status();
+}
+
+uint32_t
+PlatformWindows:

Re: [Lldb-commits] [lldb] c911cc6 - [intel-pt] Implement a basic test case

2020-04-01 Thread Pavel Labath via lldb-commits
Walter,

you were already told to write more informative messages when reverting
and recommiting patches. If you're reverting a patch, please give a
short explanation of the reason (does it fail on the bots? which ones?
what fails?). When recommiting a patch, please give a summary of what
has changed since the last version, so one does not have to diff the
patches just to see what happened.

If you're unsure about why a test fails somewhere you can ask the bot
owner for help, instead of just trying over and over..

pl

On 01/04/2020 22:44, Walter Erquinigo via lldb-commits wrote:
> 
> Author: Walter Erquinigo
> Date: 2020-04-01T13:44:03-07:00
> New Revision: c911cc6c49394909a335c8d7baffcfd8bdcc424b
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/c911cc6c49394909a335c8d7baffcfd8bdcc424b
> DIFF: 
> https://github.com/llvm/llvm-project/commit/c911cc6c49394909a335c8d7baffcfd8bdcc424b.diff
> 
> LOG: [intel-pt] Implement a basic test case
> 
> Summary:
> Depends on D76872.
> 
> There was no test for the Intel PT support on LLDB, so I'm creating one, which
> will help making progress on solid grounds.
> 
> The test is skipped if the Intel PT plugin library is not built.
> 
> Reviewers: clayborg, labath, kusmour, aadsm
> 
> Subscribers: lldb-commits
> 
> Tags: #lldb
> 
> Differential Revision: https://reviews.llvm.org/D77107
> 
> Added: 
> lldb/test/API/tools/intel-features/intel-pt/test/Makefile
> 
> lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
> lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
> 
> Modified: 
> lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
> b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
> new file mode 100644
> index ..8b20bcb0
> --- /dev/null
> +++ b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
> @@ -0,0 +1,3 @@
> +CXX_SOURCES := main.cpp
> +
> +include Makefile.rules
> 
> diff  --git 
> a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
> b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
> new file mode 100644
> index ..9bbae290a7d0
> --- /dev/null
> +++ 
> b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
> @@ -0,0 +1,60 @@
> +from __future__ import print_function
> +
> +import os
> +import lldb
> +import time
> +
> +from lldbsuite.test.decorators import *
> +from lldbsuite.test.lldbtest import *
> +from lldbsuite.test import lldbutil
> +
> +
> +class TestIntelPTSimpleBinary(TestBase):
> +
> +mydir = TestBase.compute_mydir(__file__)
> +NO_DEBUG_INFO_TESTCASE = True
> +
> +@skipIf(oslist=no_match(['linux']))
> +@skipIf(archs=no_match(['i386', 'x86_64']))
> +@skipIfRemote
> +def test_basic_flow(self):
> +"""Test collection, decoding, and dumping instructions"""
> +lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
> +lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
> +plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
> +if not os.path.isfile(plugin_file):
> +self.skipTest("features plugin missing.")
> +return
> +
> +self.build()
> +
> +self.runCmd("plugin load " + plugin_file)
> +
> +exe = self.getBuildArtifact("a.out")
> +lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
> +# We start tracing from main
> +self.runCmd("processor-trace start all")
> +
> +# We check the trace after the for loop
> +self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
> +self.runCmd("c")
> +
> +# We wait a little bit to ensure the processor has send the PT 
> packets to
> +# the memory
> +time.sleep(.1)
> +
> +# We find the start address of the 'fun' function for a later check
> +target = self.dbg.GetSelectedTarget()
> +fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
> +.GetStartAddress().GetLoadAddress(target)
> +
> +# We print the last instructions
> +self.expect("processor-trace show-instr-log -c 100",
> +patterns=[
> +# We expect to have seen the first instruction of 'fun'
> +hex(fun_start_adddress),  
> +# We expect to see the exit condition of the for loop
> +"at main.cpp:" + str(line_number('main.cpp', '// Break for 
> loop')) 
> +])
> +
> +self.runCmd("processor-trace stop")
> 
> diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
> b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
> new file mode 100644
> index ..ea826a2ac0c6
> --- /dev/null
> +++ b/lldb/test/API/tools/intel-features/in