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

436 Commits

Author SHA1 Message Date
Kevin Enderby
92582f2b18 Thread Expected<...> up from libObject’s getName() for symbols to allow llvm-objdump to produce a good error message.
Produce another specific error message for a malformed Mach-O file when a symbol’s
string index is past the end of the string table.  The existing test case in test/Object/macho-invalid.test
for macho-invalid-symbol-name-past-eof now reports the error with the message indicating
that a symbol at a specific index has a bad sting index and that bad string index value.
 
Again converting interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. Where the existing code reported the error with a
string message or an error code it was converted to do the same.  There is some
code for this that could be factored into a routine but I would like to leave that for
the code owners post-commit to do as they want for handling an llvm::Error.  An
example of how this could be done is shown in the diff in
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine
already for std::error_code so I added one like it for llvm::Error .

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(NameOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there fixes needed to lld that goes along with this that I will commit right after this.
So expect lld not to built after this commit and before the next one.

llvm-svn: 266919
2016-04-20 21:24:34 +00:00
Zachary Turner
a1935c25dc [llvm-pdbdump] Print a better error message when PDB loading fails.
Differential Revision: http://reviews.llvm.org/D19234

llvm-svn: 266772
2016-04-19 17:36:58 +00:00
Nico Weber
aa94c4fba2 Unbreak building llvm-pdbdump on Windows after r266595.
llvm-svn: 266612
2016-04-18 13:31:31 +00:00
Mehdi Amini
9ff867f98c [NFC] Header cleanup
Removed some unused headers, replaced some headers with forward class declarations.

Found using simple scripts like this one:
clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap'

Patch by Eugene Kosov <claprix@yandex.ru>

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266595
2016-04-18 09:17:29 +00:00
Richard Smith
c8f9cc971a Update and fix LLVM_ENABLE_MODULES:
1) We need to add this flag prior to adding any other, in case the user has
specified a -fmodule-cache-path= flag in their custom CXXFLAGS. Such a flag
causes -Werror builds to fail, and thus all config checks fail, until we add
the corresponding -fmodules flag. The modules selfhost bot does this, for
instance.

2) Delete module maps that were putting .cpp files into modules.

3) Enable -fmodules-local-submodule-visibility, to get proper module
visibility rules applied across submodules of the same module. Disable
-fmodules for C builds, since that flag is not available there.

llvm-svn: 266502
2016-04-16 00:48:58 +00:00
Kevin Enderby
a6534d0295 Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message
Produce the first specific error message for a malformed Mach-O file describing
the problem instead of the generic message for object_error::parse_failed of
"Invalid data was encountered while parsing the file”.  Many more good error
messages will follow after this first one.

This is built on Lang Hames’ great work of adding the ’Error' class for
structured error handling and threading Error through MachOObjectFile
construction.  And making createMachOObjectFile return Expected<...> .

So to to get the error to the llvm-obdump tool, I changed the stack of
these methods to also return Expected<...> :

  object::ObjectFile::createObjectFile()
  object::SymbolicFile::createSymbolicFile()
  object::createBinary()

Then finally in ParseInputMachO() in MachODump.cpp the error can
be reported and the specific error message can be printed in llvm-objdump
and can be seen in the existing test case for the existing malformed binary
but with the updated error message.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now use of
errorToErrorCode() and errorOrToExpected() are used where the callers
are yet to be converted.

Also there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comment:
“// TODO: Actually report errors helpfully” and a call something like
consumeError(ObjOrErr.takeError()) so the buggy code will not crash
since needed to deal with the Error.

Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along
with this that I will commit right after this.  So expect lld not to built
after this commit and before the next one.

llvm-svn: 265606
2016-04-06 22:14:09 +00:00
Nico Weber
28540b41b5 Make DIASession work if msdia*.dll isn't registered.
This fixes various symbolization test failures for me when I build with a
hermetic VS2015 without having run the 2015 installer.

http://reviews.llvm.org/D18707

llvm-svn: 265193
2016-04-01 22:21:51 +00:00
Eugene Zelenko
f9e799a8d6 Fix Clang-tidy modernize-deprecated-headers warnings in some files; other minor fixes.
Differential revision: http://reviews.llvm.org/D18469

