238 Commits

Author SHA1 Message Date
Simon Dardis
7d915c62a6 [DebugInfo][DWARF] Address paulr's comment on rL310253.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310267 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-07 16:08:11 +00:00
Simon Dardis
a09f2fcb33 [DebugInfo][DWARF] Correct some usages of PRIx32 to PRIx64
These lead to tests failing spuriously as the values after being rendered to a
string were incorrect.

Reviewers: clayborg

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310262 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-07 15:37:57 +00:00
Simon Dardis
38a5f526fd [DebugInfo][DWARF] Use PRIx64 explicitly in output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310253 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-07 13:30:03 +00:00
David Blaikie
61dba579be DebugInfo: Test & handle (differently) non-zero DW_AT_ranges_base
Followup to r309570, fixing it slightly differently (ranges_base and
addr_base should never be read from a DWO file - so there shouldn't be
any issue with 'overriding' the values - conditionalize the code and
assert that the values aren't being overriden).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309879 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 20:16:22 +00:00
Benjamin Kramer
645faa5ddf [DebugInfo] Use shrink_to_fit to simplify code. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309683 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01 14:38:08 +00:00
Spyridoula Gravani
d40539f8e3 [DWARF] Added verification check for tags in accelerator tables. This patch verifies that the atom tag is actually the same with the tag of the DIE that we retrieve from the table.
Differential Revision: https://reviews.llvm.org/D35963

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309596 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-31 18:01:16 +00:00
Benjamin Kramer
b673bd159b [DebugInfo] Don't overwrite DWARFUnit fields if the CU DIE doesn't have them.
DIEs are lazily deserialized so it's possible that the DWO CU is created
before the DIE is parsed. DWO shares .debug_addr and .debug_ranges with the
object file so overwriting the offset with 0 will make the CU unusable.

No test case because I couldn't get clang to emit a non-zero range base.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309570 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-31 15:32:39 +00:00
David Blaikie
b83dd56dc1 DebugInfo: Fix for CU index usage in 309507
Not sure quite how I failed so clearly to test this, but anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-30 15:15:58 +00:00
David Blaikie
ed297a61b7 DebugInfo: Use DWP cu_index to speed up symbolizing (as intended)
I was a bit lazy when I first implemented this & skipped the index
lookup - obviously for large files this becomes pretty crucial, so here
we go, do the index lookup. Speeds up large DWP symbolizing by... lots.
(20m -> 20s, actually, maybe more in a release build (that was a release
build without index lookup, compared to a debug/non-release build with
the index usage))

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309507 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-30 08:12:07 +00:00
David Blaikie
4cf772e1b7 DebugInfo: Provide option for explicitly specifying the name of the DWP file
If you've archived the DWP file somewhere it's probably useful to be
able to just tell llvm-symbolizer where it is when you're symbolizing
stack traces from the binary.

This only provides a mechanism for specifying a single DWP file, good if
you're symbolizing a program with a single DWP file, but it's likely if
the program is dynamically linked that you might have a DWP for each
dynamic library - in which case this feature won't help (at least as
it's surfaced in llvm-symbolizer for now) - in theory it could be
extended to specify a collection of DWP files that could all be
consulted for split CU hash resolution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309498 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-30 01:34:08 +00:00
Spyridoula Gravani
cadb11499a [DWARF] Minor code style modification, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309240 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27 00:59:33 +00:00
Spyridoula Gravani
c88d81fa3e [DWARF] Generalized verification of .apple_names accelerator table to be applicable to any acceleration table. Added verification for .apple_types, .apple_namespaces and .apple_objc sections.
Differential Revision: https://reviews.llvm.org/D35853

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309068 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26 00:52:31 +00:00
NAKAMURA Takumi
2250b309ad DWARFVerifier.cpp: Fix -m32 in r308928. Use PRIx64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308949 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25 05:03:17 +00:00
Spyridoula Gravani
ef55e4c1a3 [DWARF] Added verification check for die ranges. If highPC is an address, then it should be greater than lowPC for each range.
Differential Revision: https://reviews.llvm.org/D35733

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 21:04:11 +00:00
Rafael Espindola
8121aebb83 Move DWARFSectionMap to a .cpp file.
Thanks to Paul Robinson for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308913 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 19:34:26 +00:00
Spyridoula Gravani
e95e3157f4 [DWARF] Generalized verification of .debug_abbrev to be applicable to both .debug_abbrev and .debug_abbrev.dwo sections.
Differential Revision: https://reviews.llvm.org/D35698

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308703 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-21 00:51:32 +00:00
Spyridoula Gravani
85dd4f9605 [DWARF] Added check that verifies that no abbreviation declaration has more than one attribute with the same name.
SUMMARY

This patch adds a verification check on the abbreviation declarations in the .debug_abbrev section.
The check makes sure that no abbreviation declaration has more than one attributes with the same name.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308579 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20 02:06:52 +00:00
Reid Kleckner
318a52d6bf Use llvm::make_unique once more to avoid ADL ambiguity with std::make_unique
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308552 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19 23:42:53 +00:00
Rafael Espindola
4d1e86340c Use llvm::make_unique to try to fix the windows build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308551 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19 23:38:54 +00:00
Rafael Espindola
ce7d2f59b4 Remove some leftover DWARFContextInMemory.
Not sure how I missed these on the previous commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308550 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19 23:34:59 +00:00
Rafael Espindola
ee809acd59 Use delegation instead of inheritance.
This changes DwarfContext to delegate to DwarfObject instead of having
pure virtual methods.

With this DwarfContextInMemory is replaced with an implementation of
DwarfObject that is local to a .cpp file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308543 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19 22:27:28 +00:00
Spyridoula Gravani
0ea156d8ef [DWARF] Modification of code for the verification of .debug_info section.
Summary:
This patch modifies the handleDebugInfo() function so that we verify the contents of each unit
in the .debug_info section only if its header has been successfully verified.

This change will allow for more/different verification checks depending on the type of the unit since from
dwarf5, the .debug_info section may consist of different types of units.

Subscribers: aprantl

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308245 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18 01:00:26 +00:00
Eric Christopher
1b2c114227 Remove set but not used variables from the debug info verifier code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307987 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-14 01:40:47 +00:00
Spyridoula Gravani
e302dc70dd [DWARF] Introduce verification for the unit header chain in .debug_info section to llvm-dwarfdump.
This patch adds verification checks for the unit header chain in the .debug_info section.
Specifically, for each unit in the .debug_info section, the verifier checks that:

The unit length is valid (i.e. the unit can actually fit in the .debug_info section)
The dwarf version of the unit is valid
The address size is valid (4 or 8)
The unit type (if the unit is in dwarf5) is valid
The debug_abbrev_offset is valid

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307975 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-13 23:25:24 +00:00
Wolfgang Pieb
95621c2165 [DWARF] Fixing a bug with processing of DWARF v5 indexed strings in Mach-O objects.
Code to convert MachO - specific section debug section names to standard DWARF v5
section names was in the wrong place.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307872 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-13 01:03:28 +00:00
Rafael Espindola
41cc19a3ac Don't expose a map in the DWARFContext interface.
Doing so is leaking an implementation detail.

I have an implementation that uses the lld infrastructure and doesn't
use a map or object::SectionRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307846 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12 21:08:24 +00:00
George Rimar
72f54aa84f [DWARF] - Rename variable. NFC.
Variable was called 'Name' and contained text
name of relocation type. Problem was that
outside of this error handling scope we already
have different 'Name' variable that contains
section name.

Change helps to avoid confusion. 

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307530 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10 10:04:51 +00:00
George Rimar
505b8a7283 [DWARF] - Remove unused variables. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307528 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10 09:36:44 +00:00
Rafael Espindola
2e124626b4 Fix variable names. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307406 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07 15:20:55 +00:00
Rafael Espindola
ef8ed10be5 Reduce code duplication.
By addding a mapNameToDWARFSection we only need to check section names
in one place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307359 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07 05:36:53 +00:00
Hiroshi Inoue
de3c902144 fix trivial typos in comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307004 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-03 06:32:59 +00:00
Spyridoula Gravani
7eed73772d [DWARF] Added verification checks for the .apple_names section.
This patch verifies the number of atoms, the validity of the form for each atom, as well as the validity of the
hashdata. For hashdata, we're verifying that the hashdata offset is correct and that the offset in the .debug_info for
each DIE in the hashdata is also valid.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306735 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29 20:13:05 +00:00
Paul Robinson
502fd5ddfa [DWARF] NFC: DWARFDataExtractor combines relocs with DataExtractor.
Requires callers to directly associate relocations with a DataExtractor
used to read data from a DWARF section, which helps a callee not make
assumptions about which section it is reading.
This is the next step in reducing DWARFFormValue's dependence on DWARFUnit.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29 16:52:08 +00:00
George Rimar
f2469c0fac [DWARF] - Fix message reporting about broken relocation.
Because of mistake introduced in r306517,
wrong variable ("name" instead of "Name") was used
in error message.
As a result it reported section name instead of
relocation name.

This file still needs cleanup to match LLVM coding style
and more tests I think.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306677 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29 14:05:18 +00:00
George Rimar
c9c94f42b1 Recommit "[ELF] - Add ability for DWARFContextInMemory to exit early when any error happen."
With fix in include folder character case:
#include "llvm/Codegen/AsmPrinter.h" -> #include "llvm/CodeGen/AsmPrinter.h"

Original commit message:

Change introduces error reporting policy for DWARFContextInMemory.
New callback provided by client is able to handle error on it's
side and return Halt or Continue.

That allows to either keep current behavior when parser prints all errors
but continues parsing object or implement something very different, like
stop parsing on a first error and report an error in a client style.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306517 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28 08:21:19 +00:00
George Rimar
61e059d171 Revert r306512 "[ELF] - Add ability for DWARFContextInMemory to exit early when any error happen."
It broke BB:

[13/106] 13 0.022 Generating VCSRevision.h
[25/106] 24 1.209 Building CXX object unittests/DebugInfo/DWARF/CMakeFiles/DebugInfoDWARFTests.dir/DWARFDebugInfoTest.cpp.o
FAILED: unittests/DebugInfo/DWARF/CMakeFiles/DebugInfoDWARFTests.dir/DWARFDebugInfoTest.cpp.o 
/home/bb/bin/g++  -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iunittests/DebugInfo/DWARF -I../llvm-project/llvm/unittests/DebugInfo/DWARF -Iinclude -I../llvm-project/llvm/include -I../llvm-project/llvm/utils/unittest/googletest/include -I../llvm-project/llvm/utils/unittest/googlemock/include -fPIC -fvisibility-inlines-hidden -m32 -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O3    -UNDEBUG  -Wno-variadic-macros -fno-exceptions -fno-rtti -MD -MT unittests/DebugInfo/DWARF/CMakeFiles/DebugInfoDWARFTests.dir/DWARFDebugInfoTest.cpp.o -MF unittests/DebugInfo/DWARF/CMakeFiles/DebugInfoDWARFTests.dir/DWARFDebugInfoTest.cpp.o.d -o unittests/DebugInfo/DWARF/CMakeFiles/DebugInfoDWARFTests.dir/DWARFDebugInfoTest.cpp.o -c ../llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
../llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:18:37: fatal error: llvm/Codegen/AsmPrinter.h: No such file or directory
 #include "llvm/Codegen/AsmPrinter.h"
                                     ^
compilation terminated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306513 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28 07:06:17 +00:00
George Rimar
75f572053a [ELF] - Add ability for DWARFContextInMemory to exit early when any error happen.
Change introduces error reporting policy for DWARFContextInMemory.
New callback provided by client is able to handle error on it's
side and return Halt or Continue.

That allows to either keep current behavior when parser prints all errors
but continues parsing object or implement something very different, like
stop parsing on a first error and report an error in a client style.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28 06:57:20 +00:00
Paul Robinson
9896afe6bf [DWARF] NFC: Make string-offset handling more like address-table handling;
do the indirection and relocation all in the same method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306418 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27 15:40:18 +00:00
Paul Robinson
d2381bc76f [DWARF] NFC: Give DwarfFormat a 1-byte base type.
In particular this reduces DWARFFormParams from 64 to 32 bits; pass it
around by value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306324 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-26 19:52:32 +00:00
Paul Robinson
fd770ea497 [DWARF] NFC: Collect info used by DWARFFormValue into a helper.
Some forms have sizes that depend on the DWARF version, DWARF format
(32/64-bit), or the size of an address.  Collect these into a struct
to simplify passing them around.  Require callers to provide one when
they query a form's size.

Differential Revision: http://reviews.llvm.org/D34570


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306315 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-26 18:43:01 +00:00
Eugene Zelenko
84310abf19 [DebugInfo] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306169 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-23 21:57:40 +00:00
Wolfgang Pieb
b9c4ad20bf [DWARF] Support for DW_FORM_strx3 and complete support for DW_FORM_strx{1,2,4}
(consumer).

Reviewer: aprantl

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305944 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-21 19:37:44 +00:00
David Blaikie
ffc8b7c5b6 Remove convenient but probably not worthwhile macro for lambda workaround
Cleanup from r305405

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305731 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-19 19:01:08 +00:00
Spyridoula Gravani
3589cb5a83 [DWARF] Corrected behavior for when no .apple_names section is present in the object.
The verifier should not output any message in such a case.
Added test case with no .apple_name section in the file to verify new functionality.
Made existing test case more specific.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305597 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16 22:03:21 +00:00
Spyridoula Gravani
312d0db061 [DWARF] Removed dead code. The verifier functionality is provided by
the DWARFVerifier class (as it should).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305503 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-15 20:40:08 +00:00
Galina Kistanova
8a5ef4d360 Specified ReportError as noreturn friendly to old compilers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305405 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-14 17:32:53 +00:00
Spyridoula Gravani
2940ab652c Added partial verification for .apple_names accelerator table in llvm-dwarfdump output.
This patch adds code which verifies that each bucket in the .apple_names
accelerator table is either empty or has a valid hash index.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305344 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-14 00:17:55 +00:00
Galina Kistanova
f52e7b3036 Reverted r305339 as MSVC is not happy with noreturn in lambda.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305343 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13 23:57:51 +00:00
Galina Kistanova
4b8057ed93 Specified LLVM_ATTRIBUTE_NORETURN for ReportError.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-13 23:39:42 +00:00
David Blaikie
f79912032b dwarfdump: Handle relocs to zlib (.zdebug*) compressed sections
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305152 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-10 19:32:50 +00:00