summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo/DWARF
Commit message (Collapse)AuthorAgeFilesLines
* [DebugInfo] Make debug line address size mismatch non-fatal to parsingJames Henderson2020-01-131-8/+52
| | | | | | | | | Reasonable assumptions can be made when a parsed address length does not match the expected length, so there's no need for this to be fatal. Reviewed by: ikudrin Differential Revision: https://reviews.llvm.org/D72154
* [DebugInfo] Improve error message textJames Henderson2020-01-101-761/+763
| | | | | | | | | | Unlike most of our errors in the debug line parser, the "no end of sequence" message was missing any reference to which line table it refererred to. This change adds the offset to this message. Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D72443
* [DebugInfo] Fix infinite loop caused by reading past debug_line endJames Henderson2020-01-071-0/+29
| | | | | | | | | | | | | | | | If the claimed unit length of a debug line program is such that the line table would finish past the end of the .debug_line section, an infinite loop occurs because the data extractor will continue to "read" zeroes without changing the offset. This previously didn't hit an error because the line table program handles a series of zeroes as a bad extended opcode. This patch fixes the inifinite loop and adds a warning if the program doesn't fit in the available data. Reviewed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D72279
* [test][DebugInfo][NFC] Rename method for clarityJames Henderson2020-01-061-18/+20
| | | | | | | | | | The checkGetOrParseLineTableEmitsError function could end up generating both recoverable and unrecoverable errors, but it is only intended for handling the latter. Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D72156
* [DebugInfo] Fix printing of DW_LNS_set_isaJames Henderson2019-12-111-0/+52
| | | | | | | | | | | | | | | | | The Isa register is a uint8_t, but at least on Windows this is internally an unsigned char, which meant that prior to this patch it got formatted as an ASCII character, rather than a decimal number. This patch fixes this by casting it to a uint64_t before printing. I did it this way instead of using a uint8_t formatter because a) it is simpler, and b) it allows us to change the internal type of Isa in the future without this code breaking. I also took the opportunity to test the printing of the other standard opcodes. Reviewed by: probinson Differential Revision: https://reviews.llvm.org/D71274
* Recommit "[DWARF] Add an api to get "interpreted" location lists"Pavel Labath2019-11-202-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This recommits 089c0f581492cd6e2a3d2927be3fbf60ea2d7e62, which was reverted due to failing tests on big endian machines. It includes a fix which I believe (I don't have BE machine) should fix this issue. The fix consists of correcting the invocation DWARFYAML::EmitDebugSections, which was missing one (default) function arguments, and so didn't actually force the little-endian mode. The original commit message follows. Summary: This patch adds DWARFDie::getLocations, which returns the location expressions for a given attribute (typically DW_AT_location). It handles both "inline" locations and references to the external location list sections (currently only of the DW_FORM_sec_offset type). It is implemented on top of DWARFUnit::findLoclistFromOffset, which is also added in this patch. I tried to make their signatures similar to the equivalent range list functionality. The actual location list interpretation logic is in DWARFLocationTable::visitAbsoluteLocationList. This part is not equivalent to the range list code, but this deviation is motivated by a desire to reuse the same location list parsing code within lldb. The functionality is tested via a c++ unit test of the DWARFDie API. Reviewers: dblaikie, JDevlieghere, SouraVX Subscribers: mgorny, hiraditya, cmtice, probinson, llvm-commits, aprantl Tags: #llvm Differential Revision: https://reviews.llvm.org/D70394
* Revert "[DWARF] Add an api to get "interpreted" location lists"Pavel Labath2019-11-202-119/+0
| | | | | | | The test fails on big endian machines. This reverts commit 089c0f581492cd6e2a3d2927be3fbf60ea2d7e62 and the subsequent attempt to fix in 82dc32e2d456c75d08bc9ffe97def409ee5a03cd.
* Big-endian fix to DWARFDieTest (089c0f58)Pavel Labath2019-11-201-1/+2
| | | | | Hardcode the DWARFContext to little-endian. I don't have a BE machine to test this on, but I believe this should address the ppc64be failure.
* [DWARF] Add an api to get "interpreted" location listsPavel Labath2019-11-202-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds DWARFDie::getLocations, which returns the location expressions for a given attribute (typically DW_AT_location). It handles both "inline" locations and references to the external location list sections (currently only of the DW_FORM_sec_offset type). It is implemented on top of DWARFUnit::findLoclistFromOffset, which is also added in this patch. I tried to make their signatures similar to the equivalent range list functionality. The actual location list interpretation logic is in DWARFLocationTable::visitAbsoluteLocationList. This part is not equivalent to the range list code, but this deviation is motivated by a desire to reuse the same location list parsing code within lldb. The functionality is tested via a c++ unit test of the DWARFDie API. Reviewers: dblaikie, JDevlieghere, SouraVX Subscribers: mgorny, hiraditya, cmtice, probinson, llvm-commits, aprantl Tags: #llvm Differential Revision: https://reviews.llvm.org/D70394
* Add streaming/equality operators to DWARFAddressRange/DWARFLocationExpressionPavel Labath2019-11-192-0/+31
| | | | | | | The main motivation for this is being able to write simpler assertions and get better error messages in unit tests. Split off from D70394.
* [dwarfgen] Fix initialization order error. [NFCI]Francesco Petrogalli2019-11-181-3/+3
| | | | This commit fixes the `-Werror=reorder` builds.
* DwarfGenerator - fix uninitialized variable warnings. NFC.Simon Pilgrim2019-11-181-1/+2
|
* [Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin2019-10-231-2/+2
| | | | | | | | | | MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
* Reland [DWARF] Add a unit test for DWARFUnit::getLength().Igor Kudrin2019-09-101-0/+42
| | | | | | | | | | | This is a follow-up of rL369529, where the return value of DWARFUnit::getLength() was changed from uint32_t to uint64_t. The test checks that a unit header with Length > 4G can be successfully parsed and the value of the Length field is not truncated. Differential Revision: https://reviews.llvm.org/D67276 llvm-svn: 371510
* Revert "[DWARF] Add a unit test for DWARFUnit::getLength()" because it broke ↵Igor Kudrin2019-09-101-42/+0
| | | | | | ASAN bot. llvm-svn: 371505
* [DWARF] Add a unit test for DWARFUnit::getLength().Igor Kudrin2019-09-101-0/+42
| | | | | | | | | | | This is a follow-up of rL369529, where the return value of DWARFUnit::getLength() was changed from uint32_t to uint64_t. The test checks that a unit header with Length > 4G can be successfully parsed and the value of the Length field is not truncated. Differential Revision: https://reviews.llvm.org/D67276 llvm-svn: 371499
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-4/+4
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* DebugInfo/DWARF: Normalize DWARFObject members on the DWARF spec section namesDavid Blaikie2019-08-071-1/+1
| | | | | | | | | Some of these names were abbreviated, some were not, some pluralised, some not. Made the API difficult to use - since it's an exact 1:1 mapping to the DWARF sections - use those names (changing underscore separation for camel casing). llvm-svn: 368189
* Support 64-bit offsets in utility classes (1/5)Igor Kudrin2019-08-061-4/+4
| | | | | | | | | | Using 64-bit offsets is required to fully implement 64-bit DWARF. As these classes are used in many different libraries they should temporarily support both 32- and 64-bit offsets. Differential Revision: https://reviews.llvm.org/D64006 llvm-svn: 368013
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Silence a conversion warning after r366887. NFCPaul Robinson2019-07-241-2/+2
| | | | llvm-svn: 366906
* [DWARF][NFC] Add constants for reserved values of an initial length field.Igor Kudrin2019-07-241-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D65039 llvm-svn: 366887
* [DWARF] Add more error handling to debug line parser.Jonas Devlieghere2019-07-221-2/+13
| | | | | | | | | | This patch exnteds the error handling in the debug line parser to get rid of the existing MD5 assertion. I want to reuse the debug line parser from LLVM in LLDB where we cannot crash on invalid input. Differential revision: https://reviews.llvm.org/D64544 llvm-svn: 366762
* [DWARF] Fix the reserved values for unit length in DWARFDebugLine.Igor Kudrin2019-07-161-6/+6
| | | | | | | | | The DWARF3 documentation had inconsistency concerning the reserved range for unit length values. The issue was fixed in DWARF4. Differential Revision: https://reviews.llvm.org/D64622 llvm-svn: 366190
* Fix DWARF DebugInfo unit test errors when cross-compilingJason Liu2019-06-034-18/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When building with a Default Target set we can experience issues in the DWARF DebugInfo unit tests because: They assume we can generate object files for the host platform. Some tests assume the endianess of the target we are generating DWARF for and the host match. This patch correct these issues by ensuring the tests which generate objects in memory are run with respect to LVM_DEFAULT_TARGET_TRIPLE and it's endianess. We also make sure we don't use the hosts address size for line test and split the triple util function in DwarfUtils into a version that takes an address size and one that doesn't. See also for discussion: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131212.html Patch by: daltenty Differential Revision: https://reviews.llvm.org/D62084 llvm-svn: 362454
* [DWARF] Fix DWARFVerifier::DieRangeInfo::containsFangrui Song2019-04-151-58/+23
| | | | | | | | | It didn't handle empty LHS correctly. If two ranges of LHS were contiguous and jointly contained one range of RHS, it could also be incorrect. DWARFAddressRange::contains can be removed and its tests can be merged into DWARFVerifier::DieRangeInfo::contains llvm-svn: 358387
* [DWARF] Fix DWARFVerifier::DieRangeInfo::intersectsFangrui Song2019-04-151-0/+3
| | | | | | It was incorrect if RHS had more than 1 ranges and one of the ranges interacted with *this llvm-svn: 358376
* [DWARFFormValue] Cleanup DWARFFormValue interface. (NFC)Jonas Devlieghere2019-02-272-104/+99
| | | | | | | | | | DWARFFormValues can be created from a data extractor or by passing its value directly. Until now this was done by member functions that modified an existing object's internal state. This patch replaces a subset of these methods with static method that return a new DWARFFormValue. llvm-svn: 354941
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-197-28/+21
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [DebugInfo] Define base function on DWARFDie reverse iteratorsJonas Devlieghere2018-10-301-0/+4
| | | | | | | | | | | | | | | | | | This defines member function base on the specialization of std::reverse_iterator for DWARFDie::iterator as required by C++ [reverse.iter.conv]. This fixes unit test DWARFDebugInfoTest.cpp under EXPENSIVE_CHECKS which currently can't be built due to GNU C++ Library calling this member function in debug mode. This fixes https://llvm.org/PR38785 Patch by: Eugene Sharygin Differential revision: https://reviews.llvm.org/D53792 llvm-svn: 345621
* [DebugInfo] Reduce debug_str_offsets section sizePavel Labath2018-08-072-3/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The accelerator tables use the debug_str section to store their strings. However, they do not support the indirect method of access that is available for the debug_info section (DW_FORM_strx et al.). Currently our code is assuming that all strings can/will be referenced indirectly, and puts all of them into the debug_str_offsets section. This is generally true for regular (unsplit) dwarf, but in the DWO case, most of the strings in the debug_str section will only be used from the accelerator tables. Therefore the contents of the debug_str_offsets section will be largely unused and bloating the main executable. This patch rectifies this by teaching the DwarfStringPool to differentiate between strings accessed directly and indirectly. When a user inserts a string into the pool it has to declare whether that string will be referenced directly or not. If at least one user requsts indirect access, that string will be assigned an index ID and put into debug_str_offsets table. Otherwise, the offset table is skipped. This approach reduces the overall binary size (when compiled with -gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is shrunk by 99%). Reviewers: probinson, dblaikie, JDevlieghere Subscribers: aprantl, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D49493 llvm-svn: 339122
* [DebugInfo/DWARF] [2/4] Type units no longer in a std::deque. NFCPaul Robinson2018-08-011-1/+1
| | | | | | | | | | | | | | This is patch 2 of 4 NFC refactorings to handle type units and compile units more consistently and with less concern about the object-file section that they came from. Patch 2 takes the existing std::deque<DWARFUnitSection> for type units and makes it a simple DWARFUnitSection, simplifying the handling of type units and making it more consistent with compile units. Differential Revision: https://reviews.llvm.org/D49742 llvm-svn: 338629
* [DebugInfo/DWARF] [1/4] De-templatize DWARFUnitSection. NFCPaul Robinson2018-08-012-14/+26
| | | | | | | | | | | | | | | This is patch 1 of 4 NFC refactorings to handle type units and compile units more consistently and with less concern about the object-file section that they came from. Patch 1 replaces the templated DWARFUnitSection with a non-templated version. That is, instead of being a SmallVector of pointers to a specific unit kind, it is not a SmallVector of pointers to the base class for both type and compile units. Virtual methods are magic. Differential Revision: https://reviews.llvm.org/D49741 llvm-svn: 338628
* [DebugInfo] Have custom std::reverse_iterator<DWARFDie>Jonas Devlieghere2018-08-011-20/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DWARFDie is a lightweight utility wrapper that stores a pointer to a compile unit and a debug info entry. Currently, its iterator (used for walking over its children) stores a DWARFDie and returns a const reference when dereferencing it. When the iterator is modified (by incrementing or decrementing it), this reference becomes invalid. This was happening when calling reverse on it, because the std::reverse_iterator is keeping a temporary copy of the iterator (see https://en.cppreference.com/w/cpp/iterator/reverse_iterator for a good illustration). The relevant code in libcxx: reference operator*() const {_Iter __tmp = current; return *--__tmp;} When dereferencing the reverse iterator, we decrement and return a reference to a DWARFDie stored in the stack frame of this function, resulting in UB at runtime. This patch specifies the std::reverse_iterator for DWARFDie to do the right thing. Differential revision: https://reviews.llvm.org/D49679 llvm-svn: 338506
* dwarfgen: Add support for generating the debug_str_offsets section, take 3Pavel Labath2018-07-263-5/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous version of this patch failed on darwin targets because of different handling of cross-debug-section relocations. This fixes the tests to emit the DW_AT_str_offsets_base attribute correctly in both cases. Since doing this is a non-trivial amount of code, and I'm going to need it in more than one test, I've added a helper function to the dwarfgen DIE class to do it. Original commit message follows: The motivation for this is D49493, where we'd like to test details of debug_str_offsets behavior which is difficult to trigger from a traditional test. This adds the plubming necessary for dwarfgen to generate this section. The more interesting changes are: - I've moved emitStringOffsetsTableHeader function from DwarfFile to DwarfStringPool, so I can generate the section header more easily from the unit test. - added a new addAttribute overload taking an MCExpr*. This is used to generate the DW_AT_str_offsets_base, which links a compile unit to the offset table. I've also added a basic test for reading and writing DW_form_strx forms. Reviewers: dblaikie, JDevlieghere, probinson Subscribers: llvm-commits, aprantl Differential Revision: https://reviews.llvm.org/D49670 llvm-svn: 338031
* dwarfgen: Don't create an AsmPrinter with an invalid ObjFile loweringPavel Labath2018-07-262-16/+18
| | | | | | | | | | | | | The AsmPrinter created in the tests contained an uninitialized TargetLoweringObjectFile. Things mostly worked regardless, because we used a separate instance of that class to specify sections to emit. This rearanges the object construction order so that we can avoid creating two lowering objects. Instead, we properly initialize the object in the AsmPrinter, and have the DWARF generator store a pointer to it. llvm-svn: 338026
* Revert "dwarfgen: Add support for generating the debug_str_offsets section, ↵Pavel Labath2018-07-253-88/+5
| | | | | | | | | take 2" This reverts commit r337933. The build error is fixed but the test now fails on the darwin buildbots. Investigating... llvm-svn: 337935
* dwarfgen: Add support for generating the debug_str_offsets section, take 2Pavel Labath2018-07-253-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This recommits r337910 after fixing an "ambiguous call to addAttribute" error with some compilers (gcc circa 4.9 and MSVC). It seems that these compilers will consider a "false -> pointer" conversion during overload resolution. This creates ambiguity because one I added an overload which takes a MCExpr * as an argument. I fix this by making the new overload take MCExpr&, which avoids the conversion. It also documents the fact that we expect a valid MCExpr object. Original commit message follows: The motivation for this is D49493, where we'd like to test details of debug_str_offsets behavior which is difficult to trigger from a traditional test. This adds the plubming necessary for dwarfgen to generate this section. The more interesting changes are: - I've moved emitStringOffsetsTableHeader function from DwarfFile to DwarfStringPool, so I can generate the section header more easily from the unit test. - added a new addAttribute overload taking an MCExpr*. This is used to generate the DW_AT_str_offsets_base, which links a compile unit to the offset table. I've also added a basic test for reading and writing DW_form_strx forms. Reviewers: dblaikie, JDevlieghere, probinson Subscribers: llvm-commits, aprantl Differential Revision: https://reviews.llvm.org/D49670 llvm-svn: 337933
* Revert "dwarfgen: Add support for generating the debug_str_offsets section"Pavel Labath2018-07-253-88/+5
| | | | | | | | | This reverts commit r337910 as it's generating "ambiguous call to addAttribute" errors on some bots. Will resubmit once I get a chance to look into the problem. llvm-svn: 337924
* dwarfgen: Add support for generating the debug_str_offsets sectionPavel Labath2018-07-253-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The motivation for this is D49493, where we'd like to test details of debug_str_offsets behavior which is difficult to trigger from a traditional test. This adds the plubming necessary for dwarfgen to generate this section. The more interesting changes are: - I've moved emitStringOffsetsTableHeader function from DwarfFile to DwarfStringPool, so I can generate the section header more easily from the unit test. - added a new addAttribute overload taking an MCExpr*. This is used to generate the DW_AT_str_offsets_base, which links a compile unit to the offset table. I've also added a basic test for reading and writing DW_form_strx forms. Reviewers: dblaikie, JDevlieghere, probinson Subscribers: llvm-commits, aprantl Differential Revision: https://reviews.llvm.org/D49670 llvm-svn: 337910
* [DebugInfo] Make children iterator bidirectionalJonas Devlieghere2018-07-111-0/+26
| | | | | | | | | Make the DIE iterator bidirectional so we can move to the previous sibling of a DIE. Differential revision: https://reviews.llvm.org/D49173 llvm-svn: 336823
* [DWARF] Refactor callback usage for .debug_line error handlingJames Henderson2018-05-211-64/+70
| | | | | | | | | | | Change the "recoverable" error callback to take an Error instaed of a string. Reviewed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D46831 llvm-svn: 332845
* MC: Change the streamer ctors to take an object writer instead of a stream. ↵Peter Collingbourne2018-05-181-3/+4
| | | | | | | | | | | | | | NFCI. The idea is that a client that wants split dwarf would create a specific kind of object writer that creates two files, and use it to create the streamer. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47050 llvm-svn: 332749
* Inline a few CMake variables into their only uses.Nico Weber2018-05-141-5/+1
| | | | | | No behavior change. Makes unittests CMakeLists.txt files more self-consistent. llvm-svn: 332280
* Fix Wdocumentation warnings. NFCI.Simon Pilgrim2018-05-141-1/+1
| | | | llvm-svn: 332239
* [DWARF] Remove unused member and fix(?) the unit-tests on big endian hostsJames Henderson2018-05-103-7/+6
| | | | | | | I can't verified the fix on a big endian host, so I'm not 100% certain it will work. llvm-svn: 331986
* [DWARF] DwarfGenerator.h LineTable: explicitly mark DG as unusedRoman Lebedev2018-05-101-1/+1
| | | | | | Just want to unbreak the build. llvm-svn: 331984
* [DWARF] dwarfgen::LineTable::writeData(): pacify -Wcovered-switch-defaultRoman Lebedev2018-05-101-5/+4
| | | | llvm-svn: 331983
* [DWARF] DWARFDebugLineTest: fix a few more signed/unsigned mismatch warningsRoman Lebedev2018-05-101-3/+3
| | | | llvm-svn: 331982
* Fix signed/unsigned comparison warning and print formatJames Henderson2018-05-101-20/+20
| | | | | | | | | | | | The print format was causing at least 2 unit-test failures from r331971. The signed/unsigned comparison warnings only appeared to affect two lines but it was unclear whether it might just pop up on other lines, so I have been explicit in all the literals in the tests. There were other bot unit-test failures that I am still investigating. llvm-svn: 331978
OpenPOWER on IntegriCloud