[Lldb-commits] [PATCH] D82064: [ARM64] Add QEMU testing environment setup guide for SVE testing

2020-09-21 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 293136.
omjavaid added a comment.
Herald added a subscriber: arphaman.

This adds a rst page qemu-testing.rst that describes content which was 
previously written in README.txt.


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

https://reviews.llvm.org/D82064

Files:
  lldb/docs/index.rst
  lldb/docs/resources/test.rst
  lldb/docs/use/qemu-testing.rst
  lldb/scripts/lldb-test-qemu/rootfs.sh
  lldb/scripts/lldb-test-qemu/run-qemu.sh
  lldb/scripts/lldb-test-qemu/setup.sh

Index: lldb/scripts/lldb-test-qemu/setup.sh
===
--- /dev/null
+++ lldb/scripts/lldb-test-qemu/setup.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+
+print_usage() {
+  echo "Usage: $(basename $0) [options]"
+  echo -e "Builds QEMU and Linux kernel from source.\n"
+  echo -e "  --help\t\t\tDisplay this information."
+  echo -e "  --kernel {arm|arm64}\t\tBuild Linux kernel for the architecture."
+  echo -e "  --qemu\t\t\tBuild QEMU from source."
+  echo -e "  --clean\t\t\tRemove qemu.git and linux.git directories in current directory."
+  exit "$1"
+}
+
+update_repositories() {
+  echo -e "\nUpdating apt repositories. "
+  echo -e "\nPress 'y' to continue or any other key to exit..."
+  read -s -n 1 user_input
+  if [[ $user_input == 'Y' ]] || [[ $user_input == 'y' ]]; then
+sudo apt update
+  else
+exit
+  fi
+}
+
+check_dir_exists() {
+  user_input=
+  if [ -d "$1" ]; then
+echo -e "\n$1 already exists in working directory and will not be updated."
+echo -e "\nPress 'y' to continue or any other key to exit..."
+read -s -n 1 user_input
+if [[ $user_input != 'Y' ]] && [[ $user_input != 'y' ]]; then
+  exit
+fi
+  fi
+}
+
+invalid_arg() {
+  echo "ERROR: Unrecognized argument: $1" >&2
+  print_usage 1
+}
+
+build_qemu() {
+  echo "Installing QEMU build dependencies ..."
+  sudo apt install git python3-dev libsdl1.2-dev build-essential libpixman-1-dev
+
+  # Checkout source code
+  check_dir_exists "qemu.git"
+  if [ ! -d "qemu.git" ]; then
+git clone --depth 1 git://git.qemu.org/qemu.git qemu.git
+  fi
+
+  cd qemu.git
+  # We are going to build QEMU Arm and AArch64 system mode emulation.
+  # ./configure --help emits a list of other possible targets supported by QEMU.
+  ./configure --target-list=arm-softmmu,aarch64-softmmu
+  make -j`getconf _NPROCESSORS_ONLN`
+}
+
+build_linux() {
+  echo "Installing Linux kernel build dependencies ..."
+  sudo apt install git bison flex build-essential libssl-dev bc
+
+  check_dir_exists "linux.git"
+
+  if [ ! -d "linux.git" ]; then
+git clone --depth 1 \
+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux.git
+  fi
+
+  cd linux.git
+  make mrproper
+
+  if [[ "$1" == "arm" ]]; then
+echo "Installing gcc-arm-linux-gnueabihf ..."
+sudo apt install gcc-arm-linux-gnueabihf
+
+# Configure kernel_branch=master arch=arm config=vexpress_defconfig
+make O=../linux.build/arm ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- \
+vexpress_defconfig
+
+# Trigger Arm kernel build
+make -j`getconf _NPROCESSORS_ONLN` O=../linux.build/arm ARCH=arm \
+CROSS_COMPILE=arm-linux-gnueabihf-
+  elif [[ "$1" == "arm64" ]]; then
+echo "Installing gcc-aarch64-linux-gnu ..."
+sudo apt install gcc-aarch64-linux-gnu
+
+# Configure kernel_branch=master arch=arm64 config=defconfig
+make O=../linux.build/arm64 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
+defconfig
+
+# Trigger AArch64 kernel build
+make -j`getconf _NPROCESSORS_ONLN` O=../linux.build/arm64 ARCH=arm64 \
+CROSS_COMPILE=aarch64-linux-gnu-
+  else
+echo "ERROR: Unrecognized architecture: $1" >&2
+print_usage 1
+exit
+  fi
+}
+
+clean() {
+  if [ -d "linux.git" ]; then
+echo "Removing linux.git ..."
+rm -rf linux.git
+  fi
+
+  if [ -d "linux.build" ]; then
+echo "Removing linux.build ..."
+rm -rf linux.build
+  fi
+
+  if [ -d "qemu.git" ]; then
+echo "Removing qemu.git ..."
+rm -rf qemu.git
+  fi
+
+  exit
+}
+
+# Parse options
+while [[ $# -gt 0 ]]; do
+  case "${END_OF_OPT}${1}" in
+-h|--help)   print_usage 0 ;;
+-k|--kernel)
+  if [ "$2" == "arm64" ] || [ "$2" == "arm" ]; then
+  KERNEL_ARCH=$2
+  else
+invalid_arg "$2"
+  fi
+  shift;;
+-q|--qemu)
+QEMU=1;;
+-c|--clean)  clean ;;
+*)   invalid_arg "$1" ;;
+  esac
+  shift
+done
+
+update_repositories
+
+if [ "$KERNEL_ARCH" != "" ]; then
+  pushd .
+  build_linux $KERNEL_ARCH
+  popd
+fi
+
+if [[ $QEMU -eq 1 ]]; then
+  pushd .
+  build_qemu
+  popd
+fi
Index: lldb/scripts/lldb-test-qemu/run-qemu.sh
===
--- /dev/null
+++ lldb/scripts/lldb-test-qemu/run-qemu.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+
+print_usage() {
+  echo "Usage: $(basename $0) --arch [arm|arm64] [options]"
+  echo -e "Starts QEMU system mode emulation for the archit

[Lldb-commits] [lldb] 3b3b9ba - [lldb/Commands] Fix outdated `breakpoint command add` help string

2020-09-21 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2020-09-21T10:15:34-07:00
New Revision: 3b3b9ba1c7d89afe4909a42e2a795354bb79e062

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

LOG: [lldb/Commands] Fix outdated `breakpoint command add` help string

Update the some examples in the help string for `breakpoint command add`.

Python breakpoint commands have different output than what's shown in the help 
string.

Notes:
  * Removed an example containing an inner function, as it seems more about a 
Python technique than about `command script add`
  * Updated `print x` to `print(x)` to be python 2/3 agnostic

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectBreakpointCommand.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 45df86589011..792e90ff27a1 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -141,12 +141,16 @@ Example Python one-line breakpoint command:
 
 (lldb) breakpoint command add -s python 1
 Enter your Python command(s). Type 'DONE' to end.
-> print "Hit this breakpoint!"
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location 
information
+   internal_dict: an LLDB support object not to be used"""
+print("Hit this breakpoint!")
+DONE
 
 As a convenience, this also works for a short Python one-liner:
 
-(lldb) breakpoint command add -s python 1 -o 'import time; print 
time.asctime()'
+(lldb) breakpoint command add -s python 1 -o 'import time; 
print(time.asctime())'
 (lldb) run
 Launching '.../a.out'  (x86_64)
 (lldb) Fri Sep 10 12:17:45 2010
@@ -164,21 +168,14 @@ Example multiple line Python breakpoint command:
 
 (lldb) breakpoint command add -s p 1
 Enter your Python command(s). Type 'DONE' to end.
-> global bp_count
-> bp_count = bp_count + 1
-> print "Hit this breakpoint " + repr(bp_count) + " times!"
-> DONE
-
-Example multiple line Python breakpoint command, using function definition:
-
-(lldb) breakpoint command add -s python 1
-Enter your Python command(s). Type 'DONE' to end.
-> def breakpoint_output (bp_no):
-> out_string = "Hit breakpoint number " + repr (bp_no)
-> print out_string
-> return True
-> breakpoint_output (1)
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location 
information
+   internal_dict: an LLDB support object not to be used"""
+global bp_count
+bp_count = bp_count + 1
+print("Hit this breakpoint " + repr(bp_count) + " times!")
+DONE
 
 )"
 "In this case, since there is a reference to a global variable, \



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


