Commit Graph

357 Commits

Author SHA1 Message Date
Zachary Turner
73a1e454d7 llvm-pdbdump: Only dump whitelisted global symbols.
Dumping the global scope contains a lot of very uninteresting
things and is generally polluted with a lot of random junk.
Furthermore, it dumps values unsorted, making it hard to read.
This patch dumps known interesting types only, and as a side
effect sorts the list by symbol type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229232 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-14 03:54:28 +00:00
Zachary Turner
f94896ffa0 llvm-pdbdump: Re-order header files according to LLVM style guide.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229231 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-14 03:53:56 +00:00
Zachary Turner
c208d61bcb Fix -Wunused-variable warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229130 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 18:11:49 +00:00
Zachary Turner
4c0a8b3025 llvm-pdbdump: Improve printing of functions and signatures.
This correctly prints the function pointers, and also prints
function signatures for symbols as opposed to just types.  So
actual functions in your program will now be printed with full
name and signature, as opposed to just name as before.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229129 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 17:57:09 +00:00
Chandler Carruth
02d6288667 Re-sort #include lines using my handy dandy ./utils/sort_includes.py
script. This is in preparation for changes to lots of include lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 09:09:03 +00:00
Zachary Turner
eb95a535aa llvm-pdbdump: Add more comprehensive dumping of symbol types.
In particular this patch adds the ability to dump complete
function signature information including argument types as
correctly formatted strings.  A side effect of this is that
almost all symbol and meta types are now formatted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229076 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 07:40:03 +00:00
Zachary Turner
bcaafc81ab Improve llvm-pdbdump output display.
This patch adds a number of improvements to llvm-pdbdump.

1) Dumping of the entire global scope, and not only those
   symbols that live in individual compilands.
2) Prepend class name to member functions and data
3) Improved display of bitfields.
4) Support for dumping more kinds of data symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229012 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:23:51 +00:00
Zachary Turner
13a819cbad Add concrete type overloads to PDBSymbol::findChildren().
Frequently you only want to iterate over children of a specific
type (e.g. functions).  Previously you would get back a generic
interface that allowed iteration over the base symbol type,
which you would have to dyn_cast<> each one of.  With this patch,
we allow the user to specify the concrete type as a template
parameter, and it will return an iterator which returns instances
of the concrete type directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12 21:09:24 +00:00
Peter Collingbourne
a920925fa2 Fix build for CMake < 2.8.12.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228810 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 05:58:57 +00:00
Zachary Turner
c371307e60 Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects.
This allows IDEs to recognize the entire set of header files for
each of the core LLVM projects.

Differential Revision: http://reviews.llvm.org/D7526
Reviewed By: Chris Bieneman

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 03:28:02 +00:00
Andrew Kaylor
a73810650e Temporary workaround to fix MSVC 2012 build problems
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228788 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 02:16:34 +00:00
Zachary Turner
c6b4bedeb6 Fix some warnings due to -Wcovered-switch-default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228773 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 00:13:39 +00:00
Zachary Turner
ab884fa603 Convert std::make_unique<> to llvm::make_unique<>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228768 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 23:46:48 +00:00
Zachary Turner
1e70854148 Rewrite llvm-pdbdump in terms of LLVMDebugInfoPDB.
This makes llvm-pdbdump available on all platforms, although it
will currently fail to create a dumper if there is no PDB reader
implementation for the current platform.

It implements dumping of compilands and children, which is less
information than was previously available, but it has to be
rewritten from scratch using the new set of interfaces, so the
rest of the functionality will be added back in subsequent commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228755 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 22:43:25 +00:00
Zachary Turner
8ffa03cd98 Provide DIA implementation of DebugInfoPDB.
This implements DebugInfoPDB when the DIA SDK is present on the system.
Specifically, this means that the following conditions are met:
  1) You are building on Windows.
  2) You are building with MSVC.
  3) Visual Studio did not corrupt the installation of DIA due to a
     known issue with side-by-side installations of VS2012 and VS2013.
If all of these conditions are true, you will be able to pass a value
of PDB_Reader::DIA to PDB::createPdbReader().

