summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DWARFDebugLine.cpp: Restore LF line endingsHubert Tong2020-01-141-1188/+1188
| | | | | rG7e02406f6cf180a8c89ce64665660e7cc9dbc23e switched the file to CRLF line endings.
* [DebugInfo] Make debug line address size mismatch non-fatal to parsingJames Henderson2020-01-131-11/+20
| | | | | | | | | 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][NFC] Remove unused variable/fix variable namingJames Henderson2020-01-101-1181/+1179
| | | | | | Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D72159
* [DebugInfo] Improve error message textJames Henderson2020-01-101-3/+5
| | | | | | | | | | 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-2/+17
| | | | | | | | | | | | | | | | 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
* [NFC] Fix trivial typos in commentsJames Henderson2020-01-061-1/+1
| | | | | | | | Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D72143 Patch by Kazuaki Ishizaki.
* [DWARF] Don't assume optional always has a value.Jonas Devlieghere2020-01-031-1/+4
| | | | | | | | When getting the file name form the line table prologue we assume that a valid string form value can always be extracted as a string. If you look at the implementation of DWARFormValue this is not necessarily true. I hit this assertion from LLDB when I create a "dummy" DWARFContext that was missing the string section.
* [DebugInfo] Remove redundant checks for past-the-end of prologueJames Henderson2020-01-031-24/+0
| | | | | | | | | | | | | | The V5 directory and filename tables had checks in to make sure we hadn't read past the end of the line table prologue. Since previous changes to the data extractor class ensure we never read past the end, these checks are now redundant, so this patch removes them. There is still a check to show that the whole prologue remains within the prologue length. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D71768
* [DebugInfo][NFC] Use function_ref consistently in debug line parsingJames Henderson2020-01-021-2/+2
| | | | | | | | | | This patch fixes an inconsistency where we were using std::function in some places and function_ref in others to pass around the error handling callback. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D71762
* [DebugInfo] Fix verbose printing of rows added via DW_LNE_end_sequenceJames Henderson2019-12-191-1/+1
| | | | | | | | | | | The debug line verbose printing was printing the wrong values for rows added via DW_LNE_end_sequence, because the row was being printed AFTER its state had been reset following it being appended to the line table. This patch fixes this issue by printing the row before appending it. Reviewers: dblaikie, MaskRay Differential Revision: https://reviews.llvm.org/D71664
* [DebugInfo] Only print a single blank line after an empty line tableJames Henderson2019-12-171-1/+1
| | | | | | | | | | | | Commit 84a9756 added an extra blank line at the end of any line table. However, a blank line is also printed after the line table header, which meant that two blank lines in a row were being printed after a header, if there were no rows. This patch defers the post-header blank line printing until it has been determined that there are rows to print. Reviewed by: dblaikie Differential Revision: https://reviews.llvm.org/D71540
* [llvm-dwarfdump] Add blank line after printing line tableJames Henderson2019-12-121-0/+4
| | | | | | | | This helps delineate it in the output from later tables or other output. Reviewed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D71344
* [DebugInfo] Fix printing of DW_LNS_set_isaJames Henderson2019-12-111-1/+1
| | | | | | | | | | | | | | | | | 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
* [DebugLine] Don't try to guess the path styleJonas Devlieghere2019-08-151-25/+5
| | | | | | | | | | | In r368879 I made an attempt to guess the path style from the files in the line table. After some consideration I now think this is a poor idea. This patch undoes that behavior and instead adds an optional argument to specify the path style. This allows us to make that decision elsewhere where we have more information. In case of LLDB based on the Unit. llvm-svn: 369072
* [DebugLine] Improve path handling.Jonas Devlieghere2019-08-141-2/+20
| | | | | | | | | | | | | | | | | After switching over LLDB's line table parser to libDebugInfo, we noticed two regressions on the Windows bot. The problem is that when obtaining a file from the line table prologue, we append paths without specifying a path style. This leads to incorrect results on Windows for debug info containing Posix paths: 0x0000000000201000: /tmp\b.c, is_start_of_statement = TRUE This patch is an attempt to fix that by guessing the path style whenever possible. Differential revision: https://reviews.llvm.org/D66227 llvm-svn: 368879
* Switch LLVM to use 64-bit offsets (2/5)Igor Kudrin2019-08-061-24/+24
| | | | | | | | | This updates all libraries and tools in LLVM Core to use 64-bit offsets which directly or indirectly come to DataExtractor. Differential Revision: https://reviews.llvm.org/D65638 llvm-svn: 368014
* [DWARF][NFC] Add constants for reserved values of an initial length field.Igor Kudrin2019-07-241-3/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D65039 llvm-svn: 366887
* [DWARF] Use 32-bit format specifier for offsetJonas Devlieghere2019-07-231-7/+7
| | | | | | This should fix PR42730. llvm-svn: 366859
* [DWARF] Add more error handling to debug line parser.Jonas Devlieghere2019-07-221-34/+68
| | | | | | | | | | 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][RISCV] Add support for RISC-V relocations needed for debug infoAlex Bradbury2019-07-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When code relaxation is enabled many RISC-V fixups are not resolved but instead relocations are emitted. This happens even for DWARF debug sections. Therefore, to properly support the parsing of DWARF debug info we need to be able to resolve RISC-V relocations. This patch adds: * Support for RISC-V relocations in RelocationResolver * DWARF support for two relocations per object file offset * DWARF changes to support relocations in more DIE fields The two relocations per offset change is needed because some RISC-V relocations (used for label differences) come in pairs. Relocations can also be emitted for DWARF fields where relocations were not yet evaluated. Adding relocation support for some of these fields is essencial. On the other hand, LLVM currently emits RISC-V relocations for fixups that could be safely evaluated, since they can never be affected by code relaxations. This patch also adds relocation support for the fields affected by those extraneous relocations (the DWARF unit entry Length, and the DWARF debug line entry TotalLength and PrologueLength), for testing purposes. Differential Revision: https://reviews.llvm.org/D62062 Patch by Luís Marques. llvm-svn: 366402
* [DWARF] Fix the reserved values for unit length in DWARFDebugLine.Igor Kudrin2019-07-161-2/+2
| | | | | | | | | 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
* [DWARF] Fix an incorrect format specifier.Igor Kudrin2019-07-161-1/+1
| | | | | | | | This adjusts the format specifier because PCOffset is uint16_t. Differential Revision: https://reviews.llvm.org/D64620 llvm-svn: 366189
* Re-land "[DebugInfo] Move function from line table to the prologue (NFC)"Jonas Devlieghere2019-07-161-34/+33
| | | | | | | | | | | | | | | | | In LLDB, when parsing type units, we don't need to parse the whole line table. Instead, we only need to parse the "support files" from the line table prologue. To make that possible, this patch moves the respective functions from the LineTable into the Prologue. Because I don't think users of the LineTable should have to know that these files come from the Prologue, I've left the original methods in place, and made them redirect to the LineTable. Differential revision: https://reviews.llvm.org/D64774 llvm-svn: 366164
* Revert "[DebugInfo] Move function from line table to the prologue (NFC)"Jonas Devlieghere2019-07-161-33/+34
| | | | | | This broke LLD, which I didn't have enabled. llvm-svn: 366160
* [DebugInfo] Move function from line table to the prologue (NFC)Jonas Devlieghere2019-07-161-34/+33
| | | | | | | | | | | | | | | | | In LLDB, when parsing type units, we don't need to parse the whole line table. Instead, we only need to parse the "support files" from the line table prologue. To make that possible, this patch moves the respective functions from the LineTable into the Prologue. Because I don't think users of the LineTable should have to know that these files come from the Prologue, I've left the original methods in place, and made them redirect to the LineTable. Differential revision: https://reviews.llvm.org/D64774 llvm-svn: 366158
* DWARF v5: fix directory index in the line tableFangrui Song2019-05-061-12/+16
| | | | | | | | | | | | | | Summary: Prior to DWARF v5, a directory index of 0 represents DW_AT_comp_dir. In DWARF v5, the index starts with 0 and Entry.DirIdx is the index into Prologue.IncludeDirectories. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D61253 llvm-svn: 360015
* [DWARF] Delete a redundant check in getFileNameByIndex()Fangrui Song2019-04-291-2/+1
| | | | llvm-svn: 359422
* s/Dwarf 5/DWARF v5/ NFCFangrui Song2019-04-261-1/+1
| | | | llvm-svn: 359307
* [llvm] Prevent duplicate files in debug line header in dwarf 5: another attemptAli Tamur2019-04-191-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Another attempt to land the changes in debug line header to prevent duplicate files in Dwarf 5. I rolled back my previous commit because of a mistake in generating the object file in a test. Meanwhile, I addressed some offline comments and changed the implementation; the largest difference is that MCDwarfLineTableHeader does not keep DwarfVersion but gets it as a parameter. I also merged the patch to fix two lld tests that will strt to fail into this patch. Original Commit: https://reviews.llvm.org/D59515 Original Message: Motivation: In previous dwarf versions, file name indexes started from 1, and the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes the primary source file to be explicitly given an entry with an index number 0. The current implementation honors the specification by just duplicating the main source file, once with index number 0, and later maybe with another index number. While this is compliant with the letter of the standard, the duplication causes problems for consumers of this information such as lldb. (Some files are duplicated, where only some of them have a line table although all refer to the same file) With this change, dwarf 5 debug line section files always start from 0, and the zeroth entry is not duplicated whenever possible. This requires different handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns an index zero for a file name, it signals an error in dwarf 4, but not in dwarf 5) However, I think the minor complication is worth it, because it enables all consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the file name list homogenously. llvm-svn: 358732
* [DWARF] Make DWARFDebugLine::ParsingState::RowNumber a local variableFangrui Song2019-04-151-2/+2
| | | | llvm-svn: 358374
* [DWARF] Set discriminator to 0 for DW_LNS_copyFangrui Song2019-04-111-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make DW_LNS_copy set the discriminator register to 0, to conform to DWARF 4 & 5: "Then it sets the discriminator register to 0, and sets the basic_block, prologue_end and epilogue_begin registers to false." Because all of DW_LNE_end_sequence, DN_LNS_copy, and special opcodes reset discriminator to 0, we can move discriminator=0 to appendRowToMatrix. Also, make DW_LNS_copy print before appending the row, as it is similar to a address+=0,line+=0 special opcode, which prints before appending the row. Reviewers: dblaikie, probinson, aprantl Reviewed By: dblaikie Subscribers: danielcdh, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60364 llvm-svn: 358148
* [DWARF] Simplify LineTable::findRowInSeqFangrui Song2019-04-101-35/+11
| | | | | | | | | | | | | | We want the last row whose address is less than or equal to Address. This can be computed as upper_bound - 1, which is simpler than lower_bound followed by skipping equal rows in a loop. Since FirstRow (LowPC) does not satisfy the predicate (OrderByAddress) while LastRow-1 (HighPC) satisfies the predicate. We can decrease the search range by two, i.e. upper_bound [FirstRow,LastRow) = upper_bound [FirstRow+1,LastRow-1) llvm-svn: 358053
* [DWARF] DWARFDebugLine: replace Sequence::orderByLowPC with orderByHighPCFangrui Song2019-04-091-32/+10
| | | | | | | In a sorted list of non-overlapping [LowPC,HighPC) ranges, locating an address with upper_bound on HighPC is simpler than lower_bound on LowPC. llvm-svn: 358012
* [DWARF] DWARFDebugLine: delete unused parameter `Offset`Fangrui Song2019-04-071-4/+4
| | | | llvm-svn: 357866
* Revert "[llvm] Reapply "Prevent duplicate files in debug line header in ↵Ali Tamur2019-03-261-17/+3
| | | | | | | | | | | | | dwarf 5."" This reverts commit rL357020. The commit broke the test llvm/test/tools/llvm-objdump/embedded-source.test on some builds including clang-ppc64be-linux-multistage, clang-s390x-linux, clang-with-lto-ubuntu, clang-x64-windows-msvc, llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast (and others). llvm-svn: 357026
* [llvm] Reapply "Prevent duplicate files in debug line header in dwarf 5."Ali Tamur2019-03-261-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reapply rL356941 after regenerating the object file in the failing test llvm/test/tools/llvm-objdump/embedded-source.test from source. Original commit message: [llvm] Prevent duplicate files in debug line header in dwarf 5. Motivation: In previous dwarf versions, file name indexes started from 1, and the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes the primary source file to be explicitly given an entry with an index number 0. The current implementation honors the specification by just duplicating the main source file, once with index number 0, and later maybe with another index number. While this is compliant with the letter of the standard, the duplication causes problems for consumers of this information such as lldb. (Some files are duplicated, where only some of them have a line table although all refer to the same file) With this change, dwarf 5 debug line section files always start from 0, and the zeroth entry is not duplicated whenever possible. This requires different handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns an index zero for a file name, it signals an error in dwarf 4, but not in dwarf 5) However, I think the minor complication is worth it, because it enables all consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the file name list homogenously. Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D59515 llvm-svn: 357018
* Revert "[llvm] Prevent duplicate files in debug line header in dwarf 5."Ali Tamur2019-03-251-17/+3
| | | | | | | | This reverts commit 312ab05887d0e2caa29aaf843cefe39379a98d36. My commit broke the build; I will revert and find out what happened. llvm-svn: 356951
* [llvm] Prevent duplicate files in debug line header in dwarf 5.Ali Tamur2019-03-251-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Motivation: In previous dwarf versions, file name indexes started from 1, and the primary source file was not explicit. Dwarf 5 standard (6.2.4) prescribes the primary source file to be explicitly given an entry with an index number 0. The current implementation honors the specification by just duplicating the main source file, once with index number 0, and later maybe with another index number. While this is compliant with the letter of the standard, the duplication causes problems for consumers of this information such as lldb. (Some files are duplicated, where only some of them have a line table although all refer to the same file) With this change, dwarf 5 debug line section files always start from 0, and the zeroth entry is not duplicated whenever possible. This requires different handling of dwarf 4 and dwarf 5 during generation (e.g. when a function returns an index zero for a file name, it signals an error in dwarf 4, but not in dwarf 5) However, I think the minor complication is worth it, because it enables all consumers (lldb, gdb, dwarfdump, objdump, and so on) to treat all files in the file name list homogenously. Reviewers: dblaikie, probinson, aprantl, espindola Reviewed By: probinson Subscribers: emaste, jvesely, nhaehnle, aprantl, javed.absar, arichardson, hiraditya, MaskRay, rupprecht, jdoerfert, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D59515 llvm-svn: 356941
* [llvm] Skip over empty line table entries.Mircea Trofin2019-03-151-9/+28
| | | | | | | | | | | | | | | | | | Summary: This is similar to how addr2line handles consecutive entries with the same address - pick the last one. Reviewers: dblaikie, friss, JDevlieghere Reviewed By: dblaikie Subscribers: eugenis, vitalybuka, echristo, JDevlieghere, probinson, aprantl, hiraditya, rupprecht, jdoerfert, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D58952 llvm-svn: 356265
* Revert "[llvm] Skip over empty line table entries."Evgeniy Stepanov2019-03-131-7/+0
| | | | | | | This reverts commit r355972. See the discussion at https://reviews.llvm.org/D58952. llvm-svn: 356001
* [llvm] Skip over empty line table entries.Mircea Trofin2019-03-121-0/+7
| | | | | | | | | | | | | | | | | | Summary: This is similar to how addr2line handles consecutive entries with the same address - pick the last one. Reviewers: dblaikie, friss, JDevlieghere Reviewed By: dblaikie Subscribers: ormris, echristo, JDevlieghere, probinson, aprantl, hiraditya, rupprecht, jdoerfert, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D58952 llvm-svn: 355972
* Revert "[DWARFFormValue] Cleanup DWARFFormValue interface. (2/2) (NFC)"Vlad Tsyrklevich2019-03-021-6/+8
| | | | | | This reverts commit r355233, it was causing UBSan failures. llvm-svn: 355255
* [DWARFFormValue] Cleanup DWARFFormValue interface. (2/2) (NFC)Jonas Devlieghere2019-03-011-8/+6
| | | | | | | Continues the work started in r354941. Changes (all but one) uses of the extractValue to static createFromData. llvm-svn: 355233
* [DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin2019-02-271-24/+70
| | | | | | | | | | | | | | | | | That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
* [DWARFFormValue] Cleanup DWARFFormValue interface. (NFC)Jonas Devlieghere2019-02-271-6/+6
| | | | | | | | | | 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
* [DebugInfo]Print correct value for special opcode address incrementJames Henderson2019-02-061-2/+2
| | | | | | | | | | | The wrong variable was being used when printing the address increment in verbose output of .debug_line. This patch fixes this. Reviewed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D57693 llvm-svn: 353288
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song2018-09-271-1/+1
| | | | | | | | | | | | Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 llvm-svn: 343163
* [DWARF] Unify warning callbacks. NFC.Victor Leschuk2018-08-231-6/+0
| | | | | | | | | | | | | | | | | Both DWARFDebugLine and DWARFDebugAddr used the same callback mechanism for handling recoverable errors. They both implemented similar warn() function to be used as such callbacks. In this revision we get rid of code duplication and move this warn() function to DWARFContext as DWARFContext::dumpWarning(). Reviewers: lhames, jhenderson, aprantl, probinson, dblaikie, JDevlieghere Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D51033 llvm-svn: 340528
* [DWARF] Refactor DWARF classes to use unified error reporting. NFC.Victor Leschuk2018-08-201-26/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | DWARF-related classes in lib/DebugInfo/DWARF contained duplicating code for creating StringError instances, like: template <typename... Ts> static Error createError(char const *Fmt, const Ts &... Vals) { std::string Buffer; raw_string_ostream Stream(Buffer); Stream << format(Fmt, Vals...); return make_error<StringError>(Stream.str(), inconvertibleErrorCode()); } Similar function was placed in Support lib in https://reviews.llvm.org/D49824 This revision makes DWARF classes use this function instead of their local implementation of it. Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson Reviewed By: JDevlieghere, jhenderson Differential Revision: https://reviews.llvm.org/D49964 llvm-svn: 340163
OpenPOWER on IntegriCloud