[Lldb-commits] [PATCH] D87807: [lldb/Commands] Fix outdated `breakpoint command add` help string

2020-09-21 Thread Dave Lee via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b3b9ba1c7d8: [lldb/Commands] Fix outdated `breakpoint 
command add` help string (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87807

Files:
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp


Index: lldb/source/Commands/CommandObjectBreakpointCommand.cpp
===
--- lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -141,12 +141,16 @@
 
 (lldb) breakpoint command add -s python 1
 Enter your Python command(s). Type 'DONE' to end.
-> print "Hit this breakpoint!"
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location 
information
+   internal_dict: an LLDB support object not to be used"""
+print("Hit this breakpoint!")
+DONE
 
 As a convenience, this also works for a short Python one-liner:
 
-(lldb) breakpoint command add -s python 1 -o 'import time; print 
time.asctime()'
+(lldb) breakpoint command add -s python 1 -o 'import time; 
print(time.asctime())'
 (lldb) run
 Launching '.../a.out'  (x86_64)
 (lldb) Fri Sep 10 12:17:45 2010
@@ -164,21 +168,14 @@
 
 (lldb) breakpoint command add -s p 1
 Enter your Python command(s). Type 'DONE' to end.
-> global bp_count
-> bp_count = bp_count + 1
-> print "Hit this breakpoint " + repr(bp_count) + " times!"
-> DONE
-
-Example multiple line Python breakpoint command, using function definition:
-
-(lldb) breakpoint command add -s python 1
-Enter your Python command(s). Type 'DONE' to end.
-> def breakpoint_output (bp_no):
-> out_string = "Hit breakpoint number " + repr (bp_no)
-> print out_string
-> return True
-> breakpoint_output (1)
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location 
information
+   internal_dict: an LLDB support object not to be used"""
+global bp_count
+bp_count = bp_count + 1
+print("Hit this breakpoint " + repr(bp_count) + " times!")
+DONE
 
 )"
 "In this case, since there is a reference to a global variable, \


