[Lldb-commits] [lldb] r317411 - Improve the posix core file triple detection

2017-11-04 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Sat Nov  4 11:25:51 2017
New Revision: 317411

URL: http://llvm.org/viewvc/llvm-project?rev=317411&view=rev
Log:
Improve the posix core file triple detection

Summary:
Posix core files sometime don't contain enough information to correctly
detect the OS. If that is the case we should use the OS from the target
instead as it will contain usable information in more cases and if the
target and the core contain different OS-es then we are already in a
pretty bad state so moving from an unknown OS to a known (but possibly
incorrect) OS will do no harm.

We already had similar code in place for MIPS. This change tries to make
it more generic by using ArchSpec::MergeFrom and extends it to all
architectures but some MIPS specific issue prevent us from getting rid
of special casing MIPS.

Reviewers: clayborg, nitesh.jain

Subscribers: aemerson, sdardis, arichardson, kristof.beyls, lldb-commits

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

Modified:
lldb/trunk/source/Core/ArchSpec.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=317411&r1=317410&r2=317411&view=diff
==
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Sat Nov  4 11:25:51 2017
@@ -921,6 +921,9 @@ void ArchSpec::MergeFrom(const ArchSpec
 m_core = other.GetCore();
 CoreUpdated(true);
   }
+  if (GetFlags() == 0) {
+SetFlags(other.GetFlags());
+  }
 }
 
 bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,

Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=317411&r1=317410&r2=317411&view=diff
==
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Sat Nov  4 
11:25:51 2017
@@ -724,15 +724,18 @@ uint32_t ProcessElfCore::GetNumThreadCon
 }
 
 ArchSpec ProcessElfCore::GetArchitecture() {
-  ObjectFileELF *core_file =
-  (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
-  core_file->GetArchitecture(arch);
+  m_core_module_sp->GetObjectFile()->GetArchitecture(arch);
 
   ArchSpec target_arch = GetTarget().GetArchitecture();
-  
-  if (target_arch.IsMIPS())
+  arch.MergeFrom(target_arch);
+
+  // On MIPS there is no way to differentiate betwenn 32bit and 64bit core 
files
+  // and this information can't be merged in from the target arch so we fail
+  // back to unconditionally returning the target arch in this config.
+  if (target_arch.IsMIPS()) {
 return target_arch;
+  }
 
   return arch;
 }


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


[Lldb-commits] [lldb] r317563 - Support scoped enums in the DWARF AST parser

2017-11-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Nov  7 02:39:22 2017
New Revision: 317563

URL: http://llvm.org/viewvc/llvm-project?rev=317563&view=rev
Log:
Support scoped enums in the DWARF AST parser

Subscribers: JDevlieghere

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

Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=317563&r1=317562&r2=317563&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Nov  7 02:39:22 2017
@@ -397,7 +397,8 @@ public:
   CompilerType CreateEnumerationType(const char *name,
  clang::DeclContext *decl_ctx,
  const Declaration &decl,
- const CompilerType &integer_qual_type);
+ const CompilerType &integer_qual_type,
+ bool is_scoped);
 
   //--
   // Integer type functions

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py?rev=317563&r1=317562&r2=317563&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py
 Tue Nov  7 02:39:22 2017
