Commit Graph

1160 Commits

Author SHA1 Message Date
Rafael Espindola
0fa582d74a Convert FileOutputBuffer to Expected. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317649 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08 01:05:44 +00:00
Paul Robinson
e9d757c19e [DWARFv5] Support DW_FORM_strp in the .debug_line header.
Supporting this form in .debug_line.dwo will be done as a follow-up.

Differential Revision: https://reviews.llvm.org/D33155

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317607 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-07 19:57:12 +00:00
NAKAMURA Takumi
598658d792 Fix warnings discovered by rL317076. [-Wunused-private-field]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01 13:47:55 +00:00
Benjamin Kramer
3f39bd2824 Revert "[DWARF] Now that Optional is standard layout, put it into an union instead of splatting it."
GCC doesn't like it. This reverts commit r317028.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317030 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31 19:55:08 +00:00
Benjamin Kramer
159d0eccfe [DWARF] Now that Optional is standard layout, put it into an union instead of splatting it.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317028 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31 19:40:03 +00:00
George Rimar
ed00729d34 Fix BB after r316756 "[llvm-dwarfdump] - Teach verifier to report broken DWARF expressions."
Bot:
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/6255

Changed format of this message by mistake.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316757 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27 10:58:04 +00:00
George Rimar
603d7b3055 [llvm-dwarfdump] - Teach verifier to report broken DWARF expressions.
Patch improves next things:

* Fixes assert/crash in getOpDesc when giving it a invalid expression op code.
* DWARFExpression::print() called DWARFExpression::Operation::getEndOffset() which
  returned and used uninitialized field EndOffset. Patch fixes that.
* Teaches verifier to verify DW_AT_location and error out on broken expressions.

Differential revision: https://reviews.llvm.org/D39294

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316756 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27 10:42:04 +00:00
Reid Kleckner
eb271e82ff [PDB] Handle an empty globals hash table with no buckets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316722 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27 00:45:51 +00:00
Jonas Devlieghere
c2c04200c8 Re-land "[dwarfdump] Add -lookup option"
Add the option to lookup an address in the debug information and print
out the file, function, block and line table details.

Differential revision: https://reviews.llvm.org/D38409

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316619 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25 21:56:41 +00:00
George Rimar
db07f4c8a7 [llvm-dwarfdump] - Fix array out of bounds access crash.
This fixes possible out of bound access in
DWARFDie::getFirstChild()
which might happen when .debug_info section is corrupted,
like shown in testcase.

Differential revision: https://reviews.llvm.org/D39185


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316566 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25 10:23:49 +00:00
Reid Kleckner
91db8008a9 [codeview] Fix handling of S_HEAPALLOCSITE
The type index is from the TPI stream, not the IPI stream. Fix the
dumper, fix type index discovery, and add a test in LLD.

Also improve the log message we emit when we fail to rewrite type
indices in LLD. That's how I found this bug.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316461 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24 17:02:40 +00:00
Reid Kleckner
790af1ab79 [codeview] Add support for inlinee lists
This adds type index discovery and dumper support for symbol record kind
0x1168, which is a list of inlined function ids. This symbol kind is
undocumented, but S_INLINEES is consistent with the existing
nomenclature.

Fixes PR34222

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316398 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 23:43:40 +00:00
Reid Kleckner
28098485bc [codeview] Recognize two records with no type index fields
Thunk records do not have types and frame cookies do not have types.

These were found while linking libconcrt.lib from MSVC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 22:44:24 +00:00
George Rimar
2b3608434c [llvm-dwarfdump] - Teach tool about few GNU call_sites constants.
This teaches tool about following consants: 
DW_TAG_GNU_call_site,
DW_TAG_GNU_call_site_parameter,
DW_AT_GNU_call_site_value,
DW_AT_GNU_all_call_sites.

Constants documented here: https://sourceware.org/elfutils/DwarfExtensions

Differential revision: https://reviews.llvm.org/D39119

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316321 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 11:24:14 +00:00
Peter Collingbourne
a29687c501 COFF: Add type server pdb files to linkrepro tar file.
Differential Revision: https://reviews.llvm.org/D38977

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316233 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20 19:48:26 +00:00
George Rimar
9c5669aedb [llvm-dwarfdump] - Teach tool to parse DW_CFA_GNU_args_size.
Currently llvm-dwarfdump runs into llvm_unreachable when
faces DW_CFA_GNU_args_size. Patch implements the support.

Differential revision: https://reviews.llvm.org/D38879

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315897 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-16 10:26:17 +00:00
Jonas Devlieghere
771d209701 Re-land "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"
This patch adds printing for DW_AT_type DIEs like it is already the case
for DW_AT_specification DIEs. This is a rather naive approach and only a
start. We should have pretty printers for different languages.

Recommit after being reverted in r315299.

