Commit Graph

411 Commits

Author SHA1 Message Date
Dave Bartolomeo a779f5a401 Remove unused constants from TypeTableBuilder.cpp.
llvm-svn: 256389
2015-12-24 19:15:56 +00:00
Bill Seurer 8771bbfbe2 Fix case of path name
llvm-svn: 256388
2015-12-24 18:54:35 +00:00
Dave Bartolomeo dd38b1bf12 Fix CodeView library name and non-CMake builds
llvm-svn: 256387
2015-12-24 18:51:35 +00:00
Dave Bartolomeo 89ba802b92 LLVM CodeView library
Summary: This diff is the initial implementation of the LLVM CodeView library. There is much more work to be done, namely a CodeView dumper and tests. This patch should help others make progress on the LLVM->CodeView debug info emission while I continue with the implementation of the dumper and tests.

This library implements support for emitting debug info in the CodeView format. This phase of the implementation only includes support for CodeView type records. Clients that need to emit type records will use a class derived from TypeTableBuilder. TypeTableBuilder provides member functions for writing each kind of type record; each of these functions eventually calls the writeRecord virtual function to emit the actual bits of the record. Derived classes override writeRecord to implement the folding of duplicate records and the actual emission to the appropriate destination. LLVMCodeView provides MemoryTypeTableBuilder, which creates the table in memory. In the future, other classes derived from TypeTableBuilder will write to other destinations, such as the type stream in a PDB.

The rest of the types in LLVMCodeView define the actual CodeView type records and all of the supporting enums and other types used in the type records. The TypeIndex class is of particular interest, because it is used by clients as a handle to a type in the type table.

The library provides a relatively low-level interface based on the actual on-disk format of CodeView. For example, type records refer to other type records by TypeIndex, rather than by an actual pointer to the referent record. This allows clients to emit type records one at a time, rather than having to keep the entire transitive closure of type records in memory until everything has been emitted. At some point, having a higher-level interface layered on top of this one may be useful for debuggers and other tools that want a more holistic view of the debug info. The lower-level interface should be sufficient for compilers and linkers to do the debug info manipulation that they need to do efficiently.

Reviewers: rnk, majnemer

Subscribers: silvas, rnk, jevinskie, llvm-commits

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

llvm-svn: 256385
2015-12-24 18:12:38 +00:00
Alexey Samsonov 1eaae4c3b1 [Symbolize] Improve the ownership of parsed objects.
This code changes the way Symbolize handles parsed binaries: now
parsed OwningBinary<Binary> is not broken into (binary, memory buffer)
pair, and is just stored as-is in a cache. ObjectFile components
of Mach-O universal binaries are also stored explicitly in a
separate cache.

Additionally, this change:
* simplifies the code that parses/caches binaries: it's now done
  in a single place, not three different functions.
* makes flush() method behave as expected, and actually clear
  the cached parsed binaries and objects.
* fixes a dangling pointer issue described in
  http://reviews.llvm.org/D15638

llvm-svn: 256041
2015-12-18 22:02:14 +00:00
Pete Cooper 98052537f0 Revert "Improve DWARFDebugFrame::parse to also handle __eh_frame."
This reverts commit r256008.

Its breaking multiple buildbots, although works for me locally.

llvm-svn: 256013
2015-12-18 19:45:38 +00:00
Pete Cooper 6c97f4c7d7 Improve DWARFDebugFrame::parse to also handle __eh_frame.
LLVM MC has single methods which can handle the output of EH frame and DWARF CIE's and FDE's.

This code improves DWARFDebugFrame::parse to do the same for parsing.

This also allows llvm-objdump to support the --dwarf=frames option which objdump supports.  This
option dumps the .eh_frame section using the new code in DWARFDebugFrame::parse.

http://reviews.llvm.org/D15535

Reviewed by Rafael Espindola.

