[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Konstantin Baladurin via Phabricator via lldb-commits
kbaladurin updated this revision to Diff 140609.
kbaladurin added a comment.
Herald added a subscriber: javed.absar.

Thank you! I've extended `lldb-test` utility to dump section type:

  Showing 6 sections
Index: 0
Type: regular
Name: 
VM size: 0
File size: 0

Index: 1
Type: code
Name: .text
VM size: 8
File size: 8

Index: 2
Type: code
Name: __codesection
VM size: 8
File size: 8

Index: 3
Type: elf-symbol-table
Name: .symtab
VM size: 0
File size: 16
...

and added lit test to check section type and arm test in python test suite to 
check breakpoints in arbitrary named thumb code sections.


https://reviews.llvm.org/D44998

Files:
  include/lldb/Core/Section.h
  lit/Modules/elf-code-section.yaml
  packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
  
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
  packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  tools/lldb-test/lldb-test.cpp

Index: tools/lldb-test/lldb-test.cpp
===
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -212,6 +212,8 @@
   auto S = Sections->GetSectionAtIndex(I);
   assert(S);
   Printer.formatLine("Index: {0}", I);
+  Printer.formatLine("Type: {0}",
+ Section::GetSectionTypeAsCString(S->GetType()));
   Printer.formatLine("Name: {0}", S->GetName().GetStringRef());
   Printer.formatLine("VM size: {0}", S->GetByteSize());
   Printer.formatLine("File size: {0}", S->GetFileSize());
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1947,6 +1947,12 @@
 sect_type = kalimbaSectionType(m_header, header);
   }
 
+  if (eSectionTypeOther == sect_type &&
+  llvm::ELF::SHT_PROGBITS == header.sh_type &&
+  (header.sh_flags & SHF_EXECINSTR)) {
+sect_type = eSectionTypeCode;
+  }
+
   const uint32_t target_bytes_size =
   (eSectionTypeData == sect_type || eSectionTypeZeroFill == sect_type)
   ? m_arch_spec.GetDataByteSize()
