Commit Graph

1480 Commits

Author SHA1 Message Date
Fangrui Song b87342a824 [DWARF] Change pubnames to use DWARFSection instead of StringRef
Summary: The debug_info_offset values in .debug_{,gnu_}pub{name,types} may be relocated. Change it to DWARFSection so that we can get relocated values.

Reviewers: ruiu, dblaikie, grimar, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: aprantl, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346615 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 18:57:28 +00:00
Alexandre Ganea 65448894be [LLD] Fix Microsoft precompiled headers cross-compile on Linux
Differential revision: https://reviews.llvm.org/D54122


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346403 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-08 14:42:37 +00:00
Jorge Gorbe Moya 9a031b8a93 Add parentheses to silence warning.
DWARFContext.cpp:356:20: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-07 22:30:01 +00:00
Paul Robinson 0bb019fff9 [DWARFv5] Read and dump multiple .debug_info sections.
Type units go in .debug_info comdats, not .debug_types, in v5.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346360 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-07 21:39:09 +00:00
Fangrui Song 1d019aeea8 [DWARF] Support types CU list in .gdb_index dumping
Some executables have non-empty types CU list and -gdb-index would report "<error reporting>" before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346181 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-05 23:27:53 +00:00
Alexandre Ganea 4a52ea2ea2 [COFF][LLD] Add link support for Microsoft precompiled headers OBJs
This change allows for link-time merging of debugging information from
Microsoft precompiled types OBJs compiled with cl.exe /Z7 /Yc and /Yu.

This fixes llvm.org/PR34278

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346154 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-05 19:20:47 +00:00
Wolfgang Pieb 974dfd1b51 [DWARF v5] Verifier: Add checks for DW_FORM_strx* forms.
Adding functionality to the DWARF verifier for DWARF v5 strx* forms which 
index into the string offsets table.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346061 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-03 00:27:35 +00:00
Fangrui Song e29a02ac3f [DWARF] Fix typo, .gnu_index -> .gdb_index
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346039 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-02 20:34:40 +00:00
Reid Kleckner a754e02f2a [codeview] Add breaks to fix -Wimplicit-fallthrough
This is a minor bug fix. Previously, if you tried to encode the RSP
register on the x86 platform, that might have succeeded and been encoded
incorrectly. However, no existing producer or consumer passes the x86_64
registers when targeting x86_32.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345879 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 19:36:29 +00:00
Zachary Turner fd25d2bf30 [CodeView] Emit the correct TypeIndex for std::nullptr_t.
The TypeIndex used by cl.exe is 0x103, which indicates a SimpleTypeMode
of NearPointer (note the absence of the bitness, normally pointers use a
mode of NearPointer32 or NearPointer64) and a SimpleTypeKind of void.
So this is basically a void*, but without a specified size, which makes
sense given how std::nullptr_t is defined.

clang-cl was actually not emitting *anything* for this. Instead, when we
encountered std::nullptr_t in a DIType, we would actually just emit a
TypeIndex of 0, which is obviously wrong.

std::nullptr_t in DWARF is represented as a DW_TAG_unspecified_type with
a name of "decltype(nullptr)", so we add that logic along with a test,
as well as an update to the dumping code so that we no longer print
void* when dumping 0x103 (which would previously treat Void/NearPointer
no differently than Void/NearPointer64).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345811 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 04:02:41 +00:00
Wolfgang Pieb 29d4d64637 [DWARF][NFC] Refactor a function to return Optional<> instead of bool
Minor refactor of DWARFUnit::getStringOffsetSectionItem().

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345776 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 21:05:51 +00:00
Wolfgang Pieb daecf945cc [DWARF] Revert r345546: Refactor range list extraction and dumping
This patch caused some internal tests to break which are being investigated.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345687 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 01:12:58 +00:00
Saleem Abdulrasool 1c6bfcc50c DWARFVerifier: make the verifier more comprehensive for objects
Make the code do what was mentioned in the comment: only skip the CU types.
This enables the lexical blocks to be verified as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345675 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-30 23:45:27 +00:00
Wolfgang Pieb 3efd3a74af [DWARF][NFC] Refactor range list extraction and dumping
The purpose of this patch is twofold: 
- Fold pre-DWARF v5 functionality into v5 to eliminate the need for 2 different 
  versions of range list handling. We get rid of DWARFDebugRangelist{.cpp,.h}.