llvm-svn: 256008
2015-12-18 18:51:08 +00:00
Dave Bartolomeo ea039c121b Test commit
llvm-svn: 255926
2015-12-17 20:54:16 +00:00
David Blaikie ad07b5d65e [llvm-dwp] Retrieve the DWOID from the CU for the cu_index entry
llvm-svn: 254731
2015-12-04 17:20:04 +00:00
David Blaikie 725c4f71d1 dwarfdump: Correctly indentify the indicies for DWP records
The indicies are one-based, not zero-based, per the spec.

llvm-svn: 254626
2015-12-03 18:41:59 +00:00
David Blaikie 20f52662d4 [llvm-dwp] Don't rely on implicit move assignment operator (MSVC won't synthesize one)
llvm-svn: 254492
2015-12-02 07:09:26 +00:00
David Blaikie b073cb9be2 [llvm-dwp] Emit a rather fictional debug_cu_index
This is very rudimentary support for debug_cu_index, but it is enough to
allow llvm-dwarfdump to find the offsets for  contributions and
correctly dump debug_info.

It will need to actually find the real signature of the unit and build
the real hash table with the right number of buckets, as per the DWP
specification.

It will also need to be expanded to cover the tu_index as well.

llvm-svn: 254489
2015-12-02 06:21:34 +00:00
Craig Topper 66059c9f4d Replace dyn_cast with isa in places that weren't using the returned value for more than a boolean check. NFC.
llvm-svn: 253441
2015-11-18 07:07:59 +00:00
David Blaikie 4689ef5943 Fix null dereference committed in r253277
llvm-svn: 253393
2015-11-17 22:39:26 +00:00
David Blaikie 35c2eebfe4 dwarfdump: support indexed string dumping in dwp based on the STR_OFFSETS component of the index
llvm-svn: 253392
2015-11-17 22:39:23 +00:00
David Blaikie c4e2bed738 dwarfdump: Reference the appropriate line table segment when dumping dwp files
Also improves .dwo type unit dumping which didn't handle this either.

llvm-svn: 253377
2015-11-17 21:08:05 +00:00
David Blaikie cdec7ee565 Fix indentation
llvm-svn: 253278
2015-11-17 00:41:02 +00:00
David Blaikie 82641be467 dwarfdump: Use the index to find the right abbrev offset in DWP files
llvm-svn: 253277
2015-11-17 00:39:55 +00:00
David Blaikie 8e8dd57e0b dwarfdump: Add support for dumping the table contents of DWP indexes
This is a recommit of 252842 which was reverted in 252859. The issue was
using %s format specifier for a StringRef - used Format's
left_justify(StringRef, int) instead.

It'd be nice to have __attribute__((format(..))) on llvm::format, but
apparently it's only implemented for c-style variadics, not C++ variadic
templates. Perhaps we could fix that & conditionalize the attribute on
such...

llvm-svn: 253065
2015-11-13 19:18:49 +00:00
Reid Kleckner c038e2db4d [Symbolizer] Don't use PE symbol tables to override PDB symbols
Summary:
PE files are stripped by default, and only contain the names of exported
symbols.

The actual reason that we bother to do this override by default is
actually due to a quirk of the way -gline-tables-only is implemented, so
I phrased the check as "if we are symbolizing from dwarf, do the symtab
override".

This fixes lots of Windows ASan tests that I broke in r250582.

Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 253051
2015-11-13 17:00:36 +00:00
Amjad Aboud e59cc3e540 dwarfdump: Added macro support to llvm-dwarfdump tool.
Added "macro" option to "-debug-dump" flag, which trigger parsing and dumping of the ".debug_macinfo" section.

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

llvm-svn: 252866
2015-11-12 09:38:54 +00:00
David Blaikie 6400fc146e Mostly revert 252842 due to failures on some buildbots.
I imagine there's some UB in here somewhere, though Valgrind doesn't
seem to have picked it up (not sure if I have a working asan build right
now to test there).

GDB bot seems to be crashing:
http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/26267/steps/check-all/logs/FAIL%3A%20LLVM%3A%3Adwarfdump-dwp.test

Hexagon ELF bot is, presumably, just getting different output:
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/32927/steps/check-all/logs/FAIL%3A%20LLVM%3A%3Adwarfdump-dwp.test