@@ -99,8 +99,8 @@ class CPP11EnumTypesTestCase(TestBase):
 # Look up information about the 'DayType' enum type.
 # Check for correct display.
 self.expect("image lookup -t DayType", DATA_TYPES_DISPLAYED_CORRECTLY,
-substrs=['enum DayType {',
- 'Monday',
+patterns=['enum( struct| class) DayType {'],
+substrs=['Monday',
  'Tuesday',
  'Wednesday',
  'Thursday',

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=317563&r1=317562&r2=317563&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Nov  
7 02:39:22 2017
@@ -927,6 +927,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
 // Set a bit that lets us know that we are currently parsing this
 dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
 
+bool is_scoped = false;
 DWARFFormValue encoding_form;
 
 const size_t num_attributes = die.GetAttributes(attributes);
@@ -963,6 +964,9 @@ TypeSP DWARFASTParserClang::ParseTypeFro
   case DW_AT_declaration:
 is_forward_declaration = form_value.Boolean();
 break;
+  case DW_AT_enum_class:
+is_scoped = form_value.Boolean();
+break;
   case DW_AT_allocated:
   case DW_AT_associated:
   case DW_AT_bit_stride:
@@ -1052,7 +1056,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
 
 clang_type = m_ast.CreateEnumerationType(
 type_name_cstr, GetClangDeclContextContainingDIE(die, nullptr),
-decl, enumerator_clang_type);
+decl, enumerator_clang_type, is_scoped);
   } else {
 enumerator_clang_type =
 
m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp?rev=317563&r1=317562&r2=317563&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Tue Nov  7 
02:39:22 2017
@@ -109,7 +109,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTyp
 m_ast.GetBuiltinTypeForEncodingAndBitSize(encoding, bytes * 8);
 
 CompilerType ast_enum = m_ast.CreateEnumerationType(

[Lldb-commits] [lldb] r317574 - Fix an issue in r317563 causing a clang assert

2017-11-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Nov  7 05:43:55 2017
New Revision: 317574

URL: http://llvm.org/viewvc/llvm-project?rev=317574&view=rev
Log:
Fix an issue in r317563 causing a clang assert

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=317574&r1=317573&r2=317574&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Nov  7 05:43:55 2017
@@ -2181,9 +2181,9 @@ ClangASTContext::CreateEnumerationType(c
   EnumDecl *enum_decl = EnumDecl::Create(
   *ast, decl_ctx, SourceLocation(), SourceLocation(),
   name && name[0] ? &ast->Idents.get(name) : nullptr, nullptr,
-  is_scoped,
-  true,   // IsScopedUsingClassTag
-  false); // IsFixed
+  is_scoped, // IsScoped
+  is_scoped, // IsScopedUsingClassTag
+  false);// IsFixed
 
   if (enum_decl) {
 // TODO: check if we should be setting the promotion type too?


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


[Lldb-commits] [lldb] r298189 - Remove some dead code from DumpValueObjectOptions::PointerDepth

2017-03-18 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Sat Mar 18 12:33:00 2017
New Revision: 298189

URL: http://llvm.org/viewvc/llvm-project?rev=298189&view=rev
Log:
Remove some dead code from DumpValueObjectOptions::PointerDepth

Modified:
lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h
lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h?rev=298189&r1=298188&r2=298189&view=diff
==
--- lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h Sat Mar 18 
12:33:00 2017
@@ -27,7 +27,7 @@ namespace lldb_private {
 class DumpValueObjectOptions {
 public:
   struct PointerDepth {
-enum class Mode { Always, Formatters, Default, Never } m_mode;
+enum class Mode { Always, Default, Never } m_mode;
 uint32_t m_count;
 
 PointerDepth operator--() const {
@@ -37,9 +37,6 @@ public:
 }
 
 bool CanAllowExpansion() const;
-
-bool CanAllowExpansion(bool is_root, TypeSummaryImpl *entry,
-   ValueObject *valobj, const std::string &summary);
   };
 
   struct PointerAsArraySettings {

Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=298189&r1=298188&r2=298189&view=diff
==
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Sat Mar 18 12:33:00 
2017
@@ -468,32 +468,11 @@ bool ValueObjectPrinter::PrintObjectDesc
   return true;
 }
 
-bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion(
-bool is_root, TypeSummaryImpl *entry, ValueObject *valobj,
-const std::string &summary) {
-  switch (m_mode) {
-  case Mode::Always:
-return (m_count > 0);
-  case Mode::Never:
-return false;
-  case Mode::Default:
-if (is_root)
-  m_count = std::min(m_count, 1);
-return m_count > 0;
-  case Mode::Formatters:
-if (!entry || entry->DoesPrintChildren(valobj) || summary.empty())
-  return m_count > 0;
-return false;
-  }
-  return false;
-}
-
 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
   switch (m_mode) {
   case Mode::Always:
   case Mode::Default:
-  case Mode::Formatters:
-return (m_count > 0);
+return m_count > 0;
   case Mode::Never:
 return false;
   }
@@ -546,8 +525,7 @@ bool ValueObjectPrinter::ShouldPrintChil
 return true;
   }
 
-  return curr_ptr_depth.CanAllowExpansion(false, entry, m_valobj,
-  m_summary);
+  return curr_ptr_depth.CanAllowExpansion();
 }
 
 return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());


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


Re: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers

2017-03-30 Thread Tamas Berghammer via lldb-commits
It is possible to vend one of the actual backing object as a synthetic
child using the SB API. What is not possible from the SB API at the moment
(we might want to fix it) is to vend one of the actual backing object with
a different name then the underlying object itself. You can still say that
object X has a child named "foobar" (so X.foobar will work) but the name of
the actual child will be something like "_M_baz" when displayed.

On Wed, Mar 29, 2017 at 10:16 AM Jim Ingham  wrote:

>
> > On Mar 29, 2017, at 2:06 AM, Tamas Berghammer via Phabricator <
> revi...@reviews.llvm.org> wrote:
> >
> > tberghammer added a comment.
> >
> > SBValue::SetName is not part of the SB API (what is the right decision
> IMO as an SBValue should be mostly immutable) so this issue doesn't effect
> it. I looked through the code in examples/synthetic/gnu_libstdcpp.py and it
> is always using one of the SBValue::Create* method to produce new SBValue
> what will create a new value object one way or the other. Considering that
> nobody complained about the missing SetName method at the SB API level I
> don't see a big need for exposing the Clone method there. At the same line
> if SetName/Clone isn't part of the SB API then I think we shouldn't
> document it at the webpage.
>
> Seems like vending one of the actual backing objects as a synthetic object
> is a reasonable thing to do (it's what you are doing internally).  But if
> we don't allow a way to do that currently, then there's no reason to add
> one.
>
> Jim
>
>
> >
> > (I will upload a fix for the spelling errors later)
> >
> >
> > https://reviews.llvm.org/D31371
> >
> >
> >
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D31371: Stop calling ValueObject::SetName from synthetic child providers

2017-03-30 Thread Tamas Berghammer via lldb-commits
Created bug for exposing ValueObject::Clone as SB API:
http://bugs.llvm.org/show_bug.cgi?id=32477

On Thu, Mar 30, 2017 at 1:04 PM Jim Ingham via Phabricator <
revi...@reviews.llvm.org> wrote:

> jingham accepted this revision.
> jingham added a comment.
> This revision is now accepted and ready to land.
>
> Good.
>
>
> https://reviews.llvm.org/D31371
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r299249 - Do not dereference std::unique_ptr by default

2017-03-31 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Mar 31 15:07:20 2017
New Revision: 299249

URL: http://llvm.org/viewvc/llvm-project?rev=299249&view=rev
Log:
Do not dereference std::unique_ptr by default

Summary:
Displaying the object pointed by the unique_ptr can cause an infinite
recursion when we have a pointer loop so this change stops that
behavior. Additionally it makes the unique_ptr act more like a class
containing a pointer (what is the underlying truth) instead of some
"magic" class.

Reviewers: labath, jingham

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py?rev=299249&r1=299248&r2=299249&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 Fri Mar 31 15:07:20 2017
@@ -34,13 +34,13 @@ class StdUniquePtrDataFormatterTestCase(
 self.assertTrue(frame.IsValid())
 
 self.expect("frame variable nup", substrs=['nup = nullptr'])
-self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123'])
-self.expect("frame variable sup", substrs=['sup = 0x', 'object = 
"foobar"'])
+self.expect("frame variable iup", substrs=['iup = 0x'])
+self.expect("frame variable sup", substrs=['sup = 0x'])
 
 self.expect("frame variable ndp", substrs=['ndp = nullptr'])
-self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 
'deleter = ', 'a = 1', 'b = 2'])
-self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = 
"baz"', 'deleter = ', 'a = 3', 'b = 4'])
-
+self.expect("frame variable idp", substrs=['idp = 0x', 'deleter = ', 
'a = 1', 'b = 2'])
+self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 
'a = 3', 'b = 4'])
+
 self.assertEqual(123, 
frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
 
self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
 
@@ -59,3 +59,32 @@ class StdUniquePtrDataFormatterTestCase(
 self.assertTrue(sdp_deleter.IsValid())
 self.assertEqual(3, 
sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned())
 self.assertEqual(4, 
sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned())
+
+@skipIfFreeBSD
+@skipIfWindows  # libstdcpp not ported to Windows
+@skipIfDarwin  # doesn't compile on Darwin
+def test_recursive_unique_ptr(self):
+# Tests that LLDB can handle when we have a loop in the unique_ptr
+# reference chain and that it correctly handles the different options
+# for the frame variable command in this case.
+self.build()
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_source_regexp(
+self, "Set break point at this line.")
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', 'stop reason = breakpoint'])
+
+self.expect("frame variable f1->fp",
+substrs=['fp = 0x'])
+self.expect("frame variable --ptr-depth=1 f1->fp",
+substrs=['data = 2', 'fp = 0x'])
+self.expect("frame variable --ptr-depth=2 f1->fp",
+substrs=['data = 2', 'fp = 0x', 'data = 1'])
+
+frame = self.frame()
+self.assertTrue(frame.IsValid())
+self.assertEqual(2, 
frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned())
+self.assertEqual(1, 
frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned())
+

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp?rev=299249&r1=299248&r2=299249&view=diff
==
--- 
lldb/trunk/packages

[Lldb-commits] [lldb] r299251 - Add support for sythetic operator dereference

2017-03-31 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Mar 31 15:23:22 2017
New Revision: 299251

URL: http://llvm.org/viewvc/llvm-project?rev=299251&view=rev
Log:
Add support for sythetic operator dereference

Summary:
After this change a sythetic child provider can generate a special child
named "$$dereference$$" what if present is used when "operator*" or
"operator->" used on a ValueObject. The goal of the change is to make
expressions like "up->foo" work inside the "frame variable" command.

Reviewers: labath, jingham

Subscribers: lldb-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/www/varformats.html

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py?rev=299251&r1=299250&r2=299251&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 Fri Mar 31 15:23:22 2017
@@ -42,13 +42,17 @@ class StdUniquePtrDataFormatterTestCase(
 self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 
'a = 3', 'b = 4'])
 
 self.assertEqual(123, 
frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
+self.assertEqual(123, 
frame.GetValueForVariablePath("*iup").GetValueAsUnsigned())
 
self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
 
 self.assertEqual('"foobar"', 
frame.GetValueForVariablePath("sup.object").GetSummary())
+self.assertEqual('"foobar"', 
frame.GetValueForVariablePath("*sup").GetSummary())
 
self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid())
 
 self.assertEqual(456, 
frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned())
+self.assertEqual(456, 
frame.GetValueForVariablePath("*idp").GetValueAsUnsigned())
 self.assertEqual('"baz"', 
frame.GetValueForVariablePath("sdp.object").GetSummary())
+self.assertEqual('"baz"', 
frame.GetValueForVariablePath("*sdp").GetSummary())
 
 idp_deleter = frame.GetValueForVariablePath("idp.deleter")
 self.assertTrue(idp_deleter.IsValid())
@@ -86,5 +90,7 @@ class StdUniquePtrDataFormatterTestCase(
 frame = self.frame()
 self.assertTrue(frame.IsValid())
 self.assertEqual(2, 
frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned())
+self.assertEqual(2, 
frame.GetValueForVariablePath("f1->fp->data").GetValueAsUnsigned())
 self.assertEqual(1, 
frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned())
+self.assertEqual(1, 
frame.GetValueForVariablePath("f1->fp->fp->data").GetValueAsUnsigned())
 

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=299251&r1=299250&r2=299251&view=diff
==
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Mar 31 15:23:22 2017
@@ -2889,6 +2889,11 @@ ValueObjectSP ValueObject::Dereference(E
   child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
   language_flags);
 }
+  } else if (HasSyntheticValue()) {
+m_deref_valobj =
+GetSyntheticValue()
+->GetChildMemberWithName(ConstString("$$dereference$$"), true)
+.get();
   }
 
   if (m_deref_valobj) {

Modified: 
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=299251&r1=299250&r2=299251&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
(original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Fri 
Mar 31 15:23:22 2017
@@ -114,7 +114,8 @@ size_t LibStdcppUniquePtrSyntheticFrontE
 return 0;
   if (name == ConstString("del") || name == ConstString("deleter"))
 return 1;
-  if (name == ConstString("obj") || name == ConstString("obj

[Lldb-commits] [lldb] r299259 - Stop calling ValueObject::SetName from synthetic child providers

2017-03-31 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Mar 31 15:48:00 2017
New Revision: 299259

URL: http://llvm.org/viewvc/llvm-project?rev=299259&view=rev
Log:
Stop calling ValueObject::SetName from synthetic child providers

Summary:
Calling ValueObject::SetName from a sythetic child provider would change
the underying value object used for the non-synthetic child as well what
is clearly unintentional.

Reviewers: jingham, labath

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/DataFormatters/VectorType.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=299259&r1=299258&r2=299259&view=diff
==
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Mar 31 15:48:00 2017
@@ -553,6 +553,9 @@ public:
 
   lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
 
+  // Change the name of the current ValueObject. Should *not* be used from a
+  // synthetic child provider as it would change the name of the non synthetic
+  // child as well.
   void SetName(const ConstString &name);
 
   virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
@@ -601,6 +604,12 @@ public:
 
   virtual lldb::ValueObjectSP Dereference(Error &error);
 
+  // Creates a copy of the ValueObject with a new name and setting the current
+  // ValueObject as its parent. It should be used when we want to change the
+  // name of a ValueObject without modifying the actual ValueObject itself
+  // (e.g. sythetic child provider).
+  virtual lldb::ValueObjectSP Clone(const ConstString &new_name);
+
   virtual lldb::ValueObjectSP AddressOf(Error &error);
 
   virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=299259&r1=299258&r2=299259&view=diff
==
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Mar 31 15:48:00 2017
@@ -2962,6 +2962,10 @@ ValueObjectSP ValueObject::Cast(const Co
   return ValueObjectCast::Create(*this, GetName(), compiler_type);
 }
 
+lldb::ValueObjectSP ValueObject::Clone(const ConstString &new_name) {
+  return ValueObjectCast::Create(*this, new_name, GetCompilerType());
+}
+
 ValueObjectSP ValueObject::CastPointerType(const char *name,
CompilerType &compiler_type) {
   ValueObjectSP valobj_sp;

Modified: lldb/trunk/source/DataFormatters/VectorType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/VectorType.cpp?rev=299259&r1=299258&r2=299259&view=diff
==
--- lldb/trunk/source/DataFormatters/VectorType.cpp (original)
+++ lldb/trunk/source/DataFormatters/VectorType.cpp Fri Mar 31 15:48:00 2017
@@ -204,14 +204,12 @@ public:
 if (idx >= CalculateNumChildren())
   return lldb::ValueObjectSP();
 auto offset = idx * m_child_type.GetByteSize(nullptr);
-ValueObjectSP child_sp(
-m_backend.GetSyntheticChildAtOffset(offset, m_child_type, true));
-if (!child_sp)
-  return child_sp;
-
 StreamString idx_name;
 idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-child_sp->SetName(ConstString(idx_name.GetString()));
+ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset(
+offset, m_child_type, true, ConstString(idx_name.GetString(;
+if (!child_sp)
+  return child_sp;
 
 child_sp->SetFormat(m_item_format);
 

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=299259&r1=299258&r2=299259&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Fri Mar 31 
15:48:00 2017
@@ -406,7 +406,7 @@ lldb_private::formatters::LibcxxStdMapSy
 case 1: {
   auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
   if (child0_sp && child0_sp->GetName() == g___cc)
-potential_child_sp = child0_sp;
+potential_child_sp = child0_sp->Clone(ConstString(name.GetString()));
   break;
 }
 case 2: {
@@ -414,11 +414,10 @@ lldb_private::formatters::LibcxxS

[Lldb-commits] [lldb] r299677 - XFAIL TestDataFormatterLibcxxVBool on Linux & Android

2017-04-06 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Apr  6 13:15:43 2017
New Revision: 299677

URL: http://llvm.org/viewvc/llvm-project?rev=299677&view=rev
Log:
XFAIL TestDataFormatterLibcxxVBool on Linux & Android

The skipping logic for the test have been fixed recently but the test is
very flakey on the buildbot.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py?rev=299677&r1=299676&r2=299677&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
 Thu Apr  6 13:15:43 2017
@@ -24,6 +24,7 @@ class LibcxxVBoolDataFormatterTestCase(T
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
 @add_test_categories(["libc++"])
+@expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr32553")
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()


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


[Lldb-commits] [lldb] r309265 - XFAIL/XFlakey some tests what become very flakey on the Linux buildbot

2017-07-27 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Jul 27 05:01:32 2017
New Revision: 309265

URL: http://llvm.org/viewvc/llvm-project?rev=309265&view=rev
Log:
XFAIL/XFlakey some tests what become very flakey on the Linux buildbot

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py?rev=309265&r1=309264&r2=309265&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py
 Thu Jul 27 05:01:32 2017
@@ -16,6 +16,7 @@ class ConcurrentNWatchNBreak(ConcurrentE
 @skipIfRemoteDueToDeadlock
 # Atomic sequences are not supported yet for MIPS in LLDB.
 @skipIf(triple='^mips')
+@expectedFailureAll(oslist=["linux"]) # Very flakey
 def test(self):
 """Test with 5 watchpoint and breakpoint threads."""
 self.build(dictionary=self.getBuildFlags())

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py?rev=309265&r1=309264&r2=309265&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py
 Thu Jul 27 05:01:32 2017
@@ -16,6 +16,7 @@ class ConcurrentTwoWatchpointsOneBreakpo
 @skipIfRemoteDueToDeadlock
 # Atomic sequences are not supported yet for MIPS in LLDB.
 @skipIf(triple='^mips')
+@expectedFlakeyLinux
 def test(self):
 """Test two threads that trigger a watchpoint and one breakpoint 
thread. """
 self.build(dictionary=self.getBuildFlags())


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


[Lldb-commits] [lldb] r309554 - Add support for base address entries in the .debug_ranges section

2017-07-31 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Mon Jul 31 03:26:19 2017
New Revision: 309554

URL: http://llvm.org/viewvc/llvm-project?rev=309554&view=rev
Log:
Add support for base address entries in the .debug_ranges section

Summary:
Clang recently started to emit base address entries into the
.debug_ranges section to reduce the number of relocations needed. Lets
make sure LLDB can read them.

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

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp?rev=309554&r1=309553&r2=309554&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Mon Jul 31 
03:26:19 2017
@@ -15,6 +15,18 @@
 using namespace lldb_private;
 using namespace std;
 
+static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) {
+  switch(addr_size) {
+case 2:
+  return 0x;
+case 4:
+  return 0x;
+case 8:
+  return 0x;
+  }
+  llvm_unreachable("GetBaseAddressMarker unsupported address size.");
+}
+
 DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {}
 
 DWARFDebugRanges::~DWARFDebugRanges() {}
@@ -39,38 +51,27 @@ bool DWARFDebugRanges::Extract(SymbolFil
   const DWARFDataExtractor &debug_ranges_data =
   dwarf2Data->get_debug_ranges_data();
   uint32_t addr_size = debug_ranges_data.GetAddressByteSize();
+  dw_addr_t base_addr = 0;
+  dw_addr_t base_addr_marker = GetBaseAddressMarker(addr_size);
 
   while (
   debug_ranges_data.ValidOffsetForDataOfSize(*offset_ptr, 2 * addr_size)) {
 dw_addr_t begin = debug_ranges_data.GetMaxU64(offset_ptr, addr_size);
 dw_addr_t end = debug_ranges_data.GetMaxU64(offset_ptr, addr_size);
+
 if (!begin && !end) {
   // End of range list
   break;
 }
-// Extend 4 byte addresses that consists of 32 bits of 1's to be 64 bits
-// of ones
-switch (addr_size) {
-case 2:
-  if (begin == 0xull)
-begin = LLDB_INVALID_ADDRESS;
-  break;
-
-case 4:
-  if (begin == 0xull)
-begin = LLDB_INVALID_ADDRESS;
-  break;
-
-case 8:
-  break;
 
-default:
-  llvm_unreachable("DWARFRangeList::Extract() unsupported address size.");
+if (begin == base_addr_marker) {
+  base_addr = end;
+  continue;
 }
 
 // Filter out empty ranges
 if (begin < end)
-  range_list.Append(DWARFRangeList::Entry(begin, end - begin));
+  range_list.Append(DWARFRangeList::Entry(begin + base_addr, end - begin));
   }
 
   // Make sure we consumed at least something


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


[Lldb-commits] [lldb] r311000 - Remove the DWARFExpression -> Clang ExpressionParser dependency

2017-08-16 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Aug 16 04:45:10 2017
New Revision: 311000

URL: http://llvm.org/viewvc/llvm-project?rev=311000&view=rev
Log:
Remove the DWARFExpression -> Clang ExpressionParser dependency

It was completly unused and broke the part of the encapsulation that
common code shouldn't depend on specific plugins or language specific
features.

Modified:
lldb/trunk/include/lldb/Expression/DWARFExpression.h
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/JavaASTContext.cpp
lldb/trunk/source/Target/RegisterContext.cpp
lldb/trunk/source/Target/StackFrame.cpp

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=311000&r1=310999&r2=311000&view=diff
==
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Wed Aug 16 04:45:10 
2017
@@ -22,10 +22,6 @@ class DWARFCompileUnit;
 
 namespace lldb_private {
 
-class ClangExpressionDeclMap;
-class ClangExpressionVariable;
-class ClangExpressionVariableList;
-
 //--
 /// @class DWARFExpression DWARFExpression.h 
"lldb/Expression/DWARFExpression.h"
 /// @brief Encapsulates a DWARF location expression and interprets it.
@@ -262,8 +258,6 @@ public:
   /// member variables to populate many operands
   //--
   bool Evaluate(ExecutionContextScope *exe_scope,
-ClangExpressionVariableList *expr_locals,
-ClangExpressionDeclMap *decl_map,
 lldb::addr_t loclist_base_load_addr,
 const Value *initial_value_ptr, const Value 
*object_address_ptr,
 Value &result, Status *error_ptr) const;
@@ -272,9 +266,7 @@ public:
   /// Wrapper for the static evaluate function that uses member
   /// variables to populate many operands
   //--
-  bool Evaluate(ExecutionContext *exe_ctx,
-ClangExpressionVariableList *expr_locals,
-ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx,
+  bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
 lldb::addr_t loclist_base_load_addr,
 const Value *initial_value_ptr, const Value 
*object_address_ptr,
 Value &result, Status *error_ptr) const;
@@ -338,32 +330,14 @@ public:
   /// True on success; false otherwise.  If error_ptr is non-NULL,
   /// details of the failure are provided through it.
   //--
-  static bool
-  Evaluate(ExecutionContext *exe_ctx, ClangExpressionVariableList *expr_locals,
-   ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx,
-   lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
-   DWARFCompileUnit *dwarf_cu, const lldb::offset_t offset,
-   const lldb::offset_t length, const lldb::RegisterKind reg_set,
-   const Value *initial_value_ptr, const Value *object_address_ptr,
-   Value &result, Status *error_ptr);
-
-  //--
-  /// Loads a ClangExpressionVariableList into the object
-  ///
-  /// @param[in] locals
-  /// If non-NULL, the list of locals used by this expression.
-  /// See Evaluate().
-  //--
-  void SetExpressionLocalVariableList(ClangExpressionVariableList *locals);
-
-  //--
-  /// Loads a ClangExpressionDeclMap into the object
-  ///
-  /// @param[in] locals
-  /// If non-NULL, the list of external variables used by this
-  /// expression.  See Evaluate().
-  //--
-  void SetExpressionDeclMap(ClangExpressionDeclMap *decl_map);
+  static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
+   lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
+   DWARFCompileUnit *dwarf_cu, const lldb::offset_t offset,
+   const lldb::offset_t length,
+   const lldb::RegisterKind reg_set,
+   const Value *initial_value_ptr,
+   const Value *object_address_ptr, Value &result,
+   Status *erro

[Lldb-commits] [lldb] r311775 - Add support for the DWP debug info format

2017-08-25 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Aug 25 06:56:14 2017
New Revision: 311775

URL: http://llvm.org/viewvc/llvm-project?rev=311775&view=rev
Log:
Add support for the DWP debug info format

Summary:
The DWP (DWARF package) format is used to pack multiple dwo files
generated by split-dwarf into a single ELF file to make distributing
them easier. It is part of the DWARFv5 spec and can be generated by
dwp or llvm-dwp from a set of dwo files.

Caviats:
* Only the new version of the dwp format is supported (v2 in GNU
  numbering schema and v5 in the DWARF spec). The old version (v1) is
  already deprecated but binutils 2.24 still generates that one.
* Combining DWP files with module debugging is not yet supported.

Subscribers: emaste, mgorny, aprantl

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

Added:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=311775&r1=311774&r2=311775&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Aug 25 06:56:14 2017
@@ -628,6 +628,7 @@ enum SectionType {
   eSectionTypeDWARFDebugAbbrev,
   eSectionTypeDWARFDebugAddr,
   eSectionTypeDWARFDebugAranges,
+  eSectionTypeDWARFDebugCuIndex,
   eSectionTypeDWARFDebugFrame,
   eSectionTypeDWARFDebugInfo,
   eSectionTypeDWARFDebugLine,

Modified: lldb/trunk/source/Core/Section.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=311775&r1=311774&r2=311775&view=diff
==
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Fri Aug 25 06:56:14 2017
@@ -65,6 +65,8 @@ static const char *GetSectionTypeAsCStri
 return "dwarf-addr";
   case eSectionTypeDWARFDebugAranges:
 return "dwarf-aranges";
+  case eSectionTypeDWARFDebugCuIndex:
+return "dwarf-cu-index";
   case eSectionTypeDWARFDebugFrame:
 return "dwarf-frame";
   case eSectionTypeDWARFDebugInfo:

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=311775&r1=311774&r2=311775&view=diff
==
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Fri Aug 25 06:56:14 2017
@@ -1110,6 +1110,7 @@ bool IRExecutionUnit::CommitOneAllocatio
   case lldb::eSectionTypeDWARFDebugAbbrev:
   case lldb::eSectionTypeDWARFDebugAddr:
   case lldb::eSectionTypeDWARFDebugAranges:
+  case lldb::eSectionTypeDWARFDebugCuIndex:
   case lldb::eSectionTypeDWARFDebugFrame:
   case lldb::eSectionTypeDWARFDebugInfo:
   case lldb::eSectionTypeDWARFDebugLine:

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=311775&r1=311774&r2=311775&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Aug 25 
06:56:14 2017
@@ -1835,6 +1835,7 @@ void ObjectFileELF::CreateSections(Secti
   static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
   static ConstString g_sect_name_dwarf_debug_addr(".debug_addr");
   static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
+  static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index");
   static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
   static ConstString g_sect_name_dwarf_debug_info(".debug_info");
   static ConstString g_sect_name_dwarf_debug_line(".debug_line");
@@ -1904,6 +1905,8 @@ void ObjectFileELF::CreateSections(Secti
 sect_type = eSectionTypeDWARFDebugAddr;
   else if (name == g_sect_name_dwarf_debug_aranges)

[Lldb-commits] [lldb] r313525 - Fix Linux remote debugging after r313442

2017-09-18 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Mon Sep 18 03:24:48 2017
New Revision: 313525

URL: http://llvm.org/viewvc/llvm-project?rev=313525&view=rev
Log:
Fix Linux remote debugging after r313442

On Linux lldb-server sends an OK response to qfThreadInfo if no process
is started yet. I don't know why would LLDB issue a qfThreadInfo packet
before starting a process but creating a fake thread ID in case of an
OK or Error respoinse sounds bad anyway so lets not do it.

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=313525&r1=313524&r2=313525&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
Mon Sep 18 03:24:48 2017
@@ -2624,7 +2624,8 @@ size_t GDBRemoteCommunicationClient::Get
  * tid.
  * Assume pid=tid=1 in such cases.
 */
-if (thread_ids.size() == 0 && IsConnected()) {
+if ((response.IsUnsupportedResponse() || response.IsNormalResponse()) &&
+thread_ids.size() == 0 && IsConnected()) {
   thread_ids.push_back(1);
 }
   } else {


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


Re: [Lldb-commits] [lldb] r313442 - Fix compatibility with OpenOCD debug stub.

2017-09-18 Thread Tamas Berghammer via lldb-commits
Hi Vadim,

This change broke remote debugging on Linux and Android as for some reason
LLDB sends a qfThreadInfo on those platforms before starting a process (not
sure why, will investigate when I have a bit more time) and lldb-server
sends an OK response to it. After your change it will generate a valid
thread ID what will cause LLDB to get confused and fail to lunch a process.
I submitted a fix as r313525 what should work both for OpenOCD and for
Linux/Android but can you verify the OpenOCD part?

Thanks,
Tamas

On Sat, Sep 16, 2017 at 4:54 AM Vadim Chugunov via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: vadimcn
> Date: Fri Sep 15 20:53:13 2017
> New Revision: 313442
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313442&view=rev
> Log:
> Fix compatibility with OpenOCD debug stub.
>
> OpenOCD sends register classes as two separate  nodes, fixed
> parser to process both of them.
>
> OpenOCD returns "l" in response to "qfThreadInfo", so
> IsUnsupportedResponse() was false and we were ending up without any threads
> in the process. I think it's reasonable to assume that there's always at
> least one thread.
>
> Modified:
>
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=313442&r1=313441&r2=313442&view=diff
>
> ==
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> Fri Sep 15 20:53:13 2017
> @@ -2624,8 +2624,7 @@ size_t GDBRemoteCommunicationClient::Get
>   * tid.
>   * Assume pid=tid=1 in such cases.
>  */
> -if (response.IsUnsupportedResponse() && thread_ids.size() == 0 &&
> -IsConnected()) {
> +if (thread_ids.size() == 0 && IsConnected()) {
>thread_ids.push_back(1);
>  }
>} else {
>
> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=313442&r1=313441&r2=313442&view=diff
>
> ==
> --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri
> Sep 15 20:53:13 2017
> @@ -4168,7 +4168,6 @@ struct GdbServerTargetInfo {
>std::string osabi;
>stringVec includes;
>RegisterSetMap reg_set_map;
> -  XMLNode feature_node;
>  };
>
>  bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo
> &target_info,
> @@ -4374,8 +4373,8 @@ bool ProcessGDBRemote::GetGDBServerRegis
>
>  XMLNode target_node = xml_document.GetRootElement("target");
>  if (target_node) {
> -  XMLNode feature_node;
> -  target_node.ForEachChildElement([&target_info, &feature_node](
> +  std::vector feature_nodes;
> +  target_node.ForEachChildElement([&target_info, &feature_nodes](
>const XMLNode &node) -> bool {
>  llvm::StringRef name = node.GetName();
>  if (name == "architecture") {
> @@ -4387,7 +4386,7 @@ bool ProcessGDBRemote::GetGDBServerRegis
>if (!href.empty())
>  target_info.includes.push_back(href.str());
>  } else if (name == "feature") {
> -  feature_node = node;
> +  feature_nodes.push_back(node);
>  } else if (name == "groups") {
>node.ForEachChildElementWithName(
>"group", [&target_info](const XMLNode &node) -> bool {
> @@ -4423,7 +4422,7 @@ bool ProcessGDBRemote::GetGDBServerRegis
>// set the Target's architecture yet, so the ABI is also potentially
>// incorrect.
>ABISP abi_to_use_sp = ABI::FindPlugin(shared_from_this(),
> arch_to_use);
> -  if (feature_node) {
> +  for (auto &feature_node : feature_nodes) {
>  ParseRegisters(feature_node, target_info, this->m_register_info,
> abi_to_use_sp, cur_reg_num, reg_offset);
>}
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D37930: Use ThreadLauncher to launch TaskPool threads

2017-09-18 Thread Tamas Berghammer via lldb-commits
Are you building with cmake or with XCode? If you are using cmake then you
should be able to reproduce it with running "ninja check-lldb-unit". It
failed to link one of the unittest targets because UtilityTests don't have
an explicit dependency on lldbHost (where ThreadLauncher is defined). You
can fix it by the following patch: https://reviews.llvm.org/P8037

Tamas

On Mon, Sep 18, 2017 at 4:47 PM Francis Ricci via Phabricator <
revi...@reviews.llvm.org> wrote:

> fjricci reopened this revision.
> fjricci added a comment.
> This revision is now accepted and ready to land.
>
> Is ThreadLauncher unavailable in this code for some reason? The link
> failed on linux buildbots (building lldb on Darwin was fine locally):
> http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/13311/steps/run%20unit%20tests/logs/stdio
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D37930
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D38938: Logging: provide a way to safely disable logging in a forked process

2017-10-16 Thread Tamas Berghammer via lldb-commits
On linux when you call fork the new process will only have the thread what
called fork. Other threads will be ignored with leaving whatever dirty
state they had left in the new process. Regarding execve it doesn't do fork
so we would have to do fork & execve what have the same issue (actually we
are using execve as of now but it isn't different from exec in this regard).

Tamas

On Mon, Oct 16, 2017 at 1:57 PM Zachary Turner via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> On Sun, Oct 15, 2017 at 3:15 PM Pavel Labath  wrote:
>
>> On 15 October 2017 at 23:04, Zachary Turner  wrote:
>> > Doesn’t DisableAllLogChannels acquire a scoped lock? If so wouldn’t it
>> just
>> > release at the end of the function?
>>
>>
>> The thing is, it is unable to acquire the lock in the first place,
>> because the mutex is already "locked". So, the sequence of events is
>> process 1, thread 1: acquire lock
>> process 1, thread 2: fork(), process 2 is created
>> process 1 thread 1: release lock
>>
>
> Suppose process 1 thread 1 had been executing this code:
> ```
> lock();
> logSomething();  // thread 2 forks when thread 1 is here.
> unlock();
> ```
>
> Doesn't thread 2 in the child process resume running from the same point?
> If so, it seems that both the child and parent would both gracefully unlock
> the lock.
>
> I'm sure I'm wrong about this, but hopefully you can clarify what I'm
> missing.
>
> As a follow-up question, why can't we use execve instead of fork / exec?
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r283351 - Try to fix Android build.

2016-10-05 Thread Tamas Berghammer via lldb-commits
It is using "gcc version 4.9 20150123 (prerelease) (GCC)"

On Wed, Oct 5, 2016 at 11:12 AM Zachary Turner via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> I don't know for sure, but I'm guessing it's using GCC, and perhaps even
> an old one at that.
>
> On Wed, Oct 5, 2016 at 11:10 AM Enrico Granata  wrote:
>
> Alright, I'll bite and ask...
>
> What is so special about the Android bot? Every so often, I'll see it
> reject a piece of syntax that other compilers gleefully handle
>
> On Oct 5, 2016, at 10:58 AM, Zachary Turner via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
> Author: zturner
> Date: Wed Oct  5 12:58:46 2016
> New Revision: 283351
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283351&view=rev
> Log:
> Try to fix Android build.
>
> Seems it doesn't like the implicit conversion from
> StringRef[] to ArrayRef.
>
> Modified:
>lldb/trunk/source/Breakpoint/BreakpointID.cpp
>
> Modified: lldb/trunk/source/Breakpoint/BreakpointID.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointID.cpp?rev=283351&r1=283350&r2=283351&view=diff
>
> ==
> --- lldb/trunk/source/Breakpoint/BreakpointID.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointID.cpp Wed Oct  5 12:58:46 2016
> @@ -48,7 +48,7 @@ bool BreakpointID::IsValidIDExpression(l
> }
>
> llvm::ArrayRef BreakpointID::GetRangeSpecifiers() {
> -  return g_range_specifiers;
> +  return llvm::makeArrayRef(g_range_specifiers);
> }
>
> void BreakpointID::GetDescription(Stream *s, lldb::DescriptionLevel level)
> {
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
>
>
> Thanks,
> *- Enrico*
> 📩 egranata@.com ☎️ 27683
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] Instruction emulation of arm64 'stp d8, d9, [sp, #-0x70]!' style instruction

2016-10-12 Thread Tamas Berghammer via lldb-commits
Hi Jason,

Thank you for adding unit test for this code. I think the current
implementation doesn't fail terribly on 16 vs 32 byte stack alignment
because we use the "opc" from the instruction to calculate the write back
address (to adjust the SP) so having the wrong size of the register won't
effect that part.

Regarding the issue about s0/d0/v0 I don't have a perfect solution but here
are some ideas:
* Use a different register numbering schema then DWARF (e.g. LLDB/GDB/???).
I think it would only require us to
change EmulateInstructionARM64::CreateFunctionEntryUnwind to create an
UnwindPlan with a different register numbering schema and then to lookup
the register based on a different numbering schema using GetRegisterInfo in
functions where we want to reference s0-s31/d0-d31. In theory this should
be a simple change but I won't be surprised if changing the register
numbering breaks something.
* Introduce the concept of register pieces. This concept already exists in
the DWARF expressions where you can say that a given part of the register
is saved at a given location. I expect that doing it won't be trivial but
it would solve both this problem and would improve the way we understand
DWARF as well.

About your idea about saying that we saved v8&v9 even though we only saved
d8&d9: I think it is a good quick and dirty solution but it has a few
issues what is hard to solve. Most importantly we will lie to the user when
they read out v8&v9 what will contain some garbage data. Regarding
big/little endian we should be able to detect which one the inferior uses
and we can do different thing based on that (decide the location of v8&v9)
but it will make the hack even worth.

Tamas

On Tue, Oct 11, 2016 at 6:15 PM Jason Molenda  wrote:

Hi Tamas, I'm writing some unit tests for the unwind source generators -
x86 last week, arm64 this week, and I noticed with this prologue:



JavaScriptCore`JSC::B3::reduceDoubleToFloat:

0x192b45c0c <+0>:  0x6db923e9   stpd9, d8, [sp, #-0x70]!

0x192b45c10 <+4>:  0xa9016ffc   stpx28, x27, [sp, #0x10]

0x192b45c14 <+8>:  0xa90267fa   stpx26, x25, [sp, #0x20]

0x192b45c18 <+12>: 0xa9035ff8   stpx24, x23, [sp, #0x30]

0x192b45c1c <+16>: 0xa90457f6   stpx22, x21, [sp, #0x40]

0x192b45c20 <+20>: 0xa9054ff4   stpx20, x19, [sp, #0x50]

0x192b45c24 <+24>: 0xa9067bfd   stpx29, x30, [sp, #0x60]

0x192b45c28 <+28>: 0x910183fd   addx29, sp, #0x60; =0x60

0x192b45c2c <+32>: 0xd10a83ff   subsp, sp, #0x2a0;
=0x2a0







EmulateInstructionARM64::EmulateLDPSTP interprets this as a save of v31.
The use of reg 31 is an easy bug, the arm manual C7.2.284 ("STP (SIMD&FP)")
gives us an "opc" (0b00 == 32-bit registers, 0b01 == 64-bit registers, 0b10
== 128-bit registers), an immediate value, and three registers (Rt2, Rn,
Rt).  In the above example, these work out to Rt2 == 8 (d8), Rn == 31
("sp"), Rt == 9 (d9).  The unwinder is incorrectly saying v31 right now
because it's using Rn -



  if (vector) {

if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + n,
reg_info_Rt))

  return false;

if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + n,
reg_info_Rt2))

  return false;

  }



This would normally take up 32 bytes of stack space and cause big problems,
but because we're writing the same reg twice, I think we luck out and only
take 16 bytes of the stack.



We don't have dwarf register numbers for s0..31, d0..31, so we can't track
this instruction's behavior 100% correctly but maybe if we said that



That would be an easy fix, like



  if (vector) {

if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + t,
reg_info_Rt))

  return false;

if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + t2,
reg_info_Rt2))

  return false;

  }





We don't have dwarf register numbers for s0..31, d0..31, so I don't think
we can correctly track this instruction's actions today.  Maybe we should
put a save of v8 at CFA-112 and a save of v9 at CFA-104.  As long as the
target is operating in little endian mode, when we go to get the contents
of v8/v9 we're only actually USING the lower 64 bits so it'll work out,
right?  I think I have that right.  We'll be reading garbage in the upper
64 bits - the register reading code won't have any knowledge of the fact
that we only have the lower 32/64 bits available to us.





Throwing the problem out there, would like to hear what you think.  I don't
want to encode buggy behavior in a unit test ;) so I'd like it for us to
think about what correct behavior would be, and do that before I write the
test.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] Instruction emulation of arm64 'stp d8, d9, [sp, #-0x70]!' style instruction

2016-10-12 Thread Tamas Berghammer via lldb-commits
I am a bit surprised that we don't define the smaller floating point
registers on AArch64 the same way we do it on x86/x86_64/Arm (have no idea
about MIPS) and I would consider this as a bug what we should fix (will
gave it a try when I have a few free cycles) because currently it is very
difficult to get a 64bit double value out of the data we are displaying.

Considering the fact that based on the ABI only the bottom 64bit have to be
saved I start to like the idea of teaching our unwinder about the smaller
floating point registers because that will mean that we can inspect float
and double variables from the parent stack frame while we never show some
corrupted data for variables occupying the full 128 bit vector register.

"...the unwind plan generated currently records this as v31 being saved...":
I don't understand this part. The code never references v31 nor d31 so if
the unwind plan records it as we saved v31 then something is clearly wrong
there. Does it treat all d0-d31 register as v31 because of some instruction
decoding reason?

Tamas

On Wed, Oct 12, 2016 at 4:30 PM Jason Molenda  wrote:

> Hi Tamas, sorry for that last email being a mess, I was doing something
> else while writing it and only saw how unclear it was after I sent it.  You
> understood everything I was trying to say.
>
> I looked at the AAPCS64 again.  It says v8-v15 are callee saved, but says,
> "Additionally, only the bottom 64-bits of each value stored in v8-v15 need
> to be preserved[1]; it is the responsibility of the caller to preserve
> larger values." so we're never going to have a full 128-bit value that we
> can get off the stack (for targets following this ABI).
>
> DWARF can get away with only defining register numbers for v0-v31 because
> their use in DWARF always includes a byte size.  Having lldb register
> numbers and using that numbering scheme instead of DWARF is an interesting
> one.  It looks like all of the arm64 targets are using the definitions from
> Plugins/Process/Utility/RegisterInfos_arm64.h.  It also only defines v0-v31
> but the x86_64 RegisterInfos file defines pseudo registers ("eax") which
> are a subset of real registers ("rax") - maybe we could do something like
> that.
>
> I'm looking at this right now, but fwiw I wrote a small C program that
> uses enough fp registers that the compiler will spill all of the preserved
> registers (d8-d15) when I compile it with clang and -Os.  I'll use this for
> testing
>
>
>
> I get a prologue like
>
> a.out`foo:
> a.out[0x17a08] <+0>:   0x6dba3bef   stpd15, d14, [sp, #-96]!
> a.out[0x17a0c] <+4>:   0x6d0133ed   stpd13, d12, [sp, #16]
> a.out[0x17a10] <+8>:   0x6d022beb   stpd11, d10, [sp, #32]
> a.out[0x17a14] <+12>:  0x6d0323e9   stpd9, d8, [sp, #48]
> a.out[0x17a18] <+16>:  0xa9046ffc   stpx28, x27, [sp, #64]
> a.out[0x17a1c] <+20>:  0xa9057bfd   stpx29, x30, [sp, #80]
> a.out[0x17a20] <+24>:  0x910143fd   addx29, sp, #80  ;
> =80
>
>
> and the unwind plan generated currently records this as v31 being saved in
> the first instruction and ignores the others (because that reg has already
> been saved).  That's the easy bug - but it's a good test case that I'll
> strip down into a unit test once we get this figured out.
>
>
> J
>
>
> > On Oct 12, 2016, at 2:15 PM, Tamas Berghammer 
> wrote:
> >
> > Hi Jason,
> >
> > Thank you for adding unit test for this code. I think the current
> implementation doesn't fail terribly on 16 vs 32 byte stack alignment
> because we use the "opc" from the instruction to calculate the write back
> address (to adjust the SP) so having the wrong size of the register won't
> effect that part.
> >
> > Regarding the issue about s0/d0/v0 I don't have a perfect solution but
> here are some ideas:
> > * Use a different register numbering schema then DWARF (e.g.
> LLDB/GDB/???). I think it would only require us to change
> EmulateInstructionARM64::CreateFunctionEntryUnwind to create an UnwindPlan
> with a different register numbering schema and then to lookup the register
> based on a different numbering schema using GetRegisterInfo in functions
> where we want to reference s0-s31/d0-d31. In theory this should be a simple
> change but I won't be surprised if changing the register numbering breaks
> something.
> > * Introduce the concept of register pieces. This concept already exists
> in the DWARF expressions where you can say that a given part of the
> register is saved at a given location. I expect that doing it won't be
> trivial but it would solve both this problem and would improve the way we
> understand DWARF as well.
> >
> > About your idea about saying that we saved v8&v9 even though we only
> saved d8&d9: I think it is a good quick and dirty solution but it has a few
> issues what is hard to solve. Most importantly we will lie to the user when
> they read out v8&v9 what will contain some garbage data. Regarding
> big/little endian we should be able to detect w

Re: [Lldb-commits] Instruction emulation of arm64 'stp d8, d9, [sp, #-0x70]!' style instruction

2016-10-13 Thread Tamas Berghammer via lldb-commits
In case of Linux and Android we are using the qRegisterInfo packet and
lldb-server fills it in based on the register definitions inside LLDB so
for those targets it would be important to have all of the alias registers
available.

I don't have an AArch64-BE target at hand but I am pretty sure you are
right about the different register offsets. To handle both big and little
endian I think we will either have to create 2 separate copy of the
RegisterInfos or make it endian aware to correctly represent the offsets
because of the different offsets. I am pretty sure we currently handle it
incorrectly in case of ARM (where we have the alias registers) as we don't
have separate register contexts so if we find a way to fix the AArch64 case
then we should fix ARM as well. My preferred solution would be try to clean
up the large amount of code duplication from the RegisterInfo files and
then create correct data including all alias registers and endian aware
offsets using runtime loops instead of the current static arrays.

What do you think?

Tamas

On Thu, Oct 13, 2016 at 2:53 AM Jason Molenda  wrote:

But if I attach to an arm64 core file, where lldb is using it's own
register definitions, then lldb has no idea what s0 is.

My concern about defining these subset registers in RegisterInfos_arm64.h
is that the offsets are in a target-endian register context buffer.  My
example below was little-endian so the start of v0 was 268 bytes into the
register file and the offset of s0 is also 268 bytes.  But in a BE target,
I think s0 would be at offset 280 in the buffer.

> On Oct 12, 2016, at 6:38 PM, Jason Molenda  wrote:
>
> Yeah, it's incorrectly grabbing the stack pointer reg number (31) from
the Rn bits and using that as the register # being saved, instead of the Rt
and Rt2 register numbers, and saying that v31 is being pushed twice.  It's
an easy bug in EmulateInstructionARM64::EmulateLDPSTP but fixing that just
presents us with the next problem so I haven't fixed it.
>
> When I connect to debugserver on an arm64 device, it tells lldb about the
pseudo regs on the device, like
>
>  
>
>  
>
>  
>
>  
>
>  
>
>
> (this is the reply to the "qXfer:features:read:target.xml" packet that
lldb sends to debugserver at the startup of the debug session) so the user
can refer to these by name:
>
> (lldb) reg read -f x s0
>  s0 = 0x404e809d
> (lldb) reg read -f x d0
>  d0 = 0x41bdaf19404e809d
> (lldb) reg read -f x v0
>  v0 = 0x41bdaf19404e809d
> (lldb)
>
>
> J
>
>> On Oct 12, 2016, at 6:23 PM, Tamas Berghammer 
wrote:
>>
>> I am a bit surprised that we don't define the smaller floating point
registers on AArch64 the same way we do it on x86/x86_64/Arm (have no idea
about MIPS) and I would consider this as a bug what we should fix (will
gave it a try when I have a few free cycles) because currently it is very
difficult to get a 64bit double value out of the data we are displaying.
>>
>> Considering the fact that based on the ABI only the bottom 64bit have to
be saved I start to like the idea of teaching our unwinder about the
smaller floating point registers because that will mean that we can inspect
float and double variables from the parent stack frame while we never show
some corrupted data for variables occupying the full 128 bit vector
register.
>>
>> "...the unwind plan generated currently records this as v31 being
saved...": I don't understand this part. The code never references v31 nor
d31 so if the unwind plan records it as we saved v31 then something is
clearly wrong there. Does it treat all d0-d31 register as v31 because of
some instruction decoding reason?
>>
>> Tamas
>>
>> On Wed, Oct 12, 2016 at 4:30 PM Jason Molenda  wrote:
>> Hi Tamas, sorry for that last email being a mess, I was doing something
else while writing it and only saw how unclear it was after I sent it.  You
understood everything I was trying to say.
>>
>> I looked at the AAPCS64 again.  It says v8-v15 are callee saved, but
says, "Additionally, only the bottom 64-bits of each value stored in v8-v15
need to be preserved[1]; it is the responsibility of the caller to preserve
larger values." so we're never going to have a full 128-bit value that we
can get off the stack (for targets following this ABI).
>>
>> DWARF can get away with only defining register numbers for v0-v31
because their use in DWARF always includes a byte size.  Having lldb
register numbers and using that numbering scheme instead of DWARF is an
interesting one.  It looks like all of the arm64 targets are using the
definitions from Plugins/Process/Utility/RegisterInfos_arm64.h.  It also
only defines v0-v31 but the x86_64 RegisterInfos file defines pseudo
registers ("eax") which are a subset of real registers ("rax") - maybe we
could do something like that.
>>
>> I'm looking at this right now, but fwiw I wrote a small C program that
uses enough fp registers that the compiler will spill all of the preserved
registers (d8-d15) when I compile it with clang and -O

[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-18 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: labath, granata.enrico.
tberghammer added a subscriber: lldb-commits.

Improve the libstdc++ smart pointer formatters

  

- Display the strong/weak count in the summary
- Display the pointed object as a synthetic member
- Create synthetic children for weak/strong count


https://reviews.llvm.org/D25726

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
  source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
===
--- source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -76,6 +76,20 @@
   bool MightHaveChildren() override;
 
   size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+  bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
+
+ private:
+  ValueObjectSP m_ptr_obj;
+  ValueObjectSP m_obj_obj;
+  ValueObjectSP m_use_obj;
+  ValueObjectSP m_weak_obj;
+
+  uint8_t m_ptr_size = 0;
+  lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
+
+  bool IsEmpty();
+  bool IsValid();
 };
 
 } // end of anonymous namespace
@@ -355,35 +369,126 @@
 LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
 lldb::ValueObjectSP valobj_sp)
 : SyntheticChildrenFrontEnd(*valobj_sp) {
-  if (valobj_sp)
-Update();
+  Update();
 }
 
-size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; }
+bool LibStdcppSharedPtrSyntheticFrontEnd::Update() {
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp) return false;
 
-lldb::ValueObjectSP
-LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
-  ValueObjectSP valobj_sp = m_backend.GetSP();
-  if (!valobj_sp)
-return lldb::ValueObjectSP();
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp) return false;
 
-  if (idx == 0)
-return valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
-  else
-return lldb::ValueObjectSP();
-}
+  TargetSP target_sp(valobj_sp->GetTargetSP());
+  if (!target_sp) return false;
 
-bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { return false; }
+  m_byte_order = target_sp->GetArchitecture().GetByteOrder();
+  m_ptr_size = target_sp->GetArchitecture().GetAddressByteSize();
+
+  m_ptr_obj = valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
+
+  m_use_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+ ConstString("_M_pi"),
+ ConstString("_M_use_count")});
+
+  m_weak_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+  ConstString("_M_pi"),
+  ConstString("_M_weak_count")});
+
+  if (m_use_obj && m_weak_obj && m_use_obj->GetValueAsUnsigned(0) > 0) {
+bool success = false;
+uint64_t count = m_weak_obj->GetValueAsUnsigned(0, &success) - 1;
+if (success) {
+  auto data = std::make_shared(&count, sizeof(count));
+  m_weak_obj = CreateValueObjectFromData(
+  "weak_count", DataExtractor(data, m_byte_order, m_ptr_size),
+  m_weak_obj->GetExecutionContextRef(), m_weak_obj->GetCompilerType());
+}
+  }
+
+  if (m_ptr_obj && !IsEmpty()) {
+Error error;
+m_obj_obj = m_ptr_obj->Dereference(error);
+if (error.Success()) {
+  m_obj_obj->SetName(ConstString("object"));
+}
+  }
+
+  return false;
+}
 
 bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
 
+lldb::ValueObjectSP LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(
+size_t idx) {
+  if (idx == 0) return m_obj_obj;
+  if (idx == 1) return m_ptr_obj;
+  if (idx == 2) return m_use_obj;
+  if (idx == 3) return m_weak_obj;
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() {
+  if (IsEmpty()) return 0;
+  return 1;
+}
+
 size_t LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
 const ConstString &name) {
-  if (name == ConstString("_M_ptr"))
-return 0;
+  if (name == ConstString("obj") || name == ConstString("object")) return 0;
+  if (name == ConstString("ptr") || name == ConstString("pointer") ||
+  name == ConstString("_M_ptr"))
+return 1;
+  if (name == ConstString("cnt") || name == ConstString("count") ||
+  name == ConstString("use_count") || name == ConstString("strong") ||
+  name == ConstString("_M_use_count"))
+return 2;
+  if (name == ConstString("weak") || name == ConstString("weak_count") ||
+  name == ConstString("_M_weak_count"))
+return 3;
   return UINT32_MAX;
 }
 
+bool LibStdcppSharedPtrSyntheticFrontEnd::GetSummary(
+Stream &stream, const TypeSummaryOptions &options) {
+  if 

[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-18 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 75025.
tberghammer added a comment.
Herald added subscribers: mgorny, beanz.

Move the code to a new cpp file


https://reviews.llvm.org/D25726

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
@@ -0,0 +1,192 @@
+//===-- LibStdcppSmartPointer.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+ public:
+  explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+  bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
+
+ private:
+  ValueObjectSP m_ptr_obj;
+  ValueObjectSP m_obj_obj;
+  ValueObjectSP m_use_obj;
+  ValueObjectSP m_weak_obj;
+
+  uint8_t m_ptr_size = 0;
+  lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
+
+  bool IsEmpty();
+  bool IsValid();
+};
+
+} // end of anonymous namespace
+
+LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppSharedPtrSyntheticFrontEnd::Update() {
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp) return false;
+
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp) return false;
+
+  TargetSP target_sp(valobj_sp->GetTargetSP());
+  if (!target_sp) return false;
+
+  m_byte_order = target_sp->GetArchitecture().GetByteOrder();
+  m_ptr_size = target_sp->GetArchitecture().GetAddressByteSize();
+
+  m_ptr_obj = valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
+
+  m_use_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+ ConstString("_M_pi"),
+ ConstString("_M_use_count")});
+
+  m_weak_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+  ConstString("_M_pi"),
+  ConstString("_M_weak_count")});
+
+  if (m_use_obj && m_weak_obj && m_use_obj->GetValueAsUnsigned(0) > 0) {
+bool success = false;
+uint64_t count = m_weak_obj->GetValueAsUnsigned(0, &success) - 1;
+if (success) {
+  auto data = std::make_shared(&count, sizeof(count));
+  m_weak_obj = CreateValueObjectFromData(
+  "weak_count", DataExtractor(data, m_byte_order, m_ptr_size),
+  m_weak_obj->GetExecutionContextRef(), m_weak_obj->GetCompilerType());
+}
+  }
+
+  if (m_ptr_obj && !IsEmpty()) {
+Error error;
+m_obj_obj = m_ptr_obj->Dereference(error);
+if (error.Success()) {
+  m_obj_obj->SetName(ConstString("object"));
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(
+size_t idx) {
+  if (idx == 0) return m_obj_obj;
+  if (idx == 1) return m_ptr_obj;
+  if (idx == 2) return m_use_obj;
+  if (idx == 3) return m_weak_obj;
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() {
+  if (IsEmpty()) return 0;
+  return 1;
+}
+
+size_t LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
+const ConstString &name) {
+  if (name == ConstString("obj") || name == ConstString("object")) return 0;
+  if (name == ConstString("ptr") || name == ConstString("pointer") ||
+  name == ConstString("_M_ptr"))
+return 1;
+  if (name == ConstString("cnt") || name == ConstString("count") ||
+  name == ConstString("use_count") || name == ConstString(

[Lldb-commits] [PATCH] D25733: Add data formatter for libstdc++ tuple

2016-10-18 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: labath, granata.enrico.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: mgorny, beanz.

Add data formatter for libstdc++ tuple


https://reviews.llvm.org/D25733

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -0,0 +1,110 @@
+//===-- LibStdcppTuple.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+ public:
+  explicit LibStdcppTupleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ private:
+  std::vector m_members;
+};
+
+} // end of anonymous namespace
+
+LibStdcppTupleSyntheticFrontEnd::LibStdcppTupleSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::Update() {
+  m_members.clear();
+
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp) return false;
+
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp) return false;
+
+  ValueObjectSP next_child_sp = valobj_sp;
+  while (next_child_sp != nullptr) {
+ValueObjectSP current_child = next_child_sp;
+next_child_sp = nullptr;
+
+size_t child_count = current_child->GetNumChildren();
+for (size_t i = 0; i < child_count; ++i) {
+  ValueObjectSP child_sp = current_child->GetChildAtIndex(i, true);
+  llvm::StringRef name_str = child_sp->GetName().GetStringRef();
+  if (name_str.startswith("std::_Tuple_impl<")) {
+next_child_sp = child_sp;
+  } else if (name_str.startswith("std::_Head_base<")) {
+ValueObjectSP value_sp =
+child_sp->GetChildMemberWithName(ConstString("_M_head_impl"), true);
+if (value_sp) {
+  StreamString name;
+  name.Printf("[%" PRIu64 "]", m_members.size());
+  value_sp->SetName(ConstString(name.GetData()));
+
+  m_members.push_back(value_sp);
+}
+  }
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(
+size_t idx) {
+  if (idx < m_members.size()) return m_members[idx];
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
+  return m_members.size();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::GetIndexOfChildWithName(
+const ConstString &name) {
+  return ExtractIndexFromString(name.GetCString());
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator(
+CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+  return (valobj_sp ? new LibStdcppTupleSyntheticFrontEnd(valobj_sp) : nullptr);
+}
Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -803,16 +803,31 @@
 
   AddCXXSynthetic(
   cpp_category_sp,
+  lldb_private::formatters::LibStdcppUniquePtrSyntheticFrontEndCreator,
+  "std::unique_ptr synthetic children",
+  ConstString("^std::unique_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+  AddCXXSynthetic(
+  cpp_category_sp,
   lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
   "std::shared_ptr synthetic 

[Lldb-commits] [PATCH] D25734: Add data formatter for libstdc++ unique_ptr

2016-10-18 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: labath, granata.enrico.
tberghammer added a subscriber: lldb-commits.

Add data formatter for libstdc++ unique_ptr


https://reviews.llvm.org/D25734

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
  source/Plugins/Language/CPlusPlus/LibStdcpp.h
  source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -0,0 +1,148 @@
+//===-- LibStdcpp.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+ public:
+  explicit LibStdcppUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+  bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
+
+ private:
+  ValueObjectSP m_ptr_obj;
+  ValueObjectSP m_obj_obj;
+  ValueObjectSP m_del_obj;
+};
+
+} // end of anonymous namespace
+
+LibStdcppUniquePtrSyntheticFrontEnd::LibStdcppUniquePtrSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp) return false;
+
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp) return false;
+
+  ValueObjectSP tuple_sp =
+  valobj_sp->GetChildMemberWithName(ConstString("_M_t"), true);
+  if (!tuple_sp) return false;
+
+  std::unique_ptr tuple_frontend(
+  LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp));
+
+  m_ptr_obj = tuple_frontend->GetChildAtIndex(0);
+  if (m_ptr_obj)
+m_ptr_obj->SetName(ConstString("pointer"));
+
+  m_del_obj = tuple_frontend->GetChildAtIndex(1);
+  if (m_del_obj)
+m_del_obj->SetName(ConstString("deleter"));
+
+  if (m_ptr_obj) {
+Error error;
+m_obj_obj = m_ptr_obj->Dereference(error);
+if (error.Success()) {
+  m_obj_obj->SetName(ConstString("object"));
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(
+size_t idx) {
+  if (idx == 0) return m_obj_obj;
+  if (idx == 1) return m_del_obj;
+  if (idx == 2) return m_ptr_obj;
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
+  if (m_del_obj) return 2;
+  if (m_ptr_obj && m_ptr_obj->GetValueAsUnsigned(0) != 0) return 1;
+  return 0;
+}
+
+size_t LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(
+const ConstString &name) {
+  if (name == ConstString("obj") || name == ConstString("object")) return 0;
+  if (name == ConstString("del") || name == ConstString("deleter")) return 1;
+  if (name == ConstString("ptr") || name == ConstString("pointer")) return 2;
+  return UINT32_MAX;
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::GetSummary(
+Stream &stream, const TypeSummaryOptions &options) {
+  if (!m_ptr_obj) return false;
+
+  if (m_ptr_obj->GetValueAsUnsigned(0) == 0) {
+stream.Printf("nullptr");
+  } else {
+Error error;
+bool print_pointee = false;
+if (m_obj_obj) {
+  if (m_obj_obj->DumpPrintableRepresentation(
+  stream, ValueObject::eValueObjectRepresentationStyleSummary,
+  lldb::eFormatInvalid,
+  ValueObject::ePrintableRepresentationSpecialCasesDisable,
+  false)) {
+print_pointee = true;
+  }
+}
+if (!print_pointee)
+  stream.Printf("ptr = 0x%" PRIx64, m_ptr_obj->GetValueAsUnsigned(0));
+  }
+  return true;
+}
+
+SyntheticChildrenFro

[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-18 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

In https://reviews.llvm.org/D25726#573127, @Eugene.Zelenko wrote:

> Please run Clang-format over new code.


I run it before upload but it mush have picked up some strange config. Will run 
it again before submit. Thanks for noticing it.


https://reviews.llvm.org/D25726



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


[Lldb-commits] [lldb] r284725 - Re-generate the python and cpp reference documentation

2016-10-20 Thread Tamas Berghammer via lldb-commits
Modified: 
lldb/trunk/www/python_reference/toc-lldb.formatters.cpp.gnu_libstdcpp-module.html
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/toc-lldb.formatters.cpp.gnu_libstdcpp-module.html?rev=284725&r1=284724&r2=284725&view=diff
==
--- 
lldb/trunk/www/python_reference/toc-lldb.formatters.cpp.gnu_libstdcpp-module.html
 (original)
+++ 
lldb/trunk/www/python_reference/toc-lldb.formatters.cpp.gnu_libstdcpp-module.html
 Thu Oct 20 08:04:32 2016
@@ -19,14 +19,8 @@
  >StdVectorSynthProvider  Variables
 __package__  
-_list_capping_size  
-  
 _list_uses_loop_detector  
-  
-_map_capping_size  
 
 [hide private]

Added: lldb/trunk/www/python_reference/toc-lldb.formatters.synth-module.html
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/toc-lldb.formatters.synth-module.html?rev=284725&view=auto
==
--- lldb/trunk/www/python_reference/toc-lldb.formatters.synth-module.html 
(added)
+++ lldb/trunk/www/python_reference/toc-lldb.formatters.synth-module.html Thu 
Oct 20 08:04:32 2016
@@ -0,0 +1,33 @@
+
+
+http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
+
+  synth
+  
+  
+
+
+
+Module synth
+
+  Classes
+PythonObjectSyntheticChildProvider  Variables
+__package__
+[hide private]
+
+
+  
+
+
+

Modified: lldb/trunk/www/python_reference/toc.html
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/toc.html?rev=284725&r1=284724&r2=284725&view=diff
==
--- lldb/trunk/www/python_reference/toc.html (original)
+++ lldb/trunk/www/python_reference/toc.html Thu Oct 20 08:04:32 2016
@@ -28,7 +28,8 @@
  
onclick="setFrame('toc-lldb.formatters.cpp-module.html','lldb.formatters.cpp-module.html');"
 >lldb.formatters.cpplldb.formatters.cpp.gnu_libstdcpplldb.formatters.cpp.libcxxlldb.formatters.metricslldb.formatters.metricslldb.formatters.synthlldb.runtimelldb.utilslldb.utils.symbolication

Modified: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_dec.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_dec.gif?rev=284725&r1=284724&r2=284725&view=diff
==
Binary files - no diff available.

Modified: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_emb.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_emb.gif?rev=284725&r1=284724&r2=284725&view=diff
==
Binary files - no diff available.

Added: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for.gif?rev=284725&view=auto
==
Binary files lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for.gif 
(added) and lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for.gif 
Thu Oct 20 08:04:32 2016 differ

Added: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_2.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_2.gif?rev=284725&view=auto
==
Binary files 
lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_2.gif (added) 
and lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_2.gif Thu 
Oct 20 08:04:32 2016 differ

Added: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_3.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_3.gif?rev=284725&view=auto
==
Binary files 
lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_3.gif (added) 
and lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_for_3.gif Thu 
Oct 20 08:04:32 2016 differ

Modified: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_sba.gif
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_sba.gif?rev=284725&r1=284724&r2=284725&view=diff
==
Binary files - no diff available.

Modified: lldb/trunk/www/python_reference/uml_class_diagram_for_lldb_sba_2.gif
URL: 
http://

[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-20 Thread Tamas Berghammer via lldb-commits
tberghammer added inline comments.



Comment at: source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp:138
+return 3;
+  return UINT32_MAX;
+}

labath wrote:
> I know you just copied it, but this seems wrong (size_t can be 64-bit). Will 
> this work if you just return `~0`.
Actually as far as I can tell all use case of this API assumes it is a uint32_t 
and compares the return value against UINT32_MAX :(
I will just leave it as it is and then we should have a separate CL what cleans 
up the mess around it


https://reviews.llvm.org/D25726



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


[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-20 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 75300.
tberghammer marked 5 inline comments as done.

https://reviews.llvm.org/D25726

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
@@ -0,0 +1,200 @@
+//===-- LibStdcppSmartPointer.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Target/Target.h"
+
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class SharedPtrFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+  explicit SharedPtrFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+  bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
+
+private:
+  ValueObjectSP m_ptr_obj;
+  ValueObjectSP m_obj_obj;
+  ValueObjectSP m_use_obj;
+  ValueObjectSP m_weak_obj;
+
+  uint8_t m_ptr_size = 0;
+  lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
+
+  bool IsEmpty();
+  bool IsValid();
+};
+
+} // end of anonymous namespace
+
+SharedPtrFrontEnd::SharedPtrFrontEnd(lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool SharedPtrFrontEnd::Update() {
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp)
+return false;
+
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp)
+return false;
+
+  TargetSP target_sp(valobj_sp->GetTargetSP());
+  if (!target_sp)
+return false;
+
+  m_byte_order = target_sp->GetArchitecture().GetByteOrder();
+  m_ptr_size = target_sp->GetArchitecture().GetAddressByteSize();
+
+  m_ptr_obj = valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
+
+  m_use_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+ ConstString("_M_pi"),
+ ConstString("_M_use_count")});
+
+  m_weak_obj = valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"),
+  ConstString("_M_pi"),
+  ConstString("_M_weak_count")});
+
+  // libstdc++ implements the weak usage count in a way that it is offset by 1
+  // if the strong count is not 0 (as part of a preformance optimization). We
+  // want to undo this before showing the weak count to the user as an offseted
+  // weak count would be very confusing.
+  if (m_use_obj && m_weak_obj && m_use_obj->GetValueAsUnsigned(0) > 0) {
+bool success = false;
+uint64_t count = m_weak_obj->GetValueAsUnsigned(0, &success) - 1;
+if (success) {
+  auto data = std::make_shared(&count, sizeof(count));
+  m_weak_obj = CreateValueObjectFromData(
+  "weak_count", DataExtractor(data, m_byte_order, m_ptr_size),
+  m_weak_obj->GetExecutionContextRef(), m_weak_obj->GetCompilerType());
+}
+  }
+
+  if (m_ptr_obj && !IsEmpty()) {
+Error error;
+m_obj_obj = m_ptr_obj->Dereference(error);
+if (error.Success()) {
+  m_obj_obj->SetName(ConstString("object"));
+}
+  }
+
+  return false;
+}
+
+bool SharedPtrFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP SharedPtrFrontEnd::GetChildAtIndex(size_t idx) {
+  if (idx == 0)
+return m_obj_obj;
+  if (idx == 1)
+return m_ptr_obj;
+  if (idx == 2)
+return m_use_obj;
+  if (idx == 3)
+return m_weak_obj;
+  return lldb::ValueObjectSP();
+}
+
+size_t SharedPtrFrontEnd::CalculateNumChildren() {
+  if (IsEmpty())
+return 0;
+  return 1;
+}
+
+size_t SharedPtrFrontEnd::GetIndexOfChildWithName(const ConstString &name) {
+  if (name == ConstString("obj") || name == ConstString("object"))
+return 0;
+  if (name == ConstString("ptr") || name == ConstString("pointer") ||
+  name == ConstString("_M_ptr"))
+return 1;
+  if (name == ConstString("cnt") || name == 

[Lldb-commits] [PATCH] D25864: Fix arm64 floating point register spill recording in UnwindPlan analysis

2016-10-21 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

A few high level comments:

- I have the feeling you ported much more code over to use the LLDB register 
numbers then it would be strictly necessary. I am not sure if it is good or bad 
as it can help us consolidate the confusion around the different register 
numbering schema but it icnreases the size of this patch by a lot and also adds 
a lot of new boilerplate code.
- I would prefer to keep lldb-arm64-register-enums.h over the new file you 
added as your code contains a lot of logic in ARM64_LLDB_Registers.cpp (e.g. to 
string conversion) what seems unnecessary to me as the register tables you 
modified recently already contains all information to get from register number 
to register name
- Regarding Greg's concern I think we should have a single table 
(RegisterInfoInterface) containing all registers what can appear on the target 
and then the register context should be the one who detects which one is 
available and then returns the correct one accordingly. We already have 
functionality like this for x86_64 where RegisterInfos_x86_64.h and 
lldb-x86-register-enums.h defines all possibly available register and then 
NativeRegisterContextLinux_x86_64 detects if the AVX and MPX registers are 
available or not and then report the register list accordingly.

In mid/long term I think we should clean up the full register info handling 
code to simplify all of this in the following lines (vague ideas):

- Implement a single copy of RegisterInfoInterface for every architecture what 
returns the correct list of registers based on the architecture and 
sub-architecture
- Define register sets inside the RegisterInfoInterface instead of inside the 
RegistrerContext... classes
- Change EmulateInstruction... to use the RegisterInfoInterface to get a 
RegisterInfo object from the register numbers
- Change all RegisterContext... to use the information from the 
RegisterInfoInterface... classes instead of duplicating it into them

Doing all of the cleanup will be a lot of work so I am not asking you to do it 
or I don't want to wait with this change for that long but wanted to raise it 
here so we don't start to move in a direction what will make later improvements 
more difficult




Comment at: source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp:196-197
 
-  if (reg_kind == eRegisterKindDWARF)
-return arm64_dwarf::GetRegisterInfo(reg_num, reg_info);
+  if (reg_kind == eRegisterKindLLDB)
+return arm64_lldb::GetRegisterInfo(reg_num, reg_info);
   return false;

What do you think about teaching this function to handle both 
eRegisterKindDWARF and eRegisterKindLLDB? That way you can use both in the 
emulation code. Also that would me that you don't have to update all usage 
inside the emulation code.



Comment at: source/Utility/ARM64_LLDB_Registers.cpp:18
+
+const char *arm64_lldb::GetRegisterName(unsigned reg_num,
+bool altnernate_name) {

I think this function is completely unnecessary if you use the 
g_register_infos_arm64_le table (or one of it's wrapper)


Repository:
  rL LLVM

https://reviews.llvm.org/D25864



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


[Lldb-commits] [PATCH] D25733: Add data formatter for libstdc++ tuple

2016-10-21 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 75417.
tberghammer marked 4 inline comments as done.

https://reviews.llvm.org/D25733

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/LibStdcpp.h
  source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -0,0 +1,109 @@
+//===-- LibStdcppTuple.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+  explicit LibStdcppTupleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+  std::vector m_members;
+};
+
+} // end of anonymous namespace
+
+LibStdcppTupleSyntheticFrontEnd::LibStdcppTupleSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::Update() {
+  m_members.clear();
+
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp)
+return false;
+
+  ValueObjectSP next_child_sp = valobj_backend_sp->GetNonSyntheticValue();
+  while (next_child_sp != nullptr) {
+ValueObjectSP current_child = next_child_sp;
+next_child_sp = nullptr;
+
+size_t child_count = current_child->GetNumChildren();
+for (size_t i = 0; i < child_count; ++i) {
+  ValueObjectSP child_sp = current_child->GetChildAtIndex(i, true);
+  llvm::StringRef name_str = child_sp->GetName().GetStringRef();
+  if (name_str.startswith("std::_Tuple_impl<")) {
+next_child_sp = child_sp;
+  } else if (name_str.startswith("std::_Head_base<")) {
+ValueObjectSP value_sp =
+child_sp->GetChildMemberWithName(ConstString("_M_head_impl"), true);
+if (value_sp) {
+  StreamString name;
+  name.Printf("[%zd]", m_members.size());
+  value_sp->SetName(ConstString(name.GetData()));
+
+  m_members.push_back(value_sp);
+}
+  }
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP
+LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+  if (idx < m_members.size())
+return m_members[idx];
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
+  return m_members.size();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::GetIndexOfChildWithName(
+const ConstString &name) {
+  return ExtractIndexFromString(name.GetCString());
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator(
+CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+  return (valobj_sp ? new LibStdcppTupleSyntheticFrontEnd(valobj_sp) : nullptr);
+}
Index: source/Plugins/Language/CPlusPlus/LibStdcpp.h
===
--- source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -36,6 +36,10 @@
  lldb::ValueObjectSP);
 
 SyntheticChildrenFrontEnd *
+LibStdcppTupleSyntheticFrontEndCreator(CXXSyntheticChildren *,
+   lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
 LibStdcppVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
 lldb::ValueObjectSP);
 
Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguag

[Lldb-commits] [PATCH] D25734: Add data formatter for libstdc++ unique_ptr

2016-10-21 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 75425.
tberghammer marked 2 inline comments as done.
Herald added subscribers: mgorny, beanz.

https://reviews.llvm.org/D25734

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/LibStdcpp.h
  source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Index: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -0,0 +1,160 @@
+//===-- LibStdcppUniquePointer.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+  explicit LibStdcppUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+  bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
+
+private:
+  ValueObjectSP m_ptr_obj;
+  ValueObjectSP m_obj_obj;
+  ValueObjectSP m_del_obj;
+};
+
+} // end of anonymous namespace
+
+LibStdcppUniquePtrSyntheticFrontEnd::LibStdcppUniquePtrSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp)
+return false;
+
+  ValueObjectSP valobj_sp = valobj_backend_sp->GetNonSyntheticValue();
+  if (!valobj_sp)
+return false;
+
+  ValueObjectSP tuple_sp =
+  valobj_sp->GetChildMemberWithName(ConstString("_M_t"), true);
+  if (!tuple_sp)
+return false;
+
+  std::unique_ptr tuple_frontend(
+  LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp));
+
+  m_ptr_obj = tuple_frontend->GetChildAtIndex(0);
+  if (m_ptr_obj)
+m_ptr_obj->SetName(ConstString("pointer"));
+
+  m_del_obj = tuple_frontend->GetChildAtIndex(1);
+  if (m_del_obj)
+m_del_obj->SetName(ConstString("deleter"));
+
+  if (m_ptr_obj) {
+Error error;
+m_obj_obj = m_ptr_obj->Dereference(error);
+if (error.Success()) {
+  m_obj_obj->SetName(ConstString("object"));
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP
+LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+  if (idx == 0)
+return m_obj_obj;
+  if (idx == 1)
+return m_del_obj;
+  if (idx == 2)
+return m_ptr_obj;
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
+  if (m_del_obj)
+return 2;
+  if (m_ptr_obj && m_ptr_obj->GetValueAsUnsigned(0) != 0)
+return 1;
+  return 0;
+}
+
+size_t LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(
+const ConstString &name) {
+  if (name == ConstString("obj") || name == ConstString("object"))
+return 0;
+  if (name == ConstString("del") || name == ConstString("deleter"))
+return 1;
+  if (name == ConstString("ptr") || name == ConstString("pointer"))
+return 2;
+  return UINT32_MAX;
+}
+
+bool LibStdcppUniquePtrSyntheticFrontEnd::GetSummary(
+Stream &stream, const TypeSummaryOptions &options) {
+  if (!m_ptr_obj)
+return false;
+
+  if (m_ptr_obj->GetValueAsUnsigned(0) == 0) {
+stream.Printf("nullptr");
+  } else {
+Error error;
+bool print_pointee = false;
+if (m_obj_obj) {
+  if (m_obj_obj->DumpPrintableRepresentation(
+  stream, ValueObject::eValueObjectRepresentationStyleSummary,
+  lldb::eFormatInvalid,
+  ValueObject::ePrintableRepresentationSpecialCasesDisable,
+  false)) {
+print_pointee = true;
+  }
+}
+if (!print_pointee)
+

[Lldb-commits] [PATCH] D25734: Add data formatter for libstdc++ unique_ptr

2016-10-21 Thread Tamas Berghammer via lldb-commits
tberghammer added inline comments.



Comment at: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp:110
+  if (name == ConstString("ptr") || name == ConstString("pointer")) return 2;
+  return UINT32_MAX;
+}

labath wrote:
> ~0 ?
The user compares the result against UINT32_MAX what is wrong but I don't want 
to start changing all use case of this function in this CL.


https://reviews.llvm.org/D25734



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


[Lldb-commits] [lldb] r284828 - Improve the libstdc++ smart pointer formatters

2016-10-21 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct 21 10:02:32 2016
New Revision: 284828

URL: http://llvm.org/viewvc/llvm-project?rev=284828&view=rev
Log:
Improve the libstdc++ smart pointer formatters

* Display the strong/weak count in the summary
* Display the pointed object as a synthetic member
* Create synthetic children for weak/strong count

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

Added:
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile?rev=284828&r1=284827&r2=284828&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
 Fri Oct 21 10:02:32 2016
@@ -2,14 +2,7 @@ LEVEL = ../../../../../make
 
 CXX_SOURCES := main.cpp
 
-CXXFLAGS := -O0
 USE_LIBSTDCPP := 1
-
-# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
-# targets.  Other targets do not, which causes this test to fail.
-# This flag enables FullDebugInfo for all targets.
-ifneq (,$(findstring clang,$(CC)))
-  CFLAGS_EXTRAS += -fno-limit-debug-info
-endif
+CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS)
 
 include $(LEVEL)/Makefile.rules

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py?rev=284828&r1=284827&r2=284828&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
 Fri Oct 21 10:02:32 2016
@@ -31,19 +31,58 @@ class StdSmartPtrDataFormatterTestCase(T
 substrs=['stopped', 'stop reason = breakpoint'])
 
 self.expect("frame variable nsp", substrs=['nsp = nullptr'])
-self.expect("frame variable isp", substrs=['isp = 123'])
-self.expect("frame variable ssp", substrs=['ssp = "foobar"'])
-
+self.expect("frame variable isp", substrs=['isp = 123', 'strong=1', 
'weak=1'])
+self.expect("frame variable ssp", substrs=['ssp = "foobar"', 
'strong=1', 'weak=1'])
 self.expect("frame variable nwp", substrs=['nwp = nullptr'])
-self.expect("frame variable iwp", substrs=['iwp = 123'])
-self.expect("frame variable swp", substrs=['swp = "foobar"'])
+self.expect("frame variable iwp", substrs=['iwp = 123', 'strong=1', 
'weak=1'])
+self.expect("frame variable swp", substrs=['swp = "foobar"', 
'strong=1', 'weak=1'])
+
+frame = self.frame()
+self.assertTrue(frame.IsValid())
+
+self.assertEqual(0, 
frame.GetValueForVariablePath("nsp.pointer").GetValueAsUnsigned())
+self.assertEqual(0, 
frame.GetValueForVariablePath("nwp.pointer").GetValueAsUnsigned())
+
+self.assertNotEqual(0, 
frame.GetValueForVariablePath("isp.pointer").GetValueAsUnsigned())
+self.assertEqual(123, 
frame.GetValueForVariablePath("isp.object").GetValueAsUnsigned())
+self.assertEqual(1, 
frame.GetValueForVariablePath("isp.count").GetValueAsUnsigned())
+self.assertEqual(1, 
frame.GetValueForVariablePath("isp.weak_count").GetValueAsUnsigned())
+self.assertFalse(frame.GetValueForVariablePath("isp.foobar").IsValid())
+
+self.assertNotEqual(0, 
frame.GetValueForVariablePath("ssp.pointer").GetValueAsUnsigned())
+self.assertEqual('"foobar"', 
frame.GetValueForVariablePath("ssp.object").GetSummary())
+self.assertEqual(1, 
frame.GetValueForVariablePath("ssp.count").GetValueAsUnsigned())
+self.assertEqual(1, 
frame.GetValueForVariablePath("ssp.weak_count").GetValueAsUnsigned())
+self.assertFalse(frame.GetValueForVariablePath("ssp.foobar").IsValid())

[Lldb-commits] [lldb] r284829 - Add data formatter for libstdc++ tuple

2016-10-21 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct 21 10:02:38 2016
New Revision: 284829

URL: http://llvm.org/viewvc/llvm-project?rev=284829&view=rev
Log:
Add data formatter for libstdc++ tuple

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile?rev=284829&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
 Fri Oct 21 10:02:38 2016
@@ -0,0 +1,8 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBSTDCPP := 1
+CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS)
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py?rev=284829&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
 Fri Oct 21 10:02:38 2016
@@ -0,0 +1,49 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class StdTupleDataFormatterTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfFreeBSD
+@skipIfWindows  # libstdcpp not ported to Windows
+@skipIfDarwin  # doesn't compile on Darwin
+def test_with_run_command(self):
+self.build()
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_source_regexp(
+self, "Set break point at this line.")
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', 'stop reason = breakpoint'])
+
+frame = self.frame()
+self.assertTrue(frame.IsValid())
+
+self.expect("frame variable ti", substrs=['[0] = 1'])
+self.expect("frame variable ts", substrs=['[0] = "foobar"'])
+self.expect("frame variable tt", substrs=['[0] = 1', '[1] = "baz"', 
'[2] = 2'])
+
+self.assertEqual(1, 
frame.GetValueForVariablePath("ti[0]").GetValueAsUnsigned())
+self.assertFalse(frame.GetValueForVariablePath("ti[1]").IsValid())
+
+self.assertEqual('"foobar"', 
frame.GetValueForVariablePath("ts[0]").GetSummary())
+self.assertFalse(frame.GetValueForVariablePath("ts[1]").IsValid())
+
+self.assertEqual(1, 
frame.GetValueForVariablePath("tt[0]").GetValueAsUnsigned())
+self.assertEqual('"baz"', 
frame.GetValueForVariablePath("tt[1]").GetSummary())
+self.assertEqual(2, 
frame.GetValueForVariablePath("tt[2]").GetValueAsUnsigned())
+self.assertFalse(frame.GetValueForVariablePath("tt[3]").IsValid())

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp?rev=284829&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-for

[Lldb-commits] [lldb] r284830 - Add data formatter for libstdc++ unique_ptr

2016-10-21 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct 21 10:02:44 2016
New Revision: 284830

URL: http://llvm.org/viewvc/llvm-project?rev=284830&view=rev
Log:
Add data formatter for libstdc++ unique_ptr

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile?rev=284830&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
 Fri Oct 21 10:02:44 2016
@@ -0,0 +1,8 @@
+LEVEL = ../../../../../make
+
+CXX_SOURCES := main.cpp
+
+USE_LIBSTDCPP := 1
+CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS)
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py?rev=284830&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 Fri Oct 21 10:02:44 2016
@@ -0,0 +1,61 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+from __future__ import print_function
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class StdUniquePtrDataFormatterTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfFreeBSD
+@skipIfWindows  # libstdcpp not ported to Windows
+@skipIfDarwin  # doesn't compile on Darwin
+def test_with_run_command(self):
+self.build()
+self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_source_regexp(
+self, "Set break point at this line.")
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', 'stop reason = breakpoint'])
+
+frame = self.frame()
+self.assertTrue(frame.IsValid())
+
+self.expect("frame variable nup", substrs=['nup = nullptr'])
+self.expect("frame variable iup", substrs=['iup = 123', 'object = 
123'])
+self.expect("frame variable sup", substrs=['sup = "foobar"', 'object = 
"foobar"'])
+
+self.expect("frame variable ndp", substrs=['ndp = nullptr'])
+self.expect("frame variable idp", substrs=['idp = 456', 'object = 
456', 'deleter = ', 'a = 1', 'b = 2'])
+self.expect("frame variable sdp", substrs=['sdp = "baz"', 'object = 
"baz"', 'deleter = ', 'a = 3', 'b = 4'])
+
+self.assertEqual(123, 
frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
+
self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
+
+self.assertEqual('"foobar"', 
frame.GetValueForVariablePath("sup.object").GetSummary())
+
self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid())
+
+self.assertEqual(456, 
frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned())
+self.assertEqual('"baz"', 
frame.GetValueForVariablePath("sdp.object").GetSummary())
+
+idp_deleter = frame.GetValueForVariablePath("idp.deleter")
+self.assertTrue(idp_deleter.IsValid())
+self.assertEqual(1, 
idp_deleter

[Lldb-commits] [PATCH] D25734: Add data formatter for libstdc++ unique_ptr

2016-10-21 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284830: Add data formatter for libstdc++ unique_ptr 
(authored by tberghammer).

Changed prior to commit:
  https://reviews.llvm.org/D25734?vs=75425&id=75432#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25734

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -803,6 +803,11 @@
 
   AddCXXSynthetic(
   cpp_category_sp,
+  lldb_private::formatters::LibStdcppUniquePtrSyntheticFrontEndCreator,
+  "std::unique_ptr synthetic children",
+  ConstString("^std::unique_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+  AddCXXSynthetic(
+  cpp_category_sp,
   lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
   "std::shared_ptr synthetic children",
   ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
@@ -818,6 +823,11 @@
   stl_synth_flags, true);
 
   AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibStdcppUniquePointerSummaryProvider,
+"libstdc++ std::unique_ptr summary provider",
+ConstString("^std::unique_ptr<.+>(( )?&)?$"), stl_summary_flags,
+true);
+  AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
 "libstdc++ std::shared_ptr summary provider",
 ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_summary_flags,
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -12,4 +12,5 @@
   LibStdcpp.cpp
   LibStdcppSmartPointer.cpp
   LibStdcppTuple.cpp
+  LibStdcppUniquePointer.cpp
 )
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -31,6 +31,10 @@
 const TypeSummaryOptions
 &options); // libstdc++ std::shared_ptr<> and std::weak_ptr<>
 
+bool LibStdcppUniquePointerSummaryProvider(
+ValueObject &valobj, Stream &stream,
+const TypeSummaryOptions &options); // libstdc++ std::unique_ptr<>
+
 SyntheticChildrenFrontEnd *
 LibstdcppMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
  lldb::ValueObjectSP);
@@ -46,6 +50,11 @@
 SyntheticChildrenFrontEnd *
 LibStdcppSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibStdcppUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
+   lldb::ValueObjectSP);
+
 } // namespace formatters
 } // namespace lldb_private
 
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -0,0 +1,160 @@
+//===-- LibStdcppUniquePointer.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+  explicit LibStdcppUniquePtrSynthe

[Lldb-commits] [PATCH] D25726: Improve the libstdc++ smart pointer formatters

2016-10-21 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284828: Improve the libstdc++ smart pointer formatters 
(authored by tberghammer).

Changed prior to commit:
  https://reviews.llvm.org/D25726?vs=75300&id=75431#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25726

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
  lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp

Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -63,21 +63,6 @@
   lldb::ValueObjectSP m_pair_sp;
 };
 
-class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
-public:
-  explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
-
-  size_t CalculateNumChildren() override;
-
-  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
-
-  bool Update() override;
-
-  bool MightHaveChildren() override;
-
-  size_t GetIndexOfChildWithName(const ConstString &name) override;
-};
-
 } // end of anonymous namespace
 
 LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
@@ -351,80 +336,3 @@
   }
   return false;
 }
-
-LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
-lldb::ValueObjectSP valobj_sp)
-: SyntheticChildrenFrontEnd(*valobj_sp) {
-  if (valobj_sp)
-Update();
-}
-
-size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; }
-
-lldb::ValueObjectSP
-LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
-  ValueObjectSP valobj_sp = m_backend.GetSP();
-  if (!valobj_sp)
-return lldb::ValueObjectSP();
-
-  if (idx == 0)
-return valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
-  else
-return lldb::ValueObjectSP();
-}
-
-bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { return false; }
-
-bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
-
-size_t LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
-const ConstString &name) {
-  if (name == ConstString("_M_ptr"))
-return 0;
-  return UINT32_MAX;
-}
-
-SyntheticChildrenFrontEnd *
-lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator(
-CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
-  return (valobj_sp ? new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
-: nullptr);
-}
-
-bool lldb_private::formatters::LibStdcppSmartPointerSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
-  if (!valobj_sp)
-return false;
-
-  ValueObjectSP ptr_sp(
-  valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true));
-  if (!ptr_sp)
-return false;
-
-  ValueObjectSP usecount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("_M_refcount"), ConstString("_M_pi"),
-   ConstString("_M_use_count")}));
-  if (!usecount_sp)
-return false;
-
-  if (ptr_sp->GetValueAsUnsigned(0) == 0 ||
-  usecount_sp->GetValueAsUnsigned(0) == 0) {
-stream.Printf("nullptr");
-return true;
-  }
-
-  Error error;
-  ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
-  if (pointee_sp && error.Success()) {
-if (pointee_sp->DumpPrintableRepresentation(
-stream, ValueObject::eValueObjectRepresentationStyleSummary,
-lldb::eFormatInvalid,
-ValueObject::ePrintableRepresentationSpecialCasesDisable, false)) {
-  return true;
-}
-  }
-
-  stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
-  return true;
-}
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -10,4 +10,5 @@
   LibCxxUnorderedMap.cpp
   LibCxxVector.cpp
   LibStdcpp.cpp
+  LibStdcppSmartPointer.cpp
 )
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppSmartPointer.cpp
@@ -0,0 +1,200 @@
+//===-- LibStdcppSmartPointer.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under 

[Lldb-commits] [PATCH] D25733: Add data formatter for libstdc++ tuple

2016-10-21 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284829: Add data formatter for libstdc++ tuple (authored by 
tberghammer).

Changed prior to commit:
  https://reviews.llvm.org/D25733?vs=75417&id=75433#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25733

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp

Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -811,6 +811,11 @@
   lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
   "std::weak_ptr synthetic children",
   ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+  AddCXXSynthetic(
+  cpp_category_sp,
+  lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator,
+  "std::tuple synthetic children", ConstString("^std::tuple<.+>(( )?&)?$"),
+  stl_synth_flags, true);
 
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -0,0 +1,109 @@
+//===-- LibStdcppTuple.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibStdcpp.h"
+
+#include 
+#include 
+
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+
+class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+  explicit LibStdcppTupleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  size_t CalculateNumChildren() override;
+
+  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+  bool Update() override;
+
+  bool MightHaveChildren() override;
+
+  size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+  std::vector m_members;
+};
+
+} // end of anonymous namespace
+
+LibStdcppTupleSyntheticFrontEnd::LibStdcppTupleSyntheticFrontEnd(
+lldb::ValueObjectSP valobj_sp)
+: SyntheticChildrenFrontEnd(*valobj_sp) {
+  Update();
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::Update() {
+  m_members.clear();
+
+  ValueObjectSP valobj_backend_sp = m_backend.GetSP();
+  if (!valobj_backend_sp)
+return false;
+
+  ValueObjectSP next_child_sp = valobj_backend_sp->GetNonSyntheticValue();
+  while (next_child_sp != nullptr) {
+ValueObjectSP current_child = next_child_sp;
+next_child_sp = nullptr;
+
+size_t child_count = current_child->GetNumChildren();
+for (size_t i = 0; i < child_count; ++i) {
+  ValueObjectSP child_sp = current_child->GetChildAtIndex(i, true);
+  llvm::StringRef name_str = child_sp->GetName().GetStringRef();
+  if (name_str.startswith("std::_Tuple_impl<")) {
+next_child_sp = child_sp;
+  } else if (name_str.startswith("std::_Head_base<")) {
+ValueObjectSP value_sp =
+child_sp->GetChildMemberWithName(ConstString("_M_head_impl"), true);
+if (value_sp) {
+  StreamString name;
+  name.Printf("[%zd]", m_members.size());
+  value_sp->SetName(ConstString(name.GetData()));
+
+  m_members.push_back(value_sp);
+}
+  }
+}
+  }
+
+  return false;
+}
+
+bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+lldb::ValueObjectSP
+LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+  if (idx < m_members.size())
+return m_members[idx];
+  return lldb::ValueObjectSP();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
+  return m_members.size();
+}
+
+size_t LibStdcppTupleSyntheticFrontEnd::GetIndex

[Lldb-commits] [lldb] r284831 - Fix incorrect header order introduced in rL284830

2016-10-21 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct 21 10:05:03 2016
New Revision: 284831

URL: http://llvm.org/viewvc/llvm-project?rev=284831&view=rev
Log:
Fix incorrect header order introduced in rL284830

Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp?rev=284831&r1=284830&r2=284831&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp Fri Oct 21 
10:05:03 2016
@@ -9,14 +9,14 @@
 
 #include "LibStdcpp.h"
 
-#include 
-#include 
-
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
+#include 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;

Modified: 
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=284831&r1=284830&r2=284831&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
(original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Fri 
Oct 21 10:05:03 2016
@@ -9,14 +9,14 @@
 
 #include "LibStdcpp.h"
 
-#include 
-#include 
-
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
+#include 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;


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


[Lldb-commits] [PATCH] D25733: Add data formatter for libstdc++ tuple

2016-10-21 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

Sorry, I missed that part. I just submitted r284831 what should fix the header 
order for both case.


Repository:
  rL LLVM

https://reviews.llvm.org/D25733



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


[Lldb-commits] [PATCH] D25864: Fix arm64 floating point register spill recording in UnwindPlan analysis

2016-10-31 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.
This revision is now accepted and ready to land.

The patch generally looks good to me. I added a few high level thought about 
register context but they are clearly out of scope for this change. Also next 
time please upload your patch with full context as it is much easier to review 
that way.

In https://reviews.llvm.org/D25864#578173, @jasonmolenda wrote:

> Hi Tamas, sorry for not replying earlier, something urgent came up that I 
> needed to look at.
>
> Thanks for the review.  I agree with using your existing arm64 register enums 
> in lldb-arm64-register-enums.h.  I'd like to remove the enums in 
> RegisterInfos_arm64.h instead of having two copies that could diverge.
>
> You asked about having EmulateInstructionARM64 handle both eRegisterKindDWARF 
> and eRegisterKindLLDB.  I'm not sure how that would work - each UnwindPlan 
> must can use only one register numbering scheme.  We could use 
> eRegisterKindDWARF if there were no floating point register save/restores - 
> but that seems a bit complicated; we'd conditionally use eRegisterKindLLDB 
> sometimes, eRegisterKindDWARF most of the time.


My idea is based on the fact that every register access goes through the 
GetRegisterInfo function what gets a "register kind" and a "register number" so 
if we can teach that function to be able to fetch the correct register info 
both for eRegisterKindLLDB and for eRegisterKindDWARF then the actual emulate 
functions can use both. It would mean something like the following, but I don't 
know what should we put in place of the "...":

  if (reg_kind == eRegisterKindLLDB)
return LLDBTableGetRegisterInfo(reg_num, reg_info);
  if (reg_kind == eRegisterKindDwarf)
return ...



> As for the GetRegisterName() function in ARM64_LLDB_Registers.cpp, we could 
> have EmulateInstructionARM64 with the register file definition (we need to 
> define seven preprocessor symbols before we can include RegisterInfos_arm64.h 
> and then we'll need to write a GetRegisterName() method in 
> EmulateInstructionARM64.cpp.  Wouldn't it be clearer to have a 
> lldb-arm64-register-enums.cpp with this method?

RegisterInfos_arm64.h already contains a register name and an alternative name 
so I would prefer to use them as they are already specified but I have no 
problem with having a GetRegisterName() function if we can have a single copy 
of it. My main problem with your previous approach was that you are adding a 
second copy of it (current one is in ARM64_DWARF_Registers.cpp)

Regarding including RegisterInfos_arm64.h I am not too keen on the approach of 
having a large table and defining a set of macros as it is very verbose and 
limits the flexibility (e.g. big/little endian issue we found recently) but I 
haven't come up with a better idea yet.

> I was talking about these register numbering problems with Greg Clayton and 
> he half-jokingly said we should switch from register numbers to using 
> ConstString register names in the UnwindPlans.  It's not a bad idea!  As long 
> as everyone can agree on the register names for an architecture, anyway.

Personally I really don't like ConstString because of the global pool behind it 
(kind of leaks memory) so I think having some sort of register number is 
better. I think a betetr approach would be to agree that inside LLDB everything 
should use eRegisterKindLLDB and we do the register number translation at the 
communication boundaries (gdb-remote communication, eh_frame parsing, dwarf 
reading)


Repository:
  rL LLVM

https://reviews.llvm.org/D25864



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


[Lldb-commits] [PATCH] D26295: Change UnwindAssemblyInstEmulation to remove a register location instead of marking it as IsSame()

2016-11-04 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

My understanding (can be wrong) is that there IS a difference between not 
specifying a register in the unwind info versus specifying it as "is same" for 
volatile (caller saved) registers. I think for volatile registers not 
specifying them means that we can't access their current value in the parent 
frame (because they are lost) while specifying them as "is same" means we know 
that their value in the parent frame is the same as in the current one so we 
can display them.

If "is same" and "not specified" would be equivalent then we should just 
completely get rid of the "is same" case (as it is useless) but as far as I 
know they have subtle differences.


Repository:
  rL LLVM

https://reviews.llvm.org/D26295



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


Re: [Lldb-commits] [PATCH] D26338: [lldb] Don't build unit tests for unsupported targets

2016-11-07 Thread Tamas Berghammer via lldb-commits
The problem is that if we reuse the LLVM disassembler (I am not sure if we
do it in TestArm64InstEmulation or not but we definitely should) then we
need LLVM to be build with support for that specific architecture as
otherwise the assembly analysis based unwinding test won't work.

On Mon, Nov 7, 2016 at 4:21 PM Zachary Turner via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Why not? Just because llvm isn't building support for targeting some
> architecture doesn't mean lldb shouldn't be able to debug those
> architectures. We could add a similar LLDB specific define, but using
> llvm's seems wrong
> On Sun, Nov 6, 2016 at 6:13 PM Vedant Kumar via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
> vsk created this revision.
> vsk added a reviewer: jasonmolenda.
> vsk added a subscriber: lldb-commits.
> Herald added a subscriber: mgorny.
>
> Should fix: https://llvm.org/bugs/show_bug.cgi?id=30928
>
>
> https://reviews.llvm.org/D26338
>
> Files:
>   unittests/UnwindAssembly/CMakeLists.txt
>   unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
>
>
> Index: unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
> ===
> --- unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
> +++ unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
> @@ -1 +1,3 @@
> -add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
> +if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
> +  add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
> +endif()
> Index: unittests/UnwindAssembly/CMakeLists.txt
> ===
> --- unittests/UnwindAssembly/CMakeLists.txt
> +++ unittests/UnwindAssembly/CMakeLists.txt
> @@ -1,2 +1,5 @@
> -add_subdirectory(x86)
> +if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
> +  add_subdirectory(x86)
> +endif()
> +
>  add_subdirectory(InstEmulation)
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D26295: Change UnwindAssemblyInstEmulation to remove a register location instead of marking it as IsSame()

2016-11-08 Thread Tamas Berghammer via lldb-commits
I think the UnwindAssemblyInstEmulation tracks every register without
knowing if it is volatile or not and then RegisterContextLLDB will consult
with the ABI (during RegisterRead) to decide which registers can it recover
(based on volatile/non-volatile). For x86 I think the long term solution
would be to migrate it over to UnwindAssemblyInstEmulation instead of the
custom code what should solve the issue you mentioned.

Regarding IsSame I think it would be a useful thing if we can somehow
differentiate between a volatile register can be overwritten by something
(e.g. a call) or we know that it can be recovered using a specific rule.
Once I hit an issue on aarch64 that a hand written assembly function inside
the "[vdso]" used a volatile register in its (hand written) eh_frame as the
author know that it isn't clobbered but LLDB failed to unwind as it said
the register is volatile. My view is that making the dumps easier to read
is a very small gain (only help people working on the unwinder) so I don't
want to change the logic just for that but if IsSame and being unspecified
are equivalent then getting rid of IsSame would be a nice code
simplification.

On Fri, Nov 4, 2016 at 10:41 PM Jason Molenda  wrote:

> jasonmolenda added a comment.
>
> Ah, interesting point, I didn't think of that.  However, this touches on
> another thing I've been thinking about as I look at the assembly inspection
> unwind plan generators.  In the x86 unwind inspector, I've hardcoded the
> SysV-x86_64 ABI and the unwind plan generator ignores any saves/restores of
> volatile registers.  It's a poor choice and it's the kind of thing that
> surely won't be correct when a Windows port is up & running.
>
> I'm thinking the unwind plan generators should treat all registers as
> non-volatile.  When UnwindLLDB / RegisterContextLLDB run the UnwindPlan,
> they can ask the ABI if a register is volatile or not - and refuse to
> retrieve a volatile register for a stack frame in the middle of the stack.
> (it SHOULD be doing that already)
>
> The problem with tracking a register that is volatile is that as soon as
> the function makes a call into another function, we have to assume the
> register value is overwritten.  So if we have
>
>   0xfff021f7bd80 <+0>:stpx28, x27, [sp, #-0x60]!
>   0xfff021f7bd84 <+4>:stpx26, x25, [sp, #0x10]
>   0xfff021f7bd88 <+8>:stpx24, x23, [sp, #0x20]
>   0xfff021f7bd8c <+12>:   stpx22, x21, [sp, #0x30]
>   0xfff021f7bd90 <+16>:   stpx20, x19, [sp, #0x40]
>   0xfff021f7bd94 <+20>:   stpx29, x30, [sp, #0x50]
>   0xfff021f7bd98 <+24>:   addx29, sp, #0x50; =0x50
>   0xfff021f7bd9c <+28>:   subsp, sp, #0xe0 ; =0xe0
>   0xfff021f7bdd4 <+84>:   bl 0xfff021f8af70
>
>   0xfff021f7c334 <+1460>: strw9, [sp, #0x60]
>
> x9 is volatile in the AAPCS64 ABI, so at this offset in the assembly the
> value has already been overwritten by the call instruction at +84.  If I
> later see a load of x9 and mark the register as "IsSame", now we've got a
> problem because we're saying it has the original value.
>
> If we were going to follow the IsSame-means-unmodified thinking through,
> we'd want to mark every register as IsSame on function entry and only
> remove that markup when the register is modified.
>
> I guess I'm trying to say two things.  (1) I'd really like to get rid of
> IsSame so that the unwind plan dumps are easier for me to read ;) and (2) I
> think the instruction profiler unwind plan generators should track all
> registers without knowledge of the ABI, and leave it to the runtime code to
> decide which registers we will allow to be looked up.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26295
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r286360 - Fix expectation in TestStaticVariables.py after rL286302

2016-11-09 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Nov  9 05:52:12 2016
New Revision: 286360

URL: http://llvm.org/viewvc/llvm-project?rev=286360&view=rev
Log:
Fix expectation in TestStaticVariables.py after rL286302

The debug info emitted by clang for static variables improved by
rL286302 and it exposed an incorrect test expactation because now LLDB
able to displays more data 9thanks to better debug info) then before.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py?rev=286360&r1=286359&r2=286360&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py
 Wed Nov  9 05:52:12 2016
@@ -44,7 +44,7 @@ class StaticVariableTestCase(TestBase):
 self.expect(
 'target variable A::g_points',
 VARIABLES_DISPLAYED_CORRECTLY,
-patterns=['\(PointType \[[1-9]*\]\) A::g_points = {.*}'])
+patterns=['\(PointType \[[1-9]*\]\) A::g_points = {'])
 self.expect('target variable g_points', VARIABLES_DISPLAYED_CORRECTLY,
 substrs=['(PointType [2]) g_points'])
 


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


[Lldb-commits] [lldb] r286581 - Fix TestHelp on linux after version number syntax change

2016-11-11 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Nov 11 05:39:23 2016
New Revision: 286581

URL: http://llvm.org/viewvc/llvm-project?rev=286581&view=rev
Log:
Fix TestHelp on linux after version number syntax change

Modified:
lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py?rev=286581&r1=286580&r2=286581&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py Fri Nov 11 
05:39:23 2016
@@ -94,7 +94,7 @@ class HelpCommandTestCase(TestBase):
 if sys.platform.startswith("darwin"):
 search_regexp = ['lldb-' + (version_str if match else '[0-9]+')]
 else:
-search_regexp = ['lldb version (\d|\.)+.*$']
+search_regexp = ['lldb version (\d|\.)+.*\n']
 
 self.expect("version",
 patterns=search_regexp)


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


[Lldb-commits] [lldb] r290895 - Improve the performance of jModulesInfo in lldb-server

2017-01-03 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Jan  3 10:29:43 2017
New Revision: 290895

URL: http://llvm.org/viewvc/llvm-project?rev=290895&view=rev
Log:
Improve the performance of jModulesInfo in lldb-server

Previously it parsed /proc//maps for every module separately
resulting in a very slow response time. This CL add some caching and
optimizes the implementation to improve the code from O(n*m) to O(n+m)
where n is the number of modules requested and m is the number of
files mapped into memory.

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

Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=290895&r1=290894&r2=290895&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Tue Jan  3 
10:29:43 2017
@@ -1689,68 +1689,14 @@ Error NativeProcessLinux::GetMemoryRegio
   // Assume proc maps entries are in ascending order.
   // FIXME assert if we find differently.
 
-  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-  Error error;
-
   if (m_supports_mem_region == LazyBool::eLazyBoolNo) {
 // We're done.
-error.SetErrorString("unsupported");
-return error;
+return Error("unsupported");
   }
 
-  // If our cache is empty, pull the latest.  There should always be at least
-  // one memory region
-  // if memory region handling is supported.
-  if (m_mem_region_cache.empty()) {
-error = ProcFileReader::ProcessLineByLine(
-GetID(), "maps", [&](const std::string &line) -> bool {
-  MemoryRegionInfo info;
-  const Error parse_error =
-  ParseMemoryRegionInfoFromProcMapsLine(line, info);
-  if (parse_error.Success()) {
-m_mem_region_cache.push_back(info);
-return true;
-  } else {
-if (log)
-  log->Printf("NativeProcessLinux::%s failed to parse proc maps "
-  "line '%s': %s",
-  __FUNCTION__, line.c_str(), error.AsCString());
-return false;
-  }
-});
-
-// If we had an error, we'll mark unsupported.
-if (error.Fail()) {
-  m_supports_mem_region = LazyBool::eLazyBoolNo;
-  return error;
-} else if (m_mem_region_cache.empty()) {
-  // No entries after attempting to read them.  This shouldn't happen if
-  // /proc/{pid}/maps
-  // is supported.  Assume we don't support map entries via procfs.
-  if (log)
-log->Printf("NativeProcessLinux::%s failed to find any procfs maps "
-"entries, assuming no support for memory region metadata "
-"retrieval",
-__FUNCTION__);
-  m_supports_mem_region = LazyBool::eLazyBoolNo;
-  error.SetErrorString("not supported");
-  return error;
-}
-
-if (log)
-  log->Printf("NativeProcessLinux::%s read %" PRIu64
-  " memory region entries from /proc/%" PRIu64 "/maps",
-  __FUNCTION__,
-  static_cast(m_mem_region_cache.size()), GetID());
-
-// We support memory retrieval, remember that.
-m_supports_mem_region = LazyBool::eLazyBoolYes;
-  } else {
-if (log)
-  log->Printf("NativeProcessLinux::%s reusing %" PRIu64
-  " cached memory region entries",
-  __FUNCTION__,
-  static_cast(m_mem_region_cache.size()));
+  Error error = PopulateMemoryRegionCache();
+  if (error.Fail()) {
+return error;
   }
 
   lldb::addr_t prev_base_address = 0;
@@ -1760,7 +1706,7 @@ Error NativeProcessLinux::GetMemoryRegio
   // There can be a ton of regions on pthreads apps with lots of threads.
   for (auto it = m_mem_region_cache.begin(); it != m_mem_region_cache.end();
++it) {
-MemoryRegionInfo &proc_entry_info = *it;
+MemoryRegionInfo &proc_entry_info = it->first;
 
 // Sanity check assumption that /proc/{pid}/maps entries are ascending.
 assert((proc_entry_info.GetRange().GetRangeBase() >= prev_base_address) &&
@@ -1803,6 +1749,67 @@ Error NativeProcessLinux::GetMemoryRegio
   return error;
 }
 
+Error NativeProcessLinux::PopulateMemoryRegionCache() {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  // If our cache is empty, pull the latest.  There should always be at least
+  // one memory region if memory region handling is supported.
+  if (!m_mem_region_cache.empty()) {
+if (log)
+  log->Printf("NativeProcessLinux::%s reusing %" PRIu64
+  " cached memory region entries",
+  __FUNCTION__,
+  static_cast(m_mem_region_cache.size()));
+retu

[Lldb-commits] [lldb] r291349 - Remove an incorrect byte size calculation in DWARFASTParserClang

2017-01-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Sat Jan  7 10:39:02 2017
New Revision: 291349

URL: http://llvm.org/viewvc/llvm-project?rev=291349&view=rev
Log:
Remove an incorrect byte size calculation in DWARFASTParserClang

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=291349&r1=291348&r2=291349&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Sat Jan  
7 10:39:02 2017
@@ -2647,7 +2647,7 @@ bool DWARFASTParserClang::ParseChildMemb
 
   // Get the parent byte size so we can verify any members will fit
   const uint64_t parent_byte_size =
-  parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX) * 8;
+  parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
   const uint64_t parent_bit_size =
   parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
 


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


[Lldb-commits] [lldb] r291350 - Fix dereferencing of pointers to empty classes

2017-01-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Sat Jan  7 10:39:07 2017
New Revision: 291350

URL: http://llvm.org/viewvc/llvm-project?rev=291350&view=rev
Log:
Fix dereferencing of pointers to empty classes

Added:
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/

lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/Makefile

lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp
Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/Makefile?rev=291350&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/Makefile 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/Makefile 
Sat Jan  7 10:39:07 2017
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py?rev=291350&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py
 Sat Jan  7 10:39:07 2017
@@ -0,0 +1,60 @@
+from __future__ import print_function
+
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ValueAPIEmptyClassTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(['pyapi'])
+def test(self):
+self.build()
+exe = os.path.join(os.getcwd(), 'a.out')
+line = line_number('main.cpp', '// Break at this line')
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Create the breakpoint inside function 'main'.
+breakpoint = target.BreakpointCreateByLocation('main.cpp', line)
+self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+# Now launch the process, and do not stop at entry point.
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Get Frame #0.
+self.assertTrue(process.GetState() == lldb.eStateStopped)
+thread = lldbutil.get_stopped_thread(
+process, lldb.eStopReasonBreakpoint)
+self.assertTrue(
+thread.IsValid(),
+"There should be a thread stopped due to breakpoint condition")
+frame0 = thread.GetFrameAtIndex(0)
+
+# Verify that we can access to a frame variable with an empty class 
type
+e = frame0.FindVariable('e')
+self.assertTrue(e.IsValid(), VALID_VARIABLE)
+self.DebugSBValue(e)
+self.assertEqual(e.GetNumChildren(), 0)
+
+# Verify that we can acces to a frame variable what is a pointer to an
+# empty class
+ep = frame0.FindVariable('ep')
+self.assertTrue(ep.IsValid(), VALID_VARIABLE)
+self.DebugSBValue(ep)
+
+# Verify that we can dereference a pointer to an empty class
+epd = ep.Dereference()
+self.assertTrue(epd.IsValid(), VALID_VARIABLE)
+self.DebugSBValue(epd)
+self.assertEqual(epd.GetNumChildren(), 0)
+

Added: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp?rev=291350&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp 
Sat Jan  7 10:39:07 2017
@@ -0,0 +1,16 @@
+//===-- main.cpp *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+class Empty {};
+
+int main (int argc, char const *argv[]) {
+  Empty e;
+  Empty* ep = new Empty;
+  return 0; // Break at this line
+}

Modifie

[Lldb-commits] [lldb] r291559 - Improve Type::GetTypeScopeAndBasenameHelper and add unit tests

2017-01-10 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Jan 10 05:13:59 2017
New Revision: 291559

URL: http://llvm.org/viewvc/llvm-project?rev=291559&view=rev
Log:
Improve Type::GetTypeScopeAndBasenameHelper and add unit tests

Previously it failed to handle nested types inside templated classes
making it impossible to look up these types using the fully qualified
name.

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

Added:
lldb/trunk/unittests/Symbol/TestType.cpp
Modified:
lldb/trunk/include/lldb/Symbol/Type.h
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Symbol/Type.cpp
lldb/trunk/source/Symbol/TypeList.cpp
lldb/trunk/source/Symbol/TypeMap.cpp
lldb/trunk/unittests/Symbol/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=291559&r1=291558&r2=291559&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Tue Jan 10 05:13:59 2017
@@ -201,8 +201,9 @@ public:
 
   // From a fully qualified typename, split the type into the type basename
   // and the remaining type scope (namespaces/classes).
-  static bool GetTypeScopeAndBasename(const char *&name_cstr,
-  std::string &scope, std::string 
&basename,
+  static bool GetTypeScopeAndBasename(const llvm::StringRef& name,
+  llvm::StringRef &scope,
+  llvm::StringRef &basename,
   lldb::TypeClass &type_class);
   void SetEncodingType(Type *encoding_type) { m_encoding_type = encoding_type; 
}
 

Modified: lldb/trunk/source/Core/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=291559&r1=291558&r2=291559&view=diff
==
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Tue Jan 10 05:13:59 2017
@@ -995,8 +995,8 @@ size_t Module::FindTypes(
 TypeList &types) {
   size_t num_matches = 0;
   const char *type_name_cstr = name.GetCString();
-  std::string type_scope;
-  std::string type_basename;
+  llvm::StringRef type_scope;
+  llvm::StringRef type_basename;
   const bool append = true;
   TypeClass type_class = eTypeClassAny;
   TypeMap typesmap;
@@ -1006,13 +1006,9 @@ size_t Module::FindTypes(
 // from the root namespace and implies and exact match. The typenames we
 // get back from clang do not start with "::" so we need to strip this off
 // in order to get the qualified names to match
+exact_match = type_scope.consume_front("::");
 
-if (type_scope.size() >= 2 && type_scope[0] == ':' &&
-type_scope[1] == ':') {
-  type_scope.erase(0, 2);
-  exact_match = true;
-}
-ConstString type_basename_const_str(type_basename.c_str());
+ConstString type_basename_const_str(type_basename);
 if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append,
max_matches, searched_symbol_files, typesmap)) {
   typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=291559&r1=291558&r2=291559&view=diff
==
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Jan 10 05:13:59 2017
@@ -620,50 +620,59 @@ ConstString Type::GetQualifiedName() {
   return GetForwardCompilerType().GetConstTypeName();
 }
 
-bool Type::GetTypeScopeAndBasename(const char *&name_cstr, std::string &scope,
-   std::string &basename,
+bool Type::GetTypeScopeAndBasename(const llvm::StringRef& name,
+   llvm::StringRef &scope,
+   llvm::StringRef &basename,
TypeClass &type_class) {
-  // Protect against null c string.
-
   type_class = eTypeClassAny;
 
-  if (name_cstr && name_cstr[0]) {
-llvm::StringRef name_strref(name_cstr);
-if (name_strref.startswith("struct ")) {
-  name_cstr += 7;
-  type_class = eTypeClassStruct;
-} else if (name_strref.startswith("class ")) {
-  name_cstr += 6;
-  type_class = eTypeClassClass;
-} else if (name_strref.startswith("union ")) {
-  name_cstr += 6;
-  type_class = eTypeClassUnion;
-} else if (name_strref.startswith("enum ")) {
-  name_cstr += 5;
-  type_class = eTypeClassEnumeration;
-} else if (name_strref.startswith("typedef ")) {
-  name_cstr += 8;
-  type_class = eTypeClassTypedef;
-}
-const char *basename_cstr = name_cstr;
-const char *namespace_separator = ::strstr(basename_cstr, "::");
-if (namespace_separator

Re: [Lldb-commits] [PATCH] D30251: Map ELF files as writable so we can update the relocations in them

2017-02-22 Thread Tamas Berghammer via lldb-commits
Sure, it isn't urgent at all. I created this as a resolution for the crash
reported by Ramana (
http://lists.llvm.org/pipermail/lldb-dev/2017-February/012001.html) but I
don't fully understand the use case he/she is working on when wanting to
open a ".o" file yet (but I still wanted to get rid of an LLDB crash).

Tamas

On Wed, Feb 22, 2017 at 3:03 PM Zachary Turner  wrote:

Yea if this isn't urgent, can we wait for my other changes to go in?

Llvm does support mapping writable, but not through the same interface. So
it should still work
On Wed, Feb 22, 2017 at 6:43 AM Pavel Labath via Phabricator <
revi...@reviews.llvm.org> wrote:

labath added a reviewer: zturner.
labath added a comment.

Adding Zachary as he was about to remove this code.

The timing of this patch is a bit unfortunate, as it would complicate the
removal of the code in question. If I am not mistaken, llvm's version
currently does not support copy-on-write mappings, which is what we are
trying to do here. The c-o-w could certainly be added there, and we will
probably need to do it in the future, but I am not sure whether this is the
right time for it. I don't want to impede Zachary's cleanup effort due to a
"feature" that noone has serious commitment of supporting.


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


[Lldb-commits] [PATCH] D13288: Restrict the scope of a hack in DYLDRendezvous

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added a reviewer: labath.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

Restrict the scope of a hack in DYLDRendezvous

The hack is there to work around an incorrect load address reported
by the android linker on API 21 and 22 devices. This CL restricts the
hack to those android API levels.

http://reviews.llvm.org/D13288

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  source/Plugins/Platform/Android/PlatformAndroid.cpp
  source/Plugins/Platform/Android/PlatformAndroid.h

Index: source/Plugins/Platform/Android/PlatformAndroid.h
===
--- source/Plugins/Platform/Android/PlatformAndroid.h
+++ source/Plugins/Platform/Android/PlatformAndroid.h
@@ -76,7 +76,10 @@
 
 uint32_t
 GetSdkVersion();
-
+
+bool
+GetRemoteOSVersion() override;
+
 Error
 DisconnectRemote () override;
 
Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -362,3 +362,12 @@
 // Download the symbolfile from the remote device
 return GetFile(symfile_platform_filespec, dst_file_spec);
 }
+
+bool
+PlatformAndroid::GetRemoteOSVersion ()
+{
+m_major_os_version = GetSdkVersion();
+m_minor_os_version = 0;
+m_update_os_version = 0;
+return m_major_os_version != 0;
+}
Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===
--- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -413,10 +414,13 @@
 std::string file_path = ReadStringFromMemory(entry.path_addr);
 entry.file_spec.SetFile(file_path, false);
 
-// On Android L (5.0, 5.1) the load address of the "/system/bin/linker" 
isn't filled in
+// On Android L (API 21, 22) the load address of the "/system/bin/linker" 
isn't filled in
 // correctly. To get the correct load address we fetch the load address of 
the file from the
 // proc file system.
-if (arch.GetTriple().getEnvironment() == llvm::Triple::Android && 
entry.base_addr == 0 &&
+uint32_t os_major = 0, os_minor = 0, os_update = 0;
+if (arch.GetTriple().getEnvironment() == llvm::Triple::Android &&
+m_process->GetTarget().GetPlatform()->GetOSVersion(os_major, os_minor, 
os_update) &&
+(os_major == 21 || os_major == 22) &&
 (file_path == "/system/bin/linker" || file_path == 
"/system/bin/linker64"))
 {
 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;


Index: source/Plugins/Platform/Android/PlatformAndroid.h
===
--- source/Plugins/Platform/Android/PlatformAndroid.h
+++ source/Plugins/Platform/Android/PlatformAndroid.h
@@ -76,7 +76,10 @@
 
 uint32_t
 GetSdkVersion();
-
+
+bool
+GetRemoteOSVersion() override;
+
 Error
 DisconnectRemote () override;
 
Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -362,3 +362,12 @@
 // Download the symbolfile from the remote device
 return GetFile(symfile_platform_filespec, dst_file_spec);
 }
+
+bool
+PlatformAndroid::GetRemoteOSVersion ()
+{
+m_major_os_version = GetSdkVersion();
+m_minor_os_version = 0;
+m_update_os_version = 0;
+return m_major_os_version != 0;
+}
Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===
--- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -413,10 +414,13 @@
 std::string file_path = ReadStringFromMemory(entry.path_addr);
 entry.file_spec.SetFile(file_path, false);
 
-// On Android L (5.0, 5.1) the load address of the "/system/bin/linker" isn't filled in
+// On Android L (API 21, 22) the load address of the "/system/bin/linker" isn't filled in
 // correctly. To get the correct load address we fetch the load address of the file from the
  

[Lldb-commits] [lldb] r248901 - XFAIL 2 test in TestTargetCommands on android-aarch64

2015-09-30 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Sep 30 08:42:06 2015
New Revision: 248901

URL: http://llvm.org/viewvc/llvm-project?rev=248901&view=rev
Log:
XFAIL 2 test in TestTargetCommands on android-aarch64

The 2 test just get enabled with the recemt test system refactor.

Modified:
lldb/trunk/test/functionalities/target_command/TestTargetCommand.py

Modified: lldb/trunk/test/functionalities/target_command/TestTargetCommand.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/target_command/TestTargetCommand.py?rev=248901&r1=248900&r2=248901&view=diff
==
--- lldb/trunk/test/functionalities/target_command/TestTargetCommand.py 
(original)
+++ lldb/trunk/test/functionalities/target_command/TestTargetCommand.py Wed Sep 
30 08:42:06 2015
@@ -37,6 +37,7 @@ class targetCommandTestCase(TestBase):
 
 # rdar://problem/9763907
 # 'target variable' command fails if the target program has been run
+@expectedFailureAndroid(archs=['aarch64'])
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': 'globals'}
@@ -45,6 +46,7 @@ class targetCommandTestCase(TestBase):
 
 self.do_target_variable_command('globals')
 
+@expectedFailureAndroid(archs=['aarch64'])
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': 'globals'}


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


Re: [Lldb-commits] [PATCH] D13245: Add support for .ARM.exidx unwind information

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer marked an inline comment as done.


Comment at: source/Symbol/ArmUnwindInfo.cpp:62
@@ +61,3 @@
+static uint64_t
+GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset)
+{

labath wrote:
> Is there a reason DataExtractor::GetULEB128 could not be reused?
DataExtractor is reading from a stream of bytes while the arm unwind info is 
encoded in a bit more complicated (and strange way). It is encoded as a list of 
4 byte words and then the 1 byte values have to be read from it from the MSB 
byte to the LSB byte what isn't match with the order used by the DataExtractor.


http://reviews.llvm.org/D13245



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


[Lldb-commits] [lldb] r248903 - Add support for .ARM.exidx unwind information

2015-09-30 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Sep 30 08:50:14 2015
New Revision: 248903

URL: http://llvm.org/viewvc/llvm-project?rev=248903&view=rev
Log:
Add support for .ARM.exidx unwind information

.ARM.exidx/.ARM.extab sections contain unwind information used on ARM
architecture from unwinding from an exception.

Differential revision: http://reviews.llvm.org/D13245

Added:
lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
Modified:
lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
lldb/trunk/include/lldb/Symbol/UnwindTable.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Symbol/CMakeLists.txt
lldb/trunk/source/Symbol/FuncUnwinders.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp
lldb/trunk/source/Utility/ConvertEnum.cpp

Added: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h?rev=248903&view=auto
==
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h (added)
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h Wed Sep 30 08:50:14 2015
@@ -0,0 +1,55 @@
+//===-- ArmUnwindInfo.h -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ArmUnwindInfo_h_
+#define liblldb_ArmUnwindInfo_h_
+
+#include 
+
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RangeMap.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/lldb-private.h"
+
+/*
+ * Unwind information reader and parser for the ARM exception handling ABI
+ *
+ * Implemented based on:
+ * Exception Handling ABI for the ARM Architecture
+ * Document number: ARM IHI 0038A (current through ABI r2.09)
+ * Date of Issue: 25th January 2007, reissued 30th November 2012
+ * 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf
+ */
+
+namespace lldb_private {
+
+class ArmUnwindInfo
+{
+public:
+ArmUnwindInfo (ObjectFile& objfile, lldb::SectionSP& arm_exidx, 
lldb::SectionSP& arm_extab);
+~ArmUnwindInfo();
+
+bool
+GetUnwindPlan (Target &target, const Address& addr, UnwindPlan& 
unwind_plan);
+
+private:
+const uint8_t*
+GetExceptionHandlingTableEntry(const Address& addr);
+
+lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
+lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
+
+DataExtractor m_arm_exidx_data; // .ARM.exidx section data
+DataExtractor m_arm_extab_data; // .ARM.extab section data
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_ArmUnwindInfo_h_

Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=248903&r1=248902&r2=248903&view=diff
==
--- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original)
+++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Wed Sep 30 08:50:14 2015
@@ -103,6 +103,9 @@ public:
 GetCompactUnwindUnwindPlan (Target &target, int current_offset);
 
 lldb::UnwindPlanSP
+GetArmUnwindUnwindPlan (Target &target, int current_offset);
+
+lldb::UnwindPlanSP
 GetArchDefaultUnwindPlan (Thread &thread);
 
 lldb::UnwindPlanSP
@@ -122,6 +125,7 @@ private:
 lldb::UnwindPlanSP  m_unwind_plan_eh_frame_sp;
 lldb::UnwindPlanSP  m_unwind_plan_eh_frame_augmented_sp;   // 
augmented by assembly inspection so it's valid everywhere
 std::vector m_unwind_plan_compact_unwind;
+lldb::UnwindPlanSP  m_unwind_plan_arm_unwind_sp;
 lldb::UnwindPlanSP  m_unwind_plan_fast_sp;
 lldb::UnwindPlanSP  m_unwind_plan_arch_default_sp;
 lldb::UnwindPlanSP  
m_unwind_plan_arch_default_at_func_entry_sp;
@@ -132,6 +136,7 @@ private:
  m_tried_unwind_plan_eh_frame:1,
  m_tried_unwind_plan_eh_frame_augmented:1,
  m_tried_unwind_plan_compact_unwind:1,
+ m_tried_unwind_plan_arm_unwind:1,
  m_tried_unwind_fast:1,
  m_tried_unwind_arch_default:1,
  m_tried_unwind_arch_default_at_func_entry:1;

Modified: lldb/trunk/include/lldb/Symbol/UnwindTable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindTable.h?rev=248903&r1=24890

Re: [Lldb-commits] [PATCH] D13245: Add support for .ARM.exidx unwind information

2015-09-30 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248903: Add support for .ARM.exidx unwind information 
(authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13245?vs=35970&id=36101#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13245

Files:
  lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
  lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
  lldb/trunk/include/lldb/Symbol/UnwindTable.h
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
  lldb/trunk/source/Symbol/CMakeLists.txt
  lldb/trunk/source/Symbol/FuncUnwinders.cpp
  lldb/trunk/source/Symbol/ObjectFile.cpp
  lldb/trunk/source/Symbol/UnwindTable.cpp
  lldb/trunk/source/Utility/ConvertEnum.cpp

Index: lldb/trunk/include/lldb/lldb-enumerations.h
===
--- lldb/trunk/include/lldb/lldb-enumerations.h
+++ lldb/trunk/include/lldb/lldb-enumerations.h
@@ -616,6 +616,8 @@
 eSectionTypeELFRelocationEntries, // Elf SHT_REL or SHT_REL section
 eSectionTypeELFDynamicLinkInfo,   // Elf SHT_DYNAMIC section
 eSectionTypeEHFrame,
+eSectionTypeARMexidx,
+eSectionTypeARMextab,
 eSectionTypeCompactUnwind,// compact unwind section in Mach-O, __TEXT,__unwind_info
 eSectionTypeGoSymtab,
 eSectionTypeOther
Index: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
===
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
@@ -0,0 +1,55 @@
+//===-- ArmUnwindInfo.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_ArmUnwindInfo_h_
+#define liblldb_ArmUnwindInfo_h_
+
+#include 
+
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RangeMap.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/lldb-private.h"
+
+/*
+ * Unwind information reader and parser for the ARM exception handling ABI
+ *
+ * Implemented based on:
+ * Exception Handling ABI for the ARM Architecture
+ * Document number: ARM IHI 0038A (current through ABI r2.09)
+ * Date of Issue: 25th January 2007, reissued 30th November 2012
+ * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf
+ */
+
+namespace lldb_private {
+
+class ArmUnwindInfo
+{
+public:
+ArmUnwindInfo (ObjectFile& objfile, lldb::SectionSP& arm_exidx, lldb::SectionSP& arm_extab);
+~ArmUnwindInfo();
+
+bool
+GetUnwindPlan (Target &target, const Address& addr, UnwindPlan& unwind_plan);
+
+private:
+const uint8_t*
+GetExceptionHandlingTableEntry(const Address& addr);
+
+lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
+lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
+
+DataExtractor m_arm_exidx_data; // .ARM.exidx section data
+DataExtractor m_arm_extab_data; // .ARM.extab section data
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_ArmUnwindInfo_h_
Index: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
===
--- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
+++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
@@ -103,6 +103,9 @@
 GetCompactUnwindUnwindPlan (Target &target, int current_offset);
 
 lldb::UnwindPlanSP
+GetArmUnwindUnwindPlan (Target &target, int current_offset);
+
+lldb::UnwindPlanSP
 GetArchDefaultUnwindPlan (Thread &thread);
 
 lldb::UnwindPlanSP
@@ -122,6 +125,7 @@
 lldb::UnwindPlanSP  m_unwind_plan_eh_frame_sp;
 lldb::UnwindPlanSP  m_unwind_plan_eh_frame_augmented_sp;   // augmented by assembly inspection so it's valid everywhere
 std::vector m_unwind_plan_compact_unwind;
+lldb::UnwindPlanSP  m_unwind_plan_arm_unwind_sp;
 lldb::UnwindPlanSP  m_unwind_plan_fast_sp;
 lldb::UnwindPlanSP  m_unwind_plan_arch_default_sp;
 lldb::UnwindPlanSP  m_unwind_plan_arch_default_at_func_entry_sp;
@@ -132,6 +136,7 @@
  m_tried_unwind_plan_eh_frame:1,
  m_tried_unwind_plan_eh_frame_augmented:1,
  m_tried_unwind_plan_compact_unwind:1,
+ m_tried_unwind_plan_arm_unwind:1,
  m_tried_unwind_fast:1,
  m_tried_unwind_arch_default:1,
  m_tried_unwind_arch_default_

[Lldb-commits] [PATCH] D13291: Make the ArmUnwindInfo parsing code endian independent

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added a reviewer: labath.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: rengolin, aemerson.

Make the ArmUnwindInfo parsing code endian independent

http://reviews.llvm.org/D13291

Files:
  include/lldb/Symbol/ArmUnwindInfo.h
  source/Symbol/ArmUnwindInfo.cpp

Index: source/Symbol/ArmUnwindInfo.cpp
===
--- source/Symbol/ArmUnwindInfo.cpp
+++ source/Symbol/ArmUnwindInfo.cpp
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ArmUnwindInfo.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/UnwindPlan.h"
@@ -38,7 +39,10 @@
 };
 };
 
-ArmUnwindInfo::ArmUnwindInfo(ObjectFile& objfile, SectionSP& arm_exidx, SectionSP& arm_extab) :
+ArmUnwindInfo::ArmUnwindInfo(const ObjectFile& objfile,
+ SectionSP& arm_exidx,
+ SectionSP& arm_extab) :
+m_objfile(objfile),
 m_arm_exidx_sp(arm_exidx),
 m_arm_extab_sp(arm_extab)
 {
@@ -50,22 +54,26 @@
 {
 }
 
-static uint8_t
-GetNextByte(const uint32_t* data, uint16_t offset)
+// Read a byte from the unwind instruction stream with the given offset.
+// Custome function is required because have to red in order of significance within their containing
+// word (most significant byte first) and in increasing word address order.
+uint8_t
+ArmUnwindInfo::GetByteAtOffset(const uint32_t* data, uint16_t offset) const
 {
-data += offset / 4;
-offset = offset % 4;
-return (data[0] >> ((3 - offset) * 8)) & 0xff;
+uint32_t value = data[offset / 4];
+if (m_objfile.GetByteOrder() != endian::InlHostByteOrder())
+value = llvm::ByteSwap_32(value);
+return (data[0] >> ((3 - (offset % 4)) * 8)) & 0xff;
 }
 
-static uint64_t
-GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset)
+uint64_t
+ArmUnwindInfo::GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) const
 {
 uint64_t result = 0;
 uint8_t shift = 0;
 while (offset < max_offset)
 {
-uint8_t byte = GetNextByte(data, offset++);
+uint8_t byte = GetByteAtOffset(data, offset++);
 result |= (byte & 0x7f) << shift;
 if ((byte & 0x80) == 0)
 break;
@@ -116,7 +124,7 @@
 
 while (byte_offset < byte_count)
 {
-uint8_t byte1 = GetNextByte(data, byte_offset++);
+uint8_t byte1 = GetByteAtOffset(data, byte_offset++);
 if ((byte1&0xc0) == 0x00)
 {
 // 00xx
@@ -134,7 +142,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 if (byte1 == 0x80 && byte2 == 0)
 {
 // 1000 
@@ -210,7 +218,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 if ((byte2&0xff) == 0x00)
 {
 // 10110001 
@@ -251,7 +259,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
@@ -305,7 +313,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
@@ -321,7 +329,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
Index: include/lldb/Symbol/ArmUnwindInfo.h
===
--- include/lldb/Symbol/ArmUnwindInfo.h
+++ include/lldb/Symbol/ArmUnwindInfo.h
@@ -33,19 +33,28 @@
 class ArmUnwindInfo
 {
 public:
-ArmUnwindInfo (ObjectFile& objfile, lldb::SectionSP& arm_exidx, lldb::SectionSP& arm_extab);
+ArmUnwindInfo(const ObjectFile& objfile,
+  lldb::SectionSP& arm_exidx,
+  lldb::SectionSP& arm_extab);
+
 ~ArmUnwindInfo();
 
 bool
-GetUnwindPlan (Target &target, const Address& addr, UnwindPlan& unwind_plan);
+GetUnwindPlan(Target &target, c

[Lldb-commits] [lldb] r248908 - Fix xcode build after rL248903

2015-09-30 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Sep 30 09:55:08 2015
New Revision: 248908

URL: http://llvm.org/viewvc/llvm-project?rev=248908&view=rev
Log:
Fix xcode build after rL248903

Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=248908&r1=248907&r2=248908&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 30 09:55:08 2015
@@ -713,6 +713,7 @@
6D95DC001B9DC057000E318A /* DIERef.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 6D95DBFD1B9DC057000E318A /* DIERef.cpp */; };
6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 6D95DBFE1B9DC057000E318A /* HashedNameToDIE.cpp 
*/; };
6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 6D95DBFF1B9DC057000E318A /* 
SymbolFileDWARFDwo.cpp */; };
+   6D99A3631BBC2F3200979793 /* ArmUnwindInfo.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 6D99A3621BBC2F3200979793 /* ArmUnwindInfo.cpp 
*/; };
8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp 
*/; };
8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* 
MemoryHistoryASan.cpp */; };
8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 8CCB017A19BA283D0009FD44 /* 
ThreadCollection.cpp */; };
@@ -2403,6 +2404,8 @@
6D95DBFF1B9DC057000E318A /* SymbolFileDWARFDwo.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = SymbolFileDWARFDwo.cpp; sourceTree = ""; };
6D95DC031B9DC06F000E318A /* DIERef.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
DIERef.h; sourceTree = ""; };
6D95DC041B9DC06F000E318A /* SymbolFileDWARFDwo.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SymbolFileDWARFDwo.h; sourceTree = ""; };
+   6D99A3611BBC2F1600979793 /* ArmUnwindInfo.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArmUnwindInfo.h; 
path = include/lldb/Symbol/ArmUnwindInfo.h; sourceTree = ""; };
+   6D99A3621BBC2F3200979793 /* ArmUnwindInfo.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = ArmUnwindInfo.cpp; path = source/Symbol/ArmUnwindInfo.cpp; sourceTree = 
""; };
8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = 
""; };
8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MemoryHistory.h; 
path = include/lldb/Target/MemoryHistory.h; sourceTree = ""; };
8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = MemoryHistoryASan.cpp; sourceTree = ""; };
@@ -4207,6 +4210,8 @@
26BC7C4B10F1B6C100F91463 /* Symbol */ = {
isa = PBXGroup;
children = (
+   6D99A3621BBC2F3200979793 /* ArmUnwindInfo.cpp 
*/,
+   6D99A3611BBC2F1600979793 /* ArmUnwindInfo.h */,
26BC7C5510F1B6E900F91463 /* Block.h */,
26BC7F1310F1B8EC00F91463 /* Block.cpp */,
26BC7C5610F1B6E900F91463 /* ClangASTContext.h 
*/,
@@ -6289,6 +6294,7 @@
4984BA161B979973008658D4 /* 
ExpressionVariable.cpp in Sources */,
2689004C13353E0400698AC0 /* SourceManager.cpp 
in Sources */,
2689004D13353E0400698AC0 /* State.cpp in 
Sources */,
+   6D99A3631BBC2F3200979793 /* ArmUnwindInfo.cpp 
in Sources */,
4984BA131B978C55008658D4 /* 
ClangExpressionVariable.cpp in Sources */,
3F81691A1ABA2419001DA9DF /* NameMatches.cpp in 
Sources */,
AF0E22F018A09FB20009B7D1 /* 
AppleGetItemInfoHandler.cpp in Sources */,


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


Re: [Lldb-commits] [PATCH] D13291: Make the ArmUnwindInfo parsing code endian independent

2015-09-30 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
tberghammer marked 2 inline comments as done.
Closed by commit rL248910: Make the ArmUnwindInfo parsing code endian 
independent (authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13291?vs=36103&id=36108#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13291

Files:
  lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
  lldb/trunk/source/Symbol/ArmUnwindInfo.cpp

Index: lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
===
--- lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
+++ lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ArmUnwindInfo.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/UnwindPlan.h"
@@ -38,7 +39,10 @@
 };
 };
 
-ArmUnwindInfo::ArmUnwindInfo(ObjectFile& objfile, SectionSP& arm_exidx, SectionSP& arm_extab) :
+ArmUnwindInfo::ArmUnwindInfo(const ObjectFile& objfile,
+ SectionSP& arm_exidx,
+ SectionSP& arm_extab) :
+m_byte_order(objfile.GetByteOrder()),
 m_arm_exidx_sp(arm_exidx),
 m_arm_extab_sp(arm_extab)
 {
@@ -50,22 +54,26 @@
 {
 }
 
-static uint8_t
-GetNextByte(const uint32_t* data, uint16_t offset)
+// Read a byte from the unwind instruction stream with the given offset.
+// Custom function is required because have to red in order of significance within their containing
+// word (most significant byte first) and in increasing word address order.
+uint8_t
+ArmUnwindInfo::GetByteAtOffset(const uint32_t* data, uint16_t offset) const
 {
-data += offset / 4;
-offset = offset % 4;
-return (data[0] >> ((3 - offset) * 8)) & 0xff;
+uint32_t value = data[offset / 4];
+if (m_byte_order != endian::InlHostByteOrder())
+value = llvm::ByteSwap_32(value);
+return (value >> ((3 - (offset % 4)) * 8)) & 0xff;
 }
 
-static uint64_t
-GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset)
+uint64_t
+ArmUnwindInfo::GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) const
 {
 uint64_t result = 0;
 uint8_t shift = 0;
 while (offset < max_offset)
 {
-uint8_t byte = GetNextByte(data, offset++);
+uint8_t byte = GetByteAtOffset(data, offset++);
 result |= (byte & 0x7f) << shift;
 if ((byte & 0x80) == 0)
 break;
@@ -116,7 +124,7 @@
 
 while (byte_offset < byte_count)
 {
-uint8_t byte1 = GetNextByte(data, byte_offset++);
+uint8_t byte1 = GetByteAtOffset(data, byte_offset++);
 if ((byte1&0xc0) == 0x00)
 {
 // 00xx
@@ -134,7 +142,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 if (byte1 == 0x80 && byte2 == 0)
 {
 // 1000 
@@ -210,7 +218,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 if ((byte2&0xff) == 0x00)
 {
 // 10110001 
@@ -251,7 +259,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
@@ -305,7 +313,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
@@ -321,7 +329,7 @@
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 uint8_t s = (byte2&0xf0) >> 4;
 uint8_t c = (byte2&0x0f) >> 0;
 for (uint8_t i = 0; i <= c; ++i)
Index: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
===
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
@@ -33,19 +33,28 @@
 class ArmUnwindInfo
 {
 public:
-ArmUnwindInfo (ObjectFile& objfile, lldb::SectionSP& arm_exidx, lldb::SectionSP& arm_extab);
+ArmUnwindInfo(const ObjectFile& objfile,
+  lldb::SectionSP& arm_exidx,

[Lldb-commits] [lldb] r248910 - Make the ArmUnwindInfo parsing code endian independent

2015-09-30 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Sep 30 10:17:06 2015
New Revision: 248910

URL: http://llvm.org/viewvc/llvm-project?rev=248910&view=rev
Log:
Make the ArmUnwindInfo parsing code endian independent

Differential revision: http://reviews.llvm.org/D13291

Modified:
lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
lldb/trunk/source/Symbol/ArmUnwindInfo.cpp

Modified: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h?rev=248910&r1=248909&r2=248910&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h (original)
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h Wed Sep 30 10:17:06 2015
@@ -33,19 +33,28 @@ namespace lldb_private {
 class ArmUnwindInfo
 {
 public:
-ArmUnwindInfo (ObjectFile& objfile, lldb::SectionSP& arm_exidx, 
lldb::SectionSP& arm_extab);
+ArmUnwindInfo(const ObjectFile& objfile,
+  lldb::SectionSP& arm_exidx,
+  lldb::SectionSP& arm_extab);
+
 ~ArmUnwindInfo();
 
 bool
-GetUnwindPlan (Target &target, const Address& addr, UnwindPlan& 
unwind_plan);
+GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& 
unwind_plan);
 
 private:
 const uint8_t*
 GetExceptionHandlingTableEntry(const Address& addr);
-
+
+uint8_t
+GetByteAtOffset(const uint32_t* data, uint16_t offset) const;
+
+uint64_t
+GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset) 
const;
+
+const lldb::ByteOrder m_byte_order;
 lldb::SectionSP m_arm_exidx_sp; // .ARM.exidx section
 lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
-
 DataExtractor m_arm_exidx_data; // .ARM.exidx section data
 DataExtractor m_arm_extab_data; // .ARM.extab section data
 };

Modified: lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ArmUnwindInfo.cpp?rev=248910&r1=248909&r2=248910&view=diff
==
--- lldb/trunk/source/Symbol/ArmUnwindInfo.cpp (original)
+++ lldb/trunk/source/Symbol/ArmUnwindInfo.cpp Wed Sep 30 10:17:06 2015
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ArmUnwindInfo.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/UnwindPlan.h"
@@ -38,7 +39,10 @@ namespace
 };
 };
 
-ArmUnwindInfo::ArmUnwindInfo(ObjectFile& objfile, SectionSP& arm_exidx, 
SectionSP& arm_extab) :
+ArmUnwindInfo::ArmUnwindInfo(const ObjectFile& objfile,
+ SectionSP& arm_exidx,
+ SectionSP& arm_extab) :
+m_byte_order(objfile.GetByteOrder()),
 m_arm_exidx_sp(arm_exidx),
 m_arm_extab_sp(arm_extab)
 {
@@ -50,22 +54,26 @@ ArmUnwindInfo::~ArmUnwindInfo()
 {
 }
 
-static uint8_t
-GetNextByte(const uint32_t* data, uint16_t offset)
+// Read a byte from the unwind instruction stream with the given offset.
+// Custom function is required because have to red in order of significance 
within their containing
+// word (most significant byte first) and in increasing word address order.
+uint8_t
+ArmUnwindInfo::GetByteAtOffset(const uint32_t* data, uint16_t offset) const
 {
-data += offset / 4;
-offset = offset % 4;
-return (data[0] >> ((3 - offset) * 8)) & 0xff;
+uint32_t value = data[offset / 4];
+if (m_byte_order != endian::InlHostByteOrder())
+value = llvm::ByteSwap_32(value);
+return (value >> ((3 - (offset % 4)) * 8)) & 0xff;
 }
 
-static uint64_t
-GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t max_offset)
+uint64_t
+ArmUnwindInfo::GetULEB128(const uint32_t* data, uint16_t& offset, uint16_t 
max_offset) const
 {
 uint64_t result = 0;
 uint8_t shift = 0;
 while (offset < max_offset)
 {
-uint8_t byte = GetNextByte(data, offset++);
+uint8_t byte = GetByteAtOffset(data, offset++);
 result |= (byte & 0x7f) << shift;
 if ((byte & 0x80) == 0)
 break;
@@ -116,7 +124,7 @@ ArmUnwindInfo::GetUnwindPlan(Target &tar
 
 while (byte_offset < byte_count)
 {
-uint8_t byte1 = GetNextByte(data, byte_offset++);
+uint8_t byte1 = GetByteAtOffset(data, byte_offset++);
 if ((byte1&0xc0) == 0x00)
 {
 // 00xx
@@ -134,7 +142,7 @@ ArmUnwindInfo::GetUnwindPlan(Target &tar
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextByte(data, byte_offset++);
+uint8_t byte2 = GetByteAtOffset(data, byte_offset++);
 if (byte1 == 0x80 && byte2 == 0)
 {
 // 1000 
@@ -210,7 +218,7 @@ ArmUnwindInfo::GetUnwindPlan(Target &tar
 if (byte_offset >= byte_count)
 return false;
 
-uint8_t byte2 = GetNextBy

Re: [Lldb-commits] [PATCH] D13282: [MIPS] Emulate microMIPS instructions

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:683
@@ +682,3 @@
+
+if (m_use_alt_disaasm == true)
+decode_status = m_alt_disasm->getInstruction (mc_insn, next_inst_size, 
raw_insn, inst_addr, llvm::nulls(), llvm::nulls());

(nit): "if (m_use_alt_disaasm)"


Comment at: source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:775
@@ -660,2 +774,3 @@
 llvm::ArrayRef raw_insn (data.GetDataStart(), 
data.GetByteSize());
-decode_status = m_disasm->getInstruction (mc_insn, insn_size, 
raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+if (m_use_alt_disaasm == true)
+decode_status = m_alt_disasm->getInstruction (mc_insn, insn_size, 
raw_insn, m_addr, llvm::nulls(), llvm::nulls());

(nit): "if (m_use_alt_disaasm)"


Comment at: source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:848-849
@@ -729,4 +847,4 @@
 
 // Our previous PC is in the RA
 row->SetRegisterLocationToRegister(dwarf_pc_mips, dwarf_ra_mips, 
can_replace);
 

You don't need this if you use SetReturnAddressRegister


Repository:
  rL LLVM

http://reviews.llvm.org/D13282



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


[Lldb-commits] [PATCH] D13293: Trim the output of mktem in PlatformAndroid::DownloadSymbolFile

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added a reviewer: ovyalov.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: danalbert, tberghammer.

Trim the output of mktem in PlatformAndroid::DownloadSymbolFile

http://reviews.llvm.org/D13293

Files:
  source/Plugins/Platform/Android/PlatformAndroid.cpp

Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -331,7 +331,7 @@
 Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 
5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device 
(%s)", error.AsCString());
-tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
+tmpdir = llvm::StringRef(tmpdir).trim().str();
 
 // Create file remover for the temporary directory created on the device
 std::unique_ptr> 
tmpdir_remover(


Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -331,7 +331,7 @@
 Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device (%s)", error.AsCString());
-tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
+tmpdir = llvm::StringRef(tmpdir).trim().str();
 
 // Create file remover for the temporary directory created on the device
 std::unique_ptr> tmpdir_remover(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13162: Change oat symbolization code for android to work on non-rooted devices

2015-09-30 Thread Tamas Berghammer via lldb-commits
I haven't managed to reproduce the issue you reported (what OS and Android
version do you use?), but based on the description this change (not
committed in yet) might fix the issue: http://reviews.llvm.org/D13293. Can
you take a look?

Thanks,
Tamas

On Wed, Sep 30, 2015 at 12:49 AM Oleksiy Vyalov  wrote:

> ovyalov added inline comments.
>
> 
> Comment at: source/Plugins/Platform/Android/PlatformAndroid.cpp:341
> @@ -347,1 +340,3 @@
> +AdbClient adb(m_device_id);
> +
>  StreamString command;
> 
> I tried this CL on my device and it's failing to download a symbol file -
> "Failed to pull file: No such file or directory". As I can see tmpdir isn't
> fully cleared from tail symbols, like \r\n
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D13162
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D13300: Run tests with dwo symbol files

2015-09-30 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: clayborg, tfiala, zturner, emaste, labath.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

Run tests with dwo symbol file

dwo symbol files are generated when code compiled with the "-gsplit-dwarf" 
command option (https://gcc.gnu.org/wiki/DebugFission). This CL modifies the 
test system to run tests with inferiors compile with the "-gsplit-dwarf"

I tested "-gsplit-dwarf" on OSX, Linux and Android and there are no regression 
on these platform, for other platforms I have no access to at the moment but 
all recent compiler should support split dwarf (gcc 4.7+, clang 3.5+). If 
somebody know about configurations where split dwarf test should be disabled 
then please let me know, or disable them after commit by setting 
dont_do_dwo_test in dotest.py (see setting of dont_do_dsym_test in line 1520)

http://reviews.llvm.org/D13300

Files:
  test/dotest.py
  test/dotest_args.py
  test/functionalities/dead-strip/TestDeadStrip.py
  test/lldbtest.py
  test/make/Makefile.rules
  test/plugins/builder_base.py

Index: test/plugins/builder_base.py
===
--- test/plugins/builder_base.py
+++ test/plugins/builder_base.py
@@ -113,6 +113,17 @@
 # True signifies that we can handle building dwarf.
 return True
 
+def buildDwo(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
+"""Build the binaries with dwarf debug info."""
+commands = []
+if clean:
+commands.append([getMake(), "clean", getCmdLine(dictionary)])
+commands.append([getMake(), "MAKE_DSYM=NO", "MAKE_DWO=YES", getArchSpec(architecture), getCCSpec(compiler), getCmdLine(dictionary)])
+
+lldbtest.system(commands, sender=sender)
+# True signifies that we can handle building dwo.
+return True
+
 def cleanup(sender=None, dictionary=None):
 """Perform a platform-specific cleanup after the test."""
 #import traceback
Index: test/make/Makefile.rules
===
--- test/make/Makefile.rules
+++ test/make/Makefile.rules
@@ -185,6 +185,10 @@
 	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
 endif
 
+ifeq "$(MAKE_DWO)" "YES"
+	CFLAGS += -gsplit-dwarf
+endif
+
 CXXFLAGS += -std=c++11
 CXXFLAGS += $(CFLAGS)
 LD = $(CC)
Index: test/lldbtest.py
===
--- test/lldbtest.py
+++ test/lldbtest.py
@@ -567,6 +567,23 @@
 wrapper.__dwarf_test__ = True
 return wrapper
 
+def dwo_test(func):
+"""Decorate the item as a dwo test."""
+if isinstance(func, type) and issubclass(func, unittest2.TestCase):
+raise Exception("@dwo_test can only be used to decorate a test method")
+@wraps(func)
+def wrapper(self, *args, **kwargs):
+try:
+if lldb.dont_do_dwo_test:
+self.skipTest("dwo tests")
+except AttributeError:
+pass
+return func(self, *args, **kwargs)
+
+# Mark this function as such to separate them from the regular tests.
+wrapper.__dwo_test__ = True
+return wrapper
+
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
 if isinstance(func, type) and issubclass(func, unittest2.TestCase):
@@ -657,10 +674,13 @@
 return expectedFailure(fn, bugnumber)
 
 def expectedFailureDwarf(bugnumber=None):
-return expectedFailureAll(bugnumber==bugnumber, debug_info="dwarf")
+return expectedFailureAll(bugnumber=bugnumber, debug_info="dwarf")
+
+def expectedFailureDwo(bugnumber=None):
+return expectedFailureAll(bugnumber=bugnumber, debug_info="dwo")
 
 def expectedFailureDsym(bugnumber=None):
-return expectedFailureAll(bugnumber==bugnumber, debug_info="dsym")
+return expectedFailureAll(bugnumber=bugnumber, debug_info="dsym")
 
 def expectedFailureCompiler(compiler, compiler_version=None, bugnumber=None):
 if compiler_version is None:
@@ -2123,6 +2143,16 @@
 if not module.buildDwarf(self, architecture, compiler, dictionary, clean):
 raise Exception("Don't know how to build binary with dwarf")
 
+def buildDwo(self, architecture=None, compiler=None, dictionary=None, clean=True):
+"""Platform specific way to build binaries with dwarf maps."""
+if lldb.skip_build_and_cleanup:
+return
+module = builder_module()
+if target_is_android():
+dictionary = append_android_envs(dictionary)
+if not module.buildDwo(self, architecture, compiler, dictionary, clean):
+raise Exception("Don't know how to build binary with dwo")
+
 def buildGo(self):
 """Build the default go binary.
 """
@@ -2240,6 +2270,14 @@
 dwarf_method_name = attrname + "_dwarf"
 dwarf_test_method.__name__ = dwarf_method_name
 

Re: [Lldb-commits] [PATCH] D13323: Use %HOME%/.lldb/module_cache as a default module cache directory

2015-10-01 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D13323



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


[Lldb-commits] [lldb] r248998 - Trim the output of mktem in PlatformAndroid::DownloadSymbolFile

2015-10-01 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Oct  1 04:42:23 2015
New Revision: 248998

URL: http://llvm.org/viewvc/llvm-project?rev=248998&view=rev
Log:
Trim the output of mktem in PlatformAndroid::DownloadSymbolFile

Differential revision: http://reviews.llvm.org/D13293

Modified:
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=248998&r1=248997&r2=248998&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Thu Oct  1 
04:42:23 2015
@@ -331,7 +331,7 @@ PlatformAndroid::DownloadSymbolFile (con
 Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 
5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device 
(%s)", error.AsCString());
-tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
+tmpdir = llvm::StringRef(tmpdir).trim().str();
 
 // Create file remover for the temporary directory created on the device
 std::unique_ptr> 
tmpdir_remover(


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


Re: [Lldb-commits] [PATCH] D13293: Trim the output of mktem in PlatformAndroid::DownloadSymbolFile

2015-10-01 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248998: Trim the output of mktem in 
PlatformAndroid::DownloadSymbolFile (authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13293?vs=36111&id=36209#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13293

Files:
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp

Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -331,7 +331,7 @@
 Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 
5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device 
(%s)", error.AsCString());
-tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
+tmpdir = llvm::StringRef(tmpdir).trim().str();
 
 // Create file remover for the temporary directory created on the device
 std::unique_ptr> 
tmpdir_remover(


Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -331,7 +331,7 @@
 Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device (%s)", error.AsCString());
-tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line
+tmpdir = llvm::StringRef(tmpdir).trim().str();
 
 // Create file remover for the temporary directory created on the device
 std::unique_ptr> tmpdir_remover(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r249012 - Restrict the scope of a hack in DYLDRendezvous

2015-10-01 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Oct  1 08:57:54 2015
New Revision: 249012

URL: http://llvm.org/viewvc/llvm-project?rev=249012&view=rev
Log:
Restrict the scope of a hack in DYLDRendezvous

The hack is there to work around an incorrect load address reported
by the android linker on API 21 and 22 devices. This CL restricts the
hack to those android API levels.

Differential revision: http://reviews.llvm.org/D13288

Modified:
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h

Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp?rev=249012&r1=249011&r2=249012&view=diff
==
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp 
(original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp Thu 
Oct  1 08:57:54 2015
@@ -17,6 +17,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -372,6 +373,25 @@ DYLDRendezvous::ReadStringFromMemory(add
 return str;
 }
 
+// Returns true if the load bias reported by the linker is incorrect for the 
given entry. This
+// function is used to handle cases where we want to work around a bug in the 
system linker.
+static bool
+isLoadBiasIncorrect(Target& target, const std::string& file_path)
+{
+// On Android L (API 21, 22) the load address of the "/system/bin/linker" 
isn't filled in
+// correctly.
+uint32_t os_major = 0, os_minor = 0, os_update = 0;
+if (target.GetArchitecture().GetTriple().getEnvironment() == 
llvm::Triple::Android &&
+target.GetPlatform()->GetOSVersion(os_major, os_minor, os_update) &&
+(os_major == 21 || os_major == 22) &&
+(file_path == "/system/bin/linker" || file_path == 
"/system/bin/linker64"))
+{
+return true;
+}
+
+return false;
+}
+
 bool
 DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
 {
@@ -413,11 +433,9 @@ DYLDRendezvous::ReadSOEntryFromMemory(ll
 std::string file_path = ReadStringFromMemory(entry.path_addr);
 entry.file_spec.SetFile(file_path, false);
 
-// On Android L (5.0, 5.1) the load address of the "/system/bin/linker" 
isn't filled in
-// correctly. To get the correct load address we fetch the load address of 
the file from the
-// proc file system.
-if (arch.GetTriple().getEnvironment() == llvm::Triple::Android && 
entry.base_addr == 0 &&
-(file_path == "/system/bin/linker" || file_path == 
"/system/bin/linker64"))
+// If the load bias reported by the linker is incorrect then fetch the 
load address of the file
+// from the proc file system.
+if (isLoadBiasIncorrect(m_process->GetTarget(), file_path))
 {
 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
 bool is_loaded = false;

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=249012&r1=249011&r2=249012&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Thu Oct  1 
08:57:54 2015
@@ -362,3 +362,12 @@ PlatformAndroid::DownloadSymbolFile (con
 // Download the symbolfile from the remote device
 return GetFile(symfile_platform_filespec, dst_file_spec);
 }
+
+bool
+PlatformAndroid::GetRemoteOSVersion ()
+{
+m_major_os_version = GetSdkVersion();
+m_minor_os_version = 0;
+m_update_os_version = 0;
+return m_major_os_version != 0;
+}

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h?rev=249012&r1=249011&r2=249012&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h Thu Oct  1 
08:57:54 2015
@@ -76,7 +76,10 @@ namespace platform_android {
 
 uint32_t
 GetSdkVersion();
-
+
+bool
+GetRemoteOSVersion() override;
+
 Error
 DisconnectRemote () override;
 


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


[Lldb-commits] [lldb] r249014 - Fix Android-SDK detection on API 10 device

2015-10-01 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Oct  1 08:58:01 2015
New Revision: 249014

URL: http://llvm.org/viewvc/llvm-project?rev=249014&view=rev
Log:
Fix Android-SDK detection on API 10 device

Run the getprop command with AdbClient::Shell instead of
Platform::RunShellCommand because getting the output from getprop
with Platform::RunShellCommand have some (currently unknown) issues.

Modified:
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=249014&r1=249013&r2=249014&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Thu Oct  1 
08:58:01 2015
@@ -283,23 +283,19 @@ PlatformAndroid::GetSdkVersion()
 if (m_sdk_version != 0)
 return m_sdk_version;
 
-int status = 0;
 std::string version_string;
-Error error = RunShellCommand("getprop ro.build.version.sdk",
-  GetWorkingDirectory(),
-  &status,
-  nullptr,
-  &version_string,
-  1);
-if (error.Fail() || status != 0 || version_string.empty())
+AdbClient adb(m_device_id);
+Error error = adb.Shell("getprop ro.build.version.sdk", 5000 /* ms */, 
&version_string);
+version_string = llvm::StringRef(version_string).trim().str();
+
+if (error.Fail() || version_string.empty())
 {
 Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM);
 if (log)
-log->Printf("Get SDK version failed. (status: %d, error: %s, 
output: %s)",
-status, error.AsCString(), version_string.c_str());
+log->Printf("Get SDK version failed. (error: %s, output: %s)",
+error.AsCString(), version_string.c_str());
 return 0;
 }
-version_string.erase(version_string.size() - 1); // Remove trailing new 
line
 
 m_sdk_version = StringConvert::ToUInt32(version_string.c_str());
 return m_sdk_version;


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


[Lldb-commits] [lldb] r249013 - Fix breakpoint opcode calculation on Linux

2015-10-01 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Oct  1 08:57:57 2015
New Revision: 249013

URL: http://llvm.org/viewvc/llvm-project?rev=249013&view=rev
Log:
Fix breakpoint opcode calculation on Linux

Change the way we detect if we have to place a thumb breakpoint instead
of an arm breakpoint in the case when no symbol table or mapping symbols
are available. Detect it based on the LSB of the FileAddress instead of
the LSB of the LoadAddress because the LSB of the LoadAddress is already
masked out.

Modified:
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=249013&r1=249012&r2=249013&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Thu Oct  1 
08:57:57 2015
@@ -575,10 +575,17 @@ PlatformLinux::GetSoftwareBreakpointTrap
 AddressClass addr_class = eAddressClassUnknown;
 
 if (bp_loc_sp)
+{
 addr_class = bp_loc_sp->GetAddress ().GetAddressClass ();
 
-if (addr_class == eAddressClassCodeAlternateISA
-|| (addr_class == eAddressClassUnknown && 
(bp_site->GetLoadAddress() & 1)))
+if (addr_class == eAddressClassUnknown &&
+(bp_loc_sp->GetAddress ().GetFileAddress () & 1))
+{
+addr_class = eAddressClassCodeAlternateISA;
+}
+}
+
+if (addr_class == eAddressClassCodeAlternateISA)
 {
 trap_opcode = g_thumb_breakpoint_opcode;
 trap_opcode_size = sizeof(g_thumb_breakpoint_opcode);


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


Re: [Lldb-commits] [PATCH] D13288: Restrict the scope of a hack in DYLDRendezvous

2015-10-01 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249012: Restrict the scope of a hack in DYLDRendezvous 
(authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13288?vs=36097&id=36240#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13288

Files:
  lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h

Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
@@ -76,7 +76,10 @@
 
 uint32_t
 GetSdkVersion();
-
+
+bool
+GetRemoteOSVersion() override;
+
 Error
 DisconnectRemote () override;
 
Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -362,3 +362,12 @@
 // Download the symbolfile from the remote device
 return GetFile(symfile_platform_filespec, dst_file_spec);
 }
+
+bool
+PlatformAndroid::GetRemoteOSVersion ()
+{
+m_major_os_version = GetSdkVersion();
+m_minor_os_version = 0;
+m_update_os_version = 0;
+return m_major_os_version != 0;
+}
Index: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -372,6 +373,25 @@
 return str;
 }
 
+// Returns true if the load bias reported by the linker is incorrect for the 
given entry. This
+// function is used to handle cases where we want to work around a bug in the 
system linker.
+static bool
+isLoadBiasIncorrect(Target& target, const std::string& file_path)
+{
+// On Android L (API 21, 22) the load address of the "/system/bin/linker" 
isn't filled in
+// correctly.
+uint32_t os_major = 0, os_minor = 0, os_update = 0;
+if (target.GetArchitecture().GetTriple().getEnvironment() == 
llvm::Triple::Android &&
+target.GetPlatform()->GetOSVersion(os_major, os_minor, os_update) &&
+(os_major == 21 || os_major == 22) &&
+(file_path == "/system/bin/linker" || file_path == 
"/system/bin/linker64"))
+{
+return true;
+}
+
+return false;
+}
+
 bool
 DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
 {
@@ -413,11 +433,9 @@
 std::string file_path = ReadStringFromMemory(entry.path_addr);
 entry.file_spec.SetFile(file_path, false);
 
-// On Android L (5.0, 5.1) the load address of the "/system/bin/linker" 
isn't filled in
-// correctly. To get the correct load address we fetch the load address of 
the file from the
-// proc file system.
-if (arch.GetTriple().getEnvironment() == llvm::Triple::Android && 
entry.base_addr == 0 &&
-(file_path == "/system/bin/linker" || file_path == 
"/system/bin/linker64"))
+// If the load bias reported by the linker is incorrect then fetch the 
load address of the file
+// from the proc file system.
+if (isLoadBiasIncorrect(m_process->GetTarget(), file_path))
 {
 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
 bool is_loaded = false;


Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
@@ -76,7 +76,10 @@
 
 uint32_t
 GetSdkVersion();
-
+
+bool
+GetRemoteOSVersion() override;
+
 Error
 DisconnectRemote () override;
 
Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -362,3 +362,12 @@
 // Download the symbolfile from the remote device
 return GetFile(symfile_platform_filespec, dst_file_spec);
 }
+
+bool
+PlatformAndroid::GetRemoteOSVersion ()
+{
+m_major_os_version = GetSdkVersion();
+m_minor_os_version = 0;
+m_update_os_version = 0;
+return m_major_os_version != 0;
+}
Index: lldb/trunk/source/Plugins/Dy

[Lldb-commits] [PATCH] D13380: Fix several issues around .ARM.exidx section handling

2015-10-02 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added a reviewer: labath.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: rengolin, aemerson.

Fix several issues around .ARM.exidx section handling

* Use .ARM.exidx as a fallback unwind plan for non-call site when the
  instruction emulation based unwind failed.
* Work around an old compiler issue where the compiler isn't sort the
  entries in .ARM.exidx based on their address.
* Fix unwind info parsing when the virtual file address >= 0x8000
* Fix bug in unwind info parsing when neither lr nor pc is explicitly
  restored.

http://reviews.llvm.org/D13380

Files:
  include/lldb/Symbol/ArmUnwindInfo.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  source/Symbol/ArmUnwindInfo.cpp

Index: source/Symbol/ArmUnwindInfo.cpp
===
--- source/Symbol/ArmUnwindInfo.cpp
+++ source/Symbol/ArmUnwindInfo.cpp
@@ -30,14 +30,26 @@
 using namespace lldb;
 using namespace lldb_private;
 
-namespace
+// Converts a prel31 avlue to lldb::addr_t with sign extension
+static addr_t
+Prel31ToAddr(uint32_t prel31)
 {
-struct ArmExidxEntry
-{
-uint32_t address;
-uint32_t data;
-};
-};
+addr_t res = prel31;
+if (prel31 & (1<<30))
+res |= 0x8000ULL;
+return res;
+}
+
+ArmUnwindInfo::ArmExidxEntry::ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d) :
+file_address(f), address(a), data(d)
+{
+}
+
+bool
+ArmUnwindInfo::ArmExidxEntry::operator<(const ArmExidxEntry& other) const
+{
+return address < other.address;
+}
 
 ArmUnwindInfo::ArmUnwindInfo(const ObjectFile& objfile,
  SectionSP& arm_exidx,
@@ -48,6 +60,23 @@
 {
 objfile.ReadSectionData(arm_exidx.get(), m_arm_exidx_data);
 objfile.ReadSectionData(arm_extab.get(), m_arm_extab_data);
+
+addr_t exidx_base_addr = m_arm_exidx_sp->GetFileAddress();
+
+offset_t offset = 0;
+while (m_arm_exidx_data.ValidOffset(offset))
+{
+lldb::addr_t file_addr = exidx_base_addr + offset;
+lldb::addr_t addr = exidx_base_addr +
+(addr_t)offset +
+Prel31ToAddr(m_arm_exidx_data.GetU32(&offset));
+uint32_t data = m_arm_exidx_data.GetU32(&offset);
+m_exidx_entries.emplace_back(file_addr, addr, data);
+}
+
+// Sort the entries in the exidx section. The entries should be sorted inside the section but
+// some old compiler isn't sorted them.
+std::sort(m_exidx_entries.begin(), m_exidx_entries.end());
 }
 
 ArmUnwindInfo::~ArmUnwindInfo()
@@ -85,7 +114,7 @@
 bool
 ArmUnwindInfo::GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& unwind_plan)
 {
-const uint32_t* data = (const uint32_t*)GetExceptionHandlingTableEntry(addr.GetFileAddress());
+const uint32_t* data = (const uint32_t*)GetExceptionHandlingTableEntry(addr);
 if (data == nullptr)
 return false; // No unwind information for the function
 
@@ -382,6 +411,8 @@
 UnwindPlan::Row::RegisterLocation lr_location;
 if (row->GetRegisterInfo(dwarf_lr, lr_location))
 row->SetRegisterInfo(dwarf_pc, lr_location);
+else
+row->SetRegisterLocationToRegister(dwarf_pc, dwarf_lr, false);
 }
 
 unwind_plan.AppendRow(row);
@@ -396,38 +427,19 @@
 const uint8_t*
 ArmUnwindInfo::GetExceptionHandlingTableEntry(const Address& addr)
 {
-uint32_t file_addr = addr.GetFileAddress();
-uint32_t exidx_base_addr = m_arm_exidx_sp->GetFileAddress();
-
-const ArmExidxEntry* exidx_start = (const ArmExidxEntry*)m_arm_exidx_data.GetDataStart();
-uint32_t bs_start = 0, bs_end = m_arm_exidx_data.GetByteSize() / sizeof(ArmExidxEntry);
-while (bs_start + 1 < bs_end)
-{
-uint32_t mid = (bs_start + bs_end) / 2;
-uint32_t mid_addr = exidx_base_addr + exidx_start[mid].address + mid * sizeof(ArmExidxEntry);
-mid_addr &= 0x7fff;
-if (mid_addr > file_addr)
-bs_end = mid;
-else
-bs_start = mid;
-}
-
-uint32_t exidx_addr = exidx_base_addr +
-  exidx_start[bs_start].address +
-  bs_start * sizeof(ArmExidxEntry);
-exidx_addr &= 0x7fff;
-if (exidx_addr > file_addr)
+auto it = std::upper_bound(m_exidx_entries.begin(),
+   m_exidx_entries.end(),
+   ArmExidxEntry{0, addr.GetFileAddress(), 0});
+if (it == m_exidx_entries.begin())
 return nullptr;
+--it;
 
-if (exidx_start[bs_start].data == 0x1)
+if (it->data == 0x1)
 return nullptr; // EXIDX_CANTUNWIND
 
-if (exidx_start[bs_start].data & 0x8000)
-return (const uint8_t*)&exidx_start[bs_start].data;
+if (it->data & 0x8000)
+return (const uint8_t*)&it->data;
 
-uint32_t data_file_addr = exidx_base_addr +
-   

[Lldb-commits] [lldb] r249119 - Fix several issues around .ARM.exidx section handling

2015-10-02 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  2 06:58:26 2015
New Revision: 249119

URL: http://llvm.org/viewvc/llvm-project?rev=249119&view=rev
Log:
Fix several issues around .ARM.exidx section handling

* Use .ARM.exidx as a fallback unwind plan for non-call site when the
  instruction emulation based unwind failed.
* Work around an old compiler issue where the compiler isn't sort the
  entries in .ARM.exidx based on their address.
* Fix unwind info parsing when the virtual file address >= 0x8000
* Fix bug in unwind info parsing when neither lr nor pc is explicitly
  restored.

Differential revision: http://reviews.llvm.org/D13380

Modified:
lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Symbol/ArmUnwindInfo.cpp

Modified: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h?rev=249119&r1=249118&r2=249119&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h (original)
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h Fri Oct  2 06:58:26 2015
@@ -43,6 +43,18 @@ public:
 GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& 
unwind_plan);
 
 private:
+struct ArmExidxEntry
+{
+ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d);
+
+bool
+operator<(const ArmExidxEntry& other) const;
+
+uint32_t file_address;
+lldb::addr_t address;
+uint32_t data;
+};
+
 const uint8_t*
 GetExceptionHandlingTableEntry(const Address& addr);
 
@@ -57,6 +69,7 @@ private:
 lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
 DataExtractor m_arm_exidx_data; // .ARM.exidx section data
 DataExtractor m_arm_extab_data; // .ARM.extab section data
+std::vector m_exidx_entries;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=249119&r1=249118&r2=249119&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Fri Oct  
2 06:58:26 2015
@@ -881,12 +881,12 @@ RegisterContextLLDB::GetFullUnwindPlanFo
 // then the architecture default plan and for hand written 
assembly code it is often
 // written in a way that it valid at all location what helps 
in the most common
 // cases when the instruction emulation fails.
-UnwindPlanSP eh_frame_unwind_plan = 
func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), 
m_current_offset_backed_up_one);
-if (eh_frame_unwind_plan &&
-eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
-eh_frame_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
+UnwindPlanSP call_site_unwind_plan = 
func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), 
m_current_offset_backed_up_one);
+if (call_site_unwind_plan &&
+call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+call_site_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
 {
-m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+m_fallback_unwind_plan_sp = call_site_unwind_plan;
 }
 else
 {
@@ -926,12 +926,12 @@ RegisterContextLLDB::GetFullUnwindPlanFo
 // more reliable even on non call sites then the architecture default 
plan and for hand
 // written assembly code it is often written in a way that it valid at 
all location what
 // helps in the most common cases when the instruction emulation fails.
-UnwindPlanSP eh_frame_unwind_plan = 
func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), 
m_current_offset_backed_up_one);
-if (eh_frame_unwind_plan &&
-eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
-eh_frame_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
+UnwindPlanSP call_site_unwind_plan = 
func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), 
m_current_offset_backed_up_one);
+if (call_site_unwind_plan &&
+call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+call_site_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
 {
-m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+m_fallback_unwind_plan_sp = call_site_unwind_plan;
 }
 else
 {

Modified: lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
URL: 
http://

Re: [Lldb-commits] [PATCH] D13380: Fix several issues around .ARM.exidx section handling

2015-10-02 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249119: Fix several issues around .ARM.exidx section 
handling (authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13380?vs=36338&id=36343#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13380

Files:
  lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Symbol/ArmUnwindInfo.cpp

Index: lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
===
--- lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
+++ lldb/trunk/include/lldb/Symbol/ArmUnwindInfo.h
@@ -43,6 +43,18 @@
 GetUnwindPlan(Target &target, const Address& addr, UnwindPlan& unwind_plan);
 
 private:
+struct ArmExidxEntry
+{
+ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d);
+
+bool
+operator<(const ArmExidxEntry& other) const;
+
+uint32_t file_address;
+lldb::addr_t address;
+uint32_t data;
+};
+
 const uint8_t*
 GetExceptionHandlingTableEntry(const Address& addr);
 
@@ -57,6 +69,7 @@
 lldb::SectionSP m_arm_extab_sp; // .ARM.extab section
 DataExtractor m_arm_exidx_data; // .ARM.exidx section data
 DataExtractor m_arm_extab_data; // .ARM.extab section data
+std::vector m_exidx_entries;
 };
 
 } // namespace lldb_private
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -881,12 +881,12 @@
 // then the architecture default plan and for hand written assembly code it is often
 // written in a way that it valid at all location what helps in the most common
 // cases when the instruction emulation fails.
-UnwindPlanSP eh_frame_unwind_plan = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
-if (eh_frame_unwind_plan &&
-eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
-eh_frame_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
+UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
+if (call_site_unwind_plan &&
+call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+call_site_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
 {
-m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+m_fallback_unwind_plan_sp = call_site_unwind_plan;
 }
 else
 {
@@ -926,12 +926,12 @@
 // more reliable even on non call sites then the architecture default plan and for hand
 // written assembly code it is often written in a way that it valid at all location what
 // helps in the most common cases when the instruction emulation fails.
-UnwindPlanSP eh_frame_unwind_plan = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
-if (eh_frame_unwind_plan &&
-eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
-eh_frame_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
+UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
+if (call_site_unwind_plan &&
+call_site_unwind_plan.get() != unwind_plan_sp.get() &&
+call_site_unwind_plan->GetSourceName() != unwind_plan_sp->GetSourceName())
 {
-m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+m_fallback_unwind_plan_sp = call_site_unwind_plan;
 }
 else
 {
Index: lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
===
--- lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
+++ lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
@@ -30,14 +30,26 @@
 using namespace lldb;
 using namespace lldb_private;
 
-namespace
+// Converts a prel31 avlue to lldb::addr_t with sign extension
+static addr_t
+Prel31ToAddr(uint32_t prel31)
 {
-struct ArmExidxEntry
-{
-uint32_t address;
-uint32_t data;
-};
-};
+addr_t res = prel31;
+if (prel31 & (1<<30))
+res |= 0x8000ULL;
+return res;
+}
+
+ArmUnwindInfo::ArmExidxEntry::ArmExidxEntry(uint32_t f, lldb::addr_t a, uint32_t d) :
+file_address(f), address(a), data(d)
+{
+}
+
+bool
+ArmUnwindInfo::ArmExidxEntry::operator<(const ArmExidxEntry& other) const
+{
+return address < other.address;
+}
 
 Ar

[Lldb-commits] [lldb] r249120 - Change expected stop reason in TestInferiorAssert for Android API <= 16

2015-10-02 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  2 07:00:04 2015
New Revision: 249120

URL: http://llvm.org/viewvc/llvm-project?rev=249120&view=rev
Log:
Change expected stop reason in TestInferiorAssert for Android API <= 16

Modified:
lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py

Modified: lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py?rev=249120&r1=249119&r2=249120&view=diff
==
--- lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py 
(original)
+++ lldb/trunk/test/functionalities/inferior-assert/TestInferiorAssert.py Fri 
Oct  2 07:00:04 2015
@@ -55,7 +55,11 @@ class AssertingInferiorTestCase(TestBase
 lldbutil.run_break_set_by_file_and_line (self, "main.c", line, 
num_expected_locations=1, loc_exact=True)
 
 def check_stop_reason(self):
-stop_reason = 'stop reason = signal SIGABRT'
+if matchAndroid(api_levels=range(1, 16+1))(self):
+# On android until API-16 the abort() call ended in a sigsegv 
instead of in a sigabrt
+stop_reason = 'stop reason = signal SIGSEGV'
+else:
+stop_reason = 'stop reason = signal SIGABRT'
 
 # The stop reason of the thread should be an abort signal or exception.
 self.expect("thread list", STOPPED_DUE_TO_ASSERT,


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


Re: [Lldb-commits] [PATCH] D13462: Fix virtual/override warnings in new MIPS code.

2015-10-06 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.

I agree with Pavel, that you don't have to send these trivial changes for core 
review


http://reviews.llvm.org/D13462



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


[Lldb-commits] [lldb] r249407 - Rename a test case to avoid name conflict

2015-10-06 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Oct  6 09:39:05 2015
New Revision: 249407

URL: http://llvm.org/viewvc/llvm-project?rev=249407&view=rev
Log:
Rename a test case to avoid name conflict

Rename the python source file for DataFormatterOSTypeTestCase to match
the purpose of the test and to avoid a name conflict with
DataFormatterBoolRefPtr. The name conflict caused a race condition in
the test runner what we have to address separately.

Added:

lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py
  - copied, changed from r249405, 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py
Removed:

lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py

Removed: 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py?rev=249406&view=auto
==
--- 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py
 (original)
+++ 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py
 (removed)
@@ -1,56 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-import os, time
-import unittest2
-import lldb
-from lldbtest import *
-import datetime
-import lldbutil
-
-class DataFormatterOSTypeTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break at.
-self.line = line_number('main.mm', '// Set break point at this line.')
-
-@skipUnlessDarwin
-def test_ostype_with_run_command(self):
-"""Test the formatters we use for OSType."""
-self.build()
-self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
-
-lldbutil.run_break_set_by_file_and_line (self, "main.mm", self.line, 
num_expected_locations=1, loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs = ['stopped',
-   'stop reason = breakpoint'])
-
-# This is the function to remove the custom formats in order to have a
-# clean slate for the next test case.
-def cleanup():
-self.runCmd('type format clear', check=False)
-self.runCmd('type summary clear', check=False)
-self.runCmd('type synth clear', check=False)
-
-# Execute the cleanup function during test case tear down.
-self.addTearDownHook(cleanup)
-
-# Now check that we use the right summary for OSType
-self.expect('frame variable',
-substrs = ["'test'","'best'"])
-
-
-if __name__ == '__main__':
-import atexit
-lldb.SBDebugger.Initialize()
-atexit.register(lambda: lldb.SBDebugger.Terminate())
-unittest2.main()

Copied: 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py
 (from r249405, 
lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py?p2=lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py&p1=lldb/trunk/test/functionalities/data-formatter/ostypeformatting/TestFormattersBoolRefPtr.py&r1=249405&r2=249407&rev=249407&view=diff
==
(empty)


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


[Lldb-commits] [lldb] r249530 - Run tests with dwo symbol files

2015-10-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Oct  7 05:02:17 2015
New Revision: 249530

URL: http://llvm.org/viewvc/llvm-project?rev=249530&view=rev
Log:
Run tests with dwo symbol files

dwo symbol files are generated when code compiled with the "-gsplit-dwarf"
command option (https://gcc.gnu.org/wiki/DebugFission). This CL modifies
the test system to run tests with inferiors compile with the "-gsplit-dwarf"

Differential revision: http://reviews.llvm.org/D13300

Modified:
lldb/trunk/test/dotest.py
lldb/trunk/test/dotest_args.py
lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py
lldb/trunk/test/lldbtest.py
lldb/trunk/test/make/Makefile.rules
lldb/trunk/test/plugins/builder_base.py

Modified: lldb/trunk/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=249530&r1=249529&r2=249530&view=diff
==
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Wed Oct  7 05:02:17 2015
@@ -112,6 +112,7 @@ just_do_benchmarks_test = False
 
 dont_do_dsym_test = False
 dont_do_dwarf_test = False
+dont_do_dwo_test = False
 
 # The blacklist is optional (-b blacklistFile) and allows a central place to 
skip
 # testclass's and/or testclass.testmethod's.
@@ -469,6 +470,7 @@ def parseOptionsAndInitTestdirs():
 global just_do_benchmarks_test
 global dont_do_dsym_test
 global dont_do_dwarf_test
+global dont_do_dwo_test
 global blacklist
 global blacklistConfig
 global categoriesList
@@ -599,6 +601,8 @@ def parseOptionsAndInitTestdirs():
 # argparse makes sure we have correct options
 if args.N == 'dwarf':
 dont_do_dwarf_test = True
+elif args.N == 'dwo':
+dont_do_dwo_test = True
 elif args.N == 'dsym':
 dont_do_dsym_test = True
 

Modified: lldb/trunk/test/dotest_args.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest_args.py?rev=249530&r1=249529&r2=249530&view=diff
==
--- lldb/trunk/test/dotest_args.py (original)
+++ lldb/trunk/test/dotest_args.py Wed Oct  7 05:02:17 2015
@@ -60,7 +60,7 @@ def create_parser():
 
 # Test filtering options
 group = parser.add_argument_group('Test filtering options')
-group.add_argument('-N', choices=['dwarf', 'dsym'], help="Don't do test 
cases marked with the @dsym decorator by passing 'dsym' as the option arg, or 
don't do test cases marked with the @dwarf decorator by passing 'dwarf' as the 
option arg")
+group.add_argument('-N', choices=['dwarf', 'dwo', 'dsym'], help="Don't do 
test cases marked with the @dsym_test/@dwarf_test/@dwo_test decorator by 
passing dsym/dwarf/dwo as the option arg")
 X('-a', "Don't do lldb Python API tests")
 X('+a', "Just do lldb Python API tests. Do not specify along with '-a'", 
dest='plus_a')
 X('+b', 'Just do benchmark tests', dest='plus_b')

Modified: lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py?rev=249530&r1=249529&r2=249530&view=diff
==
--- lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py (original)
+++ lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py Wed Oct  7 
05:02:17 2015
@@ -13,6 +13,7 @@ class DeadStripTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureWindows("llvm.org/pr24778")
+@expectedFailureDwo("llvm.org/pr25087")
 @skipIfFreeBSD # The -dead_strip linker option isn't supported on FreeBSD 
versions of ld.
 def test(self):
 """Test breakpoint works correctly with dead-code stripping."""

Modified: lldb/trunk/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=249530&r1=249529&r2=249530&view=diff
==
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Oct  7 05:02:17 2015
@@ -567,6 +567,23 @@ def dwarf_test(func):
 wrapper.__dwarf_test__ = True
 return wrapper
 
+def dwo_test(func):
+"""Decorate the item as a dwo test."""
+if isinstance(func, type) and issubclass(func, unittest2.TestCase):
+raise Exception("@dwo_test can only be used to decorate a test method")
+@wraps(func)
+def wrapper(self, *args, **kwargs):
+try:
+if lldb.dont_do_dwo_test:
+self.skipTest("dwo tests")
+except AttributeError:
+pass
+return func(self, *args, **kwargs)
+
+# Mark this function as such to separate them from the regular tests.
+wrapper.__dwo_test__ = True
+return wrapper
+
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
 if isinstance(func, type) and issubclass(func, unittest2.TestCase):
@@ -65

Re: [Lldb-commits] [PATCH] D13300: Run tests with dwo symbol files

2015-10-07 Thread Tamas Berghammer via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249530: Run tests with dwo symbol files (authored by 
tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D13300?vs=36114&id=36723#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13300

Files:
  lldb/trunk/test/dotest.py
  lldb/trunk/test/dotest_args.py
  lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py
  lldb/trunk/test/lldbtest.py
  lldb/trunk/test/make/Makefile.rules
  lldb/trunk/test/plugins/builder_base.py

Index: lldb/trunk/test/dotest.py
===
--- lldb/trunk/test/dotest.py
+++ lldb/trunk/test/dotest.py
@@ -112,6 +112,7 @@
 
 dont_do_dsym_test = False
 dont_do_dwarf_test = False
+dont_do_dwo_test = False
 
 # The blacklist is optional (-b blacklistFile) and allows a central place to skip
 # testclass's and/or testclass.testmethod's.
@@ -469,6 +470,7 @@
 global just_do_benchmarks_test
 global dont_do_dsym_test
 global dont_do_dwarf_test
+global dont_do_dwo_test
 global blacklist
 global blacklistConfig
 global categoriesList
@@ -599,6 +601,8 @@
 # argparse makes sure we have correct options
 if args.N == 'dwarf':
 dont_do_dwarf_test = True
+elif args.N == 'dwo':
+dont_do_dwo_test = True
 elif args.N == 'dsym':
 dont_do_dsym_test = True
 
Index: lldb/trunk/test/plugins/builder_base.py
===
--- lldb/trunk/test/plugins/builder_base.py
+++ lldb/trunk/test/plugins/builder_base.py
@@ -113,6 +113,17 @@
 # True signifies that we can handle building dwarf.
 return True
 
+def buildDwo(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
+"""Build the binaries with dwarf debug info."""
+commands = []
+if clean:
+commands.append([getMake(), "clean", getCmdLine(dictionary)])
+commands.append([getMake(), "MAKE_DSYM=NO", "MAKE_DWO=YES", getArchSpec(architecture), getCCSpec(compiler), getCmdLine(dictionary)])
+
+lldbtest.system(commands, sender=sender)
+# True signifies that we can handle building dwo.
+return True
+
 def cleanup(sender=None, dictionary=None):
 """Perform a platform-specific cleanup after the test."""
 #import traceback
Index: lldb/trunk/test/make/Makefile.rules
===
--- lldb/trunk/test/make/Makefile.rules
+++ lldb/trunk/test/make/Makefile.rules
@@ -185,6 +185,10 @@
 	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
 endif
 
+ifeq "$(MAKE_DWO)" "YES"
+	CFLAGS += -gsplit-dwarf
+endif
+
 CXXFLAGS += -std=c++11
 CXXFLAGS += $(CFLAGS)
 LD = $(CC)
Index: lldb/trunk/test/dotest_args.py
===
--- lldb/trunk/test/dotest_args.py
+++ lldb/trunk/test/dotest_args.py
@@ -60,7 +60,7 @@
 
 # Test filtering options
 group = parser.add_argument_group('Test filtering options')
-group.add_argument('-N', choices=['dwarf', 'dsym'], help="Don't do test cases marked with the @dsym decorator by passing 'dsym' as the option arg, or don't do test cases marked with the @dwarf decorator by passing 'dwarf' as the option arg")
+group.add_argument('-N', choices=['dwarf', 'dwo', 'dsym'], help="Don't do test cases marked with the @dsym_test/@dwarf_test/@dwo_test decorator by passing dsym/dwarf/dwo as the option arg")
 X('-a', "Don't do lldb Python API tests")
 X('+a', "Just do lldb Python API tests. Do not specify along with '-a'", dest='plus_a')
 X('+b', 'Just do benchmark tests', dest='plus_b')
Index: lldb/trunk/test/lldbtest.py
===
--- lldb/trunk/test/lldbtest.py
+++ lldb/trunk/test/lldbtest.py
@@ -567,6 +567,23 @@
 wrapper.__dwarf_test__ = True
 return wrapper
 
+def dwo_test(func):
+"""Decorate the item as a dwo test."""
+if isinstance(func, type) and issubclass(func, unittest2.TestCase):
+raise Exception("@dwo_test can only be used to decorate a test method")
+@wraps(func)
+def wrapper(self, *args, **kwargs):
+try:
+if lldb.dont_do_dwo_test:
+self.skipTest("dwo tests")
+except AttributeError:
+pass
+return func(self, *args, **kwargs)
+
+# Mark this function as such to separate them from the regular tests.
+wrapper.__dwo_test__ = True
+return wrapper
+
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
 if isinstance(func, type) and issubclass(func, unittest2.TestCase):
@@ -657,10 +674,13 @@
 return expectedFailure(fn, bugnumber)
 
 def expectedFailureDwarf(bugnumber=None):
-return expectedFailureAll(bugnumber==bugnumber, debug_info="dwarf")
+return expectedFailureAll(bugnumber=bugnumber, debug_info="dwarf")
+
+def expectedFailureD

Re: [Lldb-commits] [PATCH] D13300: Run tests with dwo symbol files

2015-10-07 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

I committed in this CL in its current state (with fixing the issues raised by 
Pavel).

If you see any of the newly added dwo test failing on your platform then please 
skip/xfail them accordingly or let me know so I can take a look.

If you have to disable the running of all dwo related tests on a platform then 
you can do it with setting dont_do_dwo_test to True with the correct condition 
(see the setting of dont_do_dsym_test in dotest.py:1520)


Repository:
  rL LLVM

http://reviews.llvm.org/D13300



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


[Lldb-commits] [lldb] r249539 - XFAIL new dwo test failing with totclang on linux i386

2015-10-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Oct  7 06:40:10 2015
New Revision: 249539

URL: http://llvm.org/viewvc/llvm-project?rev=249539&view=rev
Log:
XFAIL new dwo test failing with totclang on linux i386

Modified:

lldb/trunk/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py

Modified: 
lldb/trunk/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py?rev=249539&r1=249538&r2=249539&view=diff
==
--- 
lldb/trunk/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
 (original)
+++ 
lldb/trunk/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
 Wed Oct  7 06:40:10 2015
@@ -13,6 +13,7 @@ class BreakpointLocationsTestCase(TestBa
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureWindows("llvm.org/pr24528")
+@expectedFailureAll(oslist=["linux"], compiler="clang", 
compiler_version=["=", "3.8"], archs=["i386"], debug_info="dwo")
 def test(self):
 """Test breakpoint enable/disable for a breakpoint ID with multiple 
locations."""
 self.build()


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


[Lldb-commits] [lldb] r249541 - Remove working directory from remote platform in the test suite

2015-10-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Oct  7 07:38:29 2015
New Revision: 249541

URL: http://llvm.org/viewvc/llvm-project?rev=249541&view=rev
Log:
Remove working directory from remote platform in the test suite

Previously we haven't cleaned up the working directory we created on
the remote platform and because of it we run out of storage on some
android device/emulator (caused by the 2x increase of the number of
test cases because of dwo).

Modified:
lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=249541&r1=249540&r2=249541&view=diff
==
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Oct  7 07:38:29 2015
@@ -2472,6 +2472,13 @@ class TestBase(Base):
 error = lldb.remote_platform.MakeDirectory(remote_test_dir, 0700)
 if error.Success():
 lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
+
+def remove_working_dir():
+# TODO: Make it working on Windows when we need it for 
remote debugging support
+# TODO: Add a command to SBPlatform/Platform to remove a 
(non empty) directory
+shell_cmd = lldb.SBPlatformShellCommand("rm -rf %s" % 
remote_test_dir)
+lldb.remote_platform.Run(shell_cmd)
+self.addTearDownHook(remove_working_dir)
 else:
 print "error: making remote directory '%s': %s" % 
(remote_test_dir, error)
 


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


[Lldb-commits] [lldb] r249549 - Fix race condition in the working directory cleanup code

2015-10-07 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Wed Oct  7 09:52:16 2015
New Revision: 249549

URL: http://llvm.org/viewvc/llvm-project?rev=249549&view=rev
Log:
Fix race condition in the working directory cleanup code

Modified:
lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=249549&r1=249548&r2=249549&view=diff
==
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Oct  7 09:52:16 2015
@@ -2473,12 +2473,17 @@ class TestBase(Base):
 if error.Success():
 lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
 
-def remove_working_dir():
+# This function removes all files from the current working 
directory while leaving
+# the directories in place. The cleaup is required to reduce 
the disk space required
+# by the test suit while leaving the directories untached is 
neccessary because
+# sub-directories might belong to an other test
+def clean_working_directory():
 # TODO: Make it working on Windows when we need it for 
remote debugging support
-# TODO: Add a command to SBPlatform/Platform to remove a 
(non empty) directory
-shell_cmd = lldb.SBPlatformShellCommand("rm -rf %s" % 
remote_test_dir)
+# TODO: Replace the heuristic to remove the files with a 
logic what collects the
+# list of files we have to remove during test runs.
+shell_cmd = lldb.SBPlatformShellCommand("rm %s/*" % 
remote_test_dir)
 lldb.remote_platform.Run(shell_cmd)
-self.addTearDownHook(remove_working_dir)
+self.addTearDownHook(clean_working_directory)
 else:
 print "error: making remote directory '%s': %s" % 
(remote_test_dir, error)
 


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


[Lldb-commits] [lldb] r249821 - Fix regression caused by r249769

2015-10-09 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  9 06:01:56 2015
New Revision: 249821

URL: http://llvm.org/viewvc/llvm-project?rev=249821&view=rev
Log:
Fix regression caused by r249769

* Change TestSettings to test qith go instead of pascal as ToT pascal
  support isn't complete
* Fix crash inside PluginManager

Modified:
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/test/settings/TestSettings.py

Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=249821&r1=249820&r2=249821&view=diff
==
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Fri Oct  9 06:01:56 2015
@@ -2564,6 +2564,7 @@ PluginManager::RegisterPlugin (const Con
 if (description && description[0])
 instance.description = description;
 instance.create_callback = create_callback;
+instance.enumerate_callback = enumerate_supported_languages_callback;
 Mutex::Locker locker (GetTypeSystemMutex ());
 GetTypeSystemInstances ().push_back (instance);
 }

Modified: lldb/trunk/test/settings/TestSettings.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=249821&r1=249820&r2=249821&view=diff
==
--- lldb/trunk/test/settings/TestSettings.py (original)
+++ lldb/trunk/test/settings/TestSettings.py Fri Oct  9 06:01:56 2015
@@ -405,9 +405,9 @@ class SettingsCommandTestCase(TestBase):
 self.runCmd("settings clear stop-disassembly-display", check=False)

 # language
 self.runCmd ("settings set target.language c89")  # Set to known 
value
-self.runCmd ("settings set target.language pascal ")# Set to new 
value with trailing whitespace
+self.runCmd ("settings set target.language go ")  # Set to new 
value with trailing whitespace
 self.expect ("settings show target.language", 
SETTING_MSG("target.language"),
-startstr = "target.language (language) = pascal")
+startstr = "target.language (language) = go")
 self.runCmd("settings clear target.language", check=False)
 # arguments
 self.runCmd ("settings set target.run-args 1 2 3")  # Set to known 
value


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


[Lldb-commits] [lldb] r249825 - Fix the way dwo tests are skipped on darwin

2015-10-09 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  9 07:06:07 2015
New Revision: 249825

URL: http://llvm.org/viewvc/llvm-project?rev=249825&view=rev
Log:
Fix the way dwo tests are skipped on darwin

We want to skip these tests when the target platform is darwin, not
when the host because they have to be enabled in case of darwin ->
android

Modified:
lldb/trunk/test/dotest.py

Modified: lldb/trunk/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=249825&r1=249824&r2=249825&view=diff
==
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Fri Oct  9 07:06:07 2015
@@ -112,7 +112,7 @@ just_do_benchmarks_test = False
 
 dont_do_dsym_test = False
 dont_do_dwarf_test = False
-dont_do_dwo_test = sys.platform == 'darwin'
+dont_do_dwo_test = False
 
 # The blacklist is optional (-b blacklistFile) and allows a central place to 
skip
 # testclass's and/or testclass.testmethod's.
@@ -1513,11 +1513,12 @@ if __name__ == "__main__":
 
 target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
 
-# By default, both dsym and dwarf tests are performed.
-# Use @dsym_test or @dwarf_test decorators, defined in lldbtest.py, to 
mark a test
-# as a dsym or dwarf test.  Use '-N dsym' or '-N dwarf' to exclude dsym or 
dwarf
-# tests from running.
-dont_do_dsym_test = dont_do_dsym_test or "linux" in target_platform or 
"freebsd" in target_platform or "windows" in target_platform
+# By default, both dsym, dwarf and dwo tests are performed.
+# Use @dsym_test, @dwarf_test or @dwo_test decorators, defined in 
lldbtest.py, to mark a test as
+# a dsym, dwarf or dwo test.  Use '-N dsym', '-N dwarf' or '-N dwo' to 
exclude dsym, dwarf or
+# dwo tests from running.
+dont_do_dsym_test = dont_do_dsym_test or any(platform in target_platform 
for platform in ["linux", "freebsd", "windows"])
+dont_do_dwo_test = dont_do_dwo_test or any(platform in target_platform for 
platform in ["darwin", "macosx", "ios"])
 
 # Don't do debugserver tests on everything except OS X.
 dont_do_debugserver_test = "linux" in target_platform or "freebsd" in 
target_platform or "windows" in target_platform


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


[Lldb-commits] [lldb] r249826 - Fix the windows build after r249747

2015-10-09 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  9 07:06:10 2015
New Revision: 249826

URL: http://llvm.org/viewvc/llvm-project?rev=249826&view=rev
Log:
Fix the windows build after r249747

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=249826&r1=249825&r2=249826&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct  9 07:06:10 2015
@@ -368,7 +368,9 @@ ClangASTContext::GetPluginVersion()
 }
 
 lldb::TypeSystemSP
-ClangASTContext::CreateInstance (lldb::LanguageType language, Module *module, 
Target *target)
+ClangASTContext::CreateInstance (lldb::LanguageType language,
+ lldb_private::Module *module,
+ Target *target)
 {
 if (ClangASTContextSupportsLanguage(language))
 {


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


Re: [Lldb-commits] [PATCH] D13578: Allow generic arm ArchSpec to merge with specific arm ArchSpec; allow Cortex M0-7's to always force thumb mode

2015-10-09 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

In general I like the approach you are taking and creating 
IsAlwaysThumbInstructions sounds like a good idea, but I would implement it a 
bit differently.

llvm::Triple already contains a SubArch field what is filled in from the first 
part of the triple in case of arm so I would prefer to use that instead because 
then we update the architecture information inside the Triple also what is used 
in many places (I would expect that the information you put into the core field 
will get lost at some place).

Just for curiosity, how do you debug a Cortex-M4 processor? Do you have 
PlatformJTAG/ProcessJTAG implementations or do you use debugserver on them?


Repository:
  rL LLVM

http://reviews.llvm.org/D13578



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


Re: [Lldb-commits] [PATCH] D13588: dotest.py: Fail if we detect multiple tests with the same name

2015-10-09 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D13588



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


[Lldb-commits] [lldb] r249827 - Fix a crash, an UB and add some assert to dwo symbol file handling

2015-10-09 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Fri Oct  9 07:43:08 2015
New Revision: 249827

URL: http://llvm.org/viewvc/llvm-project?rev=249827&view=rev
Log:
Fix a crash, an UB and add some assert to dwo symbol file handling

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/trunk/source/Symbol/ClangASTContext.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=249827&r1=249826&r2=249827&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Oct  
9 07:43:08 2015
@@ -772,6 +772,10 @@ DWARFASTParserClang::ParseTypeFromDWARF
 // will automatically call the SymbolFile virtual 
function
 // "SymbolFileDWARF::CompleteType(Type *)"
 // When the definition needs to be defined.
+
assert(!dwarf->GetForwardDeclClangTypeToDie().count(ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType())
 &&
+   "Type already in the forward declaration 
map!");
+
assert(((SymbolFileDWARF*)m_ast.GetSymbolFile())->UserIDMatches(die.GetDIERef().GetUID())
 &&
+   "Adding incorrect type to forward 
declaration map");
 
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = 
clang_type.GetOpaqueQualType();
 
dwarf->GetForwardDeclClangTypeToDie()[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()]
 = die.GetDIERef();
 m_ast.SetHasExternalStorage 
(clang_type.GetOpaqueQualType(), true);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=249827&r1=249826&r2=249827&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct  9 
07:43:08 2015
@@ -1555,6 +1555,8 @@ SymbolFileDWARF::CompleteType (CompilerT
 DWARFDebugInfo* debug_info = DebugInfo();
 DWARFDIE dwarf_die = debug_info->GetDIE(die_it->getSecond());
 
+assert(UserIDMatches(die_it->getSecond().GetUID()) && "CompleteType called 
on the wrong SymbolFile");
+
 // Once we start resolving this type, remove it from the forward 
declaration
 // map in case anyone child members or other types require this type to 
get resolved.
 // The type will get resolved when all of the calls to 
SymbolFileDWARF::ResolveClangOpaqueTypeDefinition

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=249827&r1=249826&r2=249827&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Fri Oct  
9 07:43:08 2015
@@ -125,3 +125,9 @@ SymbolFileDWARFDwo::GetLocationListForma
 {
 return DWARFExpression::SplitDwarfLocationList;
 }
+
+TypeSystem*
+SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language)
+{
+return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=249827&r1=249826&r2=249827&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Fri Oct  9 
07:43:08 2015
@@ -41,6 +41,9 @@ public:
 lldb_private::DWARFExpression::LocationListFormat
 GetLocationListFormat() const override;
 
+lldb_private::TypeSystem*
+GetTypeSystemForLanguage(lldb::LanguageType language) override;
+
 protected:
 DIEToTypePtr&
 GetDIEToType() override;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=249827&r1=249826&r2=249827&view=diff
==
--- lldb/t

[Lldb-commits] [lldb] r250024 - Improve TestValueOfVectorVariable

2015-10-12 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Mon Oct 12 05:33:04 2015
New Revision: 250024

URL: http://llvm.org/viewvc/llvm-project?rev=250024&view=rev
Log:
Improve TestValueOfVectorVariable

* XFAIL it for android arm/aarch64 as watchpoints aren't supported there
* Remove the dwarf/dsym test separation as they will be generated automatically

Modified:

lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py

Modified: 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py?rev=250024&r1=250023&r2=250024&view=diff
==
--- 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
 (original)
+++ 
lldb/trunk/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
 Mon Oct 12 05:33:04 2015
@@ -12,17 +12,10 @@ class TestValueOfVectorVariableTestCase(
 
 mydir = TestBase.compute_mydir(__file__)
 
-@dsym_test
-def test_value_of_vector_variable_with_dsym_using_watchpoint_set(self):
+@expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not 
supported
+def test_value_of_vector_variable_using_watchpoint_set(self):
 """Test verify displayed value of vector variable."""
-self.buildDsym(dictionary=self.d)
-self.setTearDownCleanup(dictionary=self.d)
-self.value_of_vector_variable_with_watchpoint_set()
-
-@dwarf_test
-def test_value_of_vector_variable_with_dwarf_using_watchpoint_set(self):
-"""Test verify displayed value of vector variable."""
-self.buildDwarf(dictionary=self.d)
+self.build(dictionary=self.d)
 self.setTearDownCleanup(dictionary=self.d)
 self.value_of_vector_variable_with_watchpoint_set()
 


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


[Lldb-commits] [PATCH] D13652: Change ConstString to support massive multi-threaded access

2015-10-12 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: labath, clayborg.
tberghammer added a subscriber: lldb-commits.

Change ConstString to support massive multi-threaded access

Previously ConstString had a single mutex guarding the global string
pool for each access what become a bottleneck when using it with a
large number of threads.

This CL distributes the strings to 256 individual string pools based on
a simple hash function to eliminate the bottleneck and speed up the
multi-thread access.

The goal of the change is to prepare to multi-threaded symbol parsing code
to speed up the symbol parsing speed.

http://reviews.llvm.org/D13652

Files:
  source/Core/ConstString.cpp

Index: source/Core/ConstString.cpp
===
--- source/Core/ConstString.cpp
+++ source/Core/ConstString.cpp
@@ -10,6 +10,7 @@
 #include "lldb/Core/Stream.h"
 #include "lldb/Host/Mutex.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringExtras.h"
 
 #include  // std::once
 
@@ -22,25 +23,6 @@
 typedef const char * StringPoolValueType;
 typedef llvm::StringMap StringPool;
 typedef llvm::StringMapEntry StringPoolEntryType;
-
-//--
-// Default constructor
-//
-// Initialize the member variables and create the empty string.
-//--
-Pool () :
-m_mutex (Mutex::eMutexTypeRecursive),
-m_string_map ()
-{
-}
-
-//--
-// Destructor
-//--
-~Pool ()
-{
-}
-
 
 static StringPoolEntryType &
 GetStringMapEntryFromKeyData (const char *keyData)
@@ -85,42 +67,41 @@
 {
 if (cstr)
 return GetConstCStringWithLength (cstr, strlen (cstr));
-return NULL;
+return nullptr;
 }
 
 const char *
 GetConstCStringWithLength (const char *cstr, size_t cstr_len)
 {
 if (cstr)
-{
-Mutex::Locker locker (m_mutex);
-llvm::StringRef string_ref (cstr, cstr_len);
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
-return entry.getKeyData();
-}
-return NULL;
+return GetConstCStringWithStringRef(llvm::StringRef(cstr, cstr_len));
+return nullptr;
 }
 
 const char *
 GetConstCStringWithStringRef (const llvm::StringRef &string_ref)
 {
 if (string_ref.data())
 {
-Mutex::Locker locker (m_mutex);
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
+uint8_t h = hash (string_ref);
+Mutex::Locker locker (m_string_pools[h].m_mutex);
+StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (std::make_pair (string_ref, nullptr)).first;
 return entry.getKeyData();
 }
-return NULL;
+return nullptr;
 }
 
 const char *
 GetConstCStringAndSetMangledCounterPart (const char *demangled_cstr, const char *mangled_ccstr)
 {
 if (demangled_cstr)
 {
-Mutex::Locker locker (m_mutex);
+llvm::StringRef string_ref (demangled_cstr);
+uint8_t h = hash (string_ref);
+Mutex::Locker locker (m_string_pools[h].m_mutex);
+
 // Make string pool entry with the mangled counterpart already set
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (llvm::StringRef (demangled_cstr), mangled_ccstr)).first;
+StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (std::make_pair (string_ref, mangled_ccstr)).first;
 
 // Extract the const version of the demangled_cstr
 const char *demangled_ccstr = entry.getKeyData();
@@ -130,7 +111,7 @@
 // Return the constant demangled C string
 return demangled_ccstr;
 }
-return NULL;
+return nullptr;
 }
 
 const char *
@@ -141,7 +122,7 @@
 const size_t trimmed_len = std::min (strlen (cstr), cstr_len);
 return GetConstCStringWithLength (cstr, trimmed_len);
 }
-return NULL;
+return nullptr;
 }
 
 //--
@@ -152,28 +133,36 @@
 size_t
 MemorySize() const
 {
-Mutex::Locker locker (m_mutex);
 size_t mem_size = sizeof(Pool);
-const_iterator end = m_string_map.end();
-for (const_iterator pos = m_string_map.begin(); pos != end; ++pos)
+for (const auto& pool : m_string_pools)
 {
-mem_size += sizeof(StringPoolEntryType) + pos->getKey().size();
+

[Lldb-commits] [PATCH] D13662: Make dwarf parsing multi-threaded

2015-10-12 Thread Tamas Berghammer via lldb-commits
tberghammer created this revision.
tberghammer added reviewers: labath, clayborg.
tberghammer added a subscriber: lldb-commits.

Make dwarf parsing multi-threaded

Loading the debug info from a large application is the slowest task
LLDB do. This CL makes most of the dwarf parsing code multi-threaded.

As a result the speed of "attach; backtrace; exit;" when the inferior
is an LLDB with full debug info increased by a factor of 2 (on my machine).

http://reviews.llvm.org/D13662

Files:
  source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
  source/Plugins/SymbolFile/DWARF/NameToDIE.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -65,6 +65,7 @@
 #include "SymbolFileDWARFDwo.h"
 #include "SymbolFileDWARFDebugMap.h"
 
+#include 
 #include 
 
 #include 
@@ -2038,29 +2039,54 @@
 DWARFDebugInfo* debug_info = DebugInfo();
 if (debug_info)
 {
-uint32_t cu_idx = 0;
 const uint32_t num_compile_units = GetNumCompileUnits();
-for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
+std::mutex index_mutex;
+std::vector> parsers;
+for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
 {
-DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
-
-bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded (false) > 1;
-
-dwarf_cu->Index (m_function_basename_index,
- m_function_fullname_index,
- m_function_method_index,
- m_function_selector_index,
- m_objc_class_selectors_index,
- m_global_index, 
- m_type_index,
- m_namespace_index);
-
-// Keep memory down by clearing DIEs if this generate function
-// caused them to be parsed
-if (clear_dies)
-dwarf_cu->ClearDIEs (true);
+parsers.emplace_back(std::async(std::launch::async, [this, cu_idx, debug_info, &index_mutex]()
+{
+DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded(false) > 1;
+
+NameToDIE function_basename_index;
+NameToDIE function_fullname_index;
+NameToDIE function_method_index;
+NameToDIE function_selector_index;
+NameToDIE objc_class_selectors_index;
+NameToDIE global_index;
+NameToDIE type_index;
+NameToDIE namespace_index;
+dwarf_cu->Index(function_basename_index,
+function_fullname_index,
+function_method_index,
+function_selector_index,
+objc_class_selectors_index,
+global_index, 
+type_index,
+namespace_index);
+
+// Keep memory down by clearing DIEs if this generate function
+// caused them to be parsed
+if (clear_dies)
+dwarf_cu->ClearDIEs(true);
+
+std::lock_guard lock(index_mutex);
+m_function_basename_index.Append(function_basename_index);
+m_function_fullname_index.Append(function_fullname_index);
+m_function_method_index.Append(function_method_index);
+m_function_selector_index.Append(function_selector_index);
+m_objc_class_selectors_index.Append(objc_class_selectors_index);
+m_global_index.Append(global_index);
+m_type_index.Append(type_index);
+m_namespace_index.Append(namespace_index);
+}));
 }
-
+
+// Wait for all parser to finish
+for (auto& p : parsers)
+p.wait();
+
 m_function_basename_index.Finalize();
 m_function_fullname_index.Finalize();
 m_function_method_index.Finalize();
Index: source/Plugins/SymbolFile/DWARF/NameToDIE.h
===
--- source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -38,6 +38,9 @@
 Insert (const lldb_private::ConstString& name, const DIERef& die_ref);
 
 void
+Append (const NameToDIE& other);
+
+void
 Finalize();
 
 size_t
Index: source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
===
--- source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ source/Plugins/Sym

Re: [Lldb-commits] [PATCH] D13662: Make dwarf parsing multi-threaded

2015-10-12 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

It is depending on the implementation of std::async what AFAIK isn't defined by 
the standard, but I would expect that a decent stl implementation will create a 
reasonable number of threads (in some sense).

While developing/testing the code (with ~3000 CU in a SymbolFile) I seen that 
the number of running threads (not blocked in a mutex) was around the number of 
cores I have (on Linux x86_64 with libstdc++). It was ~60 threads after fixing 
the mutex in ConstString (http://reviews.llvm.org/D13652) and ~500 before on a 
40 core machine but considering that thread creation isn't expensive on Linux 
we don't have to worry about too much thread if they are blocked anyway (thread 
creation wasn't significant on the profiling output).

I can create manual thread pool (or write a general thread pool class) but I 
think we can rely on the standard library until it is proven that it isn't 
working as we expect.


http://reviews.llvm.org/D13662



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


Re: [Lldb-commits] [PATCH] D13652: Change ConstString to support massive multi-threaded access

2015-10-12 Thread Tamas Berghammer via lldb-commits
tberghammer added inline comments.


Comment at: source/Core/ConstString.cpp:147-152
@@ -165,7 +146,8 @@
 protected:
-//--
-// Typedefs
-//--
-typedef StringPool::iterator iterator;
-typedef StringPool::const_iterator const_iterator;
+uint8_t
+hash(const llvm::StringRef &s)
+{
+uint32_t h = llvm::HashString(s);
+return ((h >> 24) ^ (h >> 16) ^ (h >> 8) ^ h) & 0xff;
+}
 

clayborg wrote:
> Is there a way we can use the hash that llvm uses for its string pool here? 
> We are calculating two hashes: one for this to see which pool it will go 
> into, and then another when the string is hashed into the string pool object. 
> It would be nice if we can calculate the hash once and maybe do/add a string 
> pool insertion that the pool with use to verify the string is in the pool or 
> insert it using the supplied hash?
I don't see any reasonable way to avoid using 2 hash function without 
re-implementing llvm::StringMap with multi-threaded support in mind with per 
bucket mutextes. One of the issue is that llvm::StringMap don't have any 
interface where we can specify a hash value for an insert to avoid the 
calculation of the hash. The other problem is that we want to use a different 
hash function for selecting the pool and then selecting the bucket to achieve a 
uniform distribution between the buckets inside the StringMap. I am already a 
little bit concerned because we use 2 very similar hash function (StringMap use 
the LSB of llvm::HashString) what can cause some performance degradation.

I think a nice solution would be to use a hash map with built in multi-threaded 
support, or even better with a lock-free implementation (lock/unlock takes a 
lot of time) but I don't think implementing it would worth the effort.


Comment at: source/Core/ConstString.cpp:175
@@ -174,3 @@
-//--
-mutable Mutex m_mutex;
-StringPool m_string_map;

zturner wrote:
> Did you consider changing this to an `llvm::RWMutex`?
I haven't tried it, but I don't see any easy way to use it because we use a 
single StringMap::insert call to read and possibly write to the map. If we want 
to get the advantage out from RWMutex then we should split it into a 
StringMap::find and then a StringMap::insert call what is doing 2 lookup.


http://reviews.llvm.org/D13652



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


Re: [Lldb-commits] [PATCH] D13695: lldb-server: add support for binary memory reads

2015-10-13 Thread Tamas Berghammer via lldb-commits
tberghammer accepted this revision.
tberghammer added a comment.
This revision is now accepted and ready to land.

Look good


http://reviews.llvm.org/D13695



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


Re: [Lldb-commits] [PATCH] D13652: Change ConstString to support massive multi-threaded access

2015-10-13 Thread Tamas Berghammer via lldb-commits
tberghammer updated this revision to Diff 37258.
tberghammer added a comment.

Use llvm::sys::RWMutex

Using it have a minor performance hit for debug info parsing because of the 
intensive write operations, but should have a positive impact on all reads 
(most access after debug info parsing). If the performance hit for writes isn't 
acceptable we can add a flag to the ConstString constructor hinting that we are 
creating a new string so we don't have to make a check in this case, but I 
prefer to don't do it until we can prove it is necessary.


http://reviews.llvm.org/D13652

Files:
  source/Core/ConstString.cpp

Index: source/Core/ConstString.cpp
===
--- source/Core/ConstString.cpp
+++ source/Core/ConstString.cpp
@@ -10,37 +10,20 @@
 #include "lldb/Core/Stream.h"
 #include "lldb/Host/Mutex.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/RWMutex.h"
 
-#include  // std::once
+#include 
+#include 
 
 using namespace lldb_private;
 
-
 class Pool
 {
 public:
 typedef const char * StringPoolValueType;
 typedef llvm::StringMap StringPool;
 typedef llvm::StringMapEntry StringPoolEntryType;
-
-//--
-// Default constructor
-//
-// Initialize the member variables and create the empty string.
-//--
-Pool () :
-m_mutex (Mutex::eMutexTypeRecursive),
-m_string_map ()
-{
-}
-
-//--
-// Destructor
-//--
-~Pool ()
-{
-}
-
 
 static StringPoolEntryType &
 GetStringMapEntryFromKeyData (const char *keyData)
@@ -85,42 +68,49 @@
 {
 if (cstr)
 return GetConstCStringWithLength (cstr, strlen (cstr));
-return NULL;
+return nullptr;
 }
 
 const char *
 GetConstCStringWithLength (const char *cstr, size_t cstr_len)
 {
 if (cstr)
-{
-Mutex::Locker locker (m_mutex);
-llvm::StringRef string_ref (cstr, cstr_len);
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
-return entry.getKeyData();
-}
-return NULL;
+return GetConstCStringWithStringRef(llvm::StringRef(cstr, cstr_len));
+return nullptr;
 }
 
 const char *
 GetConstCStringWithStringRef (const llvm::StringRef &string_ref)
 {
 if (string_ref.data())
 {
-Mutex::Locker locker (m_mutex);
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (string_ref, (StringPoolValueType)NULL)).first;
+uint8_t h = hash (string_ref);
+
+{
+llvm::sys::SmartScopedReader rlock(m_string_pools[h].m_mutex);
+auto it = m_string_pools[h].m_string_map.find (string_ref);
+if (it != m_string_pools[h].m_string_map.end())
+return it->getKeyData();
+}
+
+llvm::sys::SmartScopedWriter wlock(m_string_pools[h].m_mutex);
+StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (std::make_pair (string_ref, nullptr)).first;
 return entry.getKeyData();
 }
-return NULL;
+return nullptr;
 }
 
 const char *
 GetConstCStringAndSetMangledCounterPart (const char *demangled_cstr, const char *mangled_ccstr)
 {
 if (demangled_cstr)
 {
-Mutex::Locker locker (m_mutex);
+llvm::StringRef string_ref (demangled_cstr);
+uint8_t h = hash (string_ref);
+llvm::sys::SmartScopedWriter wlock(m_string_pools[h].m_mutex);
+
 // Make string pool entry with the mangled counterpart already set
-StringPoolEntryType& entry = *m_string_map.insert (std::make_pair (llvm::StringRef (demangled_cstr), mangled_ccstr)).first;
+StringPoolEntryType& entry = *m_string_pools[h].m_string_map.insert (std::make_pair (string_ref, mangled_ccstr)).first;
 
 // Extract the const version of the demangled_cstr
 const char *demangled_ccstr = entry.getKeyData();
@@ -130,7 +120,7 @@
 // Return the constant demangled C string
 return demangled_ccstr;
 }
-return NULL;
+return nullptr;
 }
 
 const char *
@@ -141,7 +131,7 @@
 const size_t trimmed_len = std::min (strlen (cstr), cstr_len);
 return GetConstCStringWithLength (cstr, trimmed_len);
 }
-return NULL;
+return nullptr;
 }
 
 //--
@@ -152,28 +142,31 @@
 size_t
 MemorySize() const
 {
-

[Lldb-commits] [lldb] r250180 - Fix cast in arm watchpoint handling code

2015-10-13 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Tue Oct 13 11:48:04 2015
New Revision: 250180

URL: http://llvm.org/viewvc/llvm-project?rev=250180&view=rev
Log:
Fix cast in arm watchpoint handling code

We had an incorrect sign extension when castion from a pointer to an
lldb::addr_t what broke the watchpoint hit detection on arm.

Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=250180&r1=250179&r2=250180&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Tue Oct 13 
11:48:04 2015
@@ -1282,7 +1282,7 @@ NativeProcessLinux::MonitorSIGTRAP(const
 {
 // If a watchpoint was hit, report it
 uint32_t wp_index;
-Error error = 
thread.GetRegisterContext()->GetWatchpointHitIndex(wp_index, 
(lldb::addr_t)info.si_addr);
+Error error = 
thread.GetRegisterContext()->GetWatchpointHitIndex(wp_index, 
(uintptr_t)info.si_addr);
 if (error.Fail() && log)
 log->Printf("NativeProcessLinux::%s() "
 "received error while checking for watchpoint hits, "


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


Re: [Lldb-commits] [PATCH] D13578: Allow generic arm ArchSpec to merge with specific arm ArchSpec; allow Cortex M0-7's to always force thumb mode

2015-10-13 Thread Tamas Berghammer via lldb-commits
tberghammer added inline comments.


Comment at: source/Core/ArchSpec.cpp:859-870
@@ -853,1 +858,14 @@
+
+// If this and other are both arm ArchSpecs and this ArchSpec is a generic 
"some kind of arm"
+// spec but the other ArchSpec is a specific arm core, adopt the specific 
arm core.
+if (GetTriple().getArch() == llvm::Triple::arm
+&& other.GetTriple().getArch() == llvm::Triple::arm
+&& IsCompatibleMatch (other)
+&& GetCore() == ArchSpec::eCore_arm_generic
+&& other.GetCore() != ArchSpec::eCore_arm_generic)
+{
+m_core = other.GetCore();
+CoreUpdated (true);
+}
+
 if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment)

I would like to see this part of the code to be replaced with something like 
this so we store the sub-architecture inside the triple and we don't have to 
special case arm (it is already done in llvm::Triple):

```
if (GetTriple().getSubArch() == llvm::Triple::NoSubArch)
GetTriple().setSubArch(other.GetTriple().getSubArch());
```


Repository:
  rL LLVM

http://reviews.llvm.org/D13578



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


  1   2   3   4   5   6   7   8   >