644 Commits

Author SHA1 Message Date
Zachary Turner
85c3e3ee9c Revert "[msf] Rename Msf to MSF."
This reverts commit 4d1557ffac41e079bcb1abbcf04f512474dcd6fe.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277194 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 18:38:47 +00:00
Zachary Turner
4d1557ffac [msf] Rename Msf to MSF.
In a previous patch, it was suggested to use all caps instead of
rolling caps for initialisms, so this patch changes everything
to do this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277190 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 18:24:26 +00:00
Zachary Turner
1749ba17c6 [pdb] Fix an ambiguity when writing size_t on x64 platforms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 19:29:52 +00:00
Zachary Turner
a5c0a1402c [pdb] Fix some warnings that break -Werror builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277021 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 19:18:02 +00:00
Zachary Turner
0c7a213a73 [pdb] Refactor library to more clearly separate reading/writing
Reviewed By: amccarth, ruiu
Differential Revision: https://reviews.llvm.org/D22693

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277019 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 19:12:28 +00:00
Zachary Turner
0c78d1d159 Get rid of IMsfStreamData class.
This was a pure virtual base class whose purpose was to abstract
away the notion of how you retrieve the layout of a discontiguous
stream of blocks in an Msf file.  This led to too many layers of
abstraction making it difficult to figure out what was going on
and extend things.  Ultimately, a stream's layout is decided by
its length and the array of block numbers that it lives on.  So
rather than have an abstract base class which can return this in
any number of ways, it's more straightforward to simply store them
as fields of a trivial struct, and also to give a more appropriate
name.

This patch does that.  It renames IMsfStreamData to MsfStreamLayout,
and deletes the 2 concrete implementations, DirectoryStreamData
and IndexedStreamData.  MsfStreamLayout is a trivial struct
with the necessary data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277018 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 19:11:09 +00:00
Vassil Vassilev
2b43353cb2 [modules] Add missing includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 10:26:33 +00:00
Zachary Turner
428d4aa99f Make PDBFile store an msf::Layout.
Previously it was storing all the fields of an msf::Layout as
separate members.  This is a trivial cleanup to make it store
an msf::Layout directly.  This makes the code more readable
since it becomes clear which fields of PDBFile are actually the
msf specific layout information in a sea of other bookkeeping
fields.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:33 +00:00
Zachary Turner
9a3129ad49 [pdb] Have builders share a single BumpPtrAllocator.
This makes it easier to have the writable and readable PDB
interfaces share code since the read/write and write-only
interfaces now share a single allocator, you don't have to worry
about a builder building a read only interface and then having
the read-only interface's data become corrupt when the builder
goes out of scope.  Now the allocator is specified explicitly
to all constructors, so all interfaces can share a single allocator
that is scoped appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:26 +00:00
Zachary Turner
4ab13f5ec5 [msf] Create LLVMDebugInfoMsf
This provides a better layering of responsibilities among different
aspects of PDB writing code.  Some of the MSF related code was
contained in CodeView, and some was in PDB prior to this.  Further,
we were often saying PDB when we meant MSF, and the two are
actually independent of each other since in theory you can have
other types of data besides PDB data in an MSF.  So, this patch
separates the MSF specific code into its own library, with no
dependencies on anything else, and DebugInfoCodeView and
DebugInfoPDB take dependencies on DebugInfoMsf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:05 +00:00
Zachary Turner
44bd3bd7dc [pdb] Move file layout header structs to RawTypes.h
This facilitates code reuse between the builder classes and the
"frozen" read only versions of the classes used for parsing
existing PDB files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276427 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 15:46:46 +00:00
Zachary Turner
6406b60a78 [pdb] Round-trip module & file info to/from YAML.
This implements support for writing compiland and compiland source
file info to a binary PDB.  This is tested by adding support for
dumping these fields from an existing PDB to yaml, reading them
back in, and dumping them again and verifying the values are as
expected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276426 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 15:46:37 +00:00
Pete Cooper
59023bf389 Avoid dsymutil calls to getFileNameByIndex.
This change adds a hasFileAtIndex method. getChildDeclContext can first call this method, and if it returns true it knows it can then lookup the resolved path cache for the given file index. If we hit that cache then we don't even have to call getFileNameByIndex.

Running dsymutil against the swift executable built from github gives a 20% performance improvement without any change in the binary.

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

Reviewed by friss.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276380 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 01:41:32 +00:00
Zachary Turner
9b30e73d48 [pdb] Teach MsfBuilder and other classes about the Free Page Map.
Block 1 and 2 of an MSF file are bit vectors that represent the
list of blocks allocated and free in the file.  We had been using
these blocks to write stream data and other data, so we mark them
as the free page map now.  We don't yet serialize these pages to
the disk, but at least we make a note of what it is, and avoid
writing random data to them.

