Commit Graph

541 Commits

Author SHA1 Message Date
David Majnemer
c12ac37f8d Bounds check the number of bitmap blocks in the name map
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271105 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 05:59:25 +00:00
David Majnemer
898ae7b4e8 Make sure the directory contains info for all streams
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271103 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 05:59:19 +00:00
Zachary Turner
5cfb6469b8 [pdb] Finish conversion to zero copy pdb access.
This converts remaining uses of ByteStream, which was still
left in the symbol stream and type stream, to using the new
StreamInterface zero-copy classes.

RecordIterator is finally deleted, so this is the only way left
now.  Additionally, more error checking is added when iterating
the various streams.

With this, the transition to zero copy pdb access is complete.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271101 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 05:21:57 +00:00
David Majnemer
b2f9f8e5dd Don't discard errors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271056 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 22:07:50 +00:00
Zachary Turner
fb799608d4 [pdb] Fix size check when reading stream bytes.
We were accidentally bounds checking the read against the output
ArrayRef instead of against the size of the read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271040 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 20:17:33 +00:00
David Majnemer
c21577e202 Make sure data is available before dereferencing it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271032 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 18:50:02 +00:00
Zachary Turner
e8799b644b Resubmit "[pdb] Allow zero-copy read support for symbol streams.""
Due to differences in template instantiation rules, it is not
portable to static_assert(false) inside of an invalid specialization
of a template.  Instead I just =delete the method so that it can't
be used, and leave a comment that it must be explicitly specialized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271027 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 18:47:20 +00:00
Chad Rosier
1f37794220 Revert "[pdb] Allow zero-copy read support for symbol streams."
This reverts commit r271024 due to error: static_assert failed
"You must either provide a specialization of VarStreamArrayExtractor
or a custom extractor"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271026 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 18:31:02 +00:00
Zachary Turner
6e1b1bf7c7 [pdb] Allow zero-copy read support for symbol streams.
This reduces the amount of memory used by llvm-pdbdump by roughly
1/3 of the size of the PDB file.

Differential Revision: http://reviews.llvm.org/D20724
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 18:20:20 +00:00
David Majnemer
d92a2587d3 Make sure these error codes are marked as checked
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271013 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 16:16:56 +00:00
David Majnemer
c41579b54a Make sure there are enough blocks for the stream
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271012 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 16:16:48 +00:00
David Majnemer
6768e77696 Make sure the directory block array fits in the file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271011 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 16:16:45 +00:00
David Majnemer
36fbd0404a Validate the blocksize before using it
The blocksize could be zero on disk causing later checks to divide by
zero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271008 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 15:57:38 +00:00
Benjamin Kramer
14aae01bc3 Apply clang-tidy's misc-move-constructor-init throughout LLVM.
No functionality change intended, maybe a tiny performance improvement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270997 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 14:27:24 +00:00
Zachary Turner
9cc0faee65 [codeview] Remove StreamReader copying method.
Since we want to move toward zero-copy access to stream data, we
want to remove all instances of copying operations.  So get rid
of some of those here.

Differential Revision: http://reviews.llvm.org/D20720
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270960 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 03:51:53 +00:00
Zachary Turner
0212bc82e0 [codeview,pdb] Try really hard to conserve memory when reading.
PDBs can be extremely large.  We're already mapping the entire
PDB into the process's address space, but to make matters worse
the blocks of the PDB are not arranged contiguously.  So, when
we have something like an array or a string embedded into the
stream, we have to make a copy.  Since it's convenient to use
traditional data structures to iterate and manipulate these
records, we need the memory to be contiguous.

As a result of this, we were using roughly twice as much memory
as the file size of the PDB, because every stream was copied
out and re-stitched together contiguously.

This patch addresses this by improving the MappedBlockStream
to allocate from a BumpPtrAllocator only when a read requires
a discontiguous read.  Furthermore, it introduces some data
structures backed by a stream which can iterate over both
fixed and variable length records of a PDB.  Since everything
is backed by a stream and not a buffer, we can read almost
everything from the PDB with zero copies.

