1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

578 Commits

Author SHA1 Message Date
Rui Ueyama
4c5f6e88b8 Remove a patch .rej file.
llvm-svn: 272171
2016-06-08 16:54:31 +00:00
Zachary Turner
7ea60be185 [pdb] Try to fix use after free.
llvm-svn: 272078
2016-06-08 00:25:08 +00:00
Rui Ueyama
86f9105aef [pdbdump] Print out # of hash buckets.
In the reference code, the field name is `cHashBuckets`.

llvm-svn: 272075
2016-06-07 23:53:43 +00:00
Rui Ueyama
74a7524959 [pdbdump] Print out TPI hash key size.
llvm-svn: 272073
2016-06-07 23:44:27 +00:00
Zachary Turner
d4ca019632 [pdb] Convert StringRefs to ArrayRef<uint8_t>s.
llvm-svn: 272058
2016-06-07 20:38:37 +00:00
Zachary Turner
1431c0d45e [pdb] Fix a potential overflow and remove unnecessary comments.
llvm-svn: 272043
2016-06-07 18:42:39 +00:00
Zachary Turner
df1bab5ad7 [pdb] Use MappedBlockStream to parse the PDB directory.
In order to efficiently write PDBs, we need to be able to make a
StreamWriter class similar to a StreamReader, which can transparently deal
with writing to discontiguous streams, and we need to use this for all
writing, similar to how we use StreamReader for all reading.

Most discontiguous streams are the typical numbered streams that appear in
a PDB file and are described by the directory, but the exception to this,
that until now has been parsed by hand, is the directory itself.
MappedBlockStream works by querying the directory to find out which blocks
a stream occupies and various other things, so naturally the same logic
could not possibly work to describe the blocks that the directory itself
resided on.

To solve this, I've introduced an abstraction IPDBStreamData, which allows
the client to query for the list of blocks occupied by the stream, as well
as the stream length. I provide two implementations of this: one which
queries the directory (for indexed streams), and one which queries the
super block (for the directory stream).

This has the side benefit of vastly simplifying the code to parse the
directory. Whereas before a mini state machine was rolled by hand, now we
simply use FixedStreamArray to read out the stream sizes, then build a
vector of FixedStreamArrays for the stream map, all in just a few lines of
code.

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

llvm-svn: 271982
2016-06-07 05:28:55 +00:00
Rui Ueyama
316237a8e0 Add comments.
llvm-svn: 271967
2016-06-07 00:59:04 +00:00
Reid Kleckner
1005b89a03 Try one more time to pacify -Wpessimizing-move, MSVC, libstdc++4.7, and the world without a named variable
llvm-svn: 271964
2016-06-06 23:46:14 +00:00
Reid Kleckner
236d68ce0f Attempt to work around lack of std::map::emplace in libstdc++4.7
llvm-svn: 271958
2016-06-06 23:28:03 +00:00
Rui Ueyama
f72bd6fe60 [pdbdump] Verify the size of TPI hash records.
llvm-svn: 271954
2016-06-06 23:19:23 +00:00
Rui Ueyama
a65263357a [pdbdump] Print out New FPO stream contents.
The data strucutre in the new FPO stream is described in the
PE/COFF spec. There is one record per function if frame pointer
is omitted.

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

llvm-svn: 271926
2016-06-06 18:39:21 +00:00
David Majnemer
6972cf3620 [DebugInfo, PDB] Use sparse bitfields for the name map
The name map might not be densely packed on disk.  Using a sparse map
will save memory in such situations.

llvm-svn: 271811
2016-06-04 22:47:39 +00:00
David Majnemer
08e81eef3f [CodeView] Fix a busted assert in TypeTableBuilder::writeClass
It was checking for Union when it should have checked for Interface.

llvm-svn: 271792
2016-06-04 15:40:31 +00:00
David Majnemer
3e22310a07 [TypeStreamMerger] visitUnknownMember was supposed to be visitUnknownType
llvm-svn: 271790
2016-06-04 15:40:27 +00:00
Rui Ueyama
05c45592e0 pdbdump: print out TPI hashes.
Differential Revision: http://reviews.llvm.org/D20945

llvm-svn: 271736
2016-06-03 20:48:51 +00:00
Reid Kleckner
169346bb55 Fix non-Windows build when inserting a move only type into a map
llvm-svn: 271727
2016-06-03 20:29:51 +00:00
Reid Kleckner
eb745c2e9c [Symbolize] Check if the PE file has a PDB and emit an error if we can't load it
Summary:
Previously we would try to load PDBs for every PE executable we tried to
symbolize. If that failed, we would fall back to DWARF. If there wasn't
any DWARF, we'd print mostly useless symbol information using the export
table.

