[Lldb-commits] [PATCH] D44472: Add and fix some tests for PPC64

2018-03-16 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 like what you did with the test. Originally, I wanted to just compare the raw 
memory contents, but this keeps it more inline with the spirit of the original 
test. I have just one question about the list zipping, but otherwise lgtm.




Comment at: 
packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py:48-49
+# instructions before inserting breakpoints.
+for dis_inst_before, dis_inst_after in \
+zip(disassembly_before_break, disassembly_after_break):
+inst_before = dis_inst_before.split(':')[-1]

what will this do if the lists are of different length? Should you assert that 
the length matches as well?


https://reviews.llvm.org/D44472



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


[Lldb-commits] [lldb] r327703 - [dotest] Clean up test folder clean-up

2018-03-16 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Mar 16 05:04:46 2018
New Revision: 327703

URL: http://llvm.org/viewvc/llvm-project?rev=327703&view=rev
Log:
[dotest] Clean up test folder clean-up

Summary:
This patch implements a unified way of cleaning the build folder of each
test. This is done by completely removing the build folder before each
test, in the respective setUp() method. Previously, we were using a
combination of several methods, each with it's own drawbacks:
- nuking the entire build tree before running dotest: the issue here is
  that this did not take place if you ran dotest manually
- running "make clean" before the main "make" target: this relied on the
  clean command being correctly implemented. This was usually true, but
  not always.
- for files which were not produced by make, each python file was
  responsible for ensuring their deleting, using a variety of methods.

With this approach, the previous methods become redundant. I remove the
first two, since they are centralized. For the other various bits of
clean-up code in python files, I indend to delete it when I come
across it.

Reviewers: aprantl

Subscribers: emaste, ki.stfu, mgorny, eraman, lldb-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py

lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py

lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py

lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
lldb/trunk/test/CMakeLists.txt

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py?rev=327703&r1=327702&r2=327703&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
 Fri Mar 16 05:04:46 2018
@@ -64,7 +64,6 @@ class CompDirSymLinkTestCase(TestBase):
 self.line)
 
 def create_src_symlink(self):
-self.makeBuildDir()
 pwd_symlink = self.getBuildArtifact('pwd_symlink')
 if os.path.exists(pwd_symlink):
 os.unlink(pwd_symlink)
@@ -73,7 +72,7 @@ class CompDirSymLinkTestCase(TestBase):
 return pwd_symlink
 
 def doBuild(self, pwd_symlink):
-self.build(None, None, {'PWD': pwd_symlink}, True)
+self.build(None, None, {'PWD': pwd_symlink})
 
 exe = self.getBuildArtifact(_EXE_NAME)
 self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py?rev=327703&r1=327702&r2=327703&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
 Fri Mar 16 05:04:46 2018
@@ -30,7 +30,6 @@ class CommandScriptImmediateOutputTestCa
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
 def test_command_script_immediate_output_console(self):
 """Test that LLDB correctly allows scripted commands to set immediate 
output to the console."""
-self.makeBuildDir()
 self.launch(timeout=10)
 
   

[Lldb-commits] [PATCH] D44526: [dotest] Clean up test folder clean-up

2018-03-16 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327703: [dotest] Clean up test folder clean-up (authored by 
labath, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44526?vs=138579&id=138681#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44526

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
  
lldb/trunk/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py
  
lldb/trunk/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/trunk/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_freebsd.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_linux.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_netbsd.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_win32.py
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  lldb/trunk/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py
  lldb/trunk/test/CMakeLists.txt

Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -6,8 +6,6 @@
 )
 
   add_custom_target(${name}
-# Clear the test directory first.
-COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/lldb-test-build.noindex
 COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}
 COMMENT "${comment}"
 DEPENDS ${LLDB_TEST_DEPS}
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
@@ -41,7 +41,6 @@
 self.do_test(True)
 
 def do_test(self, skip_exec):
-self.makeBuildDir()
 exe = self.getBuildArtifact("a.out")
 if self.getArchitecture() == 'x86_64':
 source = self.getSourcePath("main.cpp")
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
@@ -30,7 +30,6 @@
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
 def test_command_script_immediate_output_console(self):
 """Test that LLDB correctly allows scripted commands to set immediate output to the console."""
