[Lldb-commits] [lldb] r335967 - Add a test for reading lld-generated build-ids

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 29 05:15:55 PDT 2018


Author: labath
Date: Fri Jun 29 05:15:54 2018
New Revision: 335967

URL: http://llvm.org/viewvc/llvm-project?rev=335967&view=rev
Log:
Add a test for reading lld-generated build-ids

Summary:
This test makes sure we are able to read the shorter build-ids which are
generated by lld.

To make this work, I've extended lldb-test to print the UUID of the
loaded object file. I've renamed the lldb-test subcommand from
"module-sections" to "object-file" to reflect the fact it prints more
than just the sections.

I've also added the module Architecture to the output, so we could avoid
printing the entire symbol file information just to get the ArchSpec
details in the lc_version_min test (which was also the only test in it's
folder not using the module-sections command).

Reviewers: aprantl, zturner

Subscribers: lldb-commits

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

Added:
    lldb/trunk/lit/Modules/short-build-id.yaml
Modified:
    lldb/trunk/lit/Modules/build-id-case.yaml
    lldb/trunk/lit/Modules/compressed-sections.yaml
    lldb/trunk/lit/Modules/elf-duplicate-section.yaml
    lldb/trunk/lit/Modules/elf-section-types.yaml
    lldb/trunk/lit/Modules/lc_version_min.yaml
    lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/build-id-case.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/build-id-case.yaml?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/build-id-case.yaml (original)
+++ lldb/trunk/lit/Modules/build-id-case.yaml Fri Jun 29 05:15:54 2018
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # CHECK: Name: .debug_frame
 # CHECK-NEXT: Type: dwarf-frame

Modified: lldb/trunk/lit/Modules/compressed-sections.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/compressed-sections.yaml?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/compressed-sections.yaml Fri Jun 29 05:15:54 2018
@@ -1,6 +1,6 @@
 # REQUIRES: zlib
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections --contents %t | FileCheck %s
+# RUN: lldb-test object-file --contents %t | FileCheck %s
 --- !ELF
 FileHeader:
   Class:           ELFCLASS32

Modified: lldb/trunk/lit/Modules/elf-duplicate-section.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/elf-duplicate-section.yaml?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/elf-duplicate-section.yaml (original)
+++ lldb/trunk/lit/Modules/elf-duplicate-section.yaml Fri Jun 29 05:15:54 2018
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # Make sure that the debug_frame section is present only once.
 # CHECK: Name: .debug_frame

Modified: lldb/trunk/lit/Modules/elf-section-types.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/elf-section-types.yaml?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/elf-section-types.yaml (original)
+++ lldb/trunk/lit/Modules/elf-section-types.yaml Fri Jun 29 05:15:54 2018
@@ -1,5 +1,5 @@
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections %t | FileCheck %s
+# RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Name: .text
 # CHECK-NEXT: Type: code

Modified: lldb/trunk/lit/Modules/lc_version_min.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_version_min.yaml?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/lit/Modules/lc_version_min.yaml (original)
+++ lldb/trunk/lit/Modules/lc_version_min.yaml Fri Jun 29 05:15:54 2018
@@ -1,8 +1,8 @@
 # RUN: yaml2obj %s > %t.out
-# RUN: lldb-test symbols %t.out | FileCheck %s
+# RUN: lldb-test object-file %t.out | FileCheck %s
 
 # Test that the deployment target is parsed from the load commands.
-# CHECK: x86_64-apple-macosx10.9.0
+# CHECK: Architecture: x86_64-apple-macosx10.9.0
 --- !mach-o
 FileHeader:      
   magic:           0xFEEDFACF

Added: lldb/trunk/lit/Modules/short-build-id.yaml
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/short-build-id.yaml?rev=335967&view=auto
==============================================================================
--- lldb/trunk/lit/Modules/short-build-id.yaml (added)
+++ lldb/trunk/lit/Modules/short-build-id.yaml Fri Jun 29 05:15:54 2018
@@ -0,0 +1,26 @@
+# RUN: yaml2obj %s >%t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: UUID: 333059A4-3CC3-D5F9
+
+--- !ELF
+FileHeader:      
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+  Entry:           0x0000000000201000
+Sections:        
+  - Name:            .note.gnu.build-id
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000200190
+    AddressAlign:    0x0000000000000004
+    Content:         040000000800000003000000474E5500333059A43CC3D5F9
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x0000000000201000
+    AddressAlign:    0x0000000000000004
+    Content:         ''
+...

