[llvm] r237721 - [DWARF parser] Add basic support for DWZ DWARF multifile extensions.

Sanjay Patel spatel at rotateright.com
Wed May 20 08:36:29 PDT 2015


Anyone else seeing this 'make check' failure? I'm running Darwin x86-64;
fails the same on 2 different machines.

FAIL: LLVM :: DebugInfo/dwarfdump-dwz.test (7308 of 13739)
******************** TEST 'LLVM :: DebugInfo/dwarfdump-dwz.test' FAILED
********************
Script:
--
/Users/spatel/myllvm/build/./bin/llvm-dwarfdump
/Users/spatel/myllvm/llvm/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64
-debug-dump=info | /Users/spatel/myllvm/build/./bin/FileCheck
/Users/spatel/myllvm/llvm/test/DebugInfo/dwarfdump-dwz.test -check-prefix
DUMP_INFO
--
Exit Code: 2

Command Output (stderr):
--
0  llvm-dwarfdump           0x000000010b1e523e
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  llvm-dwarfdump           0x000000010b1e6b09
PrintStackTraceSignalHandler(void*) + 25
2  llvm-dwarfdump           0x000000010b1e6f68 SignalHandler(int) + 584
3  libsystem_platform.dylib 0x00007fff8f71bf1a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fff54bb0690 _sigtramp + 3309914000
5  llvm-dwarfdump           0x000000010b0dd1ba
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1,
2ul, true> >::ELFFile(llvm::StringRef, std::__1::error_code&) + 1882
6  llvm-dwarfdump           0x000000010b0d387d
llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1,
2ul, true> >::ELFFile(llvm::StringRef, std::__1::error_code&) + 45
7  llvm-dwarfdump           0x000000010b0d383c
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1,
2ul, true> >::ELFObjectFile(llvm::MemoryBufferRef, std::__1::error_code&) +
220
8  llvm-dwarfdump           0x000000010b0d3483
llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1,
2ul, true> >::ELFObjectFile(llvm::MemoryBufferRef, std::__1::error_code&) +
67
9  llvm-dwarfdump           0x000000010b0d2bfa
llvm::object::ObjectFile::createELFObjectFile(llvm::MemoryBufferRef) + 1994
10 llvm-dwarfdump           0x000000010b11b834
llvm::object::ObjectFile::createObjectFile(llvm::MemoryBufferRef,
llvm::sys::fs::file_magic) + 308
11 llvm-dwarfdump           0x000000010b0583e6
llvm::object::ObjectFile::createObjectFile(llvm::MemoryBufferRef) + 118
12 llvm-dwarfdump           0x000000010b05036e DumpInput(llvm::StringRef) +
798
13 llvm-dwarfdump           0x000000010b04ffee main + 1518
14 libdyld.dylib            0x00007fff8f1d25c9 start + 1
15 libdyld.dylib            0x0000000000000003 start + 1893915195
Stack dump:
0.    Program arguments: /Users/spatel/myllvm/build/./bin/llvm-dwarfdump
/Users/spatel/myllvm/llvm/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64
-debug-dump=info
FileCheck error: '-' is empty.


On Tue, May 19, 2015 at 2:29 PM, Alexey Samsonov <vonosmas at gmail.com> wrote:

