1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
Commit Graph

1936 Commits

Author SHA1 Message Date
Igor Kudrin
5f88b99c30 [DebugInfo] Simplify DWARFUnit::determineStringOffsetsTableContribution(). NFC.
The method is called from only one place and the call is already guarded
by a condition which checks that IsDWO is false.

Differential Revision: https://reviews.llvm.org/D78482
2020-04-22 12:11:17 +07:00
Amy Huang
46a7f5a6dc Reland "Implement some functions in NativeSession." with fixes so that
the tests pass on Linux.

Summary:
This change implements readFromExe, and calculating VA and RVA, which
are some of the functionalities that will be used for native PDB reading
for llvm symbolizer.

bug: https://bugs.llvm.org/show_bug.cgi?id=41795
2020-04-21 16:35:27 -07:00
Amy Huang
7487f3d198 Revert "Implement some NativeSession functions" along with some
followup fixes.

This reverts commits
a6d8a055e92eb4853805d1ad1be0b1a6523524ef
4927ae085807731eb4052e0a682443fe9399b512
1e1f5eb7c978da3b062daaf3c32c459704e65a55
2020-04-21 14:20:13 -07:00
Amy Huang
c74fd0c180 [NativeSession] Fix unchecked Expected type
(followup to https://reviews.llvm.org/D78128)
2020-04-21 12:36:55 -07:00
Michael Liao
45866e6621 Fix build. NFC. 2020-04-21 14:59:45 -04:00
Fangrui Song
312f303b26 [PDB] Change llvm/object/COFF.h to llvm/Object/COFF.h after D78128 2020-04-21 11:54:05 -07:00
Amy Huang
ae87806c29 Implement some functions in NativeSession.
Summary:
This change implements readFromExe, and calculating VA and RVA, which
are some of the functionalities that will be used for native PDB reading
for llvm symbolizer.

bug: https://bugs.llvm.org/show_bug.cgi?id=41795

Reviewers: hans, amccarth, rnk

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78128
2020-04-21 11:48:40 -07:00
Pavel Labath
4e52ec5b13 [DWARFDebugLine] Check for errors when parsing v2 file/dir lists
Summary:
Without this we could silently accept an invalid prologue because the
default DataExtractor behavior is to return an empty string when
reaching the end of file. And empty string is also used to terminate
these lists.

This makes the parsing code slightly more complicated, but this
complexity will go away once the parser starts working with truncating
data extractors. The reason I am doing it this way is because without
this, the truncation would regress the quality of error messages (right
now, we produce bad error messages only near EOF, but truncation would
make everything behave as if it was near EOF).

Reviewers: dblaikie, probinson, jhenderson

Subscribers: hiraditya, MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77555
2020-04-21 16:55:36 +02:00
Wouter van Oortmerssen
2d2a0b49b2 [WebAssembly] Add int32 DW_OP_WASM_location variant
This to allow us to add reloctable global indices as a symbol.
Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it.

See discussion in https://github.com/WebAssembly/debugging/issues/12
2020-04-16 16:32:17 -07:00
Pavel Labath
a0cd1293b9 Fix DWARFDataExtractor::getRelocatedValue near EOF
Summary:
If we have an (invalid) relocation which relocates bytes which partially
lie outside the range of the relocated section, the getRelocatedValue
would return confusing results. It would first read zero (because that's
what the underlying DataExtractor api does for out-of-bounds reads), and
then relocate that zero anyway.

A more appropriate behavior is to return zero straight away. This is
what this patch does.

Reviewers: dblaikie, jhenderson

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78113
2020-04-15 12:47:57 +02:00
David Blaikie
db9beef334 llvm-dwarfdump: Don't try to parse a debug_loclist contribution if this CU has no DW_AT_loclists_base
llvm-dwarfdump was trying to parse debug_loclists even in the absence of
a loclists_base if there was a loclists section at all.
2020-04-14 15:54:13 -07:00
David Blaikie
1519ccfd27 Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e30750939c53935051c6c750dfad2c2
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3a23449039ef2efcf476995ae1c7007.

I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
2020-04-14 14:44:32 -07:00
Sourabh Singh Tomar
a98d25eefc [DWARF5]: Added support for DW_MACRO_import form in llvm-dwarfdump
GCC emits this new form along with others forms(supported in llvm-dwardump)
and since it's support was missing in llvm-dwarfdump, it was not
able to correctly dump the content a debug_macro section for GCC
generated binaries.

This patch extends llvm-dwarfdump to support this form,
now GCC generated debug_macro section can be correctly dumped
using llvm-dwarfdump.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D78006
2020-04-14 23:51:46 +05:30
Pavel Labath
9d34186bb4 [DWARFDebugLine] Check for (EOF) errors when parsing v5 content descriptors
Summary:
Without that we could be silently reading zeroes, as that's the default
DataExtractor behavior. The entire parse would still most likely fail,
but it would do that with a seemingly unrelated/nonsensical error
message.

Reviewers: dblaikie, probinson, jhenderson

Subscribers: hiraditya, MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77554
2020-04-14 16:02:56 +02:00
David Blaikie
356c6ad409 Revert "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries"
Broke an LLDB build bot & I can't seem to build LLDB locally to fix
forward...
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/15567/steps/test/logs/stdio

This reverts commit 416fa7720e30750939c53935051c6c750dfad2c2.
2020-04-11 16:54:49 -07:00
David Blaikie
f04e26215b llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries
This probably isn't ideal - the error was being printed specifically
inline with the dumping that was more legible - but then the error
wasn't reported to stderr and didn't produce a non-zero exit code.

Probably the error message could be improved by adding more context now
that it isn't printed in-situ of the DIE dumping as much.
2020-04-10 17:28:09 -07:00
David Blaikie
4f1d6dd171 llvm-dwarfdump: Return non-zero on error
Makes it easier to test "this doesn't produce an error" (& indeed makes
that the implied default so we don't accidentally write tests that have
silent/sneaky errors as well as the positive behavior we're testing for)

Though the support for applying relocations is patchy enough that a
bunch of tests treat lack of relocation application as more of a warning
than an error - so rather than me trying to figure out how to add
support for a bunch of relocation types, let's degrade that to a warning
to match the usage (& indeed, it's sort of more of a tool warning anyway
- it's not that the DWARF is wrong, just that the tool can't fully cope
with it - and it's not like the tool won't dump the DWARF, it just won't
follow/render certain relocations - I guess in the most general case it
might try to render an unrelocated value & instead render something
bogus... but mostly seems to be about interesting relocations used in
eh_frame (& honestly it might be nice if we were lazier about doing this
relocation resolution anyway - if you're not dumping eh_frame, should we
really be erroring about the relocations in it?))
2020-04-09 20:53:58 -07:00
Pavel Labath
f3eb9c8497 [DWARF] Detect extraction errors in DWARFFormValue::extractValue
Summary:
Although the function had a bool return value, it was always returning
true. Presumably this is because the main type of errors one can
encounter here is running off the end of the stream, and until very
recently, the DataExtractor class made it very difficult to detect that.

The situation has changed now, and we can easily detect errors here,
which this patch does.

Reviewers: dblaikie, aprantl

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77308
2020-04-09 13:41:02 +02:00
Igor Kudrin
afc5a59902 [DebugInfo] Fix reading DWARFv5 type units in DWP.
In DWARFv5, type units are stored in .debug_info sections, along with
compilation units, and they are distinguished by the unit_type field
in the header, not by the name of the section. It is impossible to
associate the correct index section of a DWP file with the unit before
the unit's header is read. This patch fixes reading DWARFv5 type units
by parsing the header first and then applying the index entry according
to the actual unit type.

Differential Revision: https://reviews.llvm.org/D77552
2020-04-08 12:50:58 +07:00
Igor Kudrin
bd56c5cba9 [DebugInfo] Fix reading range lists of v5 units in DWP.
In package files, the base offset provided by index sections should be
used to find the contribution of a unit. The patch adds that base
offset when reading range list tables.

Differential revision: https://reviews.llvm.org/D77401
2020-04-06 13:28:06 +07:00
Igor Kudrin
bb7c5db8c9 [DebugInfo] Fix reading location tables headers of v5 units in DWP.
This fixes the reading of location lists headers for compilation units
in package files by adjusting the reading offset according to the
corresponding record in the unit index. This is required for
DW_FORM_loclistx to work.

Differential revision: https://reviews.llvm.org/D77146
2020-04-06 13:28:06 +07:00
Igor Kudrin
f0e687f6fb [DebugInfo] Fix reading location tables of v5 units in DWP.
Without the patch, all version 5 compile units in a DWP file read
location tables from the beginning of a .debug_loclists.dwo section.
The patch fixes that by adjusting the reading offset the same way as
for pre-v5 units. The section identifier to find the contribution
entry corresponds to the version of the unit.

Differential revision: https://reviews.llvm.org/D77145
2020-04-06 13:28:06 +07:00
Igor Kudrin
0e6bc8dff3 [DebugInfo] Support DWARFv5 index sections.
DWARFv5 defines index sections in package files in a slightly different
way than the pre-standard GNU proposal, see Section 7.3.5 in the DWARF
standard and https://gcc.gnu.org/wiki/DebugFissionDWP for GNU proposal.
The main concern here is values for section identifiers, which are
partially overlapped with changed meanings. The patch adds support for
v5 index sections and resolves that difficulty by defining a set of
identifiers for internal use which can represent and distinct values
of both standards.

Differential Revision: https://reviews.llvm.org/D75929
2020-04-06 13:28:06 +07:00
Igor Kudrin
124fb70313 [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.
This is a preparation for an upcoming patch which adds support for
DWARFv5 unit index sections. The patch adds tag "_EXT_" to identifiers
which reference sections that are deprecated in the DWARFv5 standard.
See D75929 for the discussion.

Differential Revision: https://reviews.llvm.org/D77141
2020-04-06 13:28:06 +07:00
scentini
fadb1a3c1f Silence -Wpessimizing-move warning 2020-04-03 09:37:39 +02:00
scentini
70bf2d824b Silence -Wpessimizing-move warning 2020-04-03 09:24:26 +02:00
Igor Kudrin
bdcd84e3f3 [DebugInfo] Rename getOffset() to getContribution(). NFC.
The old name was a bit misleading because the functions actually return
contributions to the corresponding sections.

Differential revision: https://reviews.llvm.org/D77302
2020-04-03 14:15:53 +07:00
Sourabh Singh Tomar
d33f7a7cb5 [DWARF5] Added support for debug_macro section parsing and dumping in llvm-dwarfdump.
Summary:
This patch adds parsing and dumping DWARFv5 .debug_macro section in llvm-dwarfdump,
it does not introduce any new switch. Existing switch "--debug-macro"
should be used to dump macinfo or macro section.

Reviewed By: dblaikie, ikudrin, jhenderson

Differential Revision: https://reviews.llvm.org/D73086
2020-04-03 12:23:51 +05:30
Nico Weber
47138b2f83 Suppress a few -Wunreachable-code warnings.
No behavior change. Also fix a comment to say match reality.
2020-03-25 13:55:42 -04:00
Pavel Labath
58fd4ef93a [DWARF] Fix v5 debug_line parsing of prologues with many files
Summary:
The directory_count and file_name_count fields are (section 6.2.4 of
DWARF5 spec) supposed to be uleb128s, not bytes. This bug meant that it
was not possible to correctly parse headers with more than 128 files or
directories.

I've found this bug by code inspection, though the limit is so small
someone would have run into it for real sooner or later. I've verified
that the producer side handles many files correctly, and that we are
able to parse such files after this fix.

Reviewers: dblaikie, jhenderson

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76498
2020-03-24 15:11:54 +01:00
David Blaikie
676f67456e Roll an expression into an assert to remove the need for a (void) cast. 2020-03-22 18:18:27 -07:00
Sterling Augustine
b72765b119 Cleanup the plumbing for DILineInfoSpecifier. [NFC - Try 2] 2020-03-20 10:29:57 -07:00
Sterling Augustine
3f51a0ef88 Revert "Cleanup the plumbing for DILineInfoSpecifier. [NFC]"
This broke lldb. Will fix and resubmit.

This reverts commit 98ff6eb679cd5a2556d990d3d629e6c03c1da6a0.
2020-03-19 17:25:05 -07:00
Sterling Augustine
7d98860ec6 Cleanup the plumbing for DILineInfoSpecifier. [NFC]
Summary:
1. FileLineInfoSpecifier::Default isn't the default for anything.
Rename to RawValue, which accurately reflects its role.
2. Most functions that take a part of a FileLineInfoSpecifier end up
constructing a full one later or plumb two values through. Make them
all just take a complete FileLineInfoSpecifier.
3. Printing basenames only was handled differently from all other
variants, make it parallel to all the other variants.

Reviewers: jhenderson

Subscribers: hiraditya, MaskRay, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76394
2020-03-19 16:56:43 -07:00
Nico Weber
57c01b04f3 Revert "[llvm-objdump] Display locations of variables alongside disassembly"
Makes tests fail on Windows, see https://reviews.llvm.org/D70720#1924542

This reverts commit 3a5ddedadb671e485ce5c638142817879ac14a8c, and
follow-ups:
f4cb9c919e28276222873453cf85de9e5a3c7be5
042eb0482aa758057c4f77616a4696cdb21b4fcc
c0cf5f5da9a7bf1bdf43ed53287b0f634fc53045
18649f48139932377c2a2909f1fb600bf5cf6e57
f62b898c1f5dd77e68b53570dc2679877bcbe4c2
2020-03-16 14:04:25 -04:00
Oliver Stannard
548bf9dd60 [llvm-objdump] Add entry_value and stack_value opcodes
Add the DW_OP_entry_value and DW_OP_stack_value opcodes to the DWARF
expression printer.

Differential revision: https://reviews.llvm.org/D74843
2020-03-16 10:54:41 +00:00
Oliver Stannard
864164dbfc [llvm-objdump] Add simple memory expressions to variable display
Add the DW_OP_breg0..DW_OP_breg31 and DW_OP_bregx opcodes to the DWARF
expression printer.

Differential revision: https://reviews.llvm.org/D74841
2020-03-16 10:54:41 +00:00
Oliver Stannard
786528ee37 [llvm-objdump] Display locations of variables alongside disassembly
This adds the --debug-vars option to llvm-objdump, which prints
locations (registers/memory) of source-level variables alongside the
disassembly based on DWARF info. A vertical line is printed for each
live-range, with a label at the top giving the variable name and
location, and the position and length of the line indicating the program
counter range in which it is valid.

Currently, this only works for object files, not executables or shared
libraries.

Differential revision: https://reviews.llvm.org/D70720
2020-03-16 10:54:40 +00:00
David Stenberg
ff84dc1e98 [DebugInfo] Handle generic type DW_OP_convert ops in llvm-dwarfdump
Summary:
This is a preparatory change for allowing LLVM to emit DW_OP_convert
operations converting to the generic type.

If DW_OP_convert's operand is 0, it converts the top of stack to the
generic type, as specified by DWARFv5 section 2.5.1.6:

"[...] takes one operand, which is an unsigned LEB128 integer that
 represents the offset of a debugging information entry in the current
 compilation unit, or value 0 which represents the generic type."

This adds support for such operations to llvm-dwarfdump.

Reviewers: aprantl, markus, jdoerfert, jhenderson

Reviewed By: aprantl

Subscribers: hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D76141
2020-03-16 11:24:01 +01:00
Richard Smith
3f9596e9a9 Fix "unused variable" warning in NDEBUG builds. 2020-03-13 13:56:57 -07:00
Alexandre Ganea
685f5dc624 [CodeView] Align type records on 4-bytes when emitting PDBs
When emitting PDBs, the TypeStreamMerger class is used to merge .debug$T records from the input .OBJ files into the output .PDB stream.
Records in .OBJs are not required to be aligned on 4-bytes, and "The Netwide Assembler 2.14" generates non-aligned records.

When compiling with -DLLVM_ENABLE_ASSERTIONS=ON, an assert was triggered in MergingTypeTableBuilder when non-ghash merging was used.
With ghash merging there was no assert.
As a result, LLD could potentially generate a non-aligned TPI stream.

We now align records on 4-bytes when record indices are remapped, in TypeStreamMerger::remapIndices().

Differential Revision: https://reviews.llvm.org/D75081
2020-03-13 12:22:19 -04:00
James Henderson
cd41ba8d27 [DebugInfo] Add check for .debug_line minimum_instruction_length of 0
If the minimum_instruction_length of a debug line program is 0, no
address advancing via special opcodes, DW_LNS_const_add_pc, and
DW_LNS_advance_pc can occur, since the minimum_instruction_length is
used in a multiplication. This patch adds a warning reporting when this
issue occurs.

Reviewed by: probinson

Differential Revision: https://reviews.llvm.org/D75189
2020-03-09 12:59:44 +00:00
James Henderson
eff38d6af0 [DebugInfo] Prevent crash when .debug_line line_range is zero
The line_range value of a debug line program header is used in divisions
related to special opcodes and DW_LNS_const_add_pc opcodes. As such, a
value of 0 cannot be used. This change introduces a new warning, if such
a situation is identified, and does not perform the relevant
calculations.

Reviewed by: probinson, aprantl

Differential Revision: https://reviews.llvm.org/D43470
2020-03-09 12:59:43 +00:00
James Henderson
14ae577b3f [DebugInfo] Report unsupported maximum_operations_per_instruction values
This patch adds a check which reports an unsupported value of the
maximum_operations_per_instruction field in a debug line table header.
This is reported once per line table, at most, and only if the tablet
would otherwise need to use it (i.e. never for tables with version 3 or
less, or for tables which don't use DW_LNS_const_add_pc or special
opcodes). Unsupported values are currently any apart from 1.

Reviewed by: probinson, MaskRay

Differential Revision: https://reviews.llvm.org/D74819
2020-03-09 12:59:43 +00:00
James Henderson
7505a1b388 [NFC][DebugInfo] Refactor address advancing operations to share code
This change is a preparatory change for subsequent commits.

Reviewed by: probinson

Differential Revision: https://reviews.llvm.org/D75188
2020-03-09 12:59:43 +00:00
Igor Kudrin
75ae27f650 [DebugInfo] Print the actual value of an unknown section identifier.
This is a follow-up for D75609. As @dblaikie suggested, it prints
the actual number for an unknown section identifier when dumping
unit index sections.

Differential Revision: https://reviews.llvm.org/D75668
2020-03-06 21:46:04 +07:00
Igor Kudrin
a4fab2c27b [DebugInfo] Do not truncate 64-bit values when dumping CIEs and FDEs.
This fixes printing long values that might reside in CIE and FDE,
including offsets, lengths, and addresses.

Differential Revision: https://reviews.llvm.org/D73887
2020-03-05 17:37:28 +07:00
Igor Kudrin
6b87aa0046 [DebugInfo] Refine the condition to detect CIEs.
The condition was not accurate enough and could interpret some FDEs in
.eh_frame or 64-bit DWARF .debug_frame sections as CIEs. Even though
such FDEs are unlikely in a normal situation, the wrong interpretation
could hide an issue in a buggy generator.

Differential Revision: https://reviews.llvm.org/D73886
2020-03-05 17:37:09 +07:00
Igor Kudrin
0ceba89b0b [DebugInfo] Avoid crashing on an invalid section identifier.
A DWARFSectionKind is read from input. It is not validated on parsing,
so an unexpected value may result in reaching llvm_unreachable() in
DWARFUnitIndex::getColumnHeader() when dumping the index section.

Differential Revision: https://reviews.llvm.org/D75609
2020-03-05 10:54:43 +07:00
Greg Clayton
8024597fa7 Fix buildbots with merge that didn't happen for 4050b01ba9ece02721ec496383baee219ca8cc2b. 2020-03-04 19:28:24 -08:00