1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
Commit Graph

1859 Commits

Author SHA1 Message Date
Sourabh Singh Tomar
b4f51213cf Revert "[NFCI][DebugInfo]: Corrected a Typo."
This reverts commit 3e1090922a0b808f424ff424b744752b0d53a3ee
as per Paul Robinson's suggestion.
2020-02-21 01:15:09 +05:30
Igor Kudrin
36cf70c05c [DebugInfo] Read CIE pointer as a relocatable value.
The CIE pointer field of an FDE record contains an offset to
a corresponding CIE record. In object files, this value comes with
relocation because the value has to be fixed when a linker combines
the final section from multiple sources. In most object files there is
only one CIE record at offset 0 of the .debug_frame section, so reading
a relocated or a raw value makes no difference. However, in partially
linked object files there are multiple CIE records and the relocations
should be applied to recover the right offset value.

Differential Revision: https://reviews.llvm.org/D74612
2020-02-20 09:12:05 +07:00
Greg Clayton
76f7457508 Add an Offset field to the SourceLocation for LookupResult objects.
Summary:
The Offset provides the offset within the function in a SourceLocation struct. This allows us to show the byte offset within a function. We also track offsets within inline functions as well. Updated the lookup tests to verify the offset for functions and inline functions.

0x1000: main + 32 @ /tmp/main.cpp:45

Reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace, aprantl, JDevlieghere

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74680
2020-02-19 16:12:32 -08:00
Sourabh Singh Tomar
743f6f19e1 [NFCI][DebugInfo]: Corrected a Typo. 2020-02-17 14:50:32 +05:30
Greg Clayton
0f9e8cbf13 [NFC] Move ValidTextRanges out of DwarfTransformer and into GsymCreator and unify address is not in GSYM errors so all strings match. 2020-02-15 16:48:23 -08:00
Alexey Lapshin
4c1f969392 [Debuginfo][NFC] Remove usages of WithColor::error and WithColor::warning.
Summary:
This patch is extracted from D74308.

It patches all usages of WithColor::error() and WithColor::warning
in DebugInfoDWARF library.

Depends on D74481

Reviewers: jhenderson, dblaikie, probinson, aprantl, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74635
2020-02-15 14:18:45 +03:00
Alexey Lapshin
d1dbbf13e4 [Debuginfo][NFC] Create common error handlers for DWARFContext.
Summary:
this review is extracted from D74308.

It creates two error handlers which allow to redefine error
reporting routine and should be used for all places
where errors are reported:

  std::function<void(Error)> RecoverableErrorHandler = defaultErrorHandler;
  std::function<void(Error)> WarningHandler = defaultWarningHandler;

It also creates accessors to above handlers which should be used to
report errors.

  function_ref<void(Error)> getRecoverableErrorHandler() {
    return RecoverableErrorHandler;
  }

  function_ref<void(Error)> getWarningHandler() { return WarningHandler; }

It patches all error reporting places inside DWARFContext and DWARLinker.

Reviewers: jhenderson, dblaikie, probinson, aprantl, JDevlieghere

Reviewed By: jhenderson, JDevlieghere

Subscribers: hiraditya, llvm-commits

Tags: #llvm, #debug-info

