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

255 Commits

Author SHA1 Message Date
Benjamin Kramer
7db3ef45b9 Remove unnecessary copying or replace it with moves in a bunch of places.
NFC.

llvm-svn: 219061
2014-10-04 16:55:56 +00:00
Frederic Riss
fb02045355 Store TypeUnits in a SmallVector<DWARFUnitSection> instead of a single DWARFUnitSection.
There will be multiple TypeUnits in an unlinked object that will be extracted
from different sections. Now that we have DWARFUnitSection that is supposed
to represent an input section, we need a DWARFUnitSection<TypeUnit> per
input .debug_types section.

Once this is done, the interface is homogenous and we can move the Section
parsing code into DWARFUnitSection.

This is a respin of r218513 that got reverted because it broke some builders.
This new version features an explicit move constructor for the DWARFUnitSection
class to workaround compilers unable to generate correct C++11 default
constructors.

Reviewers: samsonov, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 218606
2014-09-29 13:56:39 +00:00
David Majnemer
d0678b9132 Object: BSS/virtual sections don't have contents
Users of getSectionContents shouldn't try to pass in BSS or virtual
sections.  In all instances, this is a bug in the code calling this
routine.

N.B. Some COFF implementations (like CL) will mark their BSS sections as
taking space on disk.  This would confuse COFFObjectFile into thinking
the section is larger than the file.

llvm-svn: 218549
2014-09-26 22:32:16 +00:00
Frederic Riss
2e26931cef Revert "Store TypeUnits in a SmallVector<DWARFUnitSection> instead of a single DWARFUnitSection."
This reverts commit r218513.

Buildbots using libstdc++ issue an error when trying to copy
SmallVector<std::unique_ptr<>>. Revert the commit until we have a fix.

llvm-svn: 218514
2014-09-26 12:34:06 +00:00
Frederic Riss
ea404b3a9c Store TypeUnits in a SmallVector<DWARFUnitSection> instead of a single DWARFUnitSection.
Summary:
There will be multiple TypeUnits in an unlinked object that will be extracted
from different sections. Now that we have DWARFUnitSection that is supposed
to represent an input section, we need a DWARFUnitSection<TypeUnit> per
input .debug_types section.

Once this is done, the interface is homogenous and we can move the Section
parsing code into DWARFUnitSection.

Reviewers: samsonov, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 218513
2014-09-26 12:15:40 +00:00
Renato Golin
4870456c00 Revert 218406 - Refactor the RelocVisitor::visit method
llvm-svn: 218416
2014-09-24 21:30:43 +00:00
Renato Golin
382a93de99 Refactor the RelocVisitor::visit method
This change replaces the brittle if/else chain of string comparisons
with a switch statement on the detected target triple, removing the
need for testing arbitrary architecture names returned from
getFileFormatName, whose primary purpose seems to be for display
(user-interface) purposes. The visitor now takes a reference to the
object file, rather than its arbitrary file format name to figure out
whether the file is a 32 or 64-bit object file and what the detected
target triple is.

A set of tests have been added to help show that the refactoring processes
relocations for the same targets as the original code.

Patch by Charlie Turner.

llvm-svn: 218406
2014-09-24 20:07:22 +00:00
Kaelyn Takata
c2b37b7199 Revert "Refactor the RelocVisitor::visit method"
This reverts commit faac033f7364bb4226e22c8079c221c96af10d02.

The test depends on all targets to be enabled in llc in order to pass,
and needs to be rewritten/refactored to not have that dependency.

llvm-svn: 218393
2014-09-24 17:49:07 +00:00
Renato Golin
b219b3d2ff Refactor the RelocVisitor::visit method
This change replaces the brittle if/else chain of string comparisons
with a switch statement on the detected target triple, removing the
need for testing arbitrary architecture names returned from
getFileFormatName, whose primary purpose seems to be for display
(user-interface) purposes. The visitor now takes a reference to the
object file, rather than its arbitrary file format name to figure out
whether the file is a 32 or 64-bit object file and what the detected
target triple is.

A set of tests have been added to help show that the refactoring processes
relocations for the same targets as the original code.

Patch by Charlie Turner.

llvm-svn: 218388
2014-09-24 17:00:42 +00:00
Frederic Riss
bfc90ed2e1 [dwarfdump] Dump full filenames as DW_AT_(decl|call)_file attribute values
Reviewers: dblaikie samsonov

