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

625 Commits

Author SHA1 Message Date
Rui Ueyama
eb8764db35 Re-enable TPI hash verification for enum records.
We didn't read unique names correctly. As a result, we computed
hashes on (non-)unique names instead of unique names.

llvm-svn: 275150
2016-07-12 03:25:03 +00:00
Zachary Turner
63d4db3b0c Refactor the PDB writing to use a builder approach
llvm-svn: 275110
2016-07-11 21:45:26 +00:00
Benjamin Kramer
46f0905ce0 Give helper classes/functions internal linkage. NFC.
llvm-svn: 275014
2016-07-10 11:28:51 +00:00
David Majnemer
c6b6fb41da [pdb] Sanity check the stream map
Some abstractions in LLVM "know" that they are reading in-bounds,
FixedStreamArray, and provide a simple result.  This breaks down if the
stream map is bogus.

llvm-svn: 275010
2016-07-10 05:32:05 +00:00
David Majnemer
634a992c4e [llvm-pdbdump] Propagate errors a little more consistently
PDBFile::getBlockData didn't really return any indication that it
failed.  It merely returned an empty buffer.

llvm-svn: 275009
2016-07-10 03:34:47 +00:00
David Majnemer
6e3fb51f95 [CodeView] Emit an appropriate symbol kind for globals
We emitted debug info for globals/functions as if they all had external
linkage.  Instead, emit local symbol records when appropriate.

llvm-svn: 274676
2016-07-06 21:07:47 +00:00
Zachary Turner
171fbbc871 [pdb] Round trip the PDB stream between YAML and binary PDB.
This gets writing of the PDB stream working.

llvm-svn: 274647
2016-07-06 18:05:57 +00:00
Zachary Turner
47ebb3cc6f Disable hash verification of enums.
llvm-svn: 274639
2016-07-06 17:25:12 +00:00
Reid Kleckner
fa3de4eab5 Prune RelocVisitor.h include to avoid including COFF.h from MCJIT.h
This helps to mitigate the conflict between COFF.h and winnt.h, which is
PR28399.

llvm-svn: 274637
2016-07-06 16:56:42 +00:00
Reid Kleckner
c2f9ee812a [pdb] Check the display name for <unnamed-tag>, not the linkage name
This issue was encountered on libcmt.pdb, which has a type record that
looks like this:

  Struct (0x1094) {
    TypeLeafKind: LF_STRUCTURE (0x1505)
    MemberCount: 3
    Properties [ (0x200)
      HasUniqueName (0x200)
    ]
    FieldList: <field list> (0x1093)
    DerivedFrom: 0x0
    VShape: 0x0
    SizeOf: 4
    Name: <unnamed-tag>
    LinkageName: .?AU<unnamed-tag>@@
  }

The checks for startswith/endswith "<unnamed-tag>" should look at the
display name, not the linkage name.

llvm-svn: 274376
2016-07-01 18:43:29 +00:00
Reid Kleckner
1e8c103f99 [pdb] Avoid reporting an error when the module symbol stream is empty
llvm-svn: 274309
2016-07-01 00:37:49 +00:00
Reid Kleckner
a8e16f1432 [PDB] Indicate which type record failed hash validation
llvm-svn: 274308
2016-07-01 00:37:25 +00:00
Zachary Turner
05b0d33b0c [pdb] Re-add code to write PDB files.
Somehow all the functionality to write PDB files got removed,
probably accidentally when uploading the patch perhaps the wrong
one got uploaded.  This re-adds all the code, as well as the
corresponding test.

llvm-svn: 274248
2016-06-30 17:43:00 +00:00
David Majnemer
2bb75b48c6 [CodeView] Healthy paranoia around strings
Make sure strings don't get too big for a record, truncate them if
need-be.

llvm-svn: 273710
2016-06-24 19:34:41 +00:00
Kevin Enderby
413f7c6823 Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to allow
a good error message to be produced.

This is nearly the last libObject interface that used ErrorOr and the last one
that appears in llvm/include/llvm/Object/MachO.h .  For Mach-O objects this is
just a clean up because it’s version of getSymbolAddress() can’t return an
error.

I will leave it to the experts on COFF and ELF to actually add meaning full
error messages in their tests if they wish.  And also leave it to these experts
to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h
for createCOFFObjectFile() and createELFObjectFile() if they wish.

Since there are no test cases for COFF and ELF error cases with respect to
getSymbolAddress() in the test suite this is no functional change (NFC).