Index: lldb/source/Commands/CommandObjectBreakpointCommand.cpp
===
--- lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -141,12 +141,16 @@
 
 (lldb) breakpoint command add -s python 1
 Enter your Python command(s). Type 'DONE' to end.
-> print "Hit this breakpoint!"
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
+   internal_dict: an LLDB support object not to be used"""
+print("Hit this breakpoint!")
+DONE
 
 As a convenience, this also works for a short Python one-liner:
 
-(lldb) breakpoint command add -s python 1 -o 'import time; print time.asctime()'
+(lldb) breakpoint command add -s python 1 -o 'import time; print(time.asctime())'
 (lldb) run
 Launching '.../a.out'  (x86_64)
 (lldb) Fri Sep 10 12:17:45 2010
@@ -164,21 +168,14 @@
 
 (lldb) breakpoint command add -s p 1
 Enter your Python command(s). Type 'DONE' to end.
-> global bp_count
-> bp_count = bp_count + 1
-> print "Hit this breakpoint " + repr(bp_count) + " times!"
-> DONE
-
-Example multiple line Python breakpoint command, using function definition:
-
-(lldb) breakpoint command add -s python 1
-Enter your Python command(s). Type 'DONE' to end.
-> def breakpoint_output (bp_no):
-> out_string = "Hit breakpoint number " + repr (bp_no)
-> print out_string
-> return True
-> breakpoint_output (1)
-> DONE
+def function (frame, bp_loc, internal_dict):
+"""frame: the lldb.SBFrame for the location at which you stopped
+   bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
+   internal_dict: an LLDB support object not to be used"""
+global bp_count
+bp_count = bp_count + 1
+print("Hit this breakpoint " + repr(bp_count) + " times!")
+DONE
 
 )"
 "In this case, since there is a reference to a global variable, \
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Calling every symbol called mmap you find around till one returns some value 
makes me a bit nervous.  For instance, on macOS dyld has a symbol called "mmap" 
that isn't meant to be called by anybody but dyld.  We probably don't want to 
accidentally call that.

You can get around that particular instance by only looking for exported 
functions (macOS's internal mmap is not exported).  I can't think of any good 
reason we would want to call an unexported mmap, since we're trying to do what 
a program on the system would do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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


[Lldb-commits] [lldb] 6807f24 - [ASTImporter] Modifying ImportDeclContext(...) to ensure that we also handle the case when the FieldDecl is an ArrayType whose ElementType is a RecordDecl

2020-09-21 Thread via lldb-commits

Author: shafik
Date: 2020-09-21T14:57:00-07:00
New Revision: 6807f244fa67bb75ef09fb3db54743b5b358a7fa

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

LOG: [ASTImporter] Modifying ImportDeclContext(...) to ensure that we also 
handle the case when the FieldDecl is an ArrayType whose ElementType is a 
RecordDecl

When we fixed ImportDeclContext(...) in D71378 to make sure we complete each
FieldDecl of a RecordDecl when we are importing the definition we missed the
case where a FeildDecl was an ArrayType whose ElementType is a record.

This fix was motivated by a codegen crash during LLDB expression parsing. Since
we were not importing the definition we were crashing during layout which
required all the records be defined.

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

Added: 

lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile

lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py

lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp

Modified: 
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 11bf629ecdde2..60b6a9706d6ac 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1742,12 +1742,28 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, 
bool ForceImport) {
   Decl *ImportedDecl = *ImportedOrErr;
   FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
   if (FieldFrom && FieldTo) {
-const RecordType *RecordFrom = 
FieldFrom->getType()->getAs();
-const RecordType *RecordTo = FieldTo->getType()->getAs();
-if (RecordFrom && RecordTo) {
-  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
-  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+RecordDecl *FromRecordDecl = nullptr;
+RecordDecl *ToRecordDecl = nullptr;
+// If we have a field that is an ArrayType we need to check if the 
array
+// element is a RecordDecl and if so we need to import the defintion.
+if (FieldFrom->getType()->isArrayType()) {
+  // getBaseElementTypeUnsafe(...) handles multi-dimensonal arrays for 
us.
+  FromRecordDecl = 
FieldFrom->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
+  ToRecordDecl = 
FieldTo->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
+}
+
+if (!FromRecordDecl || !ToRecordDecl) {
+  const RecordType *RecordFrom =
+  FieldFrom->getType()->getAs();
+  const RecordType *RecordTo = FieldTo->getType()->getAs();
+
+  if (RecordFrom && RecordTo) {
+FromRecordDecl = RecordFrom->getDecl();
+ToRecordDecl = RecordTo->getDecl();
+  }
+}
 
+if (FromRecordDecl && ToRecordDecl) {
   if (FromRecordDecl->isCompleteDefinition() &&
   !ToRecordDecl->isCompleteDefinition()) {
 Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);

diff  --git 
a/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
new file mode 100644
index 0..a485b94a680dc
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
@@ -0,0 +1,14 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestImportDefinitionArrayType(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("__private->o", result_type="char", 
result_value="'A'")

diff  --git 
a/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp
 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp
new file mode 100644
index 0..99fc7b727cc80
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp
@@ -0,0 

[Lldb-commits] [PATCH] D86660: Modifying ImportDeclContext(...) to ensure that we also handle the case when the FieldDecl is an ArrayType whose ElementType is a RecordDecl

2020-09-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6807f244fa67: [ASTImporter] Modifying ImportDeclContext(...) 
to ensure that we also handle… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86660

Files:
  clang/lib/AST/ASTImporter.cpp
  
lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
  
lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
  
lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp

Index: lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp
@@ -0,0 +1,52 @@
+// This is a reproducer for a crash during codegen. The base issue is when we
+// Import the DeclContext we force FieldDecl that are RecordType to be defined
+// since we need these to be defined in order to layout the class.
+// This case involves an array member whose ElementType are records. In this
+// case we need to check the ElementType of an ArrayType and if it is a record
+// we need to import the definition.
+struct A {
+  int x;
+};
+
+struct B {
+  // When we import the all the FieldDecl we need to check if we have an
+  // ArrayType and then check if the ElementType is a RecordDecl and if so
+  // import the defintion. Otherwise during codegen we will attempt to layout A
+  // but won't be able to.
+  A s1[2];
+  A s2[2][2][3];
+  char o;
+};
+
+class FB {
+public:
+  union {
+struct {
+  unsigned char *_s;
+} t;
+char *tt[1];
+  } U;
+
+  FB(B *p) : __private(p) {}
+
+  // We import A but we don't import the definition.
+  void f(A **bounds) {}
+
+  void init();
+
+private:
+  B *__private;
+};
+
+void FB::init() {
+  return; // break here
+}
+
+int main() {
+  B b;
+  FB fb(&b);
+
+  b.o = 'A';
+
+  fb.init();
+}
Index: lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/TestImportDefinitionArrayType.py
@@ -0,0 +1,14 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestImportDefinitionArrayType(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("__private->o", result_type="char", result_value="'A'")
Index: lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1742,12 +1742,28 @@
   Decl *ImportedDecl = *ImportedOrErr;
   FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
   if (FieldFrom && FieldTo) {
-const RecordType *RecordFrom = FieldFrom->getType()->getAs();
-const RecordType *RecordTo = FieldTo->getType()->getAs();
-if (RecordFrom && RecordTo) {
-  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
-  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+RecordDecl *FromRecordDecl = nullptr;
+RecordDecl *ToRecordDecl = nullptr;
+// If we have a field that is an ArrayType we need to check if the array
+// element is a RecordDecl and if so we need to import the defintion.
+if (FieldFrom->getType()->isArrayType()) {
+  // getBaseElementTypeUnsafe(...) handles multi-dimensonal arrays for us.
+  FromRecordDecl = FieldFrom->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
+  ToRecordDecl = FieldTo->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();
+}
+
+if (!FromRecordDecl || !ToRecordDecl) {
+  const RecordType *RecordFrom =
+  FieldFrom->getType()->getAs();
+  const RecordType *RecordTo = FieldTo->getType()->getAs();
+
+  if (RecordFrom && RecordTo) {
+FromRecordDecl = RecordFrom->getDecl();
+ToRecordDecl = RecordTo->getDecl();
+  }
+}
 
+if (FromRecordDecl && ToRecordDecl) {
   if (FromRecordDecl->isCompleteDefinition() &&
   !To

[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

It seems like calling any 'mmap' definition should work. Is the interposed mmap 
implementation failing and correctly returning -1, or is it succeeding and 
incorrectly returning -1? In either case, it seems like it's worth digging into 
why it's failing / returning the wrong result. (Just my two cents - I'm not 
really familiar with this code, so take it with a grain of salt :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

Should lldb avoid calling asan (or any other sanitizer's) `mmap`? If so, maybe 
this function can be sanitizer aware and ignore those symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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


[Lldb-commits] [PATCH] D88051: [lldb/test] Clean up version checking.

2020-09-21 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: JDevlieghere, arsenm.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: wdng.

A few fixes while trying to figure out why tests are being skipped for arsenm:

- We check `$compiler -v`, but `-v` is `--verbose`, not `--version`. Use the 
long flag name.
- We check all lines matching `version ...`, but we should exit early for the 
first version string we see (which should be the main one). I'm not sure if 
this is the issue, but perhaps this is causing some users to skip some tests if 
another "version ..." is showing up later.
- Having `\.` in a python string is triggering pylint warnings, because it 
should be escaped as a regex string, e.g. `r'\.' However, `.` in a character 
class does not need to be escaped, as it matches only a literal `.` in that 
context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88051

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86416: [lldb] -stdlib=libc++ for linking with lldb lib also if LLVM_ENABLE_LIBCXX

2020-09-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

The change to use the configuration looks good, but I think Pavel raised a good 
point. Which tests are affected by this? How much work would it be to convert 
them as suggested?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D86416

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


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D87868#2286313 , @kastiglione wrote:

> Should lldb avoid calling asan (or any other sanitizer's) `mmap`? If so, 
> maybe this function can be sanitizer aware and ignore those symbols.

At present, this is a function that gets used for any Posix, and I don't think 
it can know about sanitizers.  If you want to do something of this sort, then 
the Platform should be asked for the library containing the canonical mmap, and 
we can load it from there.  That would have the nice effect that we wouldn't 
search the whole symbol world for mmap, and allow the Platform to pick the 
right one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

So sounds like first we should verify if the "mmap" for asan is exported or 
not. If it isn't then this is an easy fix, iterate through all possible matches 
and avoid any internal versions of mmap and only call externally visible 
symbols. Antonio, can you verify the visibility of the symbol?

  bool Symbol::IsExternal() const { return m_is_external; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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


[Lldb-commits] [lldb] 307b7a1 - [lldb/test] Clean up version checking.

2020-09-21 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2020-09-21T16:19:28-07:00
New Revision: 307b7a1d665898d0e980461919996b6a670a4847

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

LOG: [lldb/test] Clean up version checking.

A few fixes while trying to figure out why tests are being skipped for arsenm:

- We check `$compiler -v`, but `-v` is `--verbose`, not `--version`. Use the 
long flag name.
- We check all lines matching `version ...`, but we should exit early for the 
first version string we see (which should be the main one). I'm not sure if 
this is the issue, but perhaps this is causing some users to skip some tests if 
another "version ..." is showing up later.
- Having `\.` in a python string is triggering pylint warnings, because it 
should be escaped as a regex string, e.g. `r'\.' However, `.` in a character 
class does not need to be escaped, as it matches only a literal `.` in that 
context.

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 73faa2aef5e4..2ee82295c553 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@ def getCompilerVersion(self):
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """



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