Doing this also necessitated cleaning up some of the tests to be
more general and hardcode fewer values, which is nice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275629 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:17:19 +00:00
Zachary Turner
93a8d14081 [pdb] Round trip the NameMap data structure to YAML.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275628 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:17:08 +00:00
Zachary Turner
6be3e7c0e8 [pdb] Use MsfBuilder to handle the writing PDBs.
Previously we would read a PDB, then write some of it back out,
but write the directory, super block, and other pertinent metadata
back out unchanged.  This generates incorrect PDBs since the amount
of data written was not always the same as the amount of data read.

This patch changes things to use the newly introduced `MsfBuilder`
class to write out a correct and accurate set of Msf metadata for
the data *actually* written, which opens up the door for adding and
removing type records, symbol records, and other types of data to
an existing PDB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275627 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:16:56 +00:00
Saleem Abdulrasool
db823e2f44 DebugInfo: reorder some initializers
Fix a few initialization ordering warnings from gcc from `-Wreorder`.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 21:10:31 +00:00
Zachary Turner
32cf292fd8 [pdb] Introduce MsfBuilder for laying out PDB files.
Reviewed by: ruiu
Differential Revision: https://reviews.llvm.org/D22308

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 20:43:38 +00:00
Rui Ueyama
f8df5fd2ac Dump enum unique names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275152 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-12 03:33:48 +00:00
Rui Ueyama
ce6dd1b341 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275150 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-12 03:25:03 +00:00
Zachary Turner
ae108ee909 Refactor the PDB writing to use a builder approach
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275110 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 21:45:26 +00:00
Benjamin Kramer
a27e16e477 Give helper classes/functions internal linkage. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275014 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 11:28:51 +00:00
David Majnemer
65dccf7884 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275010 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 05:32:05 +00:00
David Majnemer
7aa4746755 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275009 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 03:34:47 +00:00
David Majnemer
7bae2669d5 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274676 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 21:07:47 +00:00
Zachary Turner
8bf0aed731 [pdb] Round trip the PDB stream between YAML and binary PDB.
This gets writing of the PDB stream working.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 18:05:57 +00:00
Zachary Turner
3dfcaf659a Disable hash verification of enums.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274639 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 17:25:12 +00:00
Reid Kleckner
3fb0b9e151 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 16:56:42 +00:00
Reid Kleckner
ec8e96efb0 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274376 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 18:43:29 +00:00
Reid Kleckner
1199c8cbc8 [pdb] Avoid reporting an error when the module symbol stream is empty
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274309 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 00:37:49 +00:00
Reid Kleckner
5ec7ee3af8 [PDB] Indicate which type record failed hash validation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274308 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 00:37:25 +00:00
Zachary Turner
91d41f9825 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274248 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 17:43:00 +00:00
David Majnemer
82c356cae4 [CodeView] Healthy paranoia around strings
Make sure strings don't get too big for a record, truncate them if
need-be.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273710 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 19:34:41 +00:00
Kevin Enderby
317de7ce5b 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).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 18:24:42 +00:00
Reid Kleckner
b892430f09 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273691 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 17:23:49 +00:00
Reid Kleckner
e97bf81771 [pdb] Treat a stream size of ~0U as 0
My PDBs always have this size for stream 11. Not sure why.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273504 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 22:42:24 +00:00
Reid Kleckner
83b162c3b2 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273477 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 20:59:17 +00:00
Reid Kleckner
b6e8ad38b9 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 18:33:01 +00:00
Rui Ueyama
4a94acfea8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273139 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-20 07:31:29 +00:00
Reid Kleckner
a450edf8b9 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273053 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 21:31:33 +00:00
Reid Kleckner
7abe77ab98 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 20:38:01 +00:00
Rui Ueyama
6b7e0cc92c [codeview] Use hashBufferV8 to verify all type records.
Differential Revision: http://reviews.llvm.org/D21393

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272930 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:39:17 +00:00
Zachary Turner
e8d381d02c 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272929 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:22:27 +00:00
Zachary Turner
575a9fbcc9 Revert "[pdb] Change type visitor pattern to be dynamic."
This reverts commit fb0dd311e1ad945827b8ffd5354f4810e2be1579.

This breaks some llvm-readobj tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272927 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:09:04 +00:00
Zachary Turner
fb0dd311e1 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272926 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 18:00:28 +00:00
Rui Ueyama
43c7bd0b82 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272899 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 14:47:23 +00:00
Rui Ueyama
70154cb57e [codeview] Remove unused parameter.
Differential Revision: http://reviews.llvm.org/D21433

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272898 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 14:41:22 +00:00
Rui Ueyama
a3568c118e Implement pdb::hashBufferV8 hash function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272894 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 13:48:16 +00:00
Rui Ueyama
7d0c878650 Remove redundant namespace specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272889 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 13:17:59 +00:00
Rui Ueyama
1d884ca9ef [codeview] Use CVTypeVisitor instead of a hand-written switch-cases.
Differential Revision: http://reviews.llvm.org/D21418

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272888 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 13:14:42 +00:00