- Templatize the handling of range list tables so that location list handling
  can take advantage of it as well. Location list and range list tables have the 
  same basic layout.

A non-NFC version of this patch was previously submitted with r342218, but it caused
errors with some TSan tests. This patch has no functional changes. The difference to
the non-NFC patch is that there are no changes to rangelist dumping in this patch.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345546 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 22:16:47 +00:00
Saleem Abdulrasool a8288db805 Revert "Revert "DebugInfo: reduce DIE range verification on object files""
This reverts commit 836c763dad.  Default
initialize the values that MSAN caught.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345482 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-28 22:30:48 +00:00
Vlad Tsyrklevich 836c763dad Revert "DebugInfo: reduce DIE range verification on object files"
This reverts commits r345441 and r345444, they were causing msan
buildbot failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345457 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-27 17:39:13 +00:00
Saleem Abdulrasool 3e9dcf4c0b DebugInfo: reduce DIE range verification on object files
Relocatable content may have overlapping ranges until the sections are
finalized.  This reduces the amount of verification that is done on an object
file so that invalid errors are not raised.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345441 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-27 00:49:33 +00:00
Wolfgang Pieb d0ae3cb27e [DWARF][NFC] cleanup (mostly leftovers from the implementation of string offsets tables)
Majority of the patch by David Blaikie.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345404 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-26 17:14:46 +00:00
David Blaikie 441900b083 llvm-dwarfdump: loclists: Don't expect an (albeit empty) expression for LLE_base_address
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345320 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 21:35:59 +00:00
George Rimar 8377922c28 [llvm-dwarfdump] - Fix incorrect parsing of the DW_LLE_startx_length
As was already mentioned in comments for D53364, DWARF 5
spec says about DW_LLE_startx_length:

"This is a form of bounded location description that has two unsigned ULEB operands.
The first value is an address index (into the .debug_addr section) that indicates the beginning of the address range
over which the location is valid. The second value is the length of the range. ")

Currently, the length is always parsed as U32.
Patch change the behavior to parse DW_LLE_startx_length as ULEB128 for DWARF 5
and keeps it as U32 for DWARF4+(pre-DWARF5) for compatibility.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345254 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 10:56:44 +00:00
David Blaikie b8fd9d55db llvm-dwarfdump: Account for skeleton addr_base when dumping addresses in split unit in the same file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345215 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 22:44:54 +00:00
Reid Kleckner b63f24a552 [PDB] Fix -Wunused-private-field in DIA
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345054 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 17:20:16 +00:00
Aleksandr Urakov 7fc581a267 Revert "Revert "[PDB] Extend IPDBSession's interface to retrieve frame data""
This reverts commit 466ce67d6e.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345010 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 08:14:53 +00:00
Zachary Turner c1d5ac8190 Some cleanups to the native pdb plugin [NFC].
This is mostly some cleanup done in the process of implementing
some basic support for types.  I tried to split up the patch a
bit to get some of the NFC portion of the patch out into a separate
commit, and this is the result of that.  It moves some code around,
deletes some spurious namespace qualifications, removes some
unnecessary header includes, forward declarations, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344913 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 16:19:07 +00:00
Aleksandr Urakov 466ce67d6e Revert "[PDB] Extend IPDBSession's interface to retrieve frame data"
This reverts commit b5c7e2f9a4.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344909 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 15:30:48 +00:00
George Rimar ce9fb23fb1 [llvm-dwarfdump] - Fix win10 build bot failture.
Bot failed: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20877/steps/test/logs/stdio

This was broken after the 
r344895 "[llvm-dwarfdump] - Add the support of parsing .debug_loclists."
because of wrong formatting specifiers used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344896 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 12:18:30 +00:00
George Rimar 879e2ef2a6 [llvm-dwarfdump] - Add the support of parsing .debug_loclists.
This teaches llvm-dwarfdump to dump the content of .debug_loclists sections.