Differential Revision: http://reviews.llvm.org/D20654
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 01:54:44 +00:00
Zachary Turner
213d3d3c81 [codeview] Move StreamInterface and StreamReader to libcodeview.
We have need to reuse this functionality, including making
additional generic stream types that are smarter about how and
when they copy memory versus referencing the original memory.
So all of these structures belong in the common library
rather than being pdb specific.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270751 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 20:37:03 +00:00
Zachary Turner
4f4018ce2c [llvm-pdbdump] Decipher the remaining PDB streams.
We know at least know the meaning of every stream of the
PDB file.  Yay!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270669 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 05:49:48 +00:00
Zachary Turner
fbbe74464a [llvm-pdbdump] Dump the IPI stream and all records.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270661 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 04:35:22 +00:00
Rui Ueyama
ad878ffd0d pdbdump: fix bug in name hash table.
name_ids() did not return all IDs but only the first NameCount items.
The number of non-zero entries in IDs vector is NameCount, but it
does not mean that all non-zero entries are at the beginning of IDs
vector.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270656 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 04:07:17 +00:00
Zachary Turner
3b27e60206 [llvm-pdbdump] Stream 0 isn't actually the MSF superblock.
Oddly enough, I realized we don't actually know what stream
0 is (if anything).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270655 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 03:53:16 +00:00
Zachary Turner
ec842a3379 [llvm-pdbdump] Dump stream summary list.
Try to figure out what each stream is, and dump its name.

This gives us a better picture of what streams we still don't
understand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270653 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 03:43:17 +00:00
Zachary Turner
8d473c65c9 [codeview] Add support for new types and symbols.
This patch adds support for:

S_EXPORT
LF_BITFIELD

With this patch, I have run through a couple of gigabytes of PDB
files and cannot find a type or symbol that we do not understand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 00:12:48 +00:00
Zachary Turner
a02a9cb46b [codeview] Add support for S_EXPORT symbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270636 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 00:12:40 +00:00
Zachary Turner
2d4f33a508 [codeview] Add support for new type records.
This adds support for parsing and dumping the following
symbol types:

S_LPROCREF
S_ENVBLOCK
S_COMPILE2
S_REGISTER
S_COFFGROUP
S_SECTION
S_THUNK32
S_TRAMPOLINE

As of this patch, the test PDB files no longer have any unknown
symbol types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270628 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 22:58:46 +00:00
Zachary Turner
45ab259f8d [llvm-pdbdump] Rework command line options.
When dumping huge PDB files, too many of the options were grouped
together so you would get neverending spew of output.  This patch
introduces more granular display options so you can only dump the
fields you actually care about.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270607 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:31:48 +00:00
Peter Collingbourne
84e27c2068 Add FIXMEs to all derived classes of std::error_category.
This helps make clear that we're moving away from std::error_code.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:13:46 +00:00
Zachary Turner
653eb429f5 [codeview, pdb] Dump symbol records in publics stream
Differential Revision: http://reviews.llvm.org/D20580
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270597 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 18:55:14 +00:00
Zachary Turner
7f50c3125c Fix build errors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 17:44:29 +00:00
Zachary Turner
fe03e32b28 Dump symbol record details in llvm-pdbdump
This makes use of the newly introduced `CVSymbolVisitor` to dump details
of each type of symbol record in the symbol streams.  Future patches will
bring this visitor based dumping to the publics stream, as well as
creating a `SymbolDumpDelegate` to print more information about
relocations etc.

Differential Revision: http://reviews.llvm.org/D20545
Reviewed By: ruiu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 17:30:25 +00:00
George Rimar
5ad80b222a Recommit r270547 ([llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.)
Fix was:
1) Had to regenerate dwarfdump-test-zlib.elf-x86-64, dwarfdump-test-zlib-gnu.elf-x86-64
(because llvm-symbolizer-zlib.test uses that inputs for its purposes and failed).
2) Updated llvm-symbolizer-zlib.test (updated used call function address to match new files + 
added one more check for newly created dwarfdump-test-zlib-gnu.elf-x86-64 binary input).
3) Updated comment in dwarfdump-test-zlib.cc.