> Author: samsonov
> Date: Tue May 19 15:29:28 2015
> New Revision: 237721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=237721&view=rev
> Log:
> [DWARF parser] Add basic support for DWZ DWARF multifile extensions.
>
> This change implements basic support for DWARF alternate sections
> proposal: http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open
>
> LLVM tools now understand new forms: DW_FORM_GNU_ref_alt and
> DW_FORM_GNU_strp_alt, which are used as references to .debug_info and
> .debug_str sections respectively, stored in a separate file, and
> possibly shared between different executables / shared objects.
>
> llvm-dwarfdump and llvm-symbolizer don't yet know how to access this
> alternate debug file (usually pointed by .gnu_debugaltlink section),
> but they can at lease properly parse and dump regular files, which
> refer to it.
>
> This change should fix crashes of llvm-dwarfdump and llvm-symbolizer on
> files produced by running "dwz" tool. Such files are already installed
> on some modern Linux distributions.
>
> Added:
>     llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64   (with
> props)
>     llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.elf-x86-64.dwz
>     llvm/trunk/test/DebugInfo/dwarfdump-dwz.test
> Modified:
>     llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
>     llvm/trunk/include/llvm/Support/Dwarf.h
>     llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
>     llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
>     llvm/trunk/lib/Support/Dwarf.cpp
>     llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc
>
> Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Tue May 19
> 15:29:28 2015
> @@ -87,6 +87,8 @@ public:
>
>    static ArrayRef<uint8_t> getFixedFormSizes(uint8_t AddrSize,
>                                               uint16_t Version);
> +private:
> +  void dumpString(raw_ostream &OS, const DWARFUnit *U) const;
>  };
>
>  }
>
> Modified: llvm/trunk/include/llvm/Support/Dwarf.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/Dwarf.h (original)
> +++ llvm/trunk/include/llvm/Support/Dwarf.h Tue May 19 15:29:28 2015
> @@ -285,7 +285,11 @@ enum Form : uint16_t {
>
>    // Extensions for Fission proposal
>    DW_FORM_GNU_addr_index = 0x1f01,
> -  DW_FORM_GNU_str_index = 0x1f02
> +  DW_FORM_GNU_str_index = 0x1f02,
> +
> +  // Alternate debug sections proposal (output of "dwz" tool).
> +  DW_FORM_GNU_ref_alt = 0x1f20,
> +  DW_FORM_GNU_strp_alt = 0x1f21
>  };
>
>  enum LocationAtom {
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp Tue May 19
> 15:29:28 2015
> @@ -161,14 +161,15 @@ void DWARFDebugInfoEntryMinimal::dumpAtt
>    // We have dumped the attribute raw value. For some attributes
>    // having both the raw value and the pretty-printed value is
>    // interesting. These attributes are handled below.
> -  if ((attr == DW_AT_specification || attr == DW_AT_abstract_origin) &&
> -      // The signature references aren't handled.
> -      formValue.getForm() != DW_FORM_ref_sig8) {
> -    uint32_t Ref = formValue.getAsReference(u).getValue();
> -    DWARFDebugInfoEntryMinimal DIE;
> -    if (const DWARFUnit *RefU = findUnitAndExtractFast(DIE, u, &Ref))
> -      if (const char *Ref = DIE.getName(RefU, DINameKind::LinkageName))
> -        OS << " \"" << Ref << '\"';
> +  if (attr == DW_AT_specification || attr == DW_AT_abstract_origin) {
> +    Optional<uint64_t> Ref = formValue.getAsReference(u);
> +    if (Ref.hasValue()) {
> +      uint32_t RefOffset = Ref.getValue();
> +      DWARFDebugInfoEntryMinimal DIE;
> +      if (const DWARFUnit *RefU = findUnitAndExtractFast(DIE, u,
> &RefOffset))
> +        if (const char *Name = DIE.getName(RefU, DINameKind::LinkageName))
> +          OS << " \"" << Name << '\"';
> +    }
>    } else if (attr == DW_AT_APPLE_property_attribute) {
>      if (Optional<uint64_t> OptVal = formValue.getAsUnsignedConstant())
>        dumpApplePropertyAttribute(OS, *OptVal);
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Tue May 19 15:29:28
> 2015
> @@ -113,14 +113,17 @@ bool DWARFFormValue::isFormClass(DWARFFo
>    if (Form < ArrayRef<FormClass>(DWARF4FormClasses).size() &&
>        DWARF4FormClasses[Form] == FC)
>      return true;
> -  // Check DW_FORM_ref_sig8 from DWARF4.
> -  if (Form == DW_FORM_ref_sig8)
> +  // Check more forms from DWARF4 and DWARF5 proposals.
> +  switch (Form) {
> +  case DW_FORM_ref_sig8:
> +  case DW_FORM_GNU_ref_alt:
>      return (FC == FC_Reference);
> -  // Check for some DWARF5 forms.
> -  if (Form == DW_FORM_GNU_addr_index)
> +  case DW_FORM_GNU_addr_index:
>      return (FC == FC_Address);
> -  if (Form == DW_FORM_GNU_str_index)
> +  case DW_FORM_GNU_str_index:
> +  case DW_FORM_GNU_strp_alt:
>      return (FC == FC_String);
> +  }
>    // In DWARF3 DW_FORM_data4 and DW_FORM_data8 served also as a section
> offset.
>    // Don't check for DWARF version here, as some producers may still do
> this
>    // by mistake.
> @@ -199,15 +202,6 @@ bool DWARFFormValue::extractValue(DataEx
>      case DW_FORM_sdata:
>        Value.sval = data.getSLEB128(offset_ptr);
>        break;
> -    case DW_FORM_strp: {
> -      Value.uval = data.getU32(offset_ptr);
> -      if (!cu)
> -        break;
> -      RelocAddrMap::const_iterator AI =
> cu->getRelocMap()->find(*offset_ptr-4);
> -      if (AI != cu->getRelocMap()->end())
> -        Value.uval += AI->second.second;
> -      break;
> -    }
>      case DW_FORM_udata:
>      case DW_FORM_ref_udata:
>        Value.uval = data.getULEB128(offset_ptr);
> @@ -219,14 +213,18 @@ bool DWARFFormValue::extractValue(DataEx
>        Form = data.getULEB128(offset_ptr);
>        indirect = true;
>        break;
> -    case DW_FORM_sec_offset: {
> +    case DW_FORM_sec_offset:
> +    case DW_FORM_strp:
> +    case DW_FORM_GNU_ref_alt:
> +    case DW_FORM_GNU_strp_alt: {
>        // FIXME: This is 64-bit for DWARF64.
>        Value.uval = data.getU32(offset_ptr);
>        if (!cu)
>          break;
> -      RelocAddrMap::const_iterator AI =
> cu->getRelocMap()->find(*offset_ptr-4);
> +      RelocAddrMap::const_iterator AI =
> +          cu->getRelocMap()->find(*offset_ptr - 4);
>        if (AI != cu->getRelocMap()->end())
> -        Value.uval +=  AI->second.second;
> +        Value.uval += AI->second.second;
>        break;
>      }
>      case DW_FORM_flag_present:
> @@ -323,7 +321,6 @@ DWARFFormValue::skipValue(uint16_t form,
>        return true;
>
>      // 4 byte values
> -    case DW_FORM_strp:
>      case DW_FORM_data4:
>      case DW_FORM_ref4:
>        *offset_ptr += 4;
> @@ -353,6 +350,9 @@ DWARFFormValue::skipValue(uint16_t form,
>
>      // FIXME: 4 for DWARF32, 8 for DWARF64.
>      case DW_FORM_sec_offset:
> +    case DW_FORM_strp:
> +    case DW_FORM_GNU_ref_alt:
> +    case DW_FORM_GNU_strp_alt:
>        *offset_ptr += 4;
>        return true;
>
> @@ -424,24 +424,17 @@ DWARFFormValue::dump(raw_ostream &OS, co
>    case DW_FORM_udata:     OS << Value.uval; break;
>    case DW_FORM_strp: {
>      OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
> -    Optional<const char *> DbgStr = getAsCString(cu);
> -    if (DbgStr.hasValue()) {
> -      raw_ostream &COS = WithColor(OS, syntax::String);
> -      COS << '"';
> -      COS.write_escaped(DbgStr.getValue());
> -      COS << '"';
> -    }
> +    dumpString(OS, cu);
>      break;
>    }
>    case DW_FORM_GNU_str_index: {
>      OS << format(" indexed (%8.8x) string = ", (uint32_t)uvalue);
> -    Optional<const char *> DbgStr = getAsCString(cu);
> -    if (DbgStr.hasValue()) {
> -      raw_ostream &COS = WithColor(OS, syntax::String);
> -      COS << '"';
> -      COS.write_escaped(DbgStr.getValue());
> -      COS << '"';
> -    }
> +    dumpString(OS, cu);
> +    break;
> +  }
> +  case DW_FORM_GNU_strp_alt: {
> +    OS << format("alt indirect string, offset: 0x%" PRIx64 "", uvalue);
> +    dumpString(OS, cu);
>      break;
>    }
>    case DW_FORM_ref_addr:
> @@ -467,6 +460,9 @@ DWARFFormValue::dump(raw_ostream &OS, co
>      cu_relative_offset = true;
>      OS << format("cu + 0x%" PRIx64, uvalue);
>      break;
> +  case DW_FORM_GNU_ref_alt:
> +    OS << format("<alt 0x%" PRIx64 ">", uvalue);
> +    break;
>
>      // All DW_FORM_indirect attributes should be resolved prior to calling
>      // this function
> @@ -492,12 +488,23 @@ DWARFFormValue::dump(raw_ostream &OS, co
>    }
>  }
>
> +void DWARFFormValue::dumpString(raw_ostream &OS, const DWARFUnit *U)
> const {
> +  Optional<const char *> DbgStr = getAsCString(U);
> +  if (DbgStr.hasValue()) {
> +    raw_ostream &COS = WithColor(OS, syntax::String);
> +    COS << '"';
> +    COS.write_escaped(DbgStr.getValue());
> +    COS << '"';
> +  }
> +}
> +
>  Optional<const char *> DWARFFormValue::getAsCString(const DWARFUnit *U)
> const {
>    if (!isFormClass(FC_String))
>      return None;
>    if (Form == DW_FORM_string)
>      return Value.cstr;
> -  if (!U)
> +  // FIXME: Add support for DW_FORM_GNU_strp_alt
> +  if (Form == DW_FORM_GNU_strp_alt || U == nullptr)
>      return None;
>    uint32_t Offset = Value.uval;
>    if (Form == DW_FORM_GNU_str_index) {
> @@ -539,9 +546,9 @@ Optional<uint64_t> DWARFFormValue::getAs
>      return Value.uval + U->getOffset();
>    case DW_FORM_ref_addr:
>      return Value.uval;
> -  // FIXME: Add proper support for DW_FORM_ref_sig8
> +  // FIXME: Add proper support for DW_FORM_ref_sig8 and
> DW_FORM_GNU_ref_alt.
>    default:
> -    return Value.uval;
> +    return None;
>    }
>  }
>
>
> Modified: llvm/trunk/lib/Support/Dwarf.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Support/Dwarf.cpp (original)
> +++ llvm/trunk/lib/Support/Dwarf.cpp Tue May 19 15:29:28 2015
> @@ -233,6 +233,10 @@ const char *llvm::dwarf::FormEncodingStr
>      // DWARF5 Fission Extension Forms
>    case DW_FORM_GNU_addr_index:           return "DW_FORM_GNU_addr_index";
>    case DW_FORM_GNU_str_index:            return "DW_FORM_GNU_str_index";
> +
> +  // Alternate debug sections proposal (output of "dwz" tool).
> +  case DW_FORM_GNU_ref_alt:              return "DW_FORM_GNU_ref_alt";
> +  case DW_FORM_GNU_strp_alt:             return "DW_FORM_GNU_strp_alt";
>    }
>    return nullptr;
>  }
>
> Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64?rev=237721&view=auto
>
> ==============================================================================
> Binary files
> llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64 (added) and
> llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64 Tue May 19
> 15:29:28 2015 differ
>
> Propchange: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test-dwz.elf-x86-64
>
> ------------------------------------------------------------------------------
>     svn:executable = *
>
> Modified: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc?rev=237721&r1=237720&r2=237721&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc (original)
> +++ llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc Tue May 19 15:29:28
> 2015
> @@ -21,3 +21,9 @@ int main() {
>  // $ cp dwarfdump-test.cc /tmp/dbginfo
>  // $ cd /tmp/dbginfo
>  // $ clang++ -g dwarfdump-test.cc -o <output>
> +
> +// The result is also used as an input to .dwz tool:
> +// $ cp <output> output1.dwz
> +// $ cp <output> output2.dwz
> +// $ dwz -m output.dwz -r output1.dwz output2.dwz
> +// $ rm output2.dwz
>
> Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.elf-x86-64.dwz
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.elf-x86-64.dwz?rev=237721&view=auto
>
> ==============================================================================
> Binary files
> llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.elf-x86-64.dwz (added) and
> llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.elf-x86-64.dwz Tue May 19
> 15:29:28 2015 differ
>
> Added: llvm/trunk/test/DebugInfo/dwarfdump-dwz.test
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dwz.test?rev=237721&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/dwarfdump-dwz.test (added)
> +++ llvm/trunk/test/DebugInfo/dwarfdump-dwz.test Tue May 19 15:29:28 2015
> @@ -0,0 +1,14 @@
> +; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-dwz.elf-x86-64
> -debug-dump=info | FileCheck %s -check-prefix DUMP_INFO
> +
> +; DUMP_INFO: .debug_info
> +; DUMP_INFO: DW_TAG_compile_unit [2] *
> +; DUMP_INFO-NEXT: DW_AT_producer [DW_FORM_GNU_strp_alt]     (alt indirect
> string, offset: 0x0)
> +; DUMP_INFO-NEXT: DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)
> +; DUMP_INFO-NEXT: DW_AT_name [DW_FORM_GNU_strp_alt] (alt indirect string,
> offset: 0x31)
> +; DUMP_INFO-NEXT: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
> +; DUMP_INFO-NEXT: DW_AT_stmt_list [DW_FORM_data4]   (0x00000000)
> +; DUMP_INFO-NEXT: DW_AT_comp_dir [DW_FORM_GNU_strp_alt]     (alt indirect
> string, offset: 0x6b)
> +
> +; DUMP_INFO: DW_TAG_imported_unit [4]
> +; DUMP_INFO-NEXT: DW_AT_import [DW_FORM_GNU_ref_alt]      (<alt 0xb>)
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150520/30625a51/attachment.html>


More information about the llvm-commits mailing list