It converts the DWARFDebugLocDWO class to DWARFDebugLoclists,
teaches llvm-dwarfdump about .debug_loclists section and
adds the implementation for parsing the DW_LLE_offset_pair entries.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344895 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 11:30:54 +00:00
Aleksandr Urakov b5c7e2f9a4 [PDB] Extend IPDBSession's interface to retrieve frame data
Summary:
This patch just extends the `IPDBSession` interface to allow retrieving
of frame data through it, and adds an implementation over DIA. It is needed
for an implementation (for now with DIA) of the conversion from FPO programs
to DWARF expressions mentioned in D53086.

Reviewers: zturner, asmith, rnk

Reviewed By: asmith

Subscribers: mgorny, aprantl, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344886 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 07:18:08 +00:00
David Blaikie b772afaaa9 DebugInfo: Use DW_OP_addrx in DWARFv5
Reuse addresses in the address pool, even in non-split cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344838 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-20 08:54:05 +00:00
David Blaikie 3a1bc560ac llvm-dwarfdump: Support RLE_addressx and RLE_startx_length in .debug_rnglists
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344835 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-20 06:16:25 +00:00
David Blaikie b5d5e5ebf6 DebugInfo: Use debug_addr for non-dwo addresses in DWARF 5
Putting addresses in the address pool, even with non-fission, can reduce
relocations - reusing the addresses from debug_info and debug_rnglists
(the latter coming soon)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344834 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-20 06:02:15 +00:00
Wolfgang Pieb 3b86c68554 [DWARF] Make llvm-dwarfdump display location lists in a .dwp file correctly. Fixes PR38990.
Considers the index when extracting location lists from a .dwp file.
Majority of the patch by David Blaikie.

Reviewers: dblaikie

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344807 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-19 19:23:16 +00:00
Jonas Devlieghere 65b8c0fe7a [dwarfdump] Hide ranges in diff-mode.
llvm-dwarfdump --diff should not print DW_AT_ranges. This patch fixes
that.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344794 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-19 17:57:53 +00:00
David Bolvansky 4942b853a9 [DwarfVerifier] Fixed -Wimplicit-fallthrough warning
Reviewers: JDevlieghere, RKSimon

Reviewed By: JDevlieghere

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344176 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-10 20:10:37 +00:00
Zachary Turner 6b971fb369 [PDB] Fix another bug in globals stream name lookup.
When we're on the last bucket the computation is tricky.
We were failing when the last bucket contained multiple
matches.  Added a new test for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344081 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 21:19:03 +00:00
Wolfgang Pieb 6c508a5190 [DWARF] Make llvm-dwarfdump display the .debug_loc.dwo section. Fixes PR38991.
Reviewer: dblaikie

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344068 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 18:38:55 +00:00
Zachary Turner dccf3ce84a [PDB] Fix failure on big endian machines.
We changed an ArrayRef<uint8_t> to an ArrayRef<uint32_t>, but
it needs to be an ArrayRef<support::ulittle32_t>.

We also change ArrayRef<> to FixedStreamArray<>.  Technically
an ArrayRef<> will work, but it can cause a copy in the underlying
implementation if the memory is not contiguous, and there's no
reason not to use a FixedStreamArray<>.

Thanks to nemanjai@ and thakis@ for helping me track this down
and confirm the fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344063 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 17:58:51 +00:00
Zachary Turner 78fee6e56c Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344002 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 22:56:57 +00:00
Zachary Turner 602f2b5066 [PDB] fix a bug in global stream name lookup.
When we're looking up a record in the last hash bucket chain, we
need to be careful with the end-offset calculation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344001 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 22:38:27 +00:00
Kristina Brooks 990c587f42 [DebugInfo][PDB] Fix a signed/unsigned coversion warning
Fix the following warning when compiling with clang (caused by commit
rL343951):

GlobalsStream.cpp:61:33: warning: comparison of integers of different
signs: 'int' and 'uint32_t'