Original commit message:
[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.

Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270557 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 12:48:46 +00:00
George Rimar
fd3faf4011 Revert r270543 ("Recommit r270540")
Failed build bot in another test.
I am sorry for noise.
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/23679/testReport/junit/LLVM/DebugInfo/llvm_symbolizer_zlib_test/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 11:03:10 +00:00
George Rimar
6795981199 Recommit r270540
fix: forgot to commit the updated dwarfdump-test-zlib.elf-x86-64

Original commit message:
[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.

Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270543 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 10:46:43 +00:00
George Rimar
c19728fa10 Revert r270540 "[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style."
it broked bot:
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/5036


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270541 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 09:44:44 +00:00
George Rimar
dba28a8d42 [llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.
Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270540 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 09:28:36 +00:00
Zachary Turner
2defe22bf3 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270516 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 00:06:04 +00:00
Zachary Turner
24466fcd2c Make a symbol visitor and use it to dump CV symbols.
Differential Revision: http://reviews.llvm.org/D20534
Reviewed By: rnk

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 23:41:13 +00:00
Rui Ueyama
73dfdb31f6 Fix struct member names and simplify. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270289 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 22:59:05 +00:00
Rui Ueyama
59427f6dc7 pdbdump: print out symbol names referred by publics stream.
DBI stream contains a stream number of the symbol record stream.
Symbol record streams is an array of length-type-value members.
Each member represents one symbol.

Publics stream contains offsets to the symbol record stream.
This patch is to print out all symbols that are referenced by
the publics stream.

Note that even with this patch, llvm-pdbdump cannot dump all the
information in a publics stream since it contains more information
than symbol names. I'll improve it in followup patches.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270262 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 19:55:17 +00:00
Reid Kleckner
dadccffa36 Fix -Wmicrosoft-enum-value warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270110 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:20:22 +00:00
Rui Ueyama
cc76d42fd3 pdbdump: Rename NumberOfSymbols -> SymbolRecordStreamIndex.
Differential Revision: http://reviews.llvm.org/D20441

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270088 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 18:05:58 +00:00
Rui Ueyama
17e3d064b5 pdbdump: Print out section offsets in the publics stream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 16:24:16 +00:00
Daniel Sanders
8d706cc7df Try again to fix pdbdump-headers.test on big-endian hosts after r269861.
r269898 fixed the problem with HashBuckets but the same issue occurred with
AddressMap and ThunkMap too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269913 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 12:36:25 +00:00
Daniel Sanders
adcd739c2e Attempt to fix pdbdump-headers.test on big-endian hosts after r269861.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269898 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 09:59:14 +00:00
Rui Ueyama
dce33b5457 pdbdump: Print out more strcutures.
I don't yet fully understand the meaning of these data strcutures,
but at least it seems that their sizes and types are correct.
With this change, we can read publics streams till end.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269861 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:07:48 +00:00
Reid Kleckner
87749e8b5d [codeview] Test serialization of all known type records
This just checks that we emit all type records once, and then after
merging the type stream with no other type streams, we still emit every
kind of type record.

We could test the dumper output more closely, but that would make the
test very brittle. Currently we're just getting coverage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 16:20:35 +00:00
Benjamin Kramer
95ce0c789b Move helper classes into anonymous namespaces. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269591 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-15 15:18:11 +00:00
Reid Kleckner
fed38e2afb [codeview] Add type stream merging prototype
Summary:
This code is intended to be used as part of LLD's PDB writing. Until
that exists, this is exposed via llvm-readobj for testing purposes.

Type stream merging uses the following algorithm:

- Begin with a new empty stream, and a new empty hash table that maps
  from type record contents to new type index.
- For each new type stream, maintain a map from source type index to
  destination type index.
- For each record, copy it and rewrite its type indices to be valid in
  the destination type stream.
- If the new type record is not already present in the destination
  stream hash table, append it to the destination type stream, assign it
  the next type index, and update the two hash tables.
- If the type record already exists in the destination stream, discard
  it and update the type index map to forward the source type index to
  the existing destination type index.

Reviewers: zturner, ruiu

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269521 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-14 00:02:53 +00:00
Rui Ueyama
2acb5f6a3a pdbdump: Print "Publics" stream.
Publics stream seems to contain information as to public symbols.
It actually contains a serialized hash table along with fixed-sized
headers. This patch is not complete. It scans only till the end of
the stream and dump the header information. I'll write code to
de-serialize the hash table later.

Reviewers: zturner

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269484 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 21:21:53 +00:00
Reid Kleckner
ef598a795b [codeview] Align class and print names of types
Summary: This way we can get rid of one of the fields in the .def file.

Reviewers: llvm-commits

Subscribers: zturner

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269461 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 19:37:07 +00:00