-self.makeBuildDir()
 self.launch(timeout=10)
 
 script = os.path.join(self.getSourceDir(), 'custom_command.py')
@@ -53,7 +52,6 @@
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
 def test_command_script_immediate_output_file(self):
 """Test that LLDB correctly allows scripted commands to set immediate output to a file."""
-self.makeBuildDir()
 self.launch(timeout=10)
 
 test_files = {self.getBuildArtifact('read.txt'): 'r',
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -64,16 +64,15 @@
 self.line)
 
 def create_src_symlink(self):
-self.makeBuildDir()
 pwd_symlink = self.getBuildArtifact('pwd_symlink')
 if os.path.exists(pwd_symlink):
 os.unlink(pwd_symlink)
 os.symlink(self.getBuildDir(), pwd_symlink)
 self.addTearDownHook(lambda: os.remove(pwd_symlink))
 return pwd_symlink
 
 def doBuild(self, pwd_symlink):
-self.build(None, None, {'PWD': pwd_symlink}, True)
+self.build(None, None, {'PWD': pwd_symlink})
 
 exe = self.getBuildArtifact(_EXE_NAME)
 self.runCmd('f

[Lldb-commits] [PATCH] D44472: Add and fix some tests for PPC64

2018-03-16 Thread Alexandre Yukio Yamashita via Phabricator via lldb-commits
alexandreyy updated this revision to Diff 138699.
alexandreyy added a comment.

The test would pass if one of the disassembled code had more instructions.
That should be considered.
I added the assertion for that.
Thanks @labath .


https://reviews.llvm.org/D44472

Files:
  packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
  
packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py
  packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
  
packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
  
packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
  
packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py

Index: packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -31,6 +31,9 @@
 elif re.match("mips", arch):
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", "mips")
 raw_bytes = bytearray([0x03, 0xa0, 0xf0, 0x21])
+elif re.match("powerpc64le", arch):
+target = self.dbg.CreateTargetWithFileAndTargetTriple("", "powerpc64le")
+raw_bytes = bytearray([0x00, 0x00, 0x80, 0x38])
 else:
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64")
 raw_bytes = bytearray([0x48, 0x89, 0xe5])
@@ -48,6 +51,9 @@
 self.assertTrue(inst.GetMnemonic(target) == "move")
 self.assertTrue(inst.GetOperands(target) ==
 '$' + "fp, " + '$' + "sp")
+elif re.match("powerpc64le", arch):
+self.assertTrue(inst.GetMnemonic(target) == "li")
+self.assertTrue(inst.GetOperands(target) == "4, 0")
 else:
 self.assertTrue(inst.GetMnemonic(target) == "movq")
 self.assertTrue(inst.GetOperands(target) ==
Index: packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
===
--- packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
+++ packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -81,7 +81,7 @@
 # Most of the MIPS boards provide only one H/W watchpoints, and S/W
 # watchpoints are not supported yet
 arch = self.getArchitecture()
-if re.match("^mips", arch):
+if re.match("^mips", arch) or re.match("powerpc64le", arch):
 self.runCmd("watchpoint delete 1")
 
 # resolve_location=True, read=False, write=True
Index: packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
===
--- packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
+++ packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py
@@ -39,8 +39,8 @@
 # Most of the MIPS boards provide only one H/W watchpoints, and S/W
 # watchpoints are not supported yet
 @expectedFailureAll(triple=re.compile('^mips'))
-# SystemZ also currently supports only one H/W watchpoint
-@expectedFailureAll(archs=['s390x'])
+# SystemZ and PowerPC also currently supports only one H/W watchpoint
+@expectedFailureAll(archs=['powerpc64le', 's390x'])
 @skipIfDarwin
 def test_hello_watchlocation(self):
 """Test watching a location with '-s size' option."""
Index: packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
===
--- packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
+++ packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
@@ -1,6 +1,18 @@
 void func() {
 
-#ifndef __mips__
+#ifdef __powerpc64__
+  __asm__ (
+"mflr 0;"
+"std 0,16(1);"
+"addi 1,1,-24;"
+"mr 31,1;"
+".cfi_def_cfa_offset 24;"
+"addi 0,0,0;"
+"addi 1,1,24;"
+"ld 0,16(1);"
+".cfi_def_cfa_offset 0;"
+  );
+#elif !defined __mips__
 	__asm__ (
 		"pushq $0x10;"
 		".cfi_def_cfa_offset 16;"
Index: packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
===
--- packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
+++ packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
@@ -50,8 +50,11 @@
  

[Lldb-commits] [PATCH] D43592: [DWARFASTParserClang] Always complete types read from a module/PCH AST context.

2018-03-16 Thread Frederic Riss via Phabricator via lldb-commits
friss updated this revision to Diff 138733.
friss added a comment.

I experimented quite a bit with different approches to fix this bug
without always completing the types right after importing them from
the external AST.

This is the most principled approach I came up with. I applied the
new helper in only one place (the only one we have seen failing),
but we could potentially find more uses for it in the future.


https://reviews.llvm.org/D43592

Files:
  packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
  packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
  packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -179,12 +179,6 @@
   lldb_private::CompilerType type =
   GetClangASTImporter().CopyType(m_ast, dwo_type);
 
-  // printf ("copied_qual_type: ast = %p, clang_type = %p, name =
-  // '%s'\n", m_ast, copied_qual_type.getAsOpaquePtr(),
-  // external_type->GetName().GetCString());
-  if (!type)
-return TypeSP();
-
   SymbolFileDWARF *dwarf = die.GetDWARF();
   TypeSP type_sp(new Type(
   die.GetID(), dwarf, dwo_type_sp->GetName(), dwo_type_sp->GetByteSize(),
@@ -205,6 +199,33 @@
   return type_sp;
 }
 
+static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
+clang::DeclContext *decl_ctx,
+DWARFDIE die,
+const char *type_name_cstr) {
+  auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
+  if (!tag_decl_ctx)
+return;
+
+  // If this type was not imported from an external AST, there's
+  // nothing to do.
+  CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx);
+  if (!type || !ast_importer.CanImport(type))
+return;
+
+  auto qual_type = ClangUtil::GetQualType(type);
+  if (!ast_importer.RequireCompleteType(qual_type)) {
+die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
+"Unable to complete the Decl context for DIE '%s' at offset "
+"0x%8.8x.\nPlease file a bug report.",
+type_name_cstr ?: "", die.GetOffset());
+// We need to make the type look complete otherwise, we
+// might crash in Clang when adding children.
+if (ClangASTContext::StartTagDeclarationDefinition(type))
+  ClangASTContext::CompleteTagDeclarationDefinition(type);
+  }
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
const DWARFDIE &die, Log *log,
bool *type_is_new_ptr) {
@@ -795,6 +816,16 @@
 if (!clang_type) {
   clang::DeclContext *decl_ctx =
   GetClangDeclContextContainingDIE(die, nullptr);
+
+  // If your decl context is a record that was imported from
+  // another AST context (in the gmodules case), we need to
+  // make sure the type backing the Decl is complete before
+  // adding children to it. This is not an issue in the
+  // non-gmodules case because the debug info will always contain
+  // a full definition of parent types in that case.
+  CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
+  type_name_cstr);
+
   if (accessibility == eAccessNone && decl_ctx) {
 // Check the decl context that contains this class/struct/union.
 // If it is a class we must give it an accessibility.
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
@@ -10,3 +10,8 @@
 };
 
 typedef GenericContainer IntContainer;
+
+struct Foo {
+  class Bar;
+  Bar *bar;
+};
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
@@ -1,5 +1,8 @@
+class Foo::Bar { int i = 123; };
+
 int main(int argc, const char * argv[])
 {
 IntContainer test(42);
+Foo::Bar bar;
 return 0; // break here
 }
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -69,3 +69,26 @@
 42,
 memberValue.GetValueAsSigned(),
 "Member value incorrect")

[Lldb-commits] [PATCH] D43592: [DWARFASTParserClang] Always complete types read from a module/PCH AST context.

2018-03-16 Thread Frederic Riss via Phabricator via lldb-commits
friss updated this revision to Diff 138734.
friss added a comment.

Adding back a hunk I didn't mean to delete.


https://reviews.llvm.org/D43592

Files:
  packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
  packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
  packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -205,6 +205,33 @@
   return type_sp;
 }
 
+static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
+clang::DeclContext *decl_ctx,
+DWARFDIE die,
+const char *type_name_cstr) {
+  auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
+  if (!tag_decl_ctx)
+return;
+
+  // If this type was not imported from an external AST, there's
+  // nothing to do.
+  CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx);
+  if (!type || !ast_importer.CanImport(type))
+return;
+
+  auto qual_type = ClangUtil::GetQualType(type);
+  if (!ast_importer.RequireCompleteType(qual_type)) {
+die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
+"Unable to complete the Decl context for DIE '%s' at offset "
+"0x%8.8x.\nPlease file a bug report.",
+type_name_cstr ?: "", die.GetOffset());
+// We need to make the type look complete otherwise, we
+// might crash in Clang when adding children.
+if (ClangASTContext::StartTagDeclarationDefinition(type))
+  ClangASTContext::CompleteTagDeclarationDefinition(type);
+  }
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
const DWARFDIE &die, Log *log,
bool *type_is_new_ptr) {
@@ -795,6 +822,16 @@
 if (!clang_type) {
   clang::DeclContext *decl_ctx =
   GetClangDeclContextContainingDIE(die, nullptr);
+
+  // If your decl context is a record that was imported from
+  // another AST context (in the gmodules case), we need to
+  // make sure the type backing the Decl is complete before
+  // adding children to it. This is not an issue in the
+  // non-gmodules case because the debug info will always contain
+  // a full definition of parent types in that case.
+  CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
+  type_name_cstr);
+
   if (accessibility == eAccessNone && decl_ctx) {
 // Check the decl context that contains this class/struct/union.
 // If it is a class we must give it an accessibility.
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
@@ -10,3 +10,8 @@
 };
 
 typedef GenericContainer IntContainer;
+
+struct Foo {
+  class Bar;
+  Bar *bar;
+};
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
@@ -1,5 +1,8 @@
+class Foo::Bar { int i = 123; };
+
 int main(int argc, const char * argv[])
 {
 IntContainer test(42);
+Foo::Bar bar;
 return 0; // break here
 }
Index: packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
+++ packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -69,3 +69,26 @@
 42,
 memberValue.GetValueAsSigned(),
 "Member value incorrect")