Modified: lldb/trunk/tools/lldb-test/lldb-test.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/lldb-test.cpp?rev=335967&r1=335966&r2=335967&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/lldb-test.cpp (original)
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp Fri Jun 29 05:15:54 2018
@@ -51,14 +51,15 @@ using namespace llvm;
 namespace opts {
 static cl::SubCommand BreakpointSubcommand("breakpoints",
                                            "Test breakpoint resolution");
-cl::SubCommand ModuleSubcommand("module-sections",
-                                "Display LLDB Module Information");
+cl::SubCommand ObjectFileSubcommand("object-file",
+                                    "Display LLDB object file information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
 cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
 
 cl::opt<std::string> Log("log", cl::desc("Path to a log file"), cl::init(""),
                          cl::sub(BreakpointSubcommand),
-                         cl::sub(ModuleSubcommand), cl::sub(SymbolsSubcommand),
+                         cl::sub(ObjectFileSubcommand),
+                         cl::sub(SymbolsSubcommand),
                          cl::sub(IRMemoryMapSubcommand));
 
 /// Create a target using the file pointed to by \p Filename, or abort.
@@ -85,13 +86,14 @@ static std::string substitute(StringRef
 static int evaluateBreakpoints(Debugger &Dbg);
 } // namespace breakpoint
 
-namespace module {
+namespace object {
 cl::opt<bool> SectionContents("contents",
                               cl::desc("Dump each section's contents"),
-                              cl::sub(ModuleSubcommand));
+                              cl::sub(ObjectFileSubcommand));
 cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input files>"),
-                                     cl::OneOrMore, cl::sub(ModuleSubcommand));
-} // namespace module
+                                     cl::OneOrMore,
+                                     cl::sub(ObjectFileSubcommand));
+} // namespace object
 
 namespace symbols {
 static cl::list<std::string> InputFilenames(cl::Positional,
@@ -616,11 +618,11 @@ int opts::symbols::dumpSymbols(Debugger
   return HadErrors;
 }
 
-static int dumpModules(Debugger &Dbg) {
+static int dumpObjectFiles(Debugger &Dbg) {
   LinePrinter Printer(4, llvm::outs());
 
   int HadErrors = 0;
-  for (const auto &File : opts::module::InputFilenames) {
+  for (const auto &File : opts::object::InputFilenames) {
     ModuleSpec Spec{FileSpec(File, false)};
 
     auto ModulePtr = std::make_shared<lldb_private::Module>(Spec);
@@ -634,6 +636,10 @@ static int dumpModules(Debugger &Dbg) {
       continue;
     }
 
+    Printer.formatLine("Architecture: {0}",
+                       ModulePtr->GetArchitecture().GetTriple().getTriple());
+    Printer.formatLine("UUID: {0}", ModulePtr->GetUUID().GetAsString());
+
     size_t Count = Sections->GetNumSections(0);
     Printer.formatLine("Showing {0} sections", Count);
     for (size_t I = 0; I < Count; ++I) {
@@ -646,7 +652,7 @@ static int dumpModules(Debugger &Dbg) {
       Printer.formatLine("VM size: {0}", S->GetByteSize());
       Printer.formatLine("File size: {0}", S->GetFileSize());
 
-      if (opts::module::SectionContents) {
+      if (opts::object::SectionContents) {
         DataExtractor Data;
         S->GetSectionData(Data);
         ArrayRef<uint8_t> Bytes = {Data.GetDataStart(), Data.GetDataEnd()};
@@ -841,8 +847,8 @@ int main(int argc, const char *argv[]) {
 
   if (opts::BreakpointSubcommand)
     return opts::breakpoint::evaluateBreakpoints(*Dbg);
-  if (opts::ModuleSubcommand)
-    return dumpModules(*Dbg);
+  if (opts::ObjectFileSubcommand)
+    return dumpObjectFiles(*Dbg);
   if (opts::SymbolsSubcommand)
     return opts::symbols::dumpSymbols(*Dbg);
   if (opts::IRMemoryMapSubcommand)




More information about the lldb-commits mailing list