With this change, we only try to load PDBs for executables that claim to
have them. If that fails, we can now print an error rather than falling
back silently. This should make it a lot easier to diagnose and fix
common symbolization issues, such as not having DIA or not having a PDB.

Reviewers: zturner, eugenis

Subscribers: llvm-commits

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

llvm-svn: 271725
2016-06-03 20:25:09 +00:00
Reid Kleckner
14799a2f9b [codeview] Add basic record type translation
This only translates data members for now. Translating overloaded
methods is complicated, so I stopped short of doing that.

Reviewers: aaboud

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

llvm-svn: 271680
2016-06-03 15:58:20 +00:00
Zachary Turner
eace145381 [pdb] Print out file names instead of file offsets.
When printing line information and file checksums, we were printing
the file offset field from the struct header.  This teaches
llvm-pdbdump how to turn those numbers into the filename.  In the
case of file checksums, this is done by looking in the global
string table.  In the case of line contributions, this is done
by indexing into the file names buffer of the DBI stream.  Why
they use a different technique I don't know.

llvm-svn: 271630
2016-06-03 05:52:57 +00:00
Zachary Turner
6fb9f9896d [pdb] Dump file checksums from pdb codeview line info.
llvm-svn: 271622
2016-06-03 04:01:48 +00:00
Zachary Turner
9277831e4a [codeview] Dump line number and column information.
To facilitate this, a couple of changes had to be made:

1. `ModuleSubstream` got moved from `DebugInfo/PDB` to
`DebugInfo/CodeView`, and various codeview related types are defined
there.  It turns out `DebugInfo/CodeView/Line.h` already defines many of
these structures, but this is really old code that is not endian aware,
doesn't interact well with `StreamInterface` and not very helpful for
getting stuff out of a PDB.  Eventually we should migrate the old readobj
`COFFDumper` code to these new structures, or at least merge their
functionality somehow.

2. A `ModuleSubstream` visitor is introduced.  Depending on where your
module substream array comes from, different subsets of record types can
be expected.  We are already hand parsing these substream arrays in many
places especially in `COFFDumper.cpp`.  In the future we can migrate these
paths to the visitor as well, which should reduce a lot of code in
`COFFDumper.cpp`.

Differential Revision: http://reviews.llvm.org/D20936
Reviewed By: ruiu, majnemer

llvm-svn: 271621
2016-06-03 03:25:59 +00:00
Rui Ueyama
984cef3e31 Add comments.
llvm-svn: 271597
2016-06-02 21:13:47 +00:00
Zachary Turner
8fad65b692 [llvm-pdbdump] Dump CodeView line information.
This first pass only splits apart the records and dumps the line
info kinds and binary data.  Subsequent patches will parse out
the binary data into more useful information and dump it in
detail.

llvm-svn: 271576
2016-06-02 20:11:22 +00:00
Zachary Turner
d356ecd7d3 [codeview] Fix a nasty use after free.
StreamRef was designed to be a thin wrapper over an abstract
stream interface that could itself be treated the same as any
other stream interface.  For this reason, it inherited publicly
from StreamInterface, and stored a StreamInterface* internally.

But StreamRef was also designed to be lightweight and easily
copyable, similar to ArrayRef.  This led to two misuses of
the classes.

1) When creating a StreamRef A from another StreamRef B, it was
   possible to end up with A storing a pointer to B, even when
   B was a temporary object, leading to use after free.
2) The above situation could be repeated ad nauseum, so that
   A stores a pointer to B, which itself stores a pointer to
   another StreamRef C, and so on and so on, creating an
   unnecessarily level of nesting depth.

This patch removes the public inheritance relationship between
StreamRef and StreamInterface, making it so that we can never
accidentally convert a StreamRef to a StreamInterface.

llvm-svn: 271570
2016-06-02 19:51:48 +00:00
David Majnemer
7085a0544f [CodeView] Use None instead of Void if there is no subprogram
llvm-svn: 271566
2016-06-02 18:51:24 +00:00
Rui Ueyama
7cec8d0bf2 pdbdump: print out COFF section headers.
Unlike other sections that can grow to any size, the COFF section header
stream has maximum length because each record is fixed size and the COFF
file format limits the maximum number of sections. So I decided to not
create a specific stream class for it. Instead, I added a member function
to DbiStream class which returns a vector of COFF headers.

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

llvm-svn: 271557
2016-06-02 18:20:20 +00:00
Zachary Turner
cc571053da [pdb] Parse and dump section map and section contribs
Differential Revision: http://reviews.llvm.org/D20876
Reviewed By: rnk, ruiu

llvm-svn: 271488
2016-06-02 05:07:49 +00:00
David Majnemer
73419abbaa [PDB] Make ModStream::symbols report errors
llvm-svn: 271417
2016-06-01 18:13:04 +00:00
Zachary Turner
3c1133f753 [pdb] Add unit tests for PDB MappedBlockStream and zero copy
Differential Revision: http://reviews.llvm.org/D20837
Reviewed By: ruiu