llvm-svn: 273701
2016-06-24 18:24:42 +00:00
Reid Kleckner
e8d9ec6b43 [codeview] Use one byte for S_FRAMECOOKIE CookieKind and add flags byte
We bailed out while printing codeview for an MSVC compiled
SemaExprCXX.cpp that used this record. The MS reference headers look
incorrect here, which is probably why we had this bug. They use a 32-bit
enum as the field type, but the actual record appears to use one byte
for the cookie kind followed by a flags byte.

llvm-svn: 273691
2016-06-24 17:23:49 +00:00
Reid Kleckner
90797dd1c4 [pdb] Treat a stream size of ~0U as 0
My PDBs always have this size for stream 11. Not sure why.

llvm-svn: 273504
2016-06-22 22:42:24 +00:00
Reid Kleckner
dcb890e1f1 [codeview] Fix the alignment padding that we add to list records
Tweak the big-types.ll test case to catch this bug. We just need an
enumerator name that doesn't have a length that is a multiple of 4.

llvm-svn: 273477
2016-06-22 20:59:17 +00:00
Reid Kleckner
805d357d67 [codeview] Add support for splitting field list records over 64KB
The basic structure is that once a list record goes over 64K, the last
subrecord of the list is an LF_INDEX record that refers to the next
record. Because the type record graph must be toplogically sorted, this
means we have to emit them in reverse order. We build the type record in
order of declaration, so this means that if we don't want extra copies,
we need to detect when we were about to split a record, and leave space
for a continuation subrecord that will point to the eventual split
top-level record.

Also adds dumping support for these records.

Next we should make sure that large method overload lists work properly.

llvm-svn: 273294
2016-06-21 18:33:01 +00:00
Rui Ueyama
a3f4dc8da4 [codeview] Add an extra check for TPI hash values.
This patch adds a function that corresponds to `fUDTAnon`
and use that to compute TPI hash values as the reference does.

llvm-svn: 273139
2016-06-20 07:31:29 +00:00
Reid Kleckner
62af8c4725 [codeview] Add DIFlags for pointer to member representations
Summary:
This seems like the least intrusive way to pass this information
through.

Fixes PR28151

Reviewers: majnemer, aprantl, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 273053
2016-06-17 21:31:33 +00:00
Reid Kleckner
d57cbe6487 [pdb] Don't error on missing FPO streams
64-bit PDBs never have FPO data. They have xdata instead.

Also improve error recovery of stream summary dumping while I'm here.

llvm-svn: 273046
2016-06-17 20:38:01 +00:00
Rui Ueyama
bcad6dcecd [codeview] Use hashBufferV8 to verify all type records.
Differential Revision: http://reviews.llvm.org/D21393

llvm-svn: 272930
2016-06-16 18:39:17 +00:00
Zachary Turner
b871327aa8 Resubmit "[pdb] Change type visitor pattern to be dynamic."
There was a regression introduced during type stream merging when
visiting a field list record.  This has been fixed in this patch.

llvm-svn: 272929
2016-06-16 18:22:27 +00:00
Zachary Turner
9dbc164c30 Revert "[pdb] Change type visitor pattern to be dynamic."
This reverts commit fb0dd311e1ad945827b8ffd5354f4810e2be1579.

This breaks some llvm-readobj tests.

llvm-svn: 272927
2016-06-16 18:09:04 +00:00
Zachary Turner
9300409ecf [pdb] Change type visitor pattern to be dynamic.
This allows better catching of compiler errors since we can use
the override keyword to verify that methods are actually
overridden.

Also in this patch I've changed from storing a boolean Error
code everywhere to returning an llvm::Error, to propagate richer
error information up the call stack.

Reviewed By: ruiu, rnk
Differential Revision: http://reviews.llvm.org/D21410

llvm-svn: 272926
2016-06-16 18:00:28 +00:00
Rui Ueyama
f7a0e93409 [codeview] Pass CVRecord to visitTypeBegin callback.
Both parameters to visitTypeBegin are actually members of CVRecord,
so we can just pass CVRecord instead of destructuring it.

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

llvm-svn: 272899
2016-06-16 14:47:23 +00:00
Rui Ueyama
1b33098d46 [codeview] Remove unused parameter.
Differential Revision: http://reviews.llvm.org/D21433

llvm-svn: 272898
2016-06-16 14:41:22 +00:00
Rui Ueyama
c81d309c64 Implement pdb::hashBufferV8 hash function.
llvm-svn: 272894
2016-06-16 13:48:16 +00:00
Rui Ueyama
bbf440e960 Remove redundant namespace specifiers.
llvm-svn: 272889
2016-06-16 13:17:59 +00:00
Rui Ueyama
78bcf12047 [codeview] Use CVTypeVisitor instead of a hand-written switch-cases.
Differential Revision: http://reviews.llvm.org/D21418