Index: source/Core/Section.cpp
===
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -27,7 +27,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {
   case eSectionTypeInvalid:
 return "invalid";
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
@@ -0,0 +1,8 @@
+__attribute__((section("__codesection")))
+int f(int a) {
+  return a + 1; // Set break point at this line.
+}
+
+int main() {
+  return f(10);
+}
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
@@ -0,0 +1,35 @@
+"""
+Test that breakpoints correctly work in an thumb function in an atritbary
+named codesection.
+"""
+from __future__ import print_function
+
+
+import lldb
+import os
+import time
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBreakpointThumbCodesection(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(archs=no_match(["arm"]))
+def test_breakpoint(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+line = line_number('main.c', '// Set break point at this line.')
+
+self.runCmd("target create %s" % exe)
+bpid = lldbutil.run_break_set_by_file_and_line(self, "main.c", line)
+
+self.runCmd("run")
+
+self.assertIsNotNone(lldbutil.get_one_thread_stopped_at_breakpoint_id(
+self.process(), bpid), "Process is not stopped at breakpoint")
+
+self.process().Continue()
+self.assertEqual(self.process().GetState(), lldb.eStateExited, PROCESS_EXITED)
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS = -mthumb

[Lldb-commits] [lldb] r328966 - [test] Exit lldb-dotest in a more Pythonic way.

2018-04-02 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Mon Apr  2 03:44:36 2018
New Revision: 328966

URL: http://llvm.org/viewvc/llvm-project?rev=328966&view=rev
Log:
[test] Exit lldb-dotest in a more Pythonic way.

As suggested by Keith Smiley in:
https://github.com/apple/swift-lldb/pull/486

Modified:
lldb/trunk/test/lldb-dotest.in

Modified: lldb/trunk/test/lldb-dotest.in
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldb-dotest.in?rev=328966&r1=328965&r2=328966&view=diff
==
--- lldb/trunk/test/lldb-dotest.in (original)
+++ lldb/trunk/test/lldb-dotest.in Mon Apr  2 03:44:36 2018
@@ -12,7 +12,5 @@ if __name__ == '__main__':
 cmd = [dotest_path, '-q']
 cmd.extend(dotest_args)
 cmd.extend(wrapper_args)
-# Invoke dotest.py
-exit_code = subprocess.call(cmd)
-if exit_code != 0:
-  sys.exit(exit_code)
+# Invoke dotest.py and return exit code.
+sys.exit(subprocess.call(cmd))


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


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

I think this is almost ready to go in modulo minors. I'll let also @labath 
comment on it. Thanks for your contribution!
Do you need somebody to commit this on your behalf?




Comment at: 
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py:2
+"""
+Test that breakpoints correctly work in an thumb function in an atritbary
+named codesection.

nit: arbitrary.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1950-1954
+  if (eSectionTypeOther == sect_type &&
+  llvm::ELF::SHT_PROGBITS == header.sh_type &&
+  (header.sh_flags & SHF_EXECINSTR)) {
+sect_type = eSectionTypeCode;
+  }

can you add a comment explaining why this is needed?


https://reviews.llvm.org/D44998



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


[Lldb-commits] [PATCH] D44613: Support template template parameters

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Sorry for the delay.


https://reviews.llvm.org/D44613



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


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Konstantin Baladurin via Phabricator via lldb-commits
kbaladurin updated this revision to Diff 140628.
kbaladurin added a comment.

@davide thank you! I've updated diff. Yes, I need somebody to commit this, so I 
haven't commit access.


https://reviews.llvm.org/D44998

Files:
  include/lldb/Core/Section.h
  lit/Modules/elf-code-section.yaml
  packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
  
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
  packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  tools/lldb-test/lldb-test.cpp

Index: tools/lldb-test/lldb-test.cpp
===
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -212,6 +212,8 @@
   auto S = Sections->GetSectionAtIndex(I);
   assert(S);
   Printer.formatLine("Index: {0}", I);
+  Printer.formatLine("Type: {0}",
+ Section::GetSectionTypeAsCString(S->GetType()));
   Printer.formatLine("Name: {0}", S->GetName().GetStringRef());
   Printer.formatLine("VM size: {0}", S->GetByteSize());
   Printer.formatLine("File size: {0}", S->GetFileSize());
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1947,6 +1947,16 @@
 sect_type = kalimbaSectionType(m_header, header);
   }
 
+  // In common case ELF code section can have arbitrary name (for example,
+  // we can specify it using section attribute for particular function) so
+  // assume that section is a code section if it has SHF_EXECINSTR flag set
+  // and has SHT_PROGBITS type.
+  if (eSectionTypeOther == sect_type &&
+  llvm::ELF::SHT_PROGBITS == header.sh_type &&
+  (header.sh_flags & SHF_EXECINSTR)) {
+sect_type = eSectionTypeCode;
+  }
+
   const uint32_t target_bytes_size =
   (eSectionTypeData == sect_type || eSectionTypeZeroFill == sect_type)
   ? m_arch_spec.GetDataByteSize()
Index: source/Core/Section.cpp
===
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -27,7 +27,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {
   case eSectionTypeInvalid:
 return "invalid";
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
@@ -0,0 +1,8 @@
+__attribute__((section("__codesection")))
+int f(int a) {
+  return a + 1; // Set break point at this line.
+}
+
+int main() {
+  return f(10);
+}
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
@@ -0,0 +1,35 @@
+"""
+Test that breakpoints correctly work in an thumb function in an arbitrary
+named codesection.
+"""
+from __future__ import print_function
+
+
+import lldb
+import os
+import time
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBreakpointThumbCodesection(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(archs=no_match(["arm"]))
+def test_breakpoint(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+line = line_number('main.c', '// Set break point at this line.')
+
+self.runCmd("target create %s" % exe)
+bpid = lldbutil.run_break_set_by_file_and_line(self, "main.c", line)
+
+self.runCmd("run")
+
+self.assertIsNotNone(lldbutil.get_one_thread_stopped_at_breakpoint_id(
+self.process(), bpid), "Process is not stopped at breakpoint")
+
+self.process().Continue()
+self.assertEqual(self.process().GetState(), lldb.eStateExited, PROCESS_EXITED)
Index: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS = -mthumb
+
+include $(LEVEL)/Makefile.rules
\ No newline at end of file
Index: lit/Modules/elf-code-section.yaml
===
--- /dev/null
+++ lit/Modules/elf-code-section.yaml
@@ -0,0 +

[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added inline comments.
This revision now requires changes to proceed.



Comment at: 
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c:1
+__attribute__((section("__codesection")))
+int f(int a) {

Will this work with all compilers we currently run the test suite with? I would 
assume with will work with GCC and Clang at least. IF not, we might need to 
make a lldbtest.h file that any test case can use and use a macro here?



Comment at: source/Core/Section.cpp:30
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {

Why did you take static off of this function? Please remove this change, or 
change this function to get the section type from the section itself and not 
require the argument.


https://reviews.llvm.org/D44998



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


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Konstantin Baladurin via Phabricator via lldb-commits
kbaladurin added inline comments.



Comment at: 
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c:1
+__attribute__((section("__codesection")))
+int f(int a) {

clayborg wrote:
> Will this work with all compilers we currently run the test suite with? I 
> would assume with will work with GCC and Clang at least. IF not, we might 
> need to make a lldbtest.h file that any test case can use and use a macro 
> here?
What compilers do we use with test suite? This construction works fine with gcc 
and clang. Is it enough for us?



Comment at: source/Core/Section.cpp:30
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {

clayborg wrote:
> Why did you take static off of this function? Please remove this change, or 
> change this function to get the section type from the section itself and not 
> require the argument.
I change it to static method to use it in `lldb-test`. There is similar static 
methods in `Value` and `Scalar` classes: `Value::GetValueTypeAsCString` and 
`Scalar::GetValueTypeAsCString`. Is non static method more preferable for us in 
this case?


https://reviews.llvm.org/D44998



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


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.

LGTM. I'll commit for you once Greg reviews it again.




Comment at: 
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c:1
+__attribute__((section("__codesection")))
+int f(int a) {

kbaladurin wrote:
> clayborg wrote:
> > Will this work with all compilers we currently run the test suite with? I 
> > would assume with will work with GCC and Clang at least. IF not, we might 
> > need to make a lldbtest.h file that any test case can use and use a macro 
> > here?
> What compilers do we use with test suite? This construction works fine with 
> gcc and clang. Is it enough for us?
I think this is fine.
BTW, if we really want to abstract this, the place is not lldb but llvm.
We already have an header for the purpose.

```
llvm/Support/Compiler.h
```

But again, I don't think this is needed.



Comment at: source/Core/Section.cpp:30
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {

kbaladurin wrote:
> clayborg wrote:
> > Why did you take static off of this function? Please remove this change, or 
> > change this function to get the section type from the section itself and 
> > not require the argument.
> I change it to static method to use it in `lldb-test`. There is similar 
> static methods in `Value` and `Scalar` classes: 
> `Value::GetValueTypeAsCString` and `Scalar::GetValueTypeAsCString`. Is non 
> static method more preferable for us in this case?
I think what you did was correct. Greg?


https://reviews.llvm.org/D44998



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


[Lldb-commits] [PATCH] D44613: Support template template parameters

2018-04-02 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328984: Support template template parameters (authored by 
friss, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44613

Files:
  lldb/trunk/include/lldb/Symbol/ClangASTContext.h
  
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp

Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -1482,6 +1482,29 @@
   return class_template_decl;
 }
 
+TemplateTemplateParmDecl *
+ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) {
+  ASTContext *ast = getASTContext();
+
+  auto *decl_ctx = ast->getTranslationUnitDecl();
+
+  IdentifierInfo &identifier_info = ast->Idents.get(template_name);
+  llvm::SmallVector template_param_decls;
+
+  ClangASTContext::TemplateParameterInfos template_param_infos;
+  TemplateParameterList *template_param_list = CreateTemplateParameterList(
+  ast, template_param_infos, template_param_decls);
+
+  // LLDB needs to create those decls only to be able to display a
+  // type that includes a template template argument. Only the name
+  // matters for this purpose, so we use dummy values for the other
+  // characterisitcs of the type.
+  return TemplateTemplateParmDecl::Create(
+  *ast, decl_ctx, SourceLocation(),
+  /*Depth*/ 0, /*Position*/ 0,
+  /*IsParameterPack*/ false, &identifier_info, template_param_list);
+}
+
 ClassTemplateSpecializationDecl *
 ClangASTContext::CreateClassTemplateSpecializationDecl(
 DeclContext *decl_ctx, ClassTemplateDecl *class_template_decl, int kind,
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -41,6 +41,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
 
 #include 
 #include 
@@ -2042,6 +2043,7 @@
 const DWARFDIE &die,
 ClangASTContext::TemplateParameterInfos &template_param_infos) {
   const dw_tag_t tag = die.Tag();
+  bool is_template_template_argument = false;
 
   switch (tag) {
   case DW_TAG_GNU_template_parameter_pack: {
@@ -2057,11 +2059,15 @@
 }
 return true;
   }
+  case DW_TAG_GNU_template_template_param:
+is_template_template_argument = true;
+LLVM_FALLTHROUGH;
   case DW_TAG_template_type_parameter:
   case DW_TAG_template_value_parameter: {
 DWARFAttributes attributes;
 const size_t num_attributes = die.GetAttributes(attributes);
 const char *name = nullptr;
+const char *template_name = nullptr;
 CompilerType clang_type;
 uint64_t uval64 = 0;
 bool uval64_valid = false;
@@ -2076,6 +2082,11 @@
 name = form_value.AsCString();
   break;
 
+case DW_AT_GNU_template_name:
+  if (attributes.ExtractFormValueAtIndex(i, form_value))
+template_name = form_value.AsCString();
+  break;
+
 case DW_AT_type:
   if (attributes.ExtractFormValueAtIndex(i, form_value)) {
 Type *lldb_type = die.ResolveTypeUID(DIERef(form_value));
@@ -2099,7 +2110,7 @@
   if (!clang_type)
 clang_type = m_ast.GetBasicType(eBasicTypeVoid);
 
-  if (clang_type) {
+  if (!is_template_template_argument) {
 bool is_signed = false;
 if (name && name[0])
   template_param_infos.names.push_back(name);
@@ -2119,7 +2130,10 @@
   clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
 }
   } else {
-return false;
+auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name);
+template_param_infos.names.push_back(name);
+template_param_infos.args.push_back(
+clang::TemplateArgument(clang::TemplateName(tplt_type)));
   }
 }
   }
@@ -2146,6 +2160,7 @@
 case DW_TAG_template_type_parameter:
 case DW_TAG_template_value_parameter:
 case DW_TAG_GNU_template_parameter_pack:
+case DW_TAG_GNU_template_template_param:
   ParseTemplateDIE(die, template_param_infos);
   break;
 
Index: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
===
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h
@@ -305,6 +305,9 @@
   lldb::AccessType access_type, const char *class_name,
  

[Lldb-commits] [lldb] r328984 - Support template template parameters

2018-04-02 Thread Frederic Riss via lldb-commits
Author: friss
Date: Mon Apr  2 09:18:32 2018
New Revision: 328984

URL: http://llvm.org/viewvc/llvm-project?rev=328984&view=rev
Log:
Support template template parameters

Summary:
We would fail to resolve (and thus display the value of) any
templated type which contained a template template argument even
though we don't really use template arguments.

This patch adds minimal support for template template arguments,
but I doubt we need any more than that.

Reviewers: clayborg, jingham

Subscribers: JDevlieghere, lldb-commits

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

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

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.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=328984&r1=328983&r2=328984&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Mon Apr  2 09:18:32 2018
@@ -305,6 +305,9 @@ public:
   lldb::AccessType access_type, const char *class_name,
   int kind, const TemplateParameterInfos &infos);
 
+  clang::TemplateTemplateParmDecl *
+  CreateTemplateTemplateParmDecl(const char *template_name);
+
   clang::ClassTemplateSpecializationDecl 
*CreateClassTemplateSpecializationDecl(
   clang::DeclContext *decl_ctx,
   clang::ClassTemplateDecl *class_template_decl, int kind,

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py?rev=328984&r1=328983&r2=328984&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py 
Mon Apr  2 09:18:32 2018
@@ -83,6 +83,34 @@ class TemplateArgsTestCase(TestBase):
 expr_result.GetType().GetName() == "int",
 'expr_result.GetType().GetName() == "int"')
 
+def test_template_template_args(self):
+frame = self.prepareProcess()
+
+c1 = frame.FindVariable('c1')
+self.assertTrue(
+c1.IsValid(),
+'make sure we find a local variabble named "c1"')
+self.assertTrue(c1.GetType().GetName() == 'C')
+f1 = 
c1.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f")
+self.assertTrue(f1.GetType().GetName() == 'float')
+self.assertTrue(f1.GetValue() == '1.5')
+
+c2 = frame.FindVariable('c2')
+self.assertTrue(
+c2.IsValid(),
+'make sure we find a local variabble named "c2"')
+self.assertTrue(c2.GetType().GetName() == 'C')
+f2 = 
c2.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f")
+self.assertTrue(f2.GetType().GetName() == 'double')
+self.assertTrue(f2.GetValue() == '1.5')
+f3 = 
c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("f")
+self.assertTrue(f3.GetType().GetName() == 'double')
+self.assertTrue(f3.GetValue() == '2.5')
+f4 = 
c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("i")
+self.assertTrue(f4.GetType().GetName() == 'int')
+self.assertTrue(f4.GetValue() == '42')
+
+
 # Gcc does not generate the necessary DWARF attribute for enum template
 # parameters.
 @expectedFailureAll(bugnumber="llvm.org/pr28354", compiler="gcc")

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp?rev=328984&r1=328983&r2=328984&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp Mon 
Apr  2 09:18:32 2018
@@ -6,6 +6,7 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
+#include 
 
 template 
 class TestObj
@@ -62,11 +63,17 @@ public:
 }
 };
 
+template  struct T1 { FLOAT f = 1.5; };
+template  struct T2 { FLOAT f = 2.5; int i = 42; };
+template  class ...Args> class C { 
std::tuple...> V; };
+
 int main(int argc, char **argv)
 {
   TestObj<1> testpos;
   TestObj<-1> testneg;
   EnumTemplate member(123

[Lldb-commits] [PATCH] D42656: [testsuite] Remove flakey test relying on `pexpect`

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
davide abandoned this revision.
davide added a comment.

I think this is obsolete by now.


https://reviews.llvm.org/D42656



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


[Lldb-commits] [PATCH] D41997: Build virtual override tables in DWARFASTParserClang::CompleteTypeFromDWARF

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
davide closed this revision.
davide added a comment.

Lang committed this a while ago (r323163)


Repository:
  rL LLVM

https://reviews.llvm.org/D41997



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


[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, davide, aprantl, jasonmolenda.
Herald added a subscriber: JDevlieghere.

Many things that were in DWARFCompileUnit actually need to be in DWARFUnit. 
This patch moves all DWARFUnit specific things over into DWARFUnit and fixes 
the layering. This is in preparation for adding DWARFTypeUnit for the 
.debug_types patch.


https://reviews.llvm.org/D45170

Files:
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -136,7 +136,7 @@
   friend class DebugMapModule;
   friend struct DIERef;
   friend class DWARFASTParserClang;
-  friend class DWARFCompileUnit;
+  friend class DWARFUnit;
   friend class SymbolFileDWARF;
   struct OSOInfo {
 lldb::ModuleSP module_sp;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -71,7 +71,7 @@
   friend class SymbolFileDWARFDwo;
   friend class DebugMapModule;
   friend struct DIERef;
-  friend class DWARFCompileUnit;
+  friend class DWARFUnit;
   friend class DWARFDIE;
   friend class DWARFASTParserClang;
   friend class DWARFASTParserGo;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -772,7 +772,7 @@
   } else {
 ModuleSP module_sp(m_obj_file->GetModule());
 if (module_sp) {
-  const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+  const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
   if (cu_die) {
 FileSpec cu_file_spec{cu_die.GetName(), false};
 if (cu_file_spec) {
@@ -909,7 +909,7 @@
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
 
 if (cu_die) {
   const char *cu_comp_dir = resolveCompDir(
@@ -948,7 +948,7 @@
   UpdateExternalModuleListIfNeeded();
 
   if (sc.comp_unit) {
-const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
 
 if (die) {
   for (DWARFDIE child_die = die.GetFirstChild(); child_die;
@@ -1024,7 +1024,7 @@
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
 if (dwarf_cu_die) {
   const dw_offset_t cu_line_offset =
   dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
@@ -1109,7 +1109,7 @@
   if (dwarf_cu == nullptr)
 return false;
 
-  const DWARFDIE dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+  const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
   if (!dwarf_cu_die)
 return false;
 
@@ -1620,7 +1620,7 @@
   for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
 DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
 if (die && die.HasChildren() == false) {
   const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -42,7 +42,7 @@
DWARFDIECollection &matching_dies,
uint32_t depth = UINT32_MAX) const;
   bool Verify(lldb_private::Stream *s) const;
-  void Dump(lldb_private::Stream *s) const;
+  virtual void Dump(lldb_private::Stream *s) const = 0;
   // Offset of the initial length field.
   dw_offset_t GetOffset() const { return m_offset; }
   lldb::user_id_t GetID() const;
@@ -65,24 +65,25 @@
   dw_addr_t GetBaseAddress() const;
   dw_addr_t GetAddrBase() const;
   dw_addr_t GetRangesBase() const;
-  void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base, dw_offset_t base_obj_offset);
+  void SetAddrBase(

[Lldb-commits] [lldb] r328985 - [Core] Grab-bag of improvements for Scalar.

2018-04-02 Thread Davide Italiano via lldb-commits
Author: davide
Date: Mon Apr  2 09:50:54 2018
New Revision: 328985

URL: http://llvm.org/viewvc/llvm-project?rev=328985&view=rev
Log:
[Core] Grab-bag of improvements for Scalar.

Remove Scalar::Cast.

It was noted on the list that this method is unused. So, this patch
removes it.

Fix Scalar::Promote for most integer types

This fixes promotion of most integer types (128- and 256-bit types are
handled in a subsequent patch) to floating-point types. Previously
promotion was done bitwise, where value preservation is correct.

Fix Scalar::Promote for 128- and 256-bit integer types

This patch fixes the behavior of Scalar::Promote when trying to
perform a binary operation involving a 128- or 256-bit integer type
and a floating-point type. Now, the integer is cast to the floating
point type for the operation.

Patch by Tom Tromey!

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

Modified:
lldb/trunk/include/lldb/Core/Scalar.h
lldb/trunk/source/Core/Scalar.cpp
lldb/trunk/unittests/Core/ScalarTest.cpp

Modified: lldb/trunk/include/lldb/Core/Scalar.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=328985&r1=328984&r2=328985&view=diff
==
--- lldb/trunk/include/lldb/Core/Scalar.h (original)
+++ lldb/trunk/include/lldb/Core/Scalar.h Mon Apr  2 09:50:54 2018
@@ -50,13 +50,13 @@ public:
 e_ulong,
 e_slonglong,
 e_ulonglong,
-e_float,
-e_double,
-e_long_double,
-e_uint128,
 e_sint128,
+e_uint128,
+e_sint256,
 e_uint256,
-e_sint256
+e_float,
+e_double,
+e_long_double
   };
 
   //--
@@ -165,8 +165,6 @@ public:
 
   bool Promote(Scalar::Type type);
 
-  bool Cast(Scalar::Type type);
-
   bool MakeSigned();
 
   bool MakeUnsigned();

Modified: lldb/trunk/source/Core/Scalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=328985&r1=328984&r2=328985&view=diff
==
--- lldb/trunk/source/Core/Scalar.cpp (original)
+++ lldb/trunk/source/Core/Scalar.cpp Mon Apr  2 09:50:54 2018
@@ -491,20 +491,24 @@ bool Scalar::Promote(Scalar::Type type)
   break;
 
 case e_float:
-  m_float = llvm::APFloat(m_integer.bitsToFloat());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_double:
-  m_float = llvm::APFloat(m_integer.bitsToDouble());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_long_double:
-  if (m_ieee_quad)
-m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), m_integer);
-  else
-m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), m_integer);
+  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
+  : 
llvm::APFloat::x87DoubleExtended());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 }
@@ -551,20 +555,24 @@ bool Scalar::Promote(Scalar::Type type)
   break;
 
 case e_float:
-  m_float = llvm::APFloat(m_integer.bitsToFloat());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
+  m_float.convertFromAPInt(m_integer, false,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_double:
-  m_float = llvm::APFloat(m_integer.bitsToDouble());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
+  m_float.convertFromAPInt(m_integer, false,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_long_double:
-  if (m_ieee_quad)
-m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), m_integer);
-  else
-m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), m_integer);
+  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
+  : 
llvm::APFloat::x87DoubleExtended());
+  m_float.convertFromAPInt(m_integer, false,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 }
@@ -607,20 +615,24 @@ bool Scalar::Promote(Scalar::Type type)
   break;
 
 case e_float:
-  m_float = llvm::APFloat(m_integer.bitsToFloat());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   succes

[Lldb-commits] [PATCH] D44907: Remove Scalar::Cast

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328985: [Core] Grab-bag of improvements for Scalar. 
(authored by davide, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44907?vs=139844&id=140642#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44907

Files:
  lldb/trunk/include/lldb/Core/Scalar.h
  lldb/trunk/source/Core/Scalar.cpp
  lldb/trunk/unittests/Core/ScalarTest.cpp

Index: lldb/trunk/include/lldb/Core/Scalar.h
===
--- lldb/trunk/include/lldb/Core/Scalar.h
+++ lldb/trunk/include/lldb/Core/Scalar.h
@@ -50,13 +50,13 @@
 e_ulong,
 e_slonglong,
 e_ulonglong,
-e_float,
-e_double,
-e_long_double,
-e_uint128,
 e_sint128,
+e_uint128,
+e_sint256,
 e_uint256,
-e_sint256
+e_float,
+e_double,
+e_long_double
   };
 
   //--
@@ -165,8 +165,6 @@
 
   bool Promote(Scalar::Type type);
 
-  bool Cast(Scalar::Type type);
-
   bool MakeSigned();
 
   bool MakeUnsigned();
Index: lldb/trunk/unittests/Core/ScalarTest.cpp
===
--- lldb/trunk/unittests/Core/ScalarTest.cpp
+++ lldb/trunk/unittests/Core/ScalarTest.cpp
@@ -73,6 +73,12 @@
   ASSERT_EQ((unsigned long)a, a_scalar.ULong());
   ASSERT_EQ((signed long long)a, a_scalar.SLongLong());
   ASSERT_EQ((unsigned long long)a, a_scalar.ULongLong());
+
+  int a2 = 23;
+  Scalar a2_scalar(a2);
+  ASSERT_EQ((float)a2, a2_scalar.Float());
+  ASSERT_EQ((double)a2, a2_scalar.Double());
+  ASSERT_EQ((long double)a2, a2_scalar.LongDouble());
 }
 
 TEST(ScalarTest, ExtractBitfield) {
@@ -140,3 +146,42 @@
   EXPECT_TRUE(r.IsValid());
   EXPECT_EQ(r, Scalar(2.5));
 }
+
+TEST(ScalarTest, Promotion) {
+  static Scalar::Type int_types[] = {
+  Scalar::e_sint,Scalar::e_uint,  Scalar::e_slong,
+  Scalar::e_ulong,   Scalar::e_slonglong, Scalar::e_ulonglong,
+  Scalar::e_sint128, Scalar::e_uint128,   Scalar::e_sint256,
+  Scalar::e_uint256,
+  Scalar::e_void // sentinel
+  };
+
+  static Scalar::Type float_types[] = {
+  Scalar::e_float, Scalar::e_double, Scalar::e_long_double,
+  Scalar::e_void // sentinel
+  };
+
+  for (int i = 0; int_types[i] != Scalar::e_void; ++i) {
+for (int j = 0; float_types[j] != Scalar::e_void; ++j) {
+  Scalar lhs(2);
+  EXPECT_TRUE(lhs.Promote(int_types[i])) << "int promotion #" << i;
+  Scalar rhs(0.5f);
+  EXPECT_TRUE(rhs.Promote(float_types[j])) << "float promotion #" << j;
+  Scalar x(2.5f);
+  EXPECT_TRUE(x.Promote(float_types[j]));
+  EXPECT_EQ(lhs + rhs, x);
+}
+  }
+
+  for (int i = 0; float_types[i] != Scalar::e_void; ++i) {
+for (int j = 0; float_types[j] != Scalar::e_void; ++j) {
+  Scalar lhs(2);
+  EXPECT_TRUE(lhs.Promote(float_types[i])) << "float promotion #" << i;
+  Scalar rhs(0.5f);
+  EXPECT_TRUE(rhs.Promote(float_types[j])) << "float promotion #" << j;
+  Scalar x(2.5f);
+  EXPECT_TRUE(x.Promote(float_types[j]));
+  EXPECT_EQ(lhs + rhs, x);
+}
+  }
+}
Index: lldb/trunk/source/Core/Scalar.cpp
===
--- lldb/trunk/source/Core/Scalar.cpp
+++ lldb/trunk/source/Core/Scalar.cpp
@@ -491,20 +491,24 @@
   break;
 
 case e_float:
-  m_float = llvm::APFloat(m_integer.bitsToFloat());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_double:
-  m_float = llvm::APFloat(m_integer.bitsToDouble());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_long_double:
-  if (m_ieee_quad)
-m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), m_integer);
-  else
-m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), m_integer);
+  m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
+  : llvm::APFloat::x87DoubleExtended());
+  m_float.convertFromAPInt(m_integer, true,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 }
@@ -551,20 +555,24 @@
   break;
 
 case e_float:
-  m_float = llvm::APFloat(m_integer.bitsToFloat());
+  m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
+  m_float.convertFromAPInt(m_integer, false,
+   llvm::APFloat::rmNearestTiesToEven);
   success = true;
   break;
 
 case e_double:
-  m_float = llvm::APFloat(m_integer.bitsToDouble());
+  m_

[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-02 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

Thanks Greg. This is a very large patch, but it seems mostly churn. I'll try to 
find the time to review it carefully tomorrow.


https://reviews.llvm.org/D45170



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


[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Yes this is just moving all ivars from DWARFCompileUnit to DWARFUnit, moving 
all functions that used those accessors to DWARFUnit and remove the indirection 
through DWARFCompileUnit that was in DWARFUnit using:

  virtual DWARFCompileUnit &Data() = 0;


https://reviews.llvm.org/D45170



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


[Lldb-commits] [PATCH] D45170: Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

No real functional change, just fixing layering and moving code. Also a 
renaming from GetCompileUnitDIEOnly to GetUnitDIEOnly.


https://reviews.llvm.org/D45170



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


[Lldb-commits] [lldb] r328990 - Added a BSD archive tool.

2018-04-02 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Mon Apr  2 10:20:21 2018
New Revision: 328990

URL: http://llvm.org/viewvc/llvm-project?rev=328990&view=rev
Log:
Added a BSD archive tool.

This is a combination stand alone BSD archive tool that can dump BSD archives:

% bsd.py /path/to/foo.a

Search archives for an object file:

% bsd.py --object foo.o bar.a

Dump the symbol definitions found in the __.SYMDEF objects:

% bsd.py --symdef bar.a

Find symbols by name that are listed in the __.SYMDEF objects:

% bsd.py --symbol _Z123 bar.a

Extract objects from BSD archives:

% bsd.py --object foo.o bar.a --extract
% bsd.py --object foo.o bar.a --extract --outfile /tmp/foo.o
% bsd.py --object foo.o bar.a --extract --mtime 0x1234556

It also has installs a new LLDB command line command when imported into LLDB:

(lldb) command script import ~/Dropbox/bin/bsd.py
The "verify-debug-map-objects" command has been installed, type "help 
verify-debug-map-objects" for detailed help.
(lldb) verify-debug-map-objects a.out

This will iterate through all object files and verify the modification times 
match for any .o files, it will verify any .o files from BSD archives are found 
and have matching modification times and print out errors if any are found.


Added:
lldb/trunk/examples/python/bsd.py   (with props)

Added: lldb/trunk/examples/python/bsd.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/bsd.py?rev=328990&view=auto
==
--- lldb/trunk/examples/python/bsd.py (added)
+++ lldb/trunk/examples/python/bsd.py Mon Apr  2 10:20:21 2018
@@ -0,0 +1,481 @@
+#!/usr/bin/python
+
+import optparse
+import os
+import shlex
+import struct
+import sys
+
+ARMAG = "!\n"
+SARMAG = 8
+ARFMAG = "`\n"
+AR_EFMT1 = "#1/"
+
+
+def memdump(src, bytes_per_line=16, address=0):
+FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.'
+ for x in range(256)])
+for i in range(0, len(src), bytes_per_line):
+s = src[i:i+bytes_per_line]
+hex_bytes = ' '.join(["%02x" % (ord(x)) for x in s])
+ascii = s.translate(FILTER)
+print("%#08.8x: %-*s %s" % (address+i, bytes_per_line*3, hex_bytes,
+ascii))
+
+
+class Object(object):
+def __init__(self, file):
+def read_str(file, str_len):
+return file.read(str_len).rstrip('\0 ')
+
+def read_int(file, str_len, base):
+return int(read_str(file, str_len), base)
+
+self.offset = file.tell()
+self.file = file
+self.name = read_str(file, 16)
+self.date = read_int(file, 12, 10)
+self.uid = read_int(file, 6, 10)
+self.gid = read_int(file, 6, 10)
+self.mode = read_int(file, 8, 8)
+self.size = read_int(file, 10, 10)
+if file.read(2) != ARFMAG:
+raise ValueError('invalid BSD object at offset %#08.8x' % (
+ self.offset))
+# If we have an extended name read it. Extended names start with
+name_len = 0
+if self.name.startswith(AR_EFMT1):
+name_len = int(self.name[len(AR_EFMT1):], 10)
+self.name = read_str(file, name_len)
+self.obj_offset = file.tell()
+self.obj_size = self.size - name_len
+file.seek(self.obj_size, 1)
+
+def dump(self, f=sys.stdout, flat=True):
+if flat:
+f.write('%#08.8x: %#08.8x %5u %5u %6o %#08.8x %s\n' % (self.offset,
+self.date, self.uid, self.gid, self.mode, self.size,
+self.name))
+else:
+f.write('%#08.8x: \n' % self.offset)
+f.write(' name = "%s"\n' % self.name)
+f.write(' date = %#08.8x\n' % self.date)
+f.write('  uid = %i\n' % self.uid)
+f.write('  gid = %i\n' % self.gid)
+f.write(' mode = %o\n' % self.mode)
+f.write(' size = %#08.8x\n' % (self.size))
+self.file.seek(self.obj_offset, 0)
+first_bytes = self.file.read(4)
+f.write('bytes = ')
+memdump(first_bytes)
+
+def get_bytes(self):
+saved_pos = self.file.tell()
+self.file.seek(self.obj_offset, 0)
+bytes = self.file.read(self.obj_size)
+self.file.seek(saved_pos, 0)
+return bytes
+
+
+class StringTable(object):
+def __init__(self, bytes):
+self.bytes = bytes
+
+def get_string(self, offset):
+length = len(self.bytes)
+if offset >= length:
+return None
+return self.bytes[offset:self.bytes.find('\0', offset)]
+
+
+class Archive(object):
+def __init__(self, path):
+self.path = path
+self.file = open(path, 'r')
+self.objects = []
+self.offset_to_object = {}
+if self.file.read(SARMAG) != ARMAG:
+print("error: file isn't a BSD archive")
+while True:
+try:
+self.objects.append(

Re: [Lldb-commits] [lldb] r328990 - Added a BSD archive tool.

2018-04-02 Thread Davide Italiano via lldb-commits
On Mon, Apr 2, 2018 at 10:20 AM, Greg Clayton via lldb-commits
 wrote:
> Author: gclayton
> Date: Mon Apr  2 10:20:21 2018
> New Revision: 328990
>
> URL: http://llvm.org/viewvc/llvm-project?rev=328990&view=rev
> Log:
> Added a BSD archive tool.
>
> This is a combination stand alone BSD archive tool that can dump BSD archives:
>

How is this different from llvm-objdump or llvm-readobj?
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r328990 - Added a BSD archive tool.

2018-04-02 Thread Davide Italiano via lldb-commits
Now with the correct e-mail.
How is this different from llvm-objdump or llvm-readobj?
(also you might want to update your commit e-mail as reply-to seems to
still be set to your @apple address and bounces back).

Thanks,

--
Davide

On Mon, Apr 2, 2018 at 10:25 AM, Davide Italiano  wrote:
> On Mon, Apr 2, 2018 at 10:20 AM, Greg Clayton via lldb-commits
>  wrote:
>> Author: gclayton
>> Date: Mon Apr  2 10:20:21 2018
>> New Revision: 328990
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=328990&view=rev
>> Log:
>> Added a BSD archive tool.
>>
>> This is a combination stand alone BSD archive tool that can dump BSD 
>> archives:
>>
>
> How is this different from llvm-objdump or llvm-readobj?
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The patch looks fine to me. I think I'd make the arm test (I guess that is 
interesting because of the bit 0 twiddling ?) a non-execution test, but this is 
fine as well.




Comment at: 
packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py:29
+
+self.runCmd("run")
+

Do you think there's any added value in making sure that the breakpoint is 
*hit* (instead of just making sure that it's resolved to the right file 
address). If it's the latter we could make this a non-execution test and have 
it run everywhere (e.g., via lldb-test breakpoint) instead of just on arm 
hardware.


https://reviews.llvm.org/D44998



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


[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

2018-04-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added inline comments.
This revision is now accepted and ready to land.



Comment at: source/Core/Section.cpp:30
 
-static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+const char *Section::GetSectionTypeAsCString(lldb::SectionType sect_type) {
   switch (sect_type) {

davide wrote:
> kbaladurin wrote:
> > clayborg wrote:
> > > Why did you take static off of this function? Please remove this change, 
> > > or change this function to get the section type from the section itself 
> > > and not require the argument.
> > I change it to static method to use it in `lldb-test`. There is similar 
> > static methods in `Value` and `Scalar` classes: 
> > `Value::GetValueTypeAsCString` and `Scalar::GetValueTypeAsCString`. Is non 
> > static method more preferable for us in this case?
> I think what you did was correct. Greg?
Woops, I missed the extra "Section::" that was added. You indeed did do this 
right... I thought in my mind that the "Section::" was there prior to this 
change and we were making the function a member function. My bad.


https://reviews.llvm.org/D44998



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