llvm-svn: 264598
2016-03-28 17:40:08 +00:00
Kevin Enderby
1a15e5c9c5 Fix a crash in running llvm-objdump -t with an invalid Mach-O file already
in the test suite. While this is not really an interesting tool and option to run
on a Mach-O file to show the symbol table in a generic libObject format
it shouldn’t crash.

The reason for the crash was in MachOObjectFile::getSymbolType() when it was
calling MachOObjectFile::getSymbolSection() without checking its return value
for the error case.

What makes this fix require a fair bit of diffs is that the method getSymbolType() is
in the class ObjectFile defined without an ErrorOr<> so I needed to add that all
the sub classes.  And all of the uses needed to be updated and the return value
needed to be checked for the error case.

The MachOObjectFile version of getSymbolType() “can” get an error in trying to
come up with the libObject’s internal SymbolRef::Type when the Mach-O symbol
symbol type is an N_SECT type because the code is trying to select from the
SymbolRef::ST_Data or SymbolRef::ST_Function values for the SymbolRef::Type.
And it needs the Mach-O section to use isData() and isBSS to determine if
it will return SymbolRef::ST_Data.

One other possible fix I considered is to simply return SymbolRef::ST_Other
when MachOObjectFile::getSymbolSection() returned an error.  But since in
the past when I did such changes that “ate an error in the libObject code” I
was asked instead to push the error out of the libObject code I chose not
to implement the fix this way.

As currently written both the COFF and ELF versions of getSymbolType()
can’t get an error.  But if isReservedSectionNumber() wanted to check for
the two known negative values rather than allowing all negative values or
the code wanted to add the same check as in getSymbolAddress() to use
getSection() and check for the error then these versions of getSymbolType()
could return errors.

At the end of the day the error printed now is the generic “Invalid data was
encountered while parsing the file” for object_error::parse_failed.  In the
future when we thread Lang’s new TypedError for recoverable error handling
though libObject this will improve.  And where the added // Diagnostic(…
comment is, it would be changed to produce and error message
like “bad section index (42) for symbol at index 8” for this case.

llvm-svn: 264187
2016-03-23 20:27:00 +00:00
Simon Atanasyan
1c312f2b01 [DebugInfo] Dump CIE augmentation data as a list of hex bytes
CIE augmentation data might contain non-printable characters.
The patch prints the data as a list of hex bytes.

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

llvm-svn: 262361
2016-03-01 18:38:05 +00:00
Zachary Turner
f3c152db24 [DebugInfoPDB] Add source / line number accessors for PDB.
This patch adds a variety of different methods to query source
and line number information from PDB files.

llvm-svn: 261239
2016-02-18 18:47:29 +00:00
Zachary Turner
341f9d58a9 [DebugInfoPDB] A few cleanups on PDB Variant class.
Also implements the PDBSymbolCompilandEnv::getValue() method,
which until now had been unimplemented specifically because
variant did not support string values.

llvm-svn: 261173
2016-02-17 22:46:33 +00:00
Zachary Turner
5f7b5f80e5 [DebugInfoPDB] Raise getSymIndexId() up to PDBSymbol
Every symbol, no matter what it's tag is, supports the method
getSymIndexId().  However, this was being forwarded on every
concrete symbol type, so if someone had a PDBSymbol that they
didn't know what type it was (or simply didn't have an instance
of the concrete symbol type), they would not be able to get its
index id.  This patch moves the method up to PDBSymbol, so that
no matter what type of object you have, you can always get its
id.

llvm-svn: 261153
2016-02-17 21:13:34 +00:00
Zachary Turner
e25dd60195 [DebugInfoPDB] Teach Variant to support string types.
The IDiaSymbol::getValue() method returns a variant.  Until now,
I had never encountered a string value, so the Variant wrapper
did not support VT_BSTR.  Now we have need to support string
values, so this patch just adds support for one extra type to
Variant.

llvm-svn: 261152
2016-02-17 21:13:15 +00:00
Dmitry Polukhin
53b2b4d2c5 [DebugInfo] Eliminate compilation warning about used variable LSDA
The waring was:
lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:643:20: warning: variable ‘LSDA’ set but not used

llvm-svn: 259877
2016-02-05 09:24:34 +00:00
Igor Laevsky
730e8cf8fe [DebugInfo] Support zero-length CIE in the _eh_frame parser
MCJIT emits zero-length CIE at the end of the _eh_frame section. This change
ensures that parser inside DebugInfo will not crash and correctly record such cases.
We are now recording DW_EH_PE_omit as a default value for FDE and LSDA encodings.
Also Offset != EndAugmentationOffset assertion check will only happen if augmentation 
string had 'z' letter in it.

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