There are no tests for this yet, as any test will be in the form of a
lit test which tests the llvm-pdbdump.exe, which still needs to be
rewritten in terms of this library.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228747 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 21:17:52 +00:00
David Blaikie
d309b37554 Fix -Wuninitialized build by referencing the relevant ctor parameter instead of the base class member variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228554 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-08 23:15:37 +00:00
Zachary Turner
4bb5abb075 Make PDBSymbol's IPDBSymbol reference const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228553 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-08 22:53:53 +00:00
Zachary Turner
926749af90 DebugInfoPDB: Make the symbol base case hold an IPDBSession ref.
Dumping a symbol often requires access to data that isn't inside
the symbol hierarchy, but which is only accessible through the
top-level session.  This patch is a pure interface change to give
symbols a reference to the session.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228542 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-08 20:58:09 +00:00
Zachary Turner
2c797c6dc4 Removed unused function mistakenly left in, triggering -Werror.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228517 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-08 00:41:31 +00:00
Zachary Turner
e642985be9 Some cleanup for libpdb.
This patch implements a few of the optional suggestions from the
initial patch comitting libpdb.  In particular, it implements a
virtual function out of line for each of the concrete classes.

A few other minor cleanups exist as well, such as using override
instead of virtual, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228516 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-08 00:29:29 +00:00
Zachary Turner
d0898f1565 Resubmit unittests for DebugInfoPDB.
These were originally submitted as part of r228428, but this part
caused a build breakage in LLVMConfig.  The library portion was
resubmitted independently since it was not causing breakage.

There were two reasons this was causing the build to fail.  The
first is that there were no Makefiles added for the PDB tests.  And
the second is that the DebugInfoPDB library was only being built by
CMake behind an "if (MSVC)" check.  This is wrong since this the
library hides platform specific details, and it was causing
LLVM-Config to not find the library when trying to build unittests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-07 01:47:14 +00:00
Zachary Turner
4f325e4c43 Try to fix Makefile build for LLVMDebugInfoPDB.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228437 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06 20:42:03 +00:00
Zachary Turner
44797c5a09 Resubmit "Create lib/DebugInfo/PDB" (r228428)
This change resubmits the patch that broke the build, this time
without unittests.  The unittests will be submitted separately
after the problem has been addressed:

--Original Commit Message--

Create lib/DebugInfo/PDB.

This patch creates a platform-independent interface to a PDB reader.
There is currently no implementation of this interface, which will
be provided in future patches.  This defines the basic object model
which any implementation must conform to.

Reviewed by: David Blaikie
Differential Revision: http://reviews.llvm.org/D7356

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228435 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06 20:30:52 +00:00
Zachary Turner
9c505a5d38 Revert "Create lib/DebugInfo/PDB."
This reverts commit 21028, as it is causing failures in LLVMConfig.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228431 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06 20:00:18 +00:00
Zachary Turner
1a05c567d6 Create lib/DebugInfo/PDB.
This patch creates a platform-independent interface to a PDB reader.
There is currently no implementation of this interface, which will
be provided in future patches.  This defines the basic object model
which any implementation must conform to.

Reviewed by: David Blaikie
Differential Revision: http://reviews.llvm.org/D7356

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228428 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06 19:44:09 +00:00
Zachary Turner
50418a0ac4 Move DebugInfo to DebugInfo/DWARF.
In preparation for adding PDB support to LLVM, this moves the
DWARF parsing code to its own subdirectory under DebugInfo, and
renames LLVMDebugInfo to LLVMDebugInfoDWARF.

This is purely a mechanical / build system change.

