summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo/DWARF
Commit message (Collapse)AuthorAgeFilesLines
...
* Adds initial llvm-dwarfdump --verify support with unit tests.Greg Clayton2017-05-011-0/+241
| | | | | | | | | | | | | | | | | | lldb-dwarfdump gets a new "--verify" option that will verify a single file's DWARF debug info and will print out any errors that it finds. It will return an non-zero exit status if verification fails, and a zero exit status if verification succeeds. Adding the --quiet option will suppress any output the STDOUT or STDERR. The first part of the verify does the following: - verifies that all CU relative references (DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref8, DW_FORM_ref_udata) have valid CU offsets - verifies that all DW_FORM_ref_addr references have valid .debug_info offsets - verifies that all DW_AT_ranges attributes have valid .debug_ranges offsets - verifies that all DW_AT_stmt_list attributes have valid .debug_line offsets - verifies that all DW_FORM_strp attributes have valid .debug_str offsets Unit tests were added for each of the above cases. Differential Revision: https://reviews.llvm.org/D32707 llvm-svn: 301844
* Remove the unnecessary virtual dtor from the DIEUnit hierarchy (in favor of ↵David Blaikie2017-04-221-1/+1
| | | | | | | | | protected dtor in the base, final derived classes with public non-virtual dtors) These objects are never polymorphically owned/destroyed, so the virtual dtor was unnecessary. llvm-svn: 301068
* [DWARF] Versioning for DWARF constants; verify FORMsPaul Robinson2017-04-201-8/+14
| | | | | | | | | | | | | Associate the version-when-defined with definitions of standard DWARF constants. Identify the "vendor" for DWARF extensions. Use this information to verify FORMs in .debug_abbrev are defined as of the DWARF version specified in the associated unit. Removed two tests that had specified DWARF v1 (which essentially does not exist). Differential Revision: http://reviews.llvm.org/D30785 llvm-svn: 300875
* Fix llvm-symbolizer to navigate both DW_AT_abstract_origin and ↵David Blaikie2017-03-131-12/+18
| | | | | | | | | DW_AT_specification in a single chain In a recent refactoring (r291959) this regressed to only following one or the other, not both, in a single chain. llvm-svn: 297676
* [DWARF] NFC. A few bits of minor code cleanup.Chris Bieneman2017-03-063-13/+0
| | | | | | | | David Blaikie pointed out that the `setForceChildren` API is no longer needed and should be removed from the DWARF Generator APIs. Also the DWARFDebugInfoTest file had some copy pasted comments that are not relevant. I've removed them. llvm-svn: 297056
* [ObjectYAML] [DWARF] Abstract DWARF Initial Length valuesChris Bieneman2017-03-031-1/+2
| | | | | | | | In the DWARF 4 Spec section 7.2.2, data in many DWARF sections, and some DWARF structures start with "Initial Length Values", which are a 32-bit length, and an optional 64-bit length if the 32 bit value == UINT32_MAX. This patch abstracts the Initial Length type in YAML, and extends its use to all the DWARF structures that are supported in the DWARFYAML code that have Initial Length values. llvm-svn: 296911
* [DebugInfo] [DWARFv5] Unique abbrevs for DIEs with different implicit_const ↵Victor Leschuk2017-03-011-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | values Take DW_FORM_implicit_const attribute value into account when profiling DIEAbbrevData. Currently if we have two similar types with implicit_const attributes and different values we end up with only one abbrev in .debug_abbrev section. For example consider two structures: S1 with implicit_const attribute ATTR and value VAL1 and S2 with implicit_const ATTR and value VAL2. The .debug_abbrev section will contain only 1 related record: [N] DW_TAG_structure_type DW_CHILDREN_yes DW_AT_ATTR DW_FORM_implicit_const VAL1 // .... This is incorrect as struct S2 (with VAL2) will use abbrev record with VAL1. With this patch we will have two different abbreviations here: [N] DW_TAG_structure_type DW_CHILDREN_yes DW_AT_ATTR DW_FORM_implicit_const VAL1 // .... [M] DW_TAG_structure_type DW_CHILDREN_yes DW_AT_ATTR DW_FORM_implicit_const VAL2 // .... llvm-svn: 296691
* [DWARFv5] Emit new unit header format.Paul Robinson2017-02-281-2/+8
| | | | | | | | | Requesting DWARF v5 will now get you the new compile-unit and type-unit headers. llvm-dwarfdump will also recognize them. Differential Revision: http://reviews.llvm.org/D30206 llvm-svn: 296514
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings in ↵Eugene Zelenko2017-02-091-10/+14
| | | | | | | | SubtargetFeature; other minor fixes (NFC). Same changes in files affected by reduced SubtargetFeature.h dependencies. llvm-svn: 294548
* Post-commit review feedback from dblaikieChris Bieneman2017-01-231-1/+1
| | | | | | Use ASSERT_* instead of EXPECT_* for error condition. llvm-svn: 292798
* [DWARF] [ObjectYAML] Adding APIs for unittestingChris Bieneman2017-01-202-30/+27
| | | | | | | | | | | | Summary: This patch adds some new APIs to enable using the YAML DWARF representation in unit tests. The most basic new API is DWARFYAML::EmitDebugSections which converts a YAML string into a series of owned MemoryBuffer objects stored in a StringMap. The string map can then be used to construct a DWARFContext for parsing in place of an ObjectFile. Reviewers: dblaikie, clayborg Subscribers: mgorny, fhahn, jgosnell, aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D28828 llvm-svn: 292634
* DWARFDebugInfoTest.cpp: Don't use ArrayRef with initializer. It was ↵NAKAMURA Takumi2017-01-161-3/+3
| | | | | | allocated locally. llvm-svn: 292127
* Add a variant of DWARFDie::find() and DWARFDie::findRecursively() that takes ↵Greg Clayton2017-01-131-0/+67
| | | | | | | | | | a llvm::ArrayRef<dwarf::Attribute>. This allows us efficiently look for more than one attribute, something that is quite common in DWARF consumption. Differential Revision: https://reviews.llvm.org/D28704 llvm-svn: 291967
* Cleanup how DWARFDie attributes are accessed and decoded.Greg Clayton2017-01-131-123/+281
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed all DWARFDie::getAttributeValueAs*() calls. Renamed: Optional<DWARFFormValue> DWARFDie::getAttributeValue(dwarf::Attribute); To: Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute); Added: Optional<DWARFFormValue> DWARFDie::findRecursively(dwarf::Attribute); All decoding of Optional<DWARFFormValue> values are now done using the dwarf::to*() functions from DWARFFormValue.h: Old code: auto DeclLine = DWARFDie.getAttributeValueAsSignedConstant(DW_AT_decl_line).getValueOr(0); New code: auto DeclLine = toUnsigned(DWARFDie.find(DW_AT_decl_line), 0); This composition helps us since we can now easily do: auto DeclLine = toUnsigned(DWARFDie.findRecursively(DW_AT_decl_line), 0); This allows us to easily find attribute values in the current DIE only (the first new code above) or in any DW_AT_abstract_origin or DW_AT_specification Dies using the line above. Note that the code line length is shorter and more concise. Differential Revision: https://reviews.llvm.org/D28581 llvm-svn: 291959
* Fix buildbots.Greg Clayton2017-01-131-2/+2
| | | | llvm-svn: 291864
* Add the ability to iterate across all attributes in a DIE.Greg Clayton2017-01-131-7/+62
| | | | | | Differential Revision: https://reviews.llvm.org/D28386 llvm-svn: 291861
* Remove all variants of DWARFDie::getAttributeValueAs...() that had ↵Greg Clayton2017-01-111-75/+90
| | | | | | | | | | parameters that specified default values. Now we only support returning Optional<> values and have changed all clients over to use Optional::getValueOr(). Differential Revision: https://reviews.llvm.org/D28569 llvm-svn: 291686
* DebugInfo: support for DW_FORM_implicit_constVictor Leschuk2017-01-101-2/+28
| | | | | | | | | | | | Support for DW_FORM_implicit_const DWARFv5 feature. When this form is used attribute value goes to .debug_abbrev section (as SLEB). As this form would break any debug tool which doesn't support DWARFv5 it is guarded by dwarf version check. Attempt to use this form with dwarf version <= 4 is considered a fatal error. Differential Revision: https://reviews.llvm.org/D28456 llvm-svn: 291599
* Add iterator support to DWARFDie to allow child DIE iteration.Greg Clayton2017-01-053-0/+128
| | | | | | Differential Revision: https://reviews.llvm.org/D28303 llvm-svn: 291194
* Correct the parent testing to avoid the special case where a DIE has a depth ↵Greg Clayton2017-01-041-29/+46
| | | | | | | | | | of 1 This test was testing that we could correctly find the parent of a DIE, but it was actually just testing the special case where a DIE's depth was 1. This corrects that error by adding an extra level into the the DWARF to ensure that we correctly get the parent by looking for the parent with a depth that is 1 less than the current depth. Differential Revision: https://reviews.llvm.org/D28261 llvm-svn: 290918
* DebugInfo: add explicit casts for -Wqual-castSaleem Abdulrasool2016-12-271-2/+4
| | | | | | | Fix a warning detected by gcc 6: warning: cast from type 'const void*' to type 'uint8_t* {aka unsigned char*}' casts away qualifiers [-Wcast-qual] llvm-svn: 290618
* Add the ability for DWARFDie objects to get the parent DWARFDie.Greg Clayton2016-12-211-0/+116
| | | | | | | | | | | | 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 llvm-svn: 290274
* Make a function to correctly extract the DW_AT_high_pc given the low pc value.Greg Clayton2016-12-191-0/+176
| | | | | | | | DWARF 4 and later supports encoding the PC as an address or as as offset from the low PC. Clients using DWARFDie should be insulated from how to extract the high PC value. This function takes care of extracting the form value and looking for the correct form. Differential Revision: https://reviews.llvm.org/D27885 llvm-svn: 290131
* Switch functions that returned bool and filled in a DWARFFormValue arg with ↵Greg Clayton2016-12-131-9/+13
| | | | | | | | ones that return Optional<DWARFFormValue> Differential Revision: https://reviews.llvm.org/D27737 llvm-svn: 289611
* Make a DWARFDIE class that can help avoid using the wrong DWARFUnit when ↵Greg Clayton2016-12-132-131/+130
| | | | | | | | | | | | extracting attributes Many places pass around a DWARFDebugInfoEntryMinimal and a DWARFUnit. It is easy to get things wrong by using the wrong DWARFUnit with a DWARFDebugInfoEntryMinimal. This patch creates a DWARFDie class that contains the DWARFUnit and DWARFDebugInfoEntryMinimal objects so that they can't get out of sync. All attribute extraction has been moved out of DWARFDebugInfoEntryMinimal and into DWARFDie. DWARFDebugInfoEntryMinimal was also renamed to DWARFDebugInfoEntry. DWARFDie objects are temporary objects that are used by clients and contain 2 pointers that you always need to have anyway. Keeping them grouped will avoid errors and simplify many of the attribute extracting APIs by not having to pass in a DWARFUnit. Differential Revision: https://reviews.llvm.org/D27634 llvm-svn: 289565
* Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed.Benjamin Kramer2016-12-091-1/+2
| | | | llvm-svn: 289208
* Fix memory leak in unit test.Benjamin Kramer2016-12-092-3/+3
| | | | | | | The StringPool entries are destroyed with the allocator, the string pool itself is not. llvm-svn: 289207
* Fix ASAN buildbots by fixing a double free crash.Greg Clayton2016-12-082-3/+5
| | | | | | The dwarfgen::Generator::StringPool was in a unique_ptr but it was owned by the Allocator member variable so it was being free twice. llvm-svn: 289070
* DIE::addAttribute(): Prune a redundant \param. [-Wdocumentation]NAKAMURA Takumi2016-12-081-1/+1
| | | | llvm-svn: 289056
* DebugInfoDWARFTests: Prune unused libdeps.NAKAMURA Takumi2016-12-081-4/+0
| | | | llvm-svn: 289053
* DebugInfoDWARFTests: Add missing deps, AsmPrinter and Object.NAKAMURA Takumi2016-12-081-0/+2
| | | | llvm-svn: 289052
* DebugInfoDWARFTests: Reorder LLVM_LINK_COMPONENTS.NAKAMURA Takumi2016-12-081-1/+1
| | | | llvm-svn: 289051
* Move DwarfGenerator.cpp to unittestsDaniel Jasper2016-12-084-1/+495
| | | | | | | | | 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 llvm-svn: 289044
* Unbreak buildbots where the debug info test was crashing due to unchecked error.Greg Clayton2016-12-081-4/+5
| | | | llvm-svn: 289017
* Make a DWARF generator so we can unit test DWARF APIs with gtest.Greg Clayton2016-12-082-0/+798
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 289010
* Clean up DWARFFormValue by reducing duplicated code and removing ↵Greg Clayton2016-11-111-10/+41
| | | | | | | | | | | | | | | | | | | | | DWARFFormValue::getFixedFormSizes() In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64. This patch cleans up code so that everyone is using one of the new DWARFFormValue functions: static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr); static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32); This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form. This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64. To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values. https://reviews.llvm.org/D26526 llvm-svn: 286597
* Switch all DWARF variables for tags, attributes and forms over to use the ↵Greg Clayton2016-10-271-2/+2
| | | | | | | | llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number. https://reviews.llvm.org/D26013 llvm-svn: 285309
* [NFC] Header cleanupMehdi Amini2016-04-181-0/+1
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* Remove autoconf supportChris Bieneman2016-01-261-16/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* Purge unused includes throughout libSupport.Benjamin Kramer2015-03-231-1/+2
| | | | | | NFC. llvm-svn: 232976
* Fix -Woverflow warning in unittest.Frederic Riss2015-03-051-1/+1
| | | | llvm-svn: 231368
* DWARFFormValue: Add getAsSignedConstant method.Frederic Riss2015-03-041-0/+74
| | | | | | | The implementation accepts explicitely signed forms (DW_FORM_sdata), but also unsigned forms as long as they fit in an int64_t. llvm-svn: 231299
* Resubmit unittests for DebugInfoPDB.Zachary Turner2015-02-073-0/+76
These were originally submitted as part of r228428, but this part caused a build breakage in LLVMConfig. The library portion was resubmitted independently since it was not causing breakage. There were two reasons this was causing the build to fail. The first is that there were no Makefiles added for the PDB tests. And the second is that the DebugInfoPDB library was only being built by CMake behind an "if (MSVC)" check. This is wrong since this the library hides platform specific details, and it was causing LLVM-Config to not find the library when trying to build unittests. llvm-svn: 228482
OpenPOWER on IntegriCloud