1089 Commits

Author SHA1 Message Date
Jonas Devlieghere
1eae26afe9 Revert "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"
This reverts commit r311492.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311499 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-22 21:59:46 +00:00
Jonas Devlieghere
30abbf9835 [llvm-dwarfdump] Print type names in DW_AT_type DIEs
This patch adds printing for DW_AT_type DIEs like it's currently already
the case for DW_AT_specification DIEs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311492 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-22 21:41:49 +00:00
Zachary Turner
af04423e31 [PDB] Serialize records into a stack-allocated buffer.
We were using a std::vector<> and resizing to MaxRecordLength,
which is ~64KB.  We would then do this repeatedly often many
times in a tight loop, which was causing measurable performance
impact when linking PDBs.

Patch by Alex Telishev
Differential Revision: https://reviews.llvm.org/D36940

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311375 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-21 20:17:19 +00:00
Zachary Turner
a326878490 [lld/pdb] Speed up construction of publics & globals addr map.
computeAddrMap function calls std::stable_sort with a comparison
function that computes deserialized symbols every time its called.
In the result deserializeAs<PublicSym32> is called 20-30 times per
symbol. It's much faster to calculate it beforehand and pass a
pointer to it to the comparison function.

Patch by Alex Telishev
Differential Revision: https://reviews.llvm.org/D36941

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311373 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-21 20:08:40 +00:00
Zachary Turner
b6d8c58d41 [llvm-pdbutil] Add support for dumping detailed module stats.
This adds support for dumping a summary of module symbols
and CodeView debug chunks.  This option prints a table for
each module of all of the symbols that occurred in the module
and the number of times it occurred and total byte size.  Then
at the end it prints the totals for the entire file.

Additionally, this patch adds the -jmc (just my code) option,
which suppresses modules which are from external libraries or
linker imports, so that you can focus only on the object files
and libraries that originate from your own source code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311338 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-21 14:53:25 +00:00
Benjamin Kramer
c773276189 Move helper classes into anonymous namespaces.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311288 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-20 13:03:48 +00:00
Jonas Devlieghere
15ccbc58e5 [llvm-dwarfdump] Hide .debug_str and DIE reference offsets in brief mode
This patch hides the .debug_str offset and DIE reference offsets into
the CU when llvm-dwarfdump is invoked with -brief.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311201 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-18 21:35:44 +00:00
Zachary Turner
295b95de34 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311119 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17 20:18:36 +00:00
Zachary Turner
6035f1ffb5 [llvm-pdbutil] Fix some dumping issues.
When dumping, we were treating the S_INLINESITESYM as referring
to a type record, when it actually refers to an id record.  We
had this correct in TypeIndexDiscovery, so our merging algorithm
should be fine, but we had it wrong in the dumper, which means it
would appear to work most of the time, unless the index was out
of bounds in the type stream, when it would fail.  Fixed this, and
audited a few other cases to make them match the behavior in
TypeIndexDiscovery.

Also, I've now observed a new symbol record with kind 0x1168 which
I have no clue what it is, so to avoid crashing we have to just
print "Unknown Symbol Kind".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17 20:04:51 +00:00
Adrian Prantl
4607019142 Add a convenience overload of DWARFDie::dump() for debugging purposes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311026 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-16 17:43:01 +00:00
George Rimar
f9877058a2 [llvm-dwarfdump] - Attemp to fix BB after r310915.
Now MIPS one is unhappy:
http://lab.llvm.org:8011/builders/llvm-mips-linux/builds/2221

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15 16:42:21 +00:00
George Rimar
0cca55d7f5 [llvm-dwarfdump] - Refactor section name/uniqueness gathering.
As was requested in D36313 thread,

with this patch section names and uniqueness calculated once,
and not every time when a range is dumped.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310923 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15 15:54:43 +00:00
George Rimar
03937ca748 [llvm-dwarfdump] - Print section name and index when dumping .debug_info ranges
Teaches llvm-dwarfdump to print section index and name of range
when it dumps .debug_info.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310915 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15 12:32:54 +00:00
Zachary Turner
e3e384aef7 [LLD/PDB] Write actual records to the globals stream.
Previously we were writing an empty globals stream.  Windows
tools interpret this as "private symbols are not present in
this PDB", even when they are, so we need to fix this.  Regardless,
without it we don't have information about global variables, so
we need to fix it anyway.  This patch does that.

With this patch, the "lm" command in WinDbg correctly reports
that we have private symbols available, but the "dv" command
still refuses to display local variables.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310743 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11 19:00:03 +00:00
Zachary Turner
ed601f1b51 [PDB] Fix an issue writing the publics stream.
In the refactor to merge the publics and globals stream, a bug
was introduced that wrote the wrong value for one of the fields
of the PublicsStreamHeader.  This caused debugging in WinDbg
to break.

We had no way of dumping any of these fields, so in addition to
fixing the bug I've added dumping support for them along with a
test that verifies the correct value is written.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310439 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09 04:23:59 +00:00
Zachary Turner
3be08b1e5e [PDB] Merge Global and Publics Builders.
The publics stream and globals stream are very similar. They both
contain a list of hash buckets that refer into a single shared stream,
the symbol record stream. Because of the need for each builder to manage
both an independent hash stream as well as a single shared record
stream, making the two builders be independent entities is not the right
design. This patch merges them into a single class, of which only a
single instance is needed to create all 3 streams.  PublicsStreamBuilder
and GlobalsStreamBuilder are now merged into the single GSIStreamBuilder
class, which writes all 3 streams at once.