Subscribers: llvm-commits

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

llvm-svn: 218246
2014-09-22 12:36:04 +00:00
Frederic Riss
d6f638ebe4 Allow DWARFDebugInfoEntryMinimal::getSubroutineName to resolve cross-unit references.
Summary: getSubroutineName is currently only used by llvm-symbolizer, thus add a binary test containing a cross-cu inlining example.

Reviewers: samsonov, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 218245
2014-09-22 12:35:53 +00:00
Frederic Riss
166468a68e Turn local DWARFContext helpers getFileNameForUnit() and getFileLineInfoForCompileUnit() into full-blowm DWARFDebugLine::LineTable methods.
Summary:
getFileNameForUnit() is basically a wrapper around LineTable::getFileNameByIndex().
Fold its additional functionality (adding the DWARFUnit compilation dir) into
LineTable::getFileNameByIndex().

getFileLineInfoForCompileUnit() is a wrapper around getFileNameForUnit(). As
a function to search the line information by address, it seems natural to put
it in the LineTable also.

Before this commit only the Context with its private helpers could do Linetable
lookups. This newly exposed feature will be used by the DIE dumping code to
get access to file information referenced in DIE attributes.

This commit has already been partly reviewed in D5192 and contained an
additional and a bit controversial 'realpath' call that is left out of this
patch. We can reinstate that realpath code later if it is desirable.

Test Plan:
The patch contains no tests as it should be functionally equivalent to the
previous code. As requested in the last review, I checked if the relative
path handling copied from the Context to LineTable::getFileNameByIndex()
was covered, and indeed the symbolizer tests fail if it is removed.

Reviewers: dblaikie, echristo, aprantl, samsonov

Subscribers: llvm-commits

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

llvm-svn: 218125
2014-09-19 15:11:51 +00:00
Frederic Riss
2a187d6216 Fix DWARFUnitSection::getUnitForOffset().
The current code is only able to return the right unit if the passed offset
is the exact offset of a section. Generalize the search function by comparing
againt the offset of the next unit instead and by switching the search
algorithm to upper_bound.

This way, the unit returned is the first unit with a getNextUnitOffset()
strictly greater than the searched offset, which is exactly what we want.
Note that there is no need for testing the range of the resulting unit as
the offsets of a DWARFUnitSection are in a single contiguous range from
0 inclusive to lastUnit->getNextUnitOffset() exclusive.

Reviewers: dblaikie samsonov

Subscribers: llvm-commits

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

llvm-svn: 218040
2014-09-18 09:38:15 +00:00
Frederic Riss
9922679cc9 Make DWARFUnitSection final and change base class to non-virtual protected destructor.
As per dblaikie suggestion.

llvm-svn: 217871
2014-09-16 12:58:01 +00:00
Frederic Riss
5ceed38352 Fix a non-virtual destructor warning introduced in r217747.
llvm-svn: 217756
2014-09-15 10:38:13 +00:00
Frederic Riss
b3d20faffd Fix ambiguous typedef introduced in r217747.
Use fully qualified name inside a typedef from llvm::iterator_range<...> to
iterator_range. This is reported (rightly I think) by GCC as an
ambiguous name redefinition. Hope this fixes the buildbots.

llvm-svn: 217751
2014-09-15 08:23:07 +00:00
Frederic Riss
7478c406d6 Introduce the DWARFUnitSection abstraction.
A DWARFUnitSection is the collection of Units that have been extracted from
the same debug section.

By embeding a reference to their DWARFUnitSection in each unit, the DIEs
will be able to resolve inter-unit references by interrogating their Unit's
DWARFUnitSection.

This is a minimal patch where the DWARFUnitSection is-a SmallVector of Units,
thus exposing exactly the same interface as before. Followup-up patches might
change from inheritance to composition in order to expose only the wanted
DWARFUnitSection abstraction.

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

llvm-svn: 217747
2014-09-15 07:50:27 +00:00
Alexey Samsonov
b81722a1a7 [DWARF parser] Fix nasty memory corruption in .dwo files handling.
Forge a test case where llvm-symbolizer has to use external .dwo
file to produce the inlining information.