llvm-svn: 252859
2015-11-12 06:33:14 +00:00
David Blaikie ee293c0aac dwarfdump: Add error checking to fix the buildbots/correctness
llvm-svn: 252845
2015-11-12 01:57:33 +00:00
David Blaikie 6e9c4f7f0d dwarfdump: Add some error handling for DWP index sections of the wrong size
llvm-svn: 252843
2015-11-12 01:41:59 +00:00
David Blaikie 5b9bf49c6f dwarfdump: Dump the contents of DWP indexes
llvm-svn: 252842
2015-11-12 01:41:52 +00:00
Hemant Kulkarni bdce12a01b [Symbolizer]: Add -pretty-print option
Differential Revision: http://reviews.llvm.org/D13671

llvm-svn: 252798
2015-11-11 20:41:43 +00:00
David Blaikie 51c402838c dwarfdump: DWP type unit index dumping skeleton
llvm-svn: 252786
2015-11-11 19:40:49 +00:00
David Blaikie 0b44dcc44a Format my previous commit
llvm-svn: 252782
2015-11-11 19:30:47 +00:00
David Blaikie 65a8efe441 dwarfdump: First piece of support for DWP dumping
Just a tiny piece of index dumping - the header in this instance.

llvm-svn: 252781
2015-11-11 19:28:21 +00:00
Colin LeMahieu da6cafffc0 Reverting r252760
llvm-svn: 252770
2015-11-11 18:11:06 +00:00
Hemant Kulkarni c6638c7561 [Symbolizer]: Add -pretty-print option
Differential Revision: http://reviews.llvm.org/D13671

llvm-svn: 252760
2015-11-11 17:47:54 +00:00
Alexey Samsonov 5365a01dc7 [LLVMSymbolize] Reduce indentation by using helper function. NFC.
llvm-svn: 252022
2015-11-04 00:30:26 +00:00
Alexey Samsonov 884adda0fb [LLVMSymbolize] Properly propagate object parsing errors from the library.
llvm-svn: 252021
2015-11-04 00:30:24 +00:00
Alexey Samsonov d6aa820262 [LLVMSymbolize] Factor out the logic for printing structs from DIContext. NFC.
Introduce DIPrinter which takes care of rendering DILineInfo and
friends. This allows LLVMSymbolizer class to return a structured data
instead of plain std::strings.

llvm-svn: 251989
2015-11-03 22:20:52 +00:00
Alexey Samsonov 6881249895 [LLVMSymbolize] Move demangling away from printing routines. NFC.
Make printDILineInfo and friends responsible for just rendering the
contents of the structures, demangling should actually be performed
earlier, when we have the information about the originating
SymbolizableModule at hand.

llvm-svn: 251981
2015-11-03 21:36:13 +00:00
Alexey Samsonov 46c1ce6ff5 Let the users of LLVMSymbolizer decide whether they want to symbolize inlined frames.
Introduce LLVMSymbolizer::symbolizeInlinedCode() instead of switching
on PrintInlining option passed to the constructor. This will be needed
once we retrun structured data (instead of std::string) from
LLVMSymbolizer and move printing logic out.

llvm-svn: 251675
2015-10-30 00:40:20 +00:00
Alexey Samsonov e46bd74147 [LLVMSymbolize] Simplify SymbolizableObjectFile::symbolizeInlinedCode(). NFC.
llvm-svn: 251672
2015-10-30 00:02:55 +00:00
Alexey Samsonov 76f7ecb83a [LLVMSymbolize] Move printing the description of a global into a separate function. NFC.
llvm-svn: 251669
2015-10-29 23:49:19 +00:00
Alexey Samsonov 8df3a07aa8 [LLVMSymbolize] Move ModuleInfo into a separate class (SymbolizableModule).
Summary:
This is mostly NFC. It is a first step in cleaning up LLVMSymbolize
library. It removes "ModuleInfo" class which bundles together ObjectFile
and its debug info context in favor of:
  * abstract SymbolizableModule in public headers;
  * SymbolizableObjectFile subclass in implementation.

