Skip to content
  1. Jan 10, 2017
  2. Jan 05, 2017
  3. Jan 04, 2017
  4. Dec 21, 2016
    • Greg Clayton's avatar
      Add the ability for DWARFDie objects to get the parent DWARFDie. · c880b734
      Greg Clayton authored
      In order for the llvm DWARF parser to be used in LLDB we will need to be able to get the parent of a DIE. This patch adds that functionality by changing the DWARFDebugInfoEntry class to store a depth field instead of a sibling index. Using a depth field allows us to easily calculate the sibling and the parent without increasing the size of DWARFDebugInfoEntry.
      
      I tested llvm-dsymutil on a debug version of clang where this fully parses DWARF in over 1200 .o files to verify there was no serious regression in performance.
      
      Added a full suite of unit tests to test this functionality.
      
      Differential Revision: https://reviews.llvm.org/D27995
      
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290274 91177308-0d34-0410-b5e6-96231b3b80d8
      c880b734
  5. Dec 19, 2016
  6. Dec 13, 2016
  7. Dec 08, 2016
    • Daniel Jasper's avatar
      Move DwarfGenerator.cpp to unittests · 51d83c33
      Daniel Jasper authored
      So far it creates a test helper and so it should be moved there. It also
      create a layering cycle between CodeGen and CodeGen/AsmPrinter, which
      should be avoided.
      
      Review: https://reviews.llvm.org/D27570
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289044 91177308-0d34-0410-b5e6-96231b3b80d8
      51d83c33
    • Greg Clayton's avatar
    • Greg Clayton's avatar
      Make a DWARF generator so we can unit test DWARF APIs with gtest. · 777b5c3c
      Greg Clayton authored
      The only tests we have for the DWARF parser are the tests that use llvm-dwarfdump and expect output from textual dumps.
      
      More DWARF parser modification are coming in the next few weeks and I wanted to add tests that can verify that we can encode and decode all form types, as well as test some other basic DWARF APIs where we ask DIE objects for their children and siblings.
      
      DwarfGenerator.cpp was added in the lib/CodeGen directory. This file contains the code necessary to easily create DWARF for tests:
      
      dwarfgen::Generator DG;
      Triple Triple("x86_64--");
      bool success = DG.init(Triple, Version);
      if (!success)
        return;
      dwarfgen::CompileUnit &CU = DG.addCompileUnit();
      dwarfgen::DIE CUDie = CU.getUnitDIE();
      
      CUDie.addAttribute(DW_AT_name, DW_FORM_strp, "/tmp/main.c");
      CUDie.addAttribute(DW_AT_language, DW_FORM_data2, DW_LANG_C);
      
      dwarfgen::DIE SubprogramDie = CUDie.addChild(DW_TAG_subprogram);
      SubprogramDie.addAttribute(DW_AT_name, DW_FORM_strp, "main");
      SubprogramDie.addAttribute(DW_AT_low_pc, DW_FORM_addr, 0x1000U);
      SubprogramDie.addAttribute(DW_AT_high_pc, DW_FORM_addr, 0x2000U);
      
      dwarfgen::DIE IntDie = CUDie.addChild(DW_TAG_base_type);
      IntDie.addAttribute(DW_AT_name, DW_FORM_strp, "int");
      IntDie.addAttribute(DW_AT_encoding, DW_FORM_data1, DW_ATE_signed);
      IntDie.addAttribute(DW_AT_byte_size, DW_FORM_data1, 4);
      
      dwarfgen::DIE ArgcDie = SubprogramDie.addChild(DW_TAG_formal_parameter);
      ArgcDie.addAttribute(DW_AT_name, DW_FORM_strp, "argc");
      // ArgcDie.addAttribute(DW_AT_type, DW_FORM_ref4, IntDie);
      ArgcDie.addAttribute(DW_AT_type, DW_FORM_ref_addr, IntDie);
      
      StringRef FileBytes = DG.generate();
      MemoryBufferRef FileBuffer(FileBytes, "dwarf");
      auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
      EXPECT_TRUE((bool)Obj);
      DWARFContextInMemory DwarfContext(*Obj.get());
      This code is backed by the AsmPrinter code that emits DWARF for the actual compiler.
      
      While adding unit tests it was discovered that DIEValue that used DIEEntry as their values had bugs where DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref8, and DW_FORM_ref_udata forms were not supported. These are all now supported. Added support for DW_FORM_string so we can emit inlined C strings.
      
      Centralized the code to unique abbreviations into a new DIEAbbrevSet class and made both the dwarfgen::Generator and the llvm::DwarfFile classes use the new class.
      
      Fixed comments in the llvm::DIE class so that the Offset is known to be the compile/type unit offset.
      
      DIEInteger now supports more DW_FORM values.
      
      There are also unit tests that cover:
      
      Encoding and decoding all form types and values
      Encoding and decoding all reference types (DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref8, DW_FORM_ref_udata, DW_FORM_ref_addr) including cross compile unit references with that go forward one compile unit and backward on compile unit.
      
      Differential Revision: https://reviews.llvm.org/D27326
      
      
      git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289010 91177308-0d34-0410-b5e6-96231b3b80d8
      777b5c3c