[Lldb-commits] [PATCH] D88051: [lldb/test] Clean up version checking.

2020-09-21 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG307b7a1d6658: [lldb/test] Clean up version checking. 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88051

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 74c9395 - Add a "Trace" plug-in to LLDB to add process trace support in stages.

2020-09-21 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-09-21T17:13:18-07:00
New Revision: 74c93956e1c1f1054dfb040ce26830016e0f3095

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

LOG: Add a "Trace" plug-in to LLDB to add process trace support in stages.

This is the first in a series of patches that will adds a new processor trace 
plug-in to LLDB.

The idea for this first patch to to add the plug-in interface with simple 
commands for the trace files that can "load" and "dump" the trace information. 
We can test the functionality and ensure people are happy with the way things 
are done and how things are organized before moving on to adding more 
functionality.

Processor trace information can be view in a few different ways:
- post mortem where a trace is saved off that can be viewed later in the 
debugger
- gathered while a process is running and allow the user to step back in time 
(with no variables, memory or registers) to see how each thread arrived at 
where it is currently stopped.

This patch attempts to start with the first solution of loading a trace file 
after the fact. The idea is that we will use a JSON file to load the trace 
information. JSON allows us to specify information about the trace like:
- plug-in name in LLDB
- path to trace file
- shared library load information so we can re-create a target and symbolicate 
the information in the trace
- any other info that the trace plug-in will need to be able to successfully 
parse the trace information
  - cpu type
  - version info
  - ???