Additionally, SymbolizableObjectFile is now created via factory, so we
can properly detect object parsing error at this stage instead of keeping
the broken half-parsed object. As a next step, we would be able to
propagate the error all the way back to the library user.

Further improvements might include:
  * factoring out the logic of finding appropriate file with debug info
    for a given object file, and caching all parsed object files into a
    separate class [A].
  * factoring out DILineInfo rendering [B].
This would make what is now a heavyweight "LLVMSymbolizer" a relatively
straightforward class, that calls into [A] to turn filepath into a
SymbolizableModule, delegates actual symbolization to concrete SymbolizableModule
implementation, and lets [C] render the result.

Reviewers: dblaikie, echristo, rafael

Subscribers: llvm-commits

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

llvm-svn: 251662
2015-10-29 22:21:37 +00:00
Alexey Samsonov 0fb6451ade [LLVMSymbolize] Don't use LLVMSymbolizer::Options in ModuleInfo. NFC.
LLVMSymbolizer::Options is mostly used in LLVMSymbolizer class anyway.
Let's keep their usage restricted to that class, especially given that
it's worth to move ModuleInfo to a different header, independent from
the symbolizer class.

llvm-svn: 251363
2015-10-26 22:34:56 +00:00
Alexey Samsonov ff8a80b477 Fix build failure on GCC 4.7 (old libstdc++ doesn't have std::map::emplace).
llvm-svn: 251347
2015-10-26 21:20:37 +00:00
David Blaikie efbb29153e Remove use of std::map<>::emplace which is not supported on some older versions of libstdc++
llvm-svn: 251346
2015-10-26 21:10:36 +00:00
Alexey Samsonov f3ecfd3af4 [LLVMSymbolize] Use symbol table only if function linkage name was requested.
Now it's enough to just specify -functions=short without additionally
providing -use-symbol-table=false.

llvm-svn: 251339
2015-10-26 20:12:29 +00:00
Alexey Samsonov 1d3f3271ac Fix build error by fully qualifying llvm::make_unique.
llvm-svn: 251338
2015-10-26 20:12:27 +00:00
Alexey Samsonov 7a952e53f9 [LLVMSymbolize] Use std::unique_ptr more extensively to clarify ownership.
llvm-svn: 251336
2015-10-26 19:41:23 +00:00
Alexey Samsonov 57f8837ada Move parts of llvm-symbolizer tool into LLVMSymbolize library.
Summary: See http://lists.llvm.org/pipermail/llvm-dev/2015-October/091624.html

Reviewers: echristo

Subscribers: llvm-commits, aizatsky

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

llvm-svn: 251316
2015-10-26 17:56:12 +00:00
Matt Arsenault 45cbfa5949 Use numeric_limits instead of LLONG_MAX
This is a build fix for configurations where LLONG_MAX is
not defined in system headers.

llvm-svn: 250946
2015-10-21 21:10:12 +00:00
Reid Kleckner e94fef7b3d [llvm-symbolizer] Make --relative-address work with DWARF contexts
Summary:
Previously the relative address flag only affected PDB debug info.  Now
both DIContext implementations always expect to be passed virtual
addresses. llvm-symbolizer is now responsible for adding ImageBase to
module offsets when --relative-offset is passed.

Reviewers: zturner

Subscribers: llvm-commits

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

llvm-svn: 249784
2015-10-09 00:15:01 +00:00
Craig Topper 0013be16ff Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type extra times. NFC
llvm-svn: 248140
2015-09-21 05:32:41 +00:00
Frederic Riss 7bb12261a3 [dwarfdump] Do not apply relocations in mach-o files if there is no LoadedObjectInfo.
Not only do we not need to do anything to read correct values from the
object files, but the current logic actually wrongly applies twice the
section base address when there is no LoadedObjectInfo passed to the
DWARFContext creation (as the added test shows).

Simply do not apply any relocations on the mach-o debug info if there is
no load offset to apply.

llvm-svn: 245807
2015-08-23 04:44:21 +00:00