llvm-svn: 217270
2014-09-05 19:29:45 +00:00
Frederic Riss
d3d3c64d38 [dwarfdump] Dump DW_AT_(decl|call)_line attribute values as decimal values.
llvm-svn: 217232
2014-09-05 07:21:50 +00:00
Frederic Riss
f08f2cafec [ dwarfdump ] Add symbolic dump of known DWARF attribute values.
Reviewed By: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 217186
2014-09-04 19:39:20 +00:00
Frederic Riss
72e28fe98a Fix build faliure introduced by r217129.
Looks like one can't put 'const uint8_t' as ArrayRef contained type. It fails to build with libstdc++.

llvm-svn: 217132
2014-09-04 06:35:09 +00:00
Frederic Riss
152c97cc49 Rename DWARFContext::getLineTableForCompileUnit to getLineTableForUnit.
All DWARFUnits can have line information. Rename and change arguments' type
accordingly.

llvm-svn: 217130
2014-09-04 06:14:40 +00:00
Frederic Riss
3abfc56bb1 Add DWARFFormValue::getAsBlock() and add FC_Flag as an acceptable class for an unsigned constant.
To be used in further patches that improve the dumpers.

llvm-svn: 217129
2014-09-04 06:14:35 +00:00
Frederic Riss
d7744d5ca6 Add a DWARFContext& member in DWARFUnit.
The DWARFContext will be used to pass global 'context' down, like
pointers to related debug info sections or command line options.
The first use will be for the debug_info dumper to be able to access
other debug info section to dump eg. Location Expression inline
in the debug_info dump.

llvm-svn: 217128
2014-09-04 06:14:28 +00:00
Rafael Espindola
08aa78de63 Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

llvm-svn: 216002
2014-08-19 18:44:46 +00:00
Benjamin Kramer
da144ed5a2 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

llvm-svn: 215558
2014-08-13 16:26:38 +00:00
Rafael Espindola
2ddb97e871 DWOHolder takes ownership of the argument constructor, use std::unique_ptr.
Thanks to David Blaikie for noticing it.

llvm-svn: 214434
2014-07-31 20:26:42 +00:00
Rafael Espindola
3127847c8f Use a reference instead of a pointer.
This makes using a std::unique_ptr in the caller more convenient.

llvm-svn: 214433
2014-07-31 20:19:36 +00:00
Rafael Espindola
191faa331e Use std::unique_ptr to make the ownership explicit.
llvm-svn: 214377
2014-07-31 03:12:45 +00:00
Alp Toker
97022b0c1f Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

llvm-svn: 211814
2014-06-26 22:52:05 +00:00
Alp Toker
fd9ead3b6f Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

llvm-svn: 211749
2014-06-26 00:00:48 +00:00
Alexey Samsonov
7ef493d27f [DWARF parser] Use distinction between DW_AT_ranges_base and DW_AT_GNU_ranges_base instead of DWARF version
llvm-svn: 210945
2014-06-13 22:31:03 +00:00
Rafael Espindola
98710599c1 Remove 'using std::errro_code' from lib.
llvm-svn: 210871
2014-06-13 02:24:39 +00:00
Alexey Samsonov
11cb912a27 [DWARF parser] Fix broken address ranges construction.
Previous algorithm for constructing [Address ranges]->[Compile Units]
mapping was wrong. It somewhat relied on the assumption that address ranges
for different compile units may not overlap. It is not so.
For example, two compile units may contain the definition of the same
linkonce_odr function. These definitions will be merged at link-time,
resulting in equivalent .debug_ranges entries for both these units

Instead of sorting and merging original address ranges (from .debug_ranges
and .debug_aranges), implement a different approach: save endpoints
of all ranges, and then use a sweep-line approach to construct
the desired mapping. If we find that certain address maps to
several compilation units, we just pick any of them.

llvm-svn: 210860
2014-06-12 23:58:49 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Alexey Samsonov
71917b612d [llvm-symbolizer] Fix parsing DW_AT_ranges in Fission skeleton compile unit DIEs.
Turns out that DW_AT_ranges_base attribute sets the offset for
DW_AT_ranges values specified in the .dwo file, but not for DW_AT_ranges specified
in the skeleton compile unit DIE in the main executable. This is extremely confusing,
and would hopefully be fixed in DWARF-5 when it's finalized. For now this
behavior makes sense, as otherwise Fission would break DWARF consumers who
doesn't know anything about DW_AT_ranges_base.