+
+testValue = frame.EvaluateExpression("bar")
+self.assertTrue(
+testValue.GetError().Success(),
+"Test expression value invalid: %s" %
+(testValue.GetError().GetCString()))
+self.assertTrue(
+testValue.GetTypeName() == "Foo::Bar",
+"Test expression type incorrect")
+
+memberValue = testValue.GetChildMemberWithName("i")
+self.assertTrue(
+memberValue.GetError().Success(),
+"Member value missing or invalid: %s" %
+(testValue.GetError().GetCString()))
+self.assertTrue(
+memberValue.GetTypeName() == "int",
+"Member type incorrect")
+self.assertEqual(
+123,
+memberValue.GetVal

[Lldb-commits] [lldb] r327729 - Remove -gmodules restriction from test

2018-03-16 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Fri Mar 16 11:21:48 2018
New Revision: 327729

URL: http://llvm.org/viewvc/llvm-project?rev=327729&view=rev
Log:
Remove -gmodules restriction from test

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py?rev=327729&r1=327728&r2=327729&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
 Fri Mar 16 11:21:48 2018
@@ -27,7 +27,6 @@ class ObjCModulesAutoImportTestCase(Test
 
 @skipUnlessDarwin
 @skipIf(macos_version=["<", "10.12"])
-@skipIf(debug_info=no_match(["gmodules"]))
 def test_expr(self):
 self.build()
 exe = self.getBuildArtifact("a.out")


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


[Lldb-commits] [PATCH] D43592: [DWARFASTParserClang] Always complete types read from a module/PCH AST context.

2018-03-16 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Much better. Make sure Jim is ok with this as I am ok with it if he is.


https://reviews.llvm.org/D43592



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


[Lldb-commits] [PATCH] D43592: [DWARFASTParserClang] Always complete types read from a module/PCH AST context.

2018-03-16 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

I can't see a narrower way to do this.  This sort of change makes me really 
wish we had "how many dies did you complete" metrics and some stress tests, so 
we can tell if we've just made some operation unreasonably more expensive and 
have to go back and really put our thinking caps on.  But I think this should 
be fine.


https://reviews.llvm.org/D43592



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


[Lldb-commits] [lldb] r327731 - Skip TestThreadSpecificBpPlusCondition on Darwin due to timeouts

2018-03-16 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Mar 16 12:33:39 2018
New Revision: 327731

URL: http://llvm.org/viewvc/llvm-project?rev=327731&view=rev
Log:
Skip TestThreadSpecificBpPlusCondition on Darwin due to timeouts

Bot failure: https://ci.swift.org/job/oss-lldb-incremental-osx/1104/

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py?rev=327731&r1=327730&r2=327731&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
 Fri Mar 16 12:33:39 2018
@@ -21,6 +21,7 @@ class ThreadSpecificBreakPlusConditionTe
 
 # test frequently times out or hangs
 @skipIf(oslist=['windows', 'freebsd'])
+@skipIfDarwin
 # hits break in another thread in testrun
 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522')
 @add_test_categories(['pyapi'])


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


[Lldb-commits] [lldb] r327750 - [DWARFASTParserClang] Complete external record types before using them as a decl context.

2018-03-16 Thread Frederic Riss via lldb-commits
Author: friss
Date: Fri Mar 16 15:12:22 2018
New Revision: 327750

URL: http://llvm.org/viewvc/llvm-project?rev=327750&view=rev
Log:
[DWARFASTParserClang] Complete external record types before using them as a 
decl context.

Summary:
When in a gmodules-like debugging scenario, you can have a parent decl context
that gets imported from an external AST. When this happens, we must be careful
to complete this type before adding children to it, otherwise it sometimes
results in a crash.

Reviewers: clayborg, jingham

Subscribers: aprantl, JDevlieghere, lldb-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py?rev=327750&r1=327749&r2=327750&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
 Fri Mar 16 15:12:22 2018
@@ -69,3 +69,26 @@ class TestWithGmodulesDebugInfo(TestBase
 42,
 memberValue.GetValueAsSigned(),
 "Member value incorrect")
+
+testValue = frame.EvaluateExpression("bar")
+self.assertTrue(
+testValue.GetError().Success(),
+"Test expression value invalid: %s" %
+(testValue.GetError().GetCString()))
+self.assertTrue(
+testValue.GetTypeName() == "Foo::Bar",
+"Test expression type incorrect")
+
+memberValue = testValue.GetChildMemberWithName("i")
+self.assertTrue(
+memberValue.GetError().Success(),
+"Member value missing or invalid: %s" %
+(testValue.GetError().GetCString()))
+self.assertTrue(
+memberValue.GetTypeName() == "int",
+"Member type incorrect")
+self.assertEqual(
+123,
+memberValue.GetValueAsSigned(),
+"Member value incorrect")
+

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp?rev=327750&r1=327749&r2=327750&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp Fri 
Mar 16 15:12:22 2018
@@ -1,5 +1,8 @@
+class Foo::Bar { int i = 123; };
+
 int main(int argc, const char * argv[])
 {
 IntContainer test(42);
+Foo::Bar bar;
 return 0; // break here
 }

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h?rev=327750&r1=327749&r2=327750&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h Fri Mar 
16 15:12:22 2018
@@ -10,3 +10,8 @@ class GenericContainer {
 };
 
 typedef GenericContainer IntContainer;
+
+struct Foo {
+  class Bar;
+  Bar *bar;
+};

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=327750&r1=327749&r2=327750&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Mar 
16 15:12:22 2018
@@ -205,6 +205,33 @@ TypeSP DWARFASTParserClang::ParseTypeFro
   return type_sp;
 }
 
+static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
+clang::DeclContext *decl_ctx,
+DWARFDIE die,
+const char *type_name_cstr) {
+  auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
+  if (!tag_decl_ctx)
+return;
+
+  // If this type was not imported from an external AST, there's
+  // nothing to do.
+  CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx);
+  if (!type || !ast_importer.CanImport(type))
+return;
+
+  auto qual_type = ClangUtil::GetQualType(type);
+  if