Differential revision: https://reviews.llvm.org/D36993

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315316 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-10 14:15:25 +00:00
Jonas Devlieghere
269a7003bb Revert "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"
This reverts commit r315297.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315299 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-10 11:49:56 +00:00
Jonas Devlieghere
098eeb5ecc [llvm-dwarfdump] Print type names in DW_AT_type DIEs
This patch adds printing for DW_AT_type DIEs like it is already the case
for DW_AT_specification DIEs. This is a rather naive approach and only a
start. We should have pretty printers for different languages.

Differential revision: https://reviews.llvm.org/D36993

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315297 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-10 11:24:41 +00:00
Jonas Devlieghere
9fb72f1b56 [dwarfdump] Verify that unit type matches root DIE
This patch adds two new verifiers:

  - It checks that the root DIE of a CU is actually a valid unit DIE.
    (based on its tag)
  - For DWARF5 which contains a unit type int he CU header, it checks that
    this matches the type of the unit DIE.

Differential revision: https://reviews.llvm.org/D38453

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-06 22:27:31 +00:00
Adrian Prantl
b7b34f85c5 clang-format file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314942 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-04 22:26:19 +00:00
Adrian Prantl
c09a13ddab delete commented out code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314941 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-04 22:26:19 +00:00
Hans Wennborg
f6bdff925b Fix -Wcovered-switch-default warnings from r314821
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314826 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03 18:44:12 +00:00
Hans Wennborg
f8a9b3953b Revert r314817 "[dwarfdump] Add -lookup option"
The test fails on Linux; see follow-up email on the llvm-commits list.

> Add the option to lookup an address in the debug information and print
> out the file, function, block and line table details.
>
> Differential revision: https://reviews.llvm.org/D38409

This also reverts the follow-up r314818:

> [test] Fix llvm-dwarfdump/cmdline.test
>
> Fixes test/tools/llvm-dwarfdump/cmdline.test

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314825 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03 18:39:13 +00:00
Hans Wennborg
0f3480d826 CodeView: Provide a .def file with the register ids
The list of register ids was previously written out in a couple of dirrent
places. This puts it in a .def file and also adds a few more registers (e.g.
the x87 regs) which should lead to more readable dumps, but I didn't include
the whole list since that seems unnecessary.

X86_MC::initLLVMToSEHAndCVRegMapping is pretty ugly, but at least it's not
relying on magic constants anymore. The TODO of using tablegen still stands.

Differential revision: https://reviews.llvm.org/D38480

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314821 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03 18:27:22 +00:00
Jonas Devlieghere
05dde13ff8 [dwarfdump] Add -lookup option
Add the option to lookup an address in the debug information and print
out the file, function, block and line table details.

Differential revision: https://reviews.llvm.org/D38409

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314817 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03 17:10:21 +00:00
Hans Wennborg
669e5cb88d CodeView symbol dumper: use symbolic names for registers
https://reviews.llvm.org/D38469

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-02 17:44:47 +00:00
Jonas Devlieghere
5295aa52c1 [dwarfdump] Add -show-form
This enables printing of DWARF form types after the DWARF attribute
types.

Differential revision: https://reviews.llvm.org/D38459

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314685 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-02 16:02:04 +00:00
Jonas Devlieghere
0fbd59fa12 [dwarfdump][NFC] Consistent printing of address ranges
This implement the insertion operator for DWARF address ranges so they
are consistently printed as [LowPC, HighPC).

While a dump method might have felt more consistent, it is used
exclusively for printing error messages in the verifier and never used
for actual dumping. Hence this approach is more intuitive and creates
less clutter at the call sites.

Differential revision: https://reviews.llvm.org/D38395

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314523 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29 15:41:22 +00:00
Jonas Devlieghere
553e12e54c [dwarfdump][NFC] Consistent errors and warnings with --verify
This patch introduces 3 helper functions: error(), warn() and note() to
make printing  during verification more consistent. When supported, the
respective prefixes are printed in color using the same color scheme as
clang.

Differential revision: https://reviews.llvm.org/D38368

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314498 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29 09:33:31 +00:00
Adrian Prantl
547ff0af11 llvm-dwarfdump: support .apple-namespaces in --find
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314481 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29 00:52:33 +00:00
Adrian Prantl
4d5765b0a5 llvm-dwarfdump: add support for .apple_types in --find
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314479 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-29 00:33:22 +00:00
Adrian Prantl
81f2386de4 llvm-dwarfdump: implement --find for .apple_names
This patch implements the dwarfdump option --find=<name>.  This option
looks for a DIE in the accelerator tables and dumps it if found.  This
initial patch only adds support for .apple_names to keep the review
small, adding the other sections and pubnames support should be
trivial though.

Differential Revision: https://reviews.llvm.org/D38282

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314439 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28 18:10:52 +00:00
Jonas Devlieghere
6bae1b9b2b [dwarfdump] Verify that CUs have a unit DIE.
This patch adds a check to the DWARF verifier to detect CUs without a
unit DIE.