This also avoids double evaluation of `GlobalsTable.HashBuckets.size()`.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343957 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 09:03:17 +00:00
Zachary Turner 251720c538 Fix a -Wsign-compare warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343953 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 04:44:12 +00:00
Zachary Turner 25a2b438a4 Fix a compilation failure on non-MSVC compilers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343952 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 04:34:41 +00:00
Zachary Turner cffc876a14 [PDB] Add the ability to lookup global symbols by name.
The Globals table is a hash table keyed on symbol name, so
it's possible to lookup symbols by name in O(1) time.  Add
a function to the globals stream to do this, and add an option
to llvm-pdbutil to exercise this, then use it to write some
tests to verify correctness.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343951 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 04:19:16 +00:00
David Blaikie 626a8eb054 dwarfdump: Avoid parsing units unnecessarily
NFC-ish (the parsing of the units is not a functional change - no
errors/warnings are emitted during the shallow parsing - though without
parsing them here, the "max version" would be wrong (still zero) later
on, so in those cases the units do need to be parsed)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343884 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05 20:55:20 +00:00
Vedant Kumar 78b8f9db17 [DebugInfo] Add support for DWARF5 call site-related attributes
DWARF v5 introduces DW_AT_call_all_calls, a subprogram attribute which
indicates that all calls (both regular and tail) within the subprogram
have call site entries. The information within these call site entries
can be used by a debugger to populate backtraces with synthetic tail
call frames.

Tail calling frames go missing in backtraces because the frame of the
caller is reused by the callee. Call site entries allow a debugger to
reconstruct a sequence of (tail) calls which led from one function to
another. This improves backtrace quality. There are limitations: tail
recursion isn't handled, variables within synthetic frames may not
survive to be inspected, etc. This approach is not novel, see:

  https://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=jelinek.pdf

This patch adds an IR-level flag (DIFlagAllCallsDescribed) which lowers
to DW_AT_call_all_calls. It adds the minimal amount of DWARF generation
support needed to emit standards-compliant call site entries. For easier
deployment, when the debugger tuning is LLDB, the DWARF requirement is
adjusted to v4.

Testing: Apart from check-{llvm, clang}, I built a stage2 RelWithDebInfo
clang binary. Its dSYM passed verification and grew by 1.4% compared to
the baseline. 151,879 call site entries were added.

rdar://42001377

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343883 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05 20:37:17 +00:00
Zachary Turner 5877e4ed63 [PDB] Add support for more kinds of PDB Sym Tags.
DIA SDK is returning several new sym tag types, so we update
the enumeration and printing code to support these.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343547 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 22:39:19 +00:00
Reid Kleckner 6d4c271eeb [codeview] Emit S_FRAMEPROC and use S_DEFRANGE_FRAMEPOINTER_REL
Summary:
Before this change, LLVM would always describe locals on the stack as
being relative to some specific register, RSP, ESP, EBP, ESI, etc.
Variables in stack memory are pretty common, so there is a special
S_DEFRANGE_FRAMEPOINTER_REL symbol for them. This change uses it to
reduce the size of our debug info.

On top of the size savings, there are cases on 32-bit x86 where local
variables are addressed from ESP, but ESP changes across the function.
Unlike in DWARF, there is no FPO data to describe the stack adjustments
made to push arguments onto the stack and pop them off after the call,
which makes it hard for the debugger to find the local variables in
frames further up the stack.

To handle this, CodeView has a special VFRAME register, which
corresponds to the $T0 variable set by our FPO data in 32-bit.  Offsets
to local variables are instead relative to this value.

This is part of PR38857.

Reviewers: hans, zturner, javed.absar

Subscribers: aprantl, hiraditya, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343543 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 21:59:45 +00:00
Zachary Turner b47810926d [PDB] Add support for dumping Typedef records.
These work a little differently because they are actually in
the globals stream and are treated as symbol records, even though
DIA presents them as types.  So this also adds the necessary
infrastructure to cache records that live somewhere other than
the TPI stream as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343507 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 17:55:38 +00:00
Zachary Turner a93560b336 [PDB] Add support for parsing VFTable Shape records.
This allows them to be returned from the native API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343506 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 17:55:16 +00:00
Zachary Turner e1b020acef [PDB] Add native support for dumping array types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343412 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-30 16:19:18 +00:00