llvm-svn: 258931
2016-01-27 14:05:35 +00:00
Chris Bieneman
1b8d4f74aa Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

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

llvm-svn: 258861
2016-01-26 21:29:08 +00:00
Igor Laevsky
7660fa06ad Re-submit r256008 "Improve DWARFDebugFrame::parse to also handle __eh_frame."
Originally this change was causing failures on windows buildbots.
But those problems were fixed in r258806.

llvm-svn: 258811
2016-01-26 15:09:42 +00:00
Igor Laevsky
3044550590 [DebugInfo] Fix DWARFDebugFrame instruction operand ordering
We can't rely on the evalution order of function arguments.

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

llvm-svn: 258806
2016-01-26 13:31:11 +00:00
Reid Kleckner
e09e813e57 Fix instance of -Wcovered-switch-default
llvm-svn: 257665
2016-01-13 20:39:22 +00:00
Reid Kleckner
0f638161ba [readobj] Expand CodeView dumping functionality
This rewrites and expands the existing codeview dumping functionality in
llvm-readobj using techniques similar to those in lib/Object. This defines a
number of new records and enums useful for reading memory mapped codeview
sections in COFF objects.

The dumper is intended as a testing tool for LLVM as it grows more codeview
output capabilities.

Reviewers: majnemer

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

llvm-svn: 257658
2016-01-13 19:32:35 +00:00
Mike Aizatsky
6e3d95bf83 fixing type.
llvm-svn: 257238
2016-01-09 00:31:56 +00:00
NAKAMURA Takumi
8100f735c4 llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp: Fix build in -m32. 1L is incompatible to int64_t.
llvm-svn: 257237
2016-01-09 00:28:50 +00:00
Mike Aizatsky
d03c218611 [llvm-symbolizer] -print-source-context-lines option to print source code around the line.
Differential Revision: http://reviews.llvm.org/D15909

llvm-svn: 257236
2016-01-09 00:14:35 +00:00
Dimitry Andric
0614f2a55e Fix several accidental DOS line endings in source files
Summary:
There are a number of files in the tree which have been accidentally checked in with DOS line endings.  Convert these to native line endings.

There are also a few files which have DOS line endings on purpose, and I have set the svn:eol-style property to 'CRLF' on those.

Reviewers: joerg, aaron.ballman

Subscribers: aaron.ballman, sanjoy, dsanders, llvm-commits

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

llvm-svn: 256707
2016-01-03 17:22:03 +00:00
Dave Bartolomeo
41b83cb4b3 Remove unused constants from TypeTableBuilder.cpp.
llvm-svn: 256389
2015-12-24 19:15:56 +00:00
Bill Seurer
70c5357899 Fix case of path name
llvm-svn: 256388
2015-12-24 18:54:35 +00:00
Dave Bartolomeo
ad4baf3a5d Fix CodeView library name and non-CMake builds
llvm-svn: 256387
2015-12-24 18:51:35 +00:00
Dave Bartolomeo
5c39fdd192 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
e2d62e9cd1 [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
cda523f460 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
70c961d67d 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
b69868319a Test commit
llvm-svn: 255926
2015-12-17 20:54:16 +00:00
David Blaikie
3fd553d9d8 [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
0fc2f90156 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
566497d4a9 [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
3719678673 [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
f9c69f76b7 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
b7ffd27077 Fix null dereference committed in r253277
llvm-svn: 253393
2015-11-17 22:39:26 +00:00
David Blaikie
73ea0a7369 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
60b032961b 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
11eb1233c6 Fix indentation
llvm-svn: 253278
2015-11-17 00:41:02 +00:00
David Blaikie
ff19b0c37b 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
0e901207cf 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
374f90d746 [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
e2bb8d73ce 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
4226881aba 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
58bed1b8ac dwarfdump: Add error checking to fix the buildbots/correctness
llvm-svn: 252845
2015-11-12 01:57:33 +00:00
David Blaikie
d204740e82 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
32cdbf70c5 dwarfdump: Dump the contents of DWP indexes
llvm-svn: 252842
2015-11-12 01:41:52 +00:00