llvm-svn: 210809
2014-06-12 18:52:35 +00:00
Richard Smith
cb6bc29096 [modules] Add module maps for LLVM. These are not quite ready for prime-time
yet, but only a few more Clang patches need to land. (I have 'ninja check'
passing locally.)

llvm-svn: 209269
2014-05-21 02:46:14 +00:00
Alexey Samsonov
53674245eb [DWARF parser] Teach DIContext to fetch short (non-linkage) function names for a given address.
Change --functions option in llvm-symbolizer tool to accept
values "none", "short" or "linkage". Update the tests and docs
accordingly.

llvm-svn: 209050
2014-05-17 00:07:48 +00:00
Alexey Samsonov
19e01d8ebe [DWARF parser] Use enums instead of bitfields in DILineInfoSpecifier.
It is more appropriate than the current situation, when one flag
(AbsoluteFilePath) is relevant only if another flag is set.

This refactoring would also simplify fetching the short function name
(stored in DW_AT_name) instead of a linkage name returned currently.

No functionality change.

llvm-svn: 208921
2014-05-15 21:24:32 +00:00
Alexey Samsonov
4460fa769e [DWARF parser] Cleanup code in DWARFDebugLine.
Streamline parsing and dumping line tables:
Prefer composition to multiple inheritance in DWARFDebugLine::ParsingState.
Get rid of the weird concept of "DumpingState" structure.

was:
  DWARFDebugLine::DumpingState state(OS);
  DWARFDebugLine::parseStatementTable(..., state);
now:
  DWARFDebugLine::LineTable LineTable;
  LineTable.parse(...);
  LineTable.dump(OS);

No functionality change.

llvm-svn: 207599
2014-04-30 00:09:19 +00:00
Alexey Samsonov
7815beb44c [DWARF parser] Cleanup code in DWARFDebugLine.
Move several function definitions into .cpp, unify constructors
and clear() methods (fixing a couple of latent bugs from copy-paste),
turn static function parsePrologue() into Prologue::parse().

More work needed here to untangle weird multiple inheritance
in table parsing and dumping.

No functionality change.

llvm-svn: 207579
2014-04-29 21:28:13 +00:00
Alexey Samsonov
f79fa7ca78 [DWARF parser] Compress DIEMinimal even further, simplify building DIE tree.
DIE doesn't need to store a pointer to its parent: we can traverse the DIE tree
only with functions getFirstChild() and getSibling(). Parents must be known
only when we construct the tree. Rewrite setDIERelations() procedure in a more
straightforward way, and get rid of lots of now unused DIEMinimal methods.

No functionality change.

llvm-svn: 207563
2014-04-29 17:12:42 +00:00
Alexey Samsonov
51a4bc5e65 [DWARF parser] DWARFDebugFrame: Make FrameEntry struct smaller.
FrameEntry doesn't need to hold a reference to the section it is
located in. Instead, pass DataExtractor as an argument of parsing
function.

No functionality change.

llvm-svn: 207461
2014-04-28 23:00:06 +00:00
Alexey Samsonov
9b79ae576b [DWARF parser] DWARFDebugFrame: use unique_ptr instead of raw pointer
llvm-svn: 207459
2014-04-28 22:52:24 +00:00
Alexey Samsonov
d5d88c38e4 [DWARF parser] Simplify DWARFDebugAranges generation.
There is no need to keep the whole contents of .debug_aranges section
in memory when we build address ranges table. Memory optimization that
used to be in this code (precalculate the size of vector of ranges before
filling it) is not really needed - later we will compact and resize this
vector anyway.

llvm-svn: 207457
2014-04-28 22:27:46 +00:00
Craig Topper
b663bffa27 [C++] Use 'nullptr'.
llvm-svn: 207394
2014-04-28 04:05:08 +00:00
Alexey Samsonov
ada8eb887a Fix missing include
llvm-svn: 207278
2014-04-25 21:42:35 +00:00
Alexey Samsonov
a53cb57dd2 [DWARF parser] Cleanup code in DWARFDebugAranges.
No functionality change.

llvm-svn: 207276
2014-04-25 21:30:03 +00:00
Alexey Samsonov
2e1c360259 [DWARF parser] Cleanup code in DWARFDebugAbbrev.
No functionality change.

llvm-svn: 207274
2014-04-25 21:10:56 +00:00
Alexey Samsonov
09bff5120d [DWARF parser] Make a few methods non-public
llvm-svn: 207156
2014-04-24 23:08:56 +00:00