Note that this patch does not contain any functionality change. So we're
still not yet writing any records to the globals stream. All we're doing
is making it so that when we do start writing records to the globals,
this refactor won't have to be part of that patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310438 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09 04:23:25 +00:00
Zachary Turner
e87e5c313d [PDB] Fix linking of function symbols and local variables.
The compiler outputs PROC32_ID symbols into the object files
for functions, and these symbols have an embedded type index
which, when copied to the PDB, refer to the IPI stream.  However,
the symbols themselves are also converted into regular symbols
(e.g. S_GPROC32_ID -> S_GPROC32), and type indices in the regular
symbol records refer to the TPI stream.  So this patch applies
two fixes to function records.
  1. It converts ID symbols to the proper non-ID record type.
  2. After remapping the type index from the object file's index
     space to the PDB file/IPI stream's index space, it then
     remaps that index to the TPI stream's index space by.

Besides functions, during the remapping process we were also
discarding symbol record types which we did not recognize.
In particular, we were discarding S_BPREL32 records, which is
what MSVC uses to describe local variables on the stack.  So
this patch fixes that as well by copying them to the PDB.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310394 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-08 18:34:44 +00:00
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
Adrian McCarthy
2d30fac6e9 Enable llvm-pdbutil to list enumerations using native PDB reader
This extends the native reader to enable llvm-pdbutil to list the enums in a
PDB and it includes a simple test. It does not yet list the values in the
enumerations, which requires an actual implementation of
NativeEnumSymbol::FindChildren.

To exercise this code, use a command like:

    llvm-pdbutil pretty -native -enums foo.pdb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04 22:37:58 +00:00
Reid Kleckner
63c839af68 [PDB] Fix section contributions
Summary:
PDB section contributions are supposed to use output section indices and
offsets, not input section indices and offsets.

This allows the debugger to look up the index of the module that it
should look up in the modules stream for symbol information. With this
change, windbg can now find line tables, but it still cannot print local
variables.

Fixes PR34048

Reviewers: zturner

Subscribers: hiraditya, ruiu, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309987 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-03 21:15:09 +00:00
Zachary Turner
50b0dc9e5b [pdb/lld] Write a valid FPM.
The PDB reserves certain blocks for the FPM that describe which
blocks in the file are allocated and which are free.  We weren't
filling that out at all, and in some cases we were even stomping
it with incorrect data.  This patch writes a correct FPM.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309896 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 22:31:39 +00:00
Zachary Turner
34173def44 [pdbutil] Add a command to dump the FPM.
Recently problems have been discovered in the way we write the FPM
(free page map).  In order to fix this, we first need to establish
a baseline about what a correct FPM looks like using an MSVC
generated PDB, so that we can then make our own generated PDBs
match.  And in order to do this, the dumper needs a mode where it
can dump an FPM so that we can write tests for it.

This patch adds a command to dump the FPM, as well as a test against
a known-good PDB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 22:25:52 +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
Zachary Turner
548addb1f1 [lld/pdb] Add an empty globals stream.
We don't write any actual symbols to this stream yet, but for
now we just create the stream and hook it up to the appropriate
places and give it a valid header.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309608 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-31 19:36: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
Reid Kleckner
1a8dc59306 [PDB] Initialize the std::array<ulittle32_t> used for the gsi bitmap
With ASan, we would write about 512 bytes of malloc fill value to the
PDB, with some random bits ORed in here and there. Dumping the PDB would
always fail reliably.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309331 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27 23:13:05 +00:00
Reid Kleckner
91b875c229 [PDB] Write public symbol records and the publics hash table
Summary:
MSVC link.exe records all external symbol names in the publics stream.
It provides similar functionality to an ELF .symtab.

Reviewers: zturner, ruiu

Subscribers: hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309303 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27 18:25:59 +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
Reid Kleckner
49fc1e6fbc [PDB] Remove stale GSI.h header that I intended to remove in the previous commit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309069 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26 00:58:49 +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
Reid Kleckner
4a753bdddf [PDB] Improve GSI hash table dumping for publics and globals
The PDB "symbol stream" actually contains symbol records for the publics
and the globals stream. The globals and publics streams are essentially
hash tables that point into a single stream of records. In order to
match cvdump's behavior, we need to only dump symbol records referenced
from the hash table. This patch implements that, and then implements
global stream dumping, since it's just a subset of public stream
dumping.

Now we shouldn't see S_PROCREF or S_GDATA32 records when dumping
publics, and instead we should see those record in the globals stream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309066 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26 00:40:36 +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
Tim Northover
468caf2a3b Revert "Debug: handle dumping the D language."
Reid beat me to it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308902 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 17:47:46 +00:00
Tim Northover
ea5f5cba91 Debug: handle dumping the D language.
Mostly just to silence a warning about an unhandled case. There don't seem to
be any tests for this operator (at least that I could find).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 17:39:44 +00:00
Reid Kleckner
d5395f15ca Add missing case to switch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 16:30:44 +00:00
Reid Kleckner
78116356ca [codeview] Emit 'D' as the cv source language for D code
This matches DMD:
522263965c/src/ddmd/backend/cv8.c (L199)

Fixes PR33899.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308890 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24 16:16:42 +00:00
Reid Kleckner
f45e52bfbe Fix DebugInfo/PDB build by adding missing changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308765 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-21 18:32:00 +00:00
Reid Kleckner
cf6f650daf [PDB] Dump extra info about the publics stream
This includes the hash table, the address map, and the thunk table and
section offset table. The last two are only used for incremental
linking, which LLD doesn't support, so they are less interesting. The
hash table is particularly important to get right, since this is the one
of the streams that debuggers use to translate addresses to symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308764 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-21 18:28:55 +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