[Lldb-commits] [PATCH] D43592: [DWARFASTParserClang] Always complete types read from a module/PCH AST context.

2018-03-16 Thread Frederic Riss via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327750: [DWARFASTParserClang] Complete external record types 
before using them as a… (authored by friss, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43592

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
  lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -205,6 +205,33 @@
   return type_sp;
 }
 
+static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
+clang::DeclContext *decl_ctx,
+DWARFDIE die,
+const char *type_name_cstr) {
+  auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
+  if (!tag_decl_ctx)
+return;
+
+  // If this type was not imported from an external AST, there's
+  // nothing to do.
+  CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx);
+  if (!type || !ast_importer.CanImport(type))
+return;
+
+  auto qual_type = ClangUtil::GetQualType(type);
+  if (!ast_importer.RequireCompleteType(qual_type)) {
+die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
+"Unable to complete the Decl context for DIE '%s' at offset "
+"0x%8.8x.\nPlease file a bug report.",
+type_name_cstr ?: "", die.GetOffset());
+// We need to make the type look complete otherwise, we
+// might crash in Clang when adding children.
+if (ClangASTContext::StartTagDeclarationDefinition(type))
+  ClangASTContext::CompleteTagDeclarationDefinition(type);
+  }
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
const DWARFDIE &die, Log *log,
bool *type_is_new_ptr) {
@@ -795,6 +822,16 @@
 if (!clang_type) {
   clang::DeclContext *decl_ctx =
   GetClangDeclContextContainingDIE(die, nullptr);
+
+  // If your decl context is a record that was imported from
+  // another AST context (in the gmodules case), we need to
+  // make sure the type backing the Decl is complete before
+  // adding children to it. This is not an issue in the
+  // non-gmodules case because the debug info will always contain
+  // a full definition of parent types in that case.
+  CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
+  type_name_cstr);
+
   if (accessibility == eAccessNone && decl_ctx) {
 // Check the decl context that contains this class/struct/union.
 // If it is a class we must give it an accessibility.
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h
@@ -10,3 +10,8 @@
 };
 
 typedef GenericContainer IntContainer;
+
+struct Foo {
+  class Bar;
+  Bar *bar;
+};
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp
@@ -1,5 +1,8 @@
+class Foo::Bar { int i = 123; };
+
 int main(int argc, const char * argv[])
 {
 IntContainer test(42);
+Foo::Bar bar;
 return 0; // break here
 }
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -69,3 +69,26 @@
 42,
 memberValue.GetValueAsSigned(),
 "Member value incorrect")
+
+testValue = frame.EvaluateExpression("bar")
+self.assertTrue(
+testValue.GetError().Success(),
+"Test expression value invalid: %s" %
+(testValue.GetError().GetCString()))
+self.assertTrue(
+testValue.GetTypeName() == "Foo::Bar",
+"Test expression type incorrect")
+

[Lldb-commits] [lldb] r327753 - Fix the Windows build after r327750

2018-03-16 Thread Frederic Riss via lldb-commits
Author: friss
Date: Fri Mar 16 15:19:58 2018
New Revision: 327753

URL: http://llvm.org/viewvc/llvm-project?rev=327753&view=rev
Log:
Fix the Windows build after r327750

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=327753&r1=327752&r2=327753&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Mar 
16 15:19:58 2018
@@ -224,7 +224,7 @@ static void CompleteExternalTagDeclType(
 die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
 "Unable to complete the Decl context for DIE '%s' at offset "
 "0x%8.8x.\nPlease file a bug report.",
-type_name_cstr ?: "", die.GetOffset());
+type_name_cstr ? type_name_cstr : "", die.GetOffset());
 // We need to make the type look complete otherwise, we
 // might crash in Clang when adding children.
 if (ClangASTContext::StartTagDeclarationDefinition(type))


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