Differential Revision: http://reviews.llvm.org/D7269
Reviewed by: Eric Christopher

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227586 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-30 18:07:45 +00:00
Chandler Carruth
1b279144ec [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 11:23:27 +00:00
Adrian Prantl
aea3b23b9b Implement a very basic colored syntax highlighting for llvm-dwarfdump.
The color scheme is the same as the one used by the colorize dwarfdump
script on Darwin.
A new --color option can be used to forcibly turn color on or off.

http://reviews.llvm.org/D6852

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225269 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-06 16:50:25 +00:00
Frederic Riss
7e5492d27d [DebugInfo] Move all DWARF headers to the public include directory.
dsymutil needs access to DWARF specific inforamtion, the small DIContext
wrapper isn't sufficient. Other DWARF consumers might want to use it too
(I'm looking at you lldb).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224594 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 18:26:33 +00:00
Michael Ilseman
9ecdca9115 Silence more static analyzer warnings.
Add in definedness checks for shift operators, null checks when
pointers are assumed by the code to be non-null, and explicit
unreachables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 18:48:43 +00:00
Frederic Riss
12385e603f Make DWARFAcceleratorTable::dump() const.
As dump() methods  should be. To allow that, do not store the DWARFFormValue
objects used for the dump in the header data.

Per Alexey's suggestion!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222436 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 16:21:11 +00:00
Frederic Riss
d239f8c198 Add missing copyright headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222435 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 16:21:06 +00:00
Frederic Riss
4ad9e9b0b0 [dwarfdump] Handle relocations in Dwarf accelerator tables
ELF targets (and maybe COFF) use relocations when referring
to strings in the .debug_str section. Handle that in the
accelerator table dumper. This commit restores the
test/DebugInfo/cross-cu-inlining.ll test to its expected
platform independant form, validating that the fix works
(this test failed on linux boxes).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222029 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 19:30:08 +00:00
Frederic Riss
e26d79386b Reapply "[dwarfdump] Add support for dumping accelerator tables."
This reverts commit r221842 which was a revert of r221836 and of the
test parts of r221837.

This new version fixes an UB bug pointed out by David (along with
addressing some other review comments), makes some dumping more
resilient to broken input data and forces the accelerator tables
to be dumped in the tests where we use them (this decision is
platform specific otherwise).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222003 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 16:15:53 +00:00
Frederic Riss
8839439547 Revert "[dwarfdump] Add support for dumping accelerator tables."
This reverts commit r221836.

The tests are asserting on some buildbots. This also reverts the
test part of r221837 as it relies on dwarfdump dumping the
accelerator tables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221842 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:15:15 +00:00
Frederic Riss
931e22fd7c [dwarfdump] Add support for dumping accelerator tables.
The class used for the dump only allows to dump for the moment, but
it can (and will) be easily extended to support search also.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221836 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 23:48:10 +00:00
Frederic Riss
0275be3a97 Allow DWARFFormValue::extractValue to be called with a null CU.
Currently FormValues are only used for attributes of DIEs and thus
uers always have a CU lying around when calling into the FormValue
API.
Accelerator tables encode their information using the same Forms
as the attributes, thus it is natural to use DWARFFormValue to
extract/dump them. There is no CU in that case though. Allow the
API to be called with a null CU arguemnt by making the RelocMap
lookup conditional on the CU pointer validity. And document this
new behvior in the header. (Test coverage for this use of the API
comes in the DwarfAccelTable support patch)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 23:48:04 +00:00
Frederic Riss
f1faaf2e09 Remove unsused variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221834 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 23:48:01 +00:00
Frederic Riss
9970b0fcaa [dwarfdump] Dump DW_AT_ranges values inline in the debug_info dump.
The output looks like that:
                      DW_AT_ranges [FORM_data4]    (0x00000000
                         [0x00000001000024a0 - 0x00000001000024c2)
                         [0x0000000100002505 - 0x000000010000268b))

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220466 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23 04:08:34 +00:00
Alexey Samsonov
10051f0f62 Constify input argument of RelocVisitor and DWARFContext constructors. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220228 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 20:28:51 +00:00
Fariborz Jahanian
a64ffb893b Add couple of missing 'override' keyword. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219516 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 17:34:30 +00:00
Frederic Riss
0f65dfd92b [dwarfdump] Prettyprint DW_AT_APPLE_property_attribute bitfield values.
This change depends on the ApplePropertyString helper that I sent spearately.
Not sure how you want this tested: as a tool test by adding a binary to dump, or as an llvm test starting from an IR file?

Reviewers: dblaikie, samsonov

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219507 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 15:51:10 +00:00
Frederic Riss
dd2cb9cae7 [dwarfdump] Resolve also variable specifications/abstract_origins.
DW_AT_specification and DW_AT_abstract_origin resolving was only performed
on subroutine DIEs because it used the getSubroutineName method. Introduce
a more generic getName() and use it to dump the reference attributes.

Testcases have been updated to check the printed names instead of the offsets
except when the name could be ambiguous.

Reviewers: dblaikie, samsonov

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219506 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 15:51:02 +00:00
Rafael Espindola
8175be535a Remove bogus std::error_code returns form SectionRef.
There are two methods in SectionRef that can fail:

* getName: The index into the string table can be invalid.
* getContents: The section might point to invalid contents.

Every other method will always succeed and returning and std::error_code just
complicates the code. For example, a section can have an invalid alignment,
but if we are able to get to the section structure at all and create a
SectionRef, we will always be able to read that invalid alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219314 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 15:28:58 +00:00
David Majnemer
3d371bd84b llvm-dwarfdump: Add support for some COFF relocations
DWARF in COFF utilizes several relocations.  Implement support for them
in RelocVisitor to support llvm-dwarfdump.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 06:38:50 +00:00
Alexey Samsonov
8d74900819 [DebugInfo] Pass DWARFSection down to DWARFUnit constructor (NFC).
Keep the actual section contents and the relocation map together.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219261 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 00:24:41 +00:00
Alexey Samsonov
a29287d90d [DebugInfo] Pass DWARFSection into DWARFUnitSection constructor (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219259 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 00:07:53 +00:00
Alexey Samsonov
99ff4a2dba [DebugInfo] Turn DWARFContext::Section into DWARFSection (NFC).
It would be more convenient to pass DWARFSection into DWARFUnitSection
constructor, instead of passing its components (Data and RelocAddrMap)
as a separate arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219252 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-07 23:45:11 +00:00
Eric Christopher
7d0a297dbd Refactor RelocVisitor to take an object. This removes some
string comparisons and makes it a bit easier to check individual
targets.

Patch by Charlie Turner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219108 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 06:55:55 +00:00
Yaron Keren
a37095eae6 Resolve ambiguity between llvm::make_unique and std::make_unique.
Intorduced in r219098.
 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219105 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 06:39:57 +00:00
Frederic Riss
f2eddd6694 [dwarfdump] Print the name for referenced specification of abstract_origin DIEs.
Reviewers: dblaikie, samsonov, echristo, aprantl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219099 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 03:36:31 +00:00
Frederic Riss
3736cc5be8 Factor the Unit section parsing into the DWARFUnitSection class.
Summary: No functional change.

Reviewers: dblaikie, samsonov

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219098 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 03:36:18 +00:00
Benjamin Kramer
dbc6d9b9d7 Remove unnecessary copying or replace it with moves in a bunch of places.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219061 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-04 16:55:56 +00:00
Frederic Riss
97552d7c1c 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218606 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 13:56:39 +00:00
David Majnemer
01ea611601 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218549 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-26 22:32:16 +00:00
Frederic Riss
a0d5d7aed8 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218514 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-26 12:34:06 +00:00
Frederic Riss
5fb5bdbf6a 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218513 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-26 12:15:40 +00:00
Renato Golin
bb994f55a4 Revert 218406 - Refactor the RelocVisitor::visit method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218416 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 21:30:43 +00:00
Renato Golin
c0104e4001 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218406 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 20:07:22 +00:00
Kaelyn Takata
a0d6422afe Revert "Refactor the RelocVisitor::visit method"
This reverts commit faac033f73.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 17:49:07 +00:00
Renato Golin
faac033f73 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218388 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 17:00:42 +00:00
Frederic Riss
21e5bf8461 [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218246 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-22 12:36:04 +00:00
Frederic Riss
cc55b73867 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218245 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-22 12:35:53 +00:00
Frederic Riss
b9f4e7d6e9 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218125 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19 15:11:51 +00:00
Frederic Riss
344b66866d 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218040 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-18 09:38:15 +00:00
Frederic Riss
baaa29f3a2 Make DWARFUnitSection final and change base class to non-virtual protected destructor.
As per dblaikie suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217871 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-16 12:58:01 +00:00
Frederic Riss
69513f19ba Fix a non-virtual destructor warning introduced in r217747.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217756 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 10:38:13 +00:00
Frederic Riss
d090be97a8 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217751 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 08:23:07 +00:00
Frederic Riss
ea3ce67d71 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217747 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 07:50:27 +00:00
Alexey Samsonov
54543afeba [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217270 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05 19:29:45 +00:00
Frederic Riss
94f5d4480a [dwarfdump] Dump DW_AT_(decl|call)_line attribute values as decimal values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217232 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05 07:21:50 +00:00
Frederic Riss
a49caa5e3f [ dwarfdump ] Add symbolic dump of known DWARF attribute values.
Reviewed By: dblaikie

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217186 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 19:39:20 +00:00
Frederic Riss
a41fd4f9c2 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++.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217132 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 06:35:09 +00:00
Frederic Riss
1711064e1f Rename DWARFContext::getLineTableForCompileUnit to getLineTableForUnit.
All DWARFUnits can have line information. Rename and change arguments' type
accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217130 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 06:14:40 +00:00
Frederic Riss
b81715aca8 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217129 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 06:14:35 +00:00
Frederic Riss
a1f7715ef9 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217128 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 06:14:28 +00:00
Rafael Espindola
548f2b6e8f 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 18:44:46 +00:00
Benjamin Kramer
00e08fcaa0 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Rafael Espindola
fc272c3b9e DWOHolder takes ownership of the argument constructor, use std::unique_ptr.
Thanks to David Blaikie for noticing it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214434 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 20:26:42 +00:00
Rafael Espindola
81becb73ab Use a reference instead of a pointer.
This makes using a std::unique_ptr in the caller more convenient.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214433 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 20:19:36 +00:00
Rafael Espindola
79002da926 Use std::unique_ptr to make the ownership explicit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214377 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 03:12:45 +00:00
Alp Toker
8dd8d5c2b2 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 22:52:05 +00:00
Alp Toker
2559070422 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 00:00:48 +00:00
Alexey Samsonov
869d3efac9 [DWARF parser] Use distinction between DW_AT_ranges_base and DW_AT_GNU_ranges_base instead of DWARF version
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210945 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 22:31:03 +00:00
Rafael Espindola
4e2b922131 Remove 'using std::errro_code' from lib.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210871 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 02:24:39 +00:00
Alexey Samsonov
740a75968a [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210860 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 23:58:49 +00:00
Rafael Espindola
5c792faa0e Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 21:46:39 +00:00
Alexey Samsonov
4dfa6812d7 [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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210809 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 18:52:35 +00:00
Richard Smith
651f680b79 [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.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209269 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 02:46:14 +00:00
Alexey Samsonov
bf6e3f9257 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209050 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-17 00:07:48 +00:00
Alexey Samsonov
b043c3d94a [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208921 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 21:24:32 +00:00
Alexey Samsonov
1ea858937c [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207599 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 00:09:19 +00:00
Alexey Samsonov
2387e9ecb1 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207579 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 21:28:13 +00:00
Alexey Samsonov
b58db2293d [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207563 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 17:12:42 +00:00
Alexey Samsonov
07c3167c2b [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207461 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 23:00:06 +00:00
Alexey Samsonov
2f9c1f2f17 [DWARF parser] DWARFDebugFrame: use unique_ptr instead of raw pointer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207459 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 22:52:24 +00:00
Alexey Samsonov
dc9a4f7391 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207457 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 22:27:46 +00:00
Craig Topper
c34a25d59d [C++] Use 'nullptr'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207394 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 04:05:08 +00:00
Alexey Samsonov
c744a37153 Fix missing include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207278 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 21:42:35 +00:00
Alexey Samsonov
c87722ce4b [DWARF parser] Cleanup code in DWARFDebugAranges.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207276 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 21:30:03 +00:00