A new "trace" command was added at the top level of the LLDB commmands:
- "trace load"
- "trace dump"

I did this because if we load trace information we don't need to have a process 
and we might end up creating a new target for the trace information that will 
become active. If anyone has any input on where this would be better suited, 
please let me know. Walter Erquinigo will end up filling in the Intel PT 
specific plug-in so that it works and is tested once we can agree that the 
direction of this patch is the correct one, so please feel free to chime in 
with ideas on comments!

Reviewed By: clayborg

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

Added: 
lldb/include/lldb/Target/Trace.h
lldb/include/lldb/Target/TraceSettingsParser.h
lldb/source/Commands/CommandObjectTrace.cpp
lldb/source/Commands/CommandObjectTrace.h
lldb/source/Plugins/Trace/CMakeLists.txt
lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.h
lldb/source/Target/Trace.cpp
lldb/source/Target/TraceSettingsParser.cpp
lldb/test/API/commands/trace/TestTraceLoad.py
lldb/test/API/commands/trace/TestTraceSchema.py
lldb/test/API/commands/trace/intelpt-trace/3842849.trace
lldb/test/API/commands/trace/intelpt-trace/a.out
lldb/test/API/commands/trace/intelpt-trace/main.cpp
lldb/test/API/commands/trace/intelpt-trace/trace.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json

Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/Commands/CMakeLists.txt
lldb/source/Commands/Options.td
lldb/source/Core/PluginManager.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/CMakeLists.txt
lldb/source/Target/CMakeLists.txt
lldb/source/Utility/StructuredData.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 5e0c9395dae0..cd962b668163 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -330,6 +330,14 @@ class PluginManager {
   static SymbolVendorCreateInstance
   GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
 
+  // Trace
+  static bool RegisterPlugin(ConstString name, const char *description,
+ TraceCreateInstance create_callback);
+
+  static bool UnregisterPlugin(TraceCreateInstance create_callback);
+
+  static TraceCreateInstance GetTraceCreateCallback(ConstString plugin_name);
+
   // UnwindAssembly
   static bool RegisterPlugin(ConstString name, const char *description,
  UnwindAssemblyCreateInstance create_callback);

diff  --git a/lldb/include/lldb/Target/Trace.h 
b/lldb/include/lldb/Target/Trace.h
new file mode 100644
index ..2328fba822a2
--- /dev/null
+++ b/lldb/includ

[Lldb-commits] [PATCH] D85705: Add a "Trace" plug-in to LLDB to add process trace support in stages.

2020-09-21 Thread Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74c93956e1c1: Add a "Trace" plug-in to LLDB to add 
process trace support in stages. (authored by Walter Erquinigo 
, committed by Walter Erquinigo 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85705

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Target/Trace.h
  lldb/include/lldb/Target/TraceSettingsParser.h
  lldb/include/lldb/lldb-forward.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Commands/CommandObjectTrace.h
  lldb/source/Commands/Options.td
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/Trace/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.h
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Trace.cpp
  lldb/source/Target/TraceSettingsParser.cpp
  lldb/source/Utility/StructuredData.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceSchema.py
  lldb/test/API/commands/trace/intelpt-trace/3842849.trace
  lldb/test/API/commands/trace/intelpt-trace/a.out
  lldb/test/API/commands/trace/intelpt-trace/main.cpp
  lldb/test/API/commands/trace/intelpt-trace/trace.json
  lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
  lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
  lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json

Index: lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json
@@ -0,0 +1,32 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 5678,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "6AA9A4E2-6F28-2F33-377D-59FECE874C71-5B41261A"
+}
+  ]
+},
+{}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
@@ -0,0 +1,41 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 5678,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "6AA9A4E2-6F28-2F33-377D-59FECE874C71-5B41261A"
+}
+  ]
+},
+{
+  "pid": 12345,
+  "threads": [
+{
+  "tid": 56789,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": []
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
@@ -0,0 +1,14 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+123
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace.json
@@ -0,0 +1,31 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 3842849,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x

[Lldb-commits] [lldb] 94b0d83 - Fix reporting the lack of global variables in "target var".

2020-09-21 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2020-09-21T17:29:40-07:00
New Revision: 94b0d836a105116220052313df5a58473f706cdf

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

LOG: Fix reporting the lack of global variables in "target var".

There was a little thinko which meant when stopped in a frame with
debug information but whose CU didn't have any global variables we
report:

no debug info for frame 

This patch fixes that error message to say the intended:

no global variables in current compile unit



Added: 
lldb/test/API/functionalities/target_var/no_vars/Makefile
lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py
lldb/test/API/functionalities/target_var/no_vars/main.c

Modified: 
lldb/source/Commands/CommandObjectTarget.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 30fdaf9ec9a2..431c2f3a19f0 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -907,6 +907,7 @@ class CommandObjectTargetVariable : public 
CommandObjectParsed {
 CompileUnit *comp_unit = nullptr;
 if (frame) {
   SymbolContext sc = frame->GetSymbolContext(eSymbolContextCompUnit);
+  comp_unit = sc.comp_unit;
   if (sc.comp_unit) {
 const bool can_create = true;
 VariableListSP comp_unit_varlist_sp(

diff  --git a/lldb/test/API/functionalities/target_var/no_vars/Makefile 
b/lldb/test/API/functionalities/target_var/no_vars/Makefile
new file mode 100644
index ..10495940055b
--- /dev/null
+++ b/lldb/test/API/functionalities/target_var/no_vars/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py 
b/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py
new file mode 100644
index ..60ca8b1252b3
--- /dev/null
+++ b/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py
@@ -0,0 +1,21 @@
+"""
+Test that target var with no variables returns a correct error
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestTargetVarNoVars(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_target_var_no_vars(self):
+self.build()
+lldbutil.run_to_name_breakpoint(self, 'main')
+self.expect("target variable", substrs=['no global variables in 
current compile unit', 'main.c'], error=True)
+

diff  --git a/lldb/test/API/functionalities/target_var/no_vars/main.c 
b/lldb/test/API/functionalities/target_var/no_vars/main.c
new file mode 100644
index ..d7877b0a519b
--- /dev/null
+++ b/lldb/test/API/functionalities/target_var/no_vars/main.c
@@ -0,0 +1,5 @@
+int
+main(int argc, char **argv)
+{
+  return argc;
+}



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


[Lldb-commits] [lldb] 0b9f9ec - Include sstream after D85705

2020-09-21 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2020-09-21T17:41:59-07:00
New Revision: 0b9f9eced9c532ee9bbf320216a2e85b314eb5f0

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

LOG: Include sstream after D85705

Added: 


Modified: 
lldb/source/Target/TraceSettingsParser.cpp

Removed: 




diff  --git a/lldb/source/Target/TraceSettingsParser.cpp 
b/lldb/source/Target/TraceSettingsParser.cpp
index 09e60bb35a4a..2c0f337ee9a1 100644
--- a/lldb/source/Target/TraceSettingsParser.cpp
+++ b/lldb/source/Target/TraceSettingsParser.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Target/TraceSettingsParser.h"
 
 #include 
+#include 
 
 #include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Core/Debugger.h"



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


[Lldb-commits] [lldb] 95bfeb5 - [lldb] Delete two unneeded

2020-09-21 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2020-09-21T18:11:26-07:00
New Revision: 95bfeb5903c7b75a0a9ddf5c4b53e4308bb05486

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

LOG: [lldb] Delete two unneeded 

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Target/Trace.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 1001514edede..aaf839407134 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -52,8 +52,6 @@
 #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
 
-#include 
-
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;

diff  --git a/lldb/source/Target/Trace.cpp b/lldb/source/Target/Trace.cpp
index 6a1f8eadee1b..afe4ee20be48 100644
--- a/lldb/source/Target/Trace.cpp
+++ b/lldb/source/Target/Trace.cpp
@@ -8,7 +8,6 @@
 
 #include "lldb/Target/Trace.h"
 
-#include 
 #include 
 
 #include "llvm/Support/Format.h"



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


[Lldb-commits] [PATCH] D85705: Add a "Trace" plug-in to LLDB to add process trace support in stages.

2020-09-21 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: lldb/source/Target/TraceSettingsParser.cpp:123
+  if (schema.empty()) {
+std::ostringstream schema_builder;
+schema_builder << "{\n \"trace\": ";

This requires `sstream`. Fixed.



Comment at: lldb/source/Target/TraceSettingsParser.cpp:128
+std::string plugin_schema(GetPluginSchema());
+plugin_schema = std::regex_replace(plugin_schema, std::regex("\n"), "\n  
");
+schema_builder << plugin_schema << ",\n";

The replacement here looks strange.

`` implementations tend to be large, slow and buggy. It'd be best if 
 can be avoided. (llvm has llvm/Support/Regex.h)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85705

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


[Lldb-commits] [PATCH] D85705: Add a "Trace" plug-in to LLDB to add process trace support in stages.

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



Comment at: lldb/source/Target/TraceSettingsParser.cpp:128
+std::string plugin_schema(GetPluginSchema());
+plugin_schema = std::regex_replace(plugin_schema, std::regex("\n"), "\n  
");
+schema_builder << plugin_schema << ",\n";

MaskRay wrote:
> The replacement here looks strange.
> 
> `` implementations tend to be large, slow and buggy. It'd be best if 
>  can be avoided. (llvm has llvm/Support/Regex.h)
will do!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85705

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


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-09-21 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.



> It seems like calling any 'mmap' definition should work. Is the interposed 
> mmap implementation failing and correctly returning -1, or is it succeeding 
> and incorrectly returning -1? In either case, it seems like it's worth 
> digging into why it's failing / returning the wrong result

@vsk, yeah, this is what I've tried to do before I submitted this diff. It 
should work because it works when lldb is not attached. I wanted to step into 
it (by defining SINGLE_STEP_EXPRESSIONS) and see what's going on but the 
process crashes on me when I do that. It has to work just because if I call 
`__interceptor_mmap` it works and the only difference between those two is that 
one calls `internal_iserror`. InferiorCallMmap uses ThreadPlanCallFunction 
which seems to ignore breakpoints because it uses the subplan "run to address" 
that makes sure it only stops at the address given so it has been hard to put a 
breakpoint there. The only exception to this is when I define the 
SINGLE_STEP_EXPRESSIONS but like I said the process crashes or something, don't 
remember anymore. I can try again.

@clayborg I'll try that.

Thanks everyone for their input, I'll follow up on this next week because right 
now I'm on vacation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

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