llvm-svn: 272888
2016-06-16 13:14:42 +00:00
Rui Ueyama
44f2539d12 [Codeview] Add a class for LF_UDT_MOD_SRC_LINE.
Differential Revision: http://reviews.llvm.org/D21406

llvm-svn: 272843
2016-06-15 21:25:29 +00:00
Reid Kleckner
e8b7172caa Axe some trailing whitespace from my last commit
llvm-svn: 272830
2016-06-15 20:32:42 +00:00
Reid Kleckner
2eba5b5cb6 [codeview] Move deserialization methods out of line
They aren't performance critical and don't need to be inline.

llvm-svn: 272829
2016-06-15 20:30:34 +00:00
Rui Ueyama
f759b9b9ad [pdbdump] Verify LF_{CLASS,ENUM,INTERFACE,STRUCTURE,UNION} records.
Differential Revision: http://reviews.llvm.org/D21361

llvm-svn: 272815
2016-06-15 18:26:59 +00:00
Rui Ueyama
8ec43ee7c2 [pdbdump] Verify TPI hash for LF_ENUM type records.
llvm-svn: 272728
2016-06-14 22:25:07 +00:00
Zachary Turner
ebef1e3fab Resubmit "[pdb] Actually write a PDB to disk from YAML.""
Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21220

llvm-svn: 272708
2016-06-14 20:48:36 +00:00
Zachary Turner
d084f1683f Revert "[pdb] Actually write a PDB to disk from YAML."
This reverts commit 879139e1c6577b09df52de56a6bab856a19ed185.

This was committed accidentally when I blindly typed git svn
dcommit instead of the command to generate a patch.

llvm-svn: 272693
2016-06-14 18:51:35 +00:00
Zachary Turner
9646f68e1a [pdb] Actually write a PDB to disk from YAML.
llvm-svn: 272692
2016-06-14 18:49:36 +00:00
Zachary Turner
d2ab2f7431 [pdb] Fix issues with pdb writing.
This fixes an alignment issue by forcing all cached allocations
to be 8 byte aligned, and also fixes an issue arising on big
endian systems by writing ulittle32_t's instead of uint32_t's
in the test.

llvm-svn: 272437
2016-06-10 21:47:26 +00:00
Zachary Turner
ff9c91b5ca Make PDBFile take a StreamInterface instead of a MemBuffer.
This is the next step towards being able to write PDBs.
MemoryBuffer is immutable, and StreamInterface is our replacement
which can be any combination of read-only, read-write, or write-only
depending on the particular implementation.

The one place where we were creating a PDBFile (in RawSession) is
updated to subclass ByteStream with a simple adapter that holds
a MemoryBuffer, and initializes the superclass with the buffer's
array, so that all the functionality of ByteStream works
transparently.

llvm-svn: 272370
2016-06-10 05:10:19 +00:00
Zachary Turner
8110e5a8a3 Add support for writing through StreamInterface.
This adds method and tests for writing to a PDB stream.  With
this, even a PDB stream which is discontiguous can be treated
as a sequential stream of bytes for the purposes of writing.

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

llvm-svn: 272369
2016-06-10 05:09:12 +00:00
Rui Ueyama
ddd97c558f [pdbdump] Verify part of TPI hash streams.
TPI hash table contains a parallel array for the type records.
For each type record R, a hash value is calculated by `H(R) % NumBuckets`
where H is a hash function, and the result is stored to a bucket element.
H is TPI1::hashPrec function in microsoft-pdb repository.

Our hash function does not support all type record types yet.
Currently it supports only records for line number.
I'll extend it in a follow up patch.

The aim of verify the hash table is not only detect corrupted files.
It ensures that our understanding of how the hash values are calculated
is correct.

llvm-svn: 272229
2016-06-09 00:10:19 +00:00
Rui Ueyama
a11c98620e Function names should start with lowercase letters.
llvm-svn: 272225
2016-06-08 23:15:09 +00:00
Rui Ueyama
c4f19f8773 [PDB] Move PDB functions to a separate file.
We are going to use the hash functions from TPI streams.

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

llvm-svn: 272223
2016-06-08 23:11:14 +00:00
Benjamin Kramer
d415569b3b Apply most suggestions of clang-tidy's performance-unnecessary-value-param
Avoids unnecessary copies. All changes audited & pass tests with asan.
No functional change intended.

llvm-svn: 272190
2016-06-08 19:09:22 +00:00
Zachary Turner
2e9c19aed4 [pdb] Handle stream index errors better.
Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21128

llvm-svn: 272172
2016-06-08 17:26:39 +00:00
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