Differential Revision: https://reviews.llvm.org/D74481
2020-02-15 12:46:17 +03:00
Fangrui Song
13339a0dea [MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex} 2020-02-14 23:08:40 -08:00
Fangrui Song
343c2a2b44 [MC] De-capitalize some MCStreamer::Emit* functions 2020-02-14 19:11:53 -08:00
Alexandre Ganea
ae05eb086d [Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and all NUMA groups
The goal of this patch is to maximize CPU utilization on multi-socket or high core count systems, so that parallel computations such as LLD/ThinLTO can use all hardware threads in the system. Before this patch, on Windows, a maximum of 64 hardware threads could be used at most, in some cases dispatched only on one CPU socket.

== Background ==
Windows doesn't have a flat cpu_set_t like Linux. Instead, it projects hardware CPUs (or NUMA nodes) to applications through a concept of "processor groups". A "processor" is the smallest unit of execution on a CPU, that is, an hyper-thread if SMT is active; a core otherwise. There's a limit of 32-bit processors on older 32-bit versions of Windows, which later was raised to 64-processors with 64-bit versions of Windows. This limit comes from the affinity mask, which historically is represented by the sizeof(void*). Consequently, the concept of "processor groups" was introduced for dealing with systems with more than 64 hyper-threads.

By default, the Windows OS assigns only one "processor group" to each starting application, in a round-robin manner. If the application wants to use more processors, it needs to programmatically enable it, by assigning threads to other "processor groups". This also means that affinity cannot cross "processor group" boundaries; one can only specify a "preferred" group on start-up, but the application is free to allocate more groups if it wants to.

This creates a peculiar situation, where newer CPUs like the AMD EPYC 7702P (64-cores, 128-hyperthreads) are projected by the OS as two (2) "processor groups". This means that by default, an application can only use half of the cores. This situation could only get worse in the years to come, as dies with more cores will appear on the market.

== The problem ==
The heavyweight_hardware_concurrency() API was introduced so that only *one hardware thread per core* was used. Once that API returns, that original intention is lost, only the number of threads is retained. Consider a situation, on Windows, where the system has 2 CPU sockets, 18 cores each, each core having 2 hyper-threads, for a total of 72 hyper-threads. Both heavyweight_hardware_concurrency() and hardware_concurrency() currently return 36, because on Windows they are simply wrappers over std:🧵:hardware_concurrency() -- which can only return processors from the current "processor group".

== The changes in this patch ==
To solve this situation, we capture (and retain) the initial intention until the point of usage, through a new ThreadPoolStrategy class. The number of threads to use is deferred as late as possible, until the moment where the std::threads are created (ThreadPool in the case of ThinLTO).

When using hardware_concurrency(), setting ThreadCount to 0 now means to use all the possible hardware CPU (SMT) threads. Providing a ThreadCount above to the maximum number of threads will have no effect, the maximum will be used instead.
The heavyweight_hardware_concurrency() is similar to hardware_concurrency(), except that only one thread per hardware *core* will be used.

When LLVM_ENABLE_THREADS is OFF, the threading APIs will always return 1, to ensure any caller loops will be exercised at least once.

Differential Revision: https://reviews.llvm.org/D71775
2020-02-14 10:24:22 -05:00
James Henderson
a0c4d6a1cc [DebugInfo] Error if unsupported address size detected in line table
Prior to this patch, if a DW_LNE_set_address opcode was parsed with an
address size (i.e. with a length after the opcode) of anything other 1,
2, 4, or 8, an llvm_unreachable would be hit, as the data extractor does
not support other values. This patch introduces a new error check that
verifies the address size is one of the supported sizes, in common with
other places within the DWARF parsing.

This patch also fixes calculation of a generated line table's size in
unit tests. One of the tests in this patch highlighted a bug introduced
in 1271cde4745, when non-byte operands were used as arguments for
extended or standard opcodes.

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D73962
2020-02-14 11:08:12 +00:00
Francesco Petrogalli
236754c773 [build] Fix shared lib builds. 2020-02-13 22:09:52 +00:00
Greg Clayton
32dd03dc63 Fix buildbots that create shared libraries from GSYM library by adding a dependency on LLVMDebugInfoDWARF. 2020-02-13 11:43:07 -08:00
Greg Clayton
e962ea1e6c Fix buildbots by not using "and" and "not". 2020-02-13 11:35:43 -08:00
Greg Clayton
ccea019faf Add a DWARF transformer class that converts DWARF to GSYM.
Summary:
The DWARF transformer is added as a class so it can be unit tested fully.

The DWARF is converted to GSYM format and handles many special cases for functions:
- omit functions in compile units with 4 byte addresses whose address is UINT32_MAX (dead stripped)
- omit functions in compile units with 8 byte addresses whose address is UINT64_MAX (dead stripped)
- omit any functions whose high PC is <= low PC (dead stripped)
- StringTable builder doesn't copy strings, so we need to make backing copies of strings but only when needed. Many strings come from sections in object files and won't need to have backing copies, but some do.
- When a function doesn't have a mangled name, store the fully qualified name by creating a string by traversing the parent decl context DIEs and then. If we don't do this, we end up having cases where some function might appear in the GSYM as "erase" instead of "std::vector<int>::erase".
- omit any functions whose address isn't in the optional TextRanges member variable of DwarfTransformer. This allows object file to register address ranges that are known valid code ranges and can help omit functions that should have been dead stripped, but just had their low PC values set to zero. In this case we have many functions that all appear at address zero and can omit these functions by making sure they fall into good address ranges on the object file. Many compilers do this when the DWARF has a DW_AT_low_pc with a DW_FORM_addr, and a DW_AT_high_pc with a DW_FORM_data4 as the offset from the low PC. In this case the linker can't write the same address to both the high and low PC since there is only a relocation for the DW_AT_low_pc, so many linkers tend to just zero it out.

Reviewers: aprantl, dblaikie, probinson

Subscribers: mgorny, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74450
2020-02-13 10:48:37 -08:00
Igor Kudrin
2da0ac3ddb [DebugInfo] Fix dumping CIE ID in .eh_frame sections.
We do not keep the actual value of the CIE ID field, because it is
predefined, and use a constant when dumping a CIE record. The issue
was that the predefined value is different for .debug_frame and
.eh_frame sections, but we always printed the one which corresponds
to .debug_frame. The patch fixes that by choosing an appropriate
constant to print.

See the following for more information about .eh_frame sections:
https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html

Differential Revision: https://reviews.llvm.org/D73627
2020-02-13 15:42:14 +07:00
Sven van Haastregt
9c2e7dd6ae Add missing newlines at EOF; NFC 2020-02-12 15:57:25 +00:00
James Henderson
28d5339ea7 [DebugInfo] Add checks for v2 directory and file name table terminators
The DWARFv2-4 specification for the line table header states that the
include directories and file name tables both end with a single null
byte. Prior to this change, the parser did not detect if this byte was
missing, because it also stopped reading the tables once it reached the
prologue end, as claimed by the header_length field. This change adds a
check that the terminator has been seen at the end of each table.

Reviewed by: dblaikie, MaskRay

Differential Revision: https://reviews.llvm.org/D74413
2020-02-12 14:49:22 +00:00
James Henderson
9d0fa600e4 [DebugInfo] Add check for zero debug line opcode_base
The number of standard opcodes is defined to be opcode_base - 1, so a
value of 0 for the opcode_base caused a crash as an attempt was made to
reserve many entries in a vector. This change fixes the crash, by
issuing a warning and skipping reading of standard opcode lengths in the
event of an opcode_base of 0.

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D74309
2020-02-12 14:49:22 +00:00
James Henderson
dff704a989 [DebugInfo] Print version in error message in decimal
Also remove some test duplication and add a test case that shows the
maximum version is rejected (this also shows that the value in the error
message is actually in decimal, and not just missing an 0x prefix).

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D74403
2020-02-12 14:49:22 +00:00
Igor Kudrin
c206b32aa7 [DebugInfo] Add support for DWARF64 into DWARFDebugAddr.
Differential Revision: https://reviews.llvm.org/D74198
2020-02-12 13:33:01 +07:00
Igor Kudrin
98bbb1f23e [DebugInfo] Simplify DWARFDebugAddr.
The patch removes unnecessary members of DWARFDebugAddr and further
simplifies the implementation by separating parsing methods of tables
in the DWARFv5 and pre-standard formats.

Differential Revision: https://reviews.llvm.org/D74197
2020-02-12 13:33:00 +07:00
Igor Kudrin
70f13e0c61 [DebugInfo] Refine error messages in DWARFDebugAddr.
As a preparation for the subsequent patches, this updates the wordings
of some error messages in DWARFDebugAddr.

Differential Revision: https://reviews.llvm.org/D74196
2020-02-12 13:33:00 +07:00
Igor Kudrin
5c5156a6a9 [DebugInfo] Use "an address table" in diagnostic messages of DWARFDebugAddr.
This replaces a collocation "a .debug_addr table" with "an address table"
because the latter sounds more accurate.

Differential Revision: https://reviews.llvm.org/D74407
2020-02-12 13:33:00 +07:00
Igor Kudrin
80d0555a9c [DebugInfo] Do not dump header field for pre-DWARFv5 address tables.
As there is no header in pre-DWARFv5 address tables, and we fill
the class data members with some artificial values, we should not
dump them as that might be misleading.

Differential Revision: https://reviews.llvm.org/D74195
2020-02-12 13:33:00 +07:00
Igor Kudrin
aba0bf1de0 [DebugInfo] Fix reading addresses in DWARFDebugAddr.
As addresses in the address tables may have relocations, thus,
the relocations should be resolved to read the correct address.
That is especially important for targets that use RELA relocations
because in that case addends are stored in relocation sections.

Differential Revision: https://reviews.llvm.org/D74404
2020-02-12 13:32:59 +07:00
Sterling Augustine
ad25ac2e9f Allow retrieving source files relative to the compilation directory.
Summary:
Dwarf stores source-file names the three parts:
<compilation_directory><include_directory><filename>

Prior to this change, the code only allowed retrieving either all
three as the absolute path, or just the filename.  But many
compile-command lines--especially those in hermetic build systems
don't specify an absolute path, nor just the filename, but rather the
path relative to the compilation directory. This features allows
retrieving them in that style.

Add tests for path printing styles.

Modify createBasicPrologue to handle include directories.

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73383
2020-02-11 11:46:20 -08:00
Alexey Lapshin
fb26ef9c1c [Debuginfo][NFC] Rename error handling functions using the same pattern.
Summary:
That patch is extracted from https://reviews.llvm.org/D74308.
Currently there are two patterns to name error handling functions:
using "Callback" and "Handler". This patch uses "Handler" for all
usage places.

Reviewers: jhenderson, dblaikie, probinson, aprantl

Reviewed By: jhenderson, dblaikie

Subscribers: hiraditya, llvm-commits

Tags: #llvm, #debug-info

Differential Revision: https://reviews.llvm.org/D74354
2020-02-11 14:50:53 +03:00
Bill Wendling
0816222e8f Revert "Remove redundant "std::move"s in return statements"
The build failed with

  error: call to deleted constructor of 'llvm::Error'

errors.

This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10 07:07:40 -08:00
James Henderson
f0566b59e2 [DebugInfo] Reject line tables of version > 5
If a debug line section with version of greater than 5 is encountered,
prior to this change the parser would accept it and treat it as version
5. This might work to some extent, but then it might not at all, as it
really depends on the format of the unspecified future version, which
will be different (otherwise there would be no point in changing the
version number). Any information we could provide has a good chance of
being invalid, so we should just refuse to parse such tables.

Reviewed by: dblaikie, MaskRay

Differential Revision: https://reviews.llvm.org/D74204
2020-02-10 14:43:10 +00:00
Bill Wendling
e45b5f33f3 Remove redundant "std::move"s in return statements 2020-02-10 06:39:44 -08:00
Fangrui Song
db8bcae104 [DebugInfo] Add a DWARFDataExtractor constructor that takes ArrayRef<uint8_t>
Similar to D67797 (DataExtractor).
2020-02-09 17:45:32 -08:00
Igor Kudrin
17419b129b [DebugInfo] Allow reading an address table with a mismatched address.
This case does not look as an unrecoverable error.

Differential Revision: https://reviews.llvm.org/D74194
2020-02-08 20:00:03 +07:00
Benjamin Kramer
61932f0a34 Use heterogenous lookup for std;:map<std::string with a StringRef. NFCI. 2020-02-08 13:28:29 +01:00
David Blaikie
e22892d408 DebugInfo: Allow dumping macinfo and macinfo.dwo from the same file
If dumping an Split DWARF file that hasn't been split into separate
files (such as from llc - that includes the plain and .dwo sections in
the same file) allow both macinfo and macinfo.dwo sections to be dumped.
2020-01-31 12:47:50 -08:00
Igor Kudrin
2e7956d059 [DWARF] Add support for 64-bit DWARF in .debug_names.
Differential Revision: https://reviews.llvm.org/D72900
2020-01-31 16:12:35 +07:00
James Henderson
076adf9c49 [DebugInfo] Fix DebugLine::Prologue::getLength
The function a) returned 32-bits when in DWARF64, the PrologueLength
field is 64-bits in size, and b) didn't work for DWARF version 5.