Differential revision: https://reviews.llvm.org/D38363

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28 15:57:50 +00:00
Jonas Devlieghere
edfbacb90b [dwarfdump] Fix printing of .debug_line offset.
Fixes 32-bit buildbots:
  http://bb.pgr.jp/builders/test-llvm-i686-linux-RA/builds/542
  http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/11533
  http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/11494

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314291 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27 10:00:27 +00:00
Jonas Devlieghere
8d542e127f [dwarfdump] Add support for -debug-line=OFFSET
This patch adds support for passing an offset to -debug-line.

Differential revision: https://reviews.llvm.org/D38240

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314288 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27 09:33:45 +00:00
Jonas Devlieghere
932c395059 [dwarfdump] Add support for -debug-loc=OFFSET
This patch adds support for passing an offset to -debug-loc.

Differential revision: https://reviews.llvm.org/D38237

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314286 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27 09:33:36 +00:00
Jonas Devlieghere
ac9a500e73 [dwarfdump] Skip 'stripped' sections
When dsymutil generates the companion file, its strips all unnecessary
sections by omitting their body and setting the offset in their
corresponding load command to zero.

One such section is the .eh_frame section, as it contains runtime
information rather than debug information and is part of the __TEXT
segment. When reading this section, we would just read the number of
bytes specified in the load command, starting from offset 0 (i.e. the
beginning of the file).

Rather than trying to parse this obviously invalid section, dwarfdump
now skips this.

Differential revision: https://reviews.llvm.org/D38135

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314208 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-26 14:22:35 +00:00
Jonas Devlieghere
45b741c841 [dwarfdump] Add verbose output for .debug-line section
This patch adds dumping of line table instructions as well as the final
state at each specified pc value in verbose mode. This is essentially
the same as the default in Darwin's dwarfdump. Dumping the actual line
table opcodes can be particularly useful for something like debugging a
bad `.debug_line` section.

Differential revision: https://reviews.llvm.org/D37971

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313910 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-21 20:15:30 +00:00
Adrian Prantl
67be5f5362 llvm-dwarfdump support --debug-frame=<offset> and --eh-frame=<offset>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313900 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-21 18:52:03 +00:00
Benjamin Kramer
93b713bb17 [DWARF] Shrink AttributeSpec from 24 to 16 bytes.
This is a bit ugly because we can't put Optional into a union. Hide all
of that behind a set of accessors and make accesses safer using asserts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313884 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-21 15:27:45 +00:00
Adrian Prantl
ae599aa1b4 llvm-dwarfdump: implement --recurse-depth=<N>
This patch implements the Darwin dwarfdump option --recurse-depth=<N>,
which limits the recursion depth when selectively printing DIEs at an
offset.

Differential Revision: https://reviews.llvm.org/D38064

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313778 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-20 17:44:00 +00:00
David Blaikie
b4ea5a3b36 dwarfdump/symbolizer: Avoid loading unneeded CUs from a DWP
When symbolizing large binaries, parsing every CU in a DWP file is a
significant performance penalty. Instead, use the index to only load the
CUs that are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313659 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-19 18:36:11 +00:00
David Blaikie
7414b5dffd dwarfdump: Delay parsing abbreviations until they're needed
This speeds up dumping specific DIEs by not parsing abbreviations for
units that are not used.

(this is also handy to have in eventually to speed up llvm-symbolizer
for .dwp files, where parsing most of the DWP file can be avoided by
using the index)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313635 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-19 15:13:55 +00:00
Adrian Prantl
d8f94b89b5 llvm-dwarfdump: use more efficient API (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18 21:44:40 +00:00
Adrian Prantl
8801a104a5 Fix indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313568 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18 21:28:13 +00:00
Adrian Prantl
8233b30822 llvm-dwarfdump: add a --show-parents options when selectively dumping DIEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313567 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18 21:27:44 +00:00
Adrian Prantl
9c71e1d903 llvm-dwarfdump: Sink the handling of ShowChildren into DWARFDie::dump(). NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313560 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18 19:55:00 +00:00
Jonas Devlieghere
6ad4356f4d [dwarfdump] Make .eh_frame an alias for .debug_frame
This patch makes the `.eh_frame` extension an alias for `.debug_frame`.
Up till now it was only possible to dump the section using objdump, but
not with dwarfdump. Since the two are essentially interchangeable, we
dump whichever of the two is present.

As a workaround, this patch also adds parsing for 3 currently
unimplemented CFA instructions: `DW_CFA_def_cfa_expression`,
`DW_CFA_expression`, and `DW_CFA_val_expression`. Because I lack the
required knowledge, I just parse the fields without actually creating
the instructions.

Finally, this also fixes the typo in the `.debug_frame` section name
which incorrectly contained a trailing `s`.

Differential revision: https://reviews.llvm.org/D37852

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313530 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18 14:15:57 +00:00
Adrian Prantl
d4e3753582 llvm-dwarfdump: support a --show-children option
This will print all children of a DIE when selectively printing only
one DIE at a given offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-16 17:28:00 +00:00