llvm-svn: 271346
2016-05-31 22:41:52 +00:00
Kevin Enderby
945617b128 Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is from a slice of a Mach-O Universal Binary use something like
"foo.o (for architecture i386)" as part of the error message when expected.

Also fixed places in these tools that were ignoring object file errors from
MachOUniversalBinary::getAsObjectFile() when the code moved on to see if
the slice was an archive.

To do this MachOUniversalBinary::getAsObjectFile() and
MachOUniversalBinary::getObjectForArch() were changed from returning
ErrorOr<...> to Expected<...> then that was threaded up to its users.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in two places yet to be fully converted.

llvm-svn: 271332
2016-05-31 20:35:34 +00:00
Reid Kleckner
05a06ad643 [codeview] Improve readability of type record assembly
Adds the method MCStreamer::EmitBinaryData, which is usually an alias
for EmitBytes. In the MCAsmStreamer case, it is overridden to emit hex
dump output like this:
        .byte   0x0e, 0x00, 0x08, 0x10
        .byte   0x03, 0x00, 0x00, 0x00
        .byte   0x00, 0x00, 0x00, 0x00
        .byte   0x00, 0x10, 0x00, 0x00

Also, when verbose asm comments are enabled, this patch prints the dump
output for each comment before its record, like this:
        # ArgList (0x1000) {
        #   TypeLeafKind: LF_ARGLIST (0x1201)
        #   NumArgs: 0
        #   Arguments [
        #   ]
        # }
        .byte   0x06, 0x00, 0x01, 0x12
        .byte   0x00, 0x00, 0x00, 0x00

This should make debugging easier and testing more convenient.

Reviewers: aaboud

Subscribers: majnemer, zturner, amccarth, aaboud, llvm-commits

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

llvm-svn: 271313
2016-05-31 18:45:36 +00:00
Reid Kleckner
0021f4c0e0 [codeview] Add a CVTypeDumper::dump(ArrayRef<uint8_t>) overload
This is a convenient wrapper when the type record is already laid out as
bytes in memory.

llvm-svn: 271309
2016-05-31 18:15:23 +00:00
David Majnemer
6d741ef1bb Make sure we don't add an empty string to the stringmap
llvm-svn: 271172
2016-05-29 06:18:06 +00:00
David Majnemer
40cf622629 [SymbolDumper] Validate the string table offset before using it
llvm-svn: 271145
2016-05-28 20:04:46 +00:00
David Majnemer
c990a21322 [SymbolDumper] Validate the string table offset before using it
llvm-svn: 271142
2016-05-28 19:45:56 +00:00
David Majnemer
b55ee75c35 Tighten some of the name map checks further
llvm-svn: 271130
2016-05-28 18:03:37 +00:00
David Majnemer
f902db6562 Bounds check the number of bitmap blocks in the name map
llvm-svn: 271105
2016-05-28 05:59:25 +00:00
David Majnemer
de2f8d9120 Make sure the directory contains info for all streams
llvm-svn: 271103
2016-05-28 05:59:19 +00:00
Zachary Turner
94e5255730 [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.

llvm-svn: 271101
2016-05-28 05:21:57 +00:00
David Majnemer
3c56b8ce44 Don't discard errors
llvm-svn: 271056
2016-05-27 22:07:50 +00:00
Zachary Turner
f560f82e38 [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.

llvm-svn: 271040
2016-05-27 20:17:33 +00:00
David Majnemer
517cb96201 Make sure data is available before dereferencing it
llvm-svn: 271032
2016-05-27 18:50:02 +00:00
Zachary Turner
0b5ee08758 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.

llvm-svn: 271027
2016-05-27 18:47:20 +00:00
Chad Rosier
bdab1e9a71 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"

llvm-svn: 271026
2016-05-27 18:31:02 +00:00
Zachary Turner
f7482c3f63 [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

llvm-svn: 271025
2016-05-27 18:20:20 +00:00
David Majnemer
28d34a556a Make sure these error codes are marked as checked
llvm-svn: 271013
2016-05-27 16:16:56 +00:00
David Majnemer
f4e1d5fc8d Make sure there are enough blocks for the stream
llvm-svn: 271012
2016-05-27 16:16:48 +00:00
David Majnemer
fc0e03c4b0 Make sure the directory block array fits in the file
llvm-svn: 271011
2016-05-27 16:16:45 +00:00
David Majnemer
f36149144f Validate the blocksize before using it
The blocksize could be zero on disk causing later checks to divide by
zero.

llvm-svn: 271008
2016-05-27 15:57:38 +00:00