Also deleted some related dead code. With this deletion, getLength is
itself dead, but another change is about to make use of it.

Reviewed by: probinson

Differential Revision: https://reviews.llvm.org/D73626
2020-01-30 09:35:50 +00:00
Sterling Augustine
0474d30343 Print discriminators when printing .debug_line in GNU style.
Summary:
gnu addr2line prints DWARF line table discriminators like so:

<file>:<line> (discriminator <Number>)

This matches that behavior.

Document how and when --output-style=GNU prints discriminators

Add test for new GNU-style discriminator printing.

Reviewers: rupprecht, labath, jhenderson

Subscribers: aprantl, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73318
2020-01-29 12:22:12 -08:00
Sterling Augustine
287f3d0352 Handle non-absolute include dirs properly for both dwarf4 and dwarf5.
Summary:
Add test case for the same. This test case will also serve as a
starting point for later symbolizer tests.

Reviewers: dblaikie, jdoerfert

Subscribers: hiraditya, llvm-commits, jhenderson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73583
2020-01-29 10:51:51 -08:00
Adrian Prantl
212647e67d Add dwarfdump support for DW_OP_regval_type.
Differential Revision: https://reviews.llvm.org/D73598
2020-01-29 10:02:23 -08:00
James Henderson
0edcf38c7a [DebugInfo] Make most debug line prologue errors non-fatal to parsing
Many of the debug line prologue errors are not inherently fatal. In most
cases, we can make reasonable assumptions and carry on. This patch does
exactly that. In the case of length problems, the approach of "assume
stated length is correct" is taken which means the offset might need
adjusting.

This is a relanding of b94191fe, fixing an LLD test and the LLDB build.

Reviewed by: dblaikie, labath

Differential Revision: https://reviews.llvm.org/D72158
2020-01-29 10:23:41 +00:00
Benjamin Kramer
5313b54c46 One more batch of things found by g++ 6 2020-01-29 00:50:34 +01:00
Benjamin Kramer
87d13166c7 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
James Henderson
b93b2eeaa3 Revert "[DebugInfo] Make most debug line prologue errors non-fatal to parsing"
This reverts commit b94191fecdbadc18b342a27df1109754edcb8c4b.

The change broke both an LLD test and the LLDB build.
2020-01-28 11:49:30 +00:00
James Henderson
89524e5f12 [DebugInfo] Make most debug line prologue errors non-fatal to parsing
Many of the debug line prologue errors are not inherently fatal. In most
cases, we can make reasonable assumptions and carry on. This patch does
exactly that. In the case of length problems, the approach of "the
claimed length is correct" is taken to be consistent with other
instances such as the SectionParser, which ignores the read length.

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D72158
2020-01-28 11:29:50 +00:00
Petr Hosek
d81def4b19 [Symbolize] Handle error after the notes loop
We always have to check the error, even if we're going to ignore it.
2020-01-27 11:00:27 -08:00
James Henderson
a050bdcc58 [DebugInfo] Make incorrect debug line extended opcode length non-fatal
It is possible to try to keep parsing a debug line program even when the
length of an extended opcode does not match what is expected for that
opcode. This patch changes what was previously a fatal error to be
non-fatal. The parser now continues by assuming the the claimed length
is correct, even if it means moving the offset backwards.

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D72155
2020-01-27 15:32:41 +00:00
Igor Kudrin
70ab7c2444 [DWARF] Do not pass Version to DWARFExpression. NFCI.
The Version was used only to determine the size of an operand of
DW_OP_call_ref. The size was 4 for all versions apart from 2, but
the DW_OP_call_ref operation was introduced only in DWARF3. Thus,
the code may be simplified and using of Version may be eliminated.

Differential Revision: https://reviews.llvm.org/D73264
2020-01-27 19:08:46 +07:00
Igor Kudrin
b22a094351 [DWARF] Simplify DWARFExpression. NFC.
As DataExtractor already has a method to extract an unsigned value of
a specified size, there is no need to duplicate that.

Differential Revision: https://reviews.llvm.org/D73263
2020-01-27 19:08:46 +07:00
Reid Kleckner
c822eded13 [codeview] Prune SimpleTypeSerializer.h headers, NFC
These are left over from when the class was more complicated. Add a
header comment banner to the .cpp file, which was missing.
2020-01-24 16:07:36 -08:00