Commit Graph

492 Commits

Author SHA1 Message Date
Pavel Labath 0ace98c9df ObjectFileELF: Add support for gnu-style compressed sections
With this style, a compressed section is indicated by a "z" in the section
name, instead of a section header flag. This patch consists of two small tweaks:
- use an llvm Decompressor method in order to properly detect compressed sections
- make sure we recognise .zdebug_info (and friends) when classifying section types.

llvm-svn: 365654
2019-07-10 16:10:43 +00:00
Pavel Labath a1c64dcdec [DWARF] Add one more type unit test
This test passes already, but it seems interesting to test that we can
jump between type units in different dwo files nonetheless.

llvm-svn: 364890
2019-07-02 07:57:08 +00:00
Jan Kratochvil 3f594ed168 Fix lookup of symbols at the same address with no size vs. size
This fixes a failing testcase on Fedora 30 x86_64 (regression Fedora 29->30):

PASS:
./bin/lldb ./lldb-test-build.noindex/functionalities/unwind/noreturn/TestNoreturnUnwind.test_dwarf/a.out -o 'settings set symbols.enable-external-lookup false' -o r -o bt -o quit
  * frame #0: 0x00007ffff7aa6e75 libc.so.6`__GI_raise + 325
    frame #1: 0x00007ffff7a91895 libc.so.6`__GI_abort + 295
    frame #2: 0x0000000000401140 a.out`func_c at main.c:12:2
    frame #3: 0x000000000040113a a.out`func_b at main.c:18:2
    frame #4: 0x0000000000401134 a.out`func_a at main.c:26:2
    frame #5: 0x000000000040112e a.out`main(argc=<unavailable>, argv=<unavailable>) at main.c:32:2
    frame #6: 0x00007ffff7a92f33 libc.so.6`__libc_start_main + 243
    frame #7: 0x000000000040106e a.out`_start + 46

vs.

FAIL - unrecognized abort() function:
./bin/lldb ./lldb-test-build.noindex/functionalities/unwind/noreturn/TestNoreturnUnwind.test_dwarf/a.out -o 'settings set symbols.enable-external-lookup false' -o r -o bt -o quit
  * frame #0: 0x00007ffff7aa6e75 libc.so.6`.annobin_raise.c + 325
    frame #1: 0x00007ffff7a91895 libc.so.6`.annobin_loadmsgcat.c_end.unlikely + 295
    frame #2: 0x0000000000401140 a.out`func_c at main.c:12:2
    frame #3: 0x000000000040113a a.out`func_b at main.c:18:2
    frame #4: 0x0000000000401134 a.out`func_a at main.c:26:2
    frame #5: 0x000000000040112e a.out`main(argc=<unavailable>, argv=<unavailable>) at main.c:32:2
    frame #6: 0x00007ffff7a92f33 libc.so.6`.annobin_libc_start.c + 243
    frame #7: 0x000000000040106e a.out`.annobin_init.c.hot + 46

The extra ELF symbols are there due to Annobin (I did not investigate why this problem happened specifically since F-30 and not since F-28).
It is due to:

Symbol table '.dynsym' contains 2361 entries:
Valu e          Size Type   Bind   Vis     Name
0000000000022769   5 FUNC   LOCAL  DEFAULT _nl_load_domain.cold
000000000002276e   0 NOTYPE LOCAL  HIDDEN  .annobin_abort.c.unlikely
...
000000000002276e   0 NOTYPE LOCAL  HIDDEN  .annobin_loadmsgcat.c_end.unlikely
...
000000000002276e   0 NOTYPE LOCAL  HIDDEN  .annobin_textdomain.c_end.unlikely
000000000002276e 548 FUNC   GLOBAL DEFAULT abort
000000000002276e 548 FUNC   GLOBAL DEFAULT abort@@GLIBC_2.2.5
000000000002276e 548 FUNC   LOCAL  DEFAULT __GI_abort
0000000000022992   0 NOTYPE LOCAL  HIDDEN  .annobin_abort.c_end.unlikely

Differential Revision: https://reviews.llvm.org/D63540

llvm-svn: 364773
2019-07-01 14:31:26 +00:00
Pavel Labath fcad3bc415 DWARF: Add support for type units+split dwarf combo
Summary:
With the last round of refactors, supporting type units in dwo files
becomes almost trivial. This patch contains a couple of small fixes,
which taken as a whole make type units work in the split dwarf scenario
(both DWARF4 and DWARF5):
- DWARFContext: make sure we actually read the debug_types.dwo section
- DWARFUnit: set string offsets base on all units in the dwo file, not
  just the main CU
- ManualDWARFIndex: index all units in the file
- SymbolFileDWARFDwo: Search for the single compile unit in the file, as
  we can no longer assume it will be the first one

The last part makes it obvious that there is still some work to be done
here, namely that we do not support dwo files with multiple compile
units. That is something that should be easier after the DIERef
refactors, but it still requires more work.

Tests are added for the type units+split dwarf + dwarf4/5 scenarios, as
well as a test that checks we behave reasonably in the presence of dwo
files with multiple CUs.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: arphaman, lldb-commits

Differential Revision: https://reviews.llvm.org/D63643

llvm-svn: 364274
2019-06-25 06:59:48 +00:00
Adrian Prantl c8e8b274f1 Reapply "Fix a crash in option parsing."
with an additional read-out-of-bounds bugfix applied.

Differential Revision: https://reviews.llvm.org/D63110

llvm-svn: 364260
2019-06-25 00:55:27 +00:00
Jonas Devlieghere 892f022ec2 [lit] Deduplicate logic in toolchain.py
No need to compute the path of lit-lldb-init twice.

llvm-svn: 364113
2019-06-21 23:12:25 +00:00
Jonas Devlieghere 1c6fc7d70d [lit] Make lit-lldb-init configurable by CMake
This makes the `lit-lldb-init` file configurable by CMake. This matters
to us downstream in Swift, where we want to set environment variables
with the `env` command for every test.

Differential revision: https://reviews.llvm.org/D63679

llvm-svn: 364112
2019-06-21 23:12:22 +00:00
Pavel Labath 3b9269882e DWARF: Add "dwo_num" field to the DIERef class
Summary:
When dwo support was introduced, it used a trick where debug info
entries were referenced by the offset of the compile unit in the main
file, but the die offset was relative to the dwo file. Although there
was some elegance to it, this representation was starting to reach its
breaking point:
- the fact that the skeleton compile unit owned the DWO file meant that
  it was impossible (or at least hard and unintuitive) to support DWO
  files containing more than one compile unit. These kinds of files are
  produced by LTO for example.
- it made it impossible to reference any DIEs in the skeleton compile
  unit (although the skeleton units are generally empty, clang still
  puts some info into them with -fsplit-dwarf-inlining).
- (current motivation) it made it very hard to support type units placed
  in DWO files, as type units don't have any skeleton units which could
  be referenced in the main file

This patch addresses this problem by introducing an new
"dwo_num" field to the DIERef class, whose purpose is to identify the
dwo file. It's kind of similar to the dwo_id field in DWARF5 unit
headers, but while this is a 64bit hash whose main purpose is to catch
file mismatches, this is just a smaller integer used to indentify a
loaded dwo file. Currently, this is based on the index of the skeleton
compile unit which owns the dwo file, but it is intended to be
eventually independent of that (to support the LTO use case).

Simultaneously the cu_offset is dropped to conserve space, as it is no
longer necessary.  This means we can remove the "BaseObjectOffset" field
from the DWARFUnit class. It also means we can remove some of the
workarounds put in place to support the skeleton-unit+dwo-die combo.
More work is needed to remove all of them, which is out of scope of this
patch.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: mehdi_amini, dexonsmith, arphaman, lldb-commits

Differential Revision: https://reviews.llvm.org/D63428

llvm-svn: 364009
2019-06-21 07:56:50 +00:00
Davide Italiano 0cdae2681a Revert "Fix a crash in option parsing."
This fails on the bots around 1/10 of the time.

llvm-svn: 363999
2019-06-20 23:44:37 +00:00
Jonas Devlieghere c470ac50a8 [Reproducers] Make reproducer relocatable
Before this patch, reproducers weren't relocatable. The reproducer
contained hard coded paths in the VFS mapping, as well in the yaml file
listing the different input files for the command interpreter. This
patch changes that:

 - Use relative paths for the DataCollector.
 - Use an overlay prefix for the FileCollector.

Differential revision: https://reviews.llvm.org/D63467

llvm-svn: 363697
2019-06-18 16:20:17 +00:00
Jan Kratochvil 8c82c41262 [lldb] [test] Extend D55859 symbols.enable-external-lookup=false for more testcases
D55859 <https://reviews.llvm.org/D55859> has no effect for some of the
testcases so this patch extends it even for (all?) other testcases known to me.
LLDB was failing when LLDB prints errors reading system debug infos
(`*-debuginfo.rpm`, DWZ-optimized) which should never happen as LLDB testcases
should not be affected by system debug infos.

`lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template` is
using only SB API which does not expose `ModuleList` so I had to call
`HandleCommand()` there.

`lldb-test.cpp` could also use `HandleCommand` and then there would be no need
for `ModuleListProperties::SetEnableExternalLookup()` but I think it is cleaner
with API and not on based on text commands.

Differential Revision: https://reviews.llvm.org/D63339

llvm-svn: 363567
2019-06-17 14:46:17 +00:00
Pavel Labath ad17e289f0 DWARF: Don't create lldb CompileUnits for DWARF type units
Summary:
Type units don't represent actual compilations and a lot of the
operations that we do with lldb compile units (getting their line
tables, variables, etc.) don't make sense for them. There is also a lot
more of them (sometimes over 100x), so making them more lightweight pays
off.

The main change in this patch is that we stop creating lldb CompileUnits
for DWARF type units. The trickiest part here is that the SymbolFile
interface requires that we assign consecutive sequence IDs to the
compile units we create. As DWARF type and compile units can come in any
order (in v5), this means we can no longer use 1-1 mapping between DWARF
and lldb compile units. Instead I build a translation table between the
two indices. To avoid pessimizing the case where there are no type
units, I build the translation table only in case we have at least one
type unit.

Additionaly, I also tried to strenghted type safete by replacing
DWARFUnit with DWARFCompileUnit where applicable. Though that was not
stricly necessary, I found it a good way to ensure that the
transformations I am doing here make sense. In the places where I was
changing the function signatures, and where it was obvious that the
objects being handled were not null, I also replaced pointers with
references.

There shouldn't be any major functional change with this patch. The only
change I observed is that now the types in the type units will not be
parsed when one calls Module::ParseAllDebugSymbols, unless they are
referenced from other compile units. This makes sense, given how
ParseAllDebugSymbols is implemented (it iterates over all compile
units), and it only matters for one hand-writted test where I did not
bother to reference the types from the compile units (which I now do).

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D63005

llvm-svn: 363250
2019-06-13 11:22:47 +00:00
Jonas Devlieghere c2e2df7f7a [Reproducers] Include lldb version in the reproducer root
Generally, reproducers are rev-locked to the version of LLDB, so it's
valuable to have the LLDB version in the reproducer. For now I just want
the information to be present, without enforcing it, but I envision
emitting a warning during replay in the future.

Differential revision: https://reviews.llvm.org/D63229

llvm-svn: 363225
2019-06-13 04:35:22 +00:00
Pavel Labath ad805ef95a Recognise debug_types.dwo as a debug info section
This is a preparatory patch to allow reading type units from dwo files.

llvm-svn: 363146
2019-06-12 11:42:42 +00:00
Pavel Labath ca9c3de17e DWARF: Share line tables of type units
Summary:
This patch creates a cache of file lists in line tables referenced by
type units.  This cache is used to avoid parsing a line table twice
(since a file list will generally be shared by many type units).

It also sets things up in a way that parsing of DW_AT_decl_file
attributes will keep working even when we stop creating lldb compile
units for dwarf type units, but it stops short of actually doing that.
This means that the request for files now go directly to SymbolFileDWARF
instead of being routed there indirectly via the
lldb_private::CompileUnit class.

As a result of this, a number of occurences of SymbolContext variables
in DWARFASTParserClang have become unused, so I remove them.

This patch reduces the number of times a file list is being parsed, but
the situation is still suboptimal, as the parsed list is being copied
multiple times. This will be fixed when we stop creating CompileUnits
for DWARF type units.

Reviewers: clayborg, aprantl, JDevlieghere

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D62894

llvm-svn: 363143
2019-06-12 11:29:50 +00:00
Adrian Prantl e6130a3090 Fix a crash in option parsing.
The call to getopt_long didn't handle the case where the *last* option
had an argument missing.

<rdar://problem/51231882>

Differential Revision: https://reviews.llvm.org/D63110

llvm-svn: 363101
2019-06-11 21:14:02 +00:00
Pavel Labath 5e173dc5ea Breakpad: Add support for the arm64e "architecture"
llvm-svn: 362960
2019-06-10 16:21:26 +00:00
Pavel Labath c573032ded Add "REQUIRES: x86" to DWARF assembly tests
These tests don't require an x86 host, but they do require that we build
the x86 llvm target.

llvm-svn: 362948
2019-06-10 15:08:00 +00:00
Stefan Granitz 088410ffc6 [CMake] Add special case for processing LLDB_DOTEST_ARGS
Summary:
Allow to run the test suite when building LLDB Standalone with Xcode against a provided LLVM build-tree that used a single-configuration generator like Ninja.

So far both test drivers, lit-based `check-lldb` as well as `lldb-dotest`, were looking for test dependencies (clang/dsymutil/etc.) in a subdirectory with the configuration name (Debug/Release/etc.). It was implicitly assuming that both, LLDB and the provided LLVM used the same generator. In practice, however, the opposite is quite common: build the dependencies with Ninja and LLDB with Xcode for development*. With this patch it becomes the default.

(* In fact, it turned out that the Xcode<->Xcode variant didn't even build out of the box. It's fixed since D62879)

Once this is sound, I'm planning the following steps:
* add stage to the [lldb-cmake-standalone bot](http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/) to build and test it
* update `Building LLDB with Xcode` section in the docs
* bring the same mechanism to swift-lldb
* fade out the manually maintained Xcode project

On macOS build and test like this:
```
$ git clone https://github.com/llvm/llvm-project.git /path/to/llvm-project

$ cd /path/to/lldb-dev-deps
$ cmake -GNinja -C/path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" /path/to/llvm-project/llvm
$ ninja

$ cd /path/to/lldb-dev-xcode
$ cmake -GXcode -C/path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake -DLLDB_BUILD_FRAMEWORK=Off -DLLVM_DIR=/path/to/lldb-dev-deps/lib/cmake/llvm -DClang_DIR=/path/to/lldb-dev-deps/lib/cmake/clang /path/to/llvm-project/lldb
$ xcodebuild -configuration Debug -target check-lldb
$ xcodebuild -configuration Debug -target lldb-dotest
$ ./Debug/bin/lldb-dotest
```

Reviewers: JDevlieghere, jingham, xiaobai, stella.stamenova, labath

Reviewed By: stella.stamenova

Subscribers: labath, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D62859

llvm-svn: 362803
2019-06-07 14:32:51 +00:00
Pavel Labath da7f033693 Ignore DIEs in the skeleton unit in a DWO scenario
Summary:
r362103 exposed a bug, where we could read incorrect data if a skeleton
unit contained more than the single unit DIE. Clang emits these kinds of
units with -fsplit-dwarf-inlining (which is also the default).

Changing lldb to handle these DIEs is nontrivial, as we'd have to change
the UID encoding logic to be able to reference these DIEs, and fix up
various places which are assuming that all DIEs come from the separate
compile unit.

However, it turns out this is not necessary, as the DWO unit contains
all the information that the skeleton unit does. So, this patch just
skips parsing the extra DIEs if we have successfully found the DWO file.
This enforces the invariant that the rest of the code is already
operating under.

This patch fixes a couple of existing tests, but I've also included a
simpler test which does not depend on execution of binaries, and would
have helped us in catching this sooner.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: probinson, dblaikie, lldb-commits

Differential Revision: https://reviews.llvm.org/D62852

llvm-svn: 362586
2019-06-05 07:29:55 +00:00
Jonas Devlieghere a33964b570 [FormatEntity] Ignore ASCII escape sequences when colors are disabled.
This patch makes the FormatEntity honor the debugger's color settings by
not inserting ASCII escape sequences when colors are disabled.

Differential revision: https://reviews.llvm.org/D62714

llvm-svn: 362240
2019-05-31 16:27:44 +00:00
Pavel Labath 78cfe1e6fe DWARF: Fix address range support in mixed 4+5 scenario
Summary:
debug_ranges got renamed to debug_rnglists in DWARF 5. Prior to this
patch lldb was just picking the first section it could find in the file,
and using that for all address ranges lookups. This is not correct in
case the file contains a mixture of compile units with various standard
versions (not a completely unlikely scenario).

In this patch I make lldb support reading from both sections
simulaneously, and decide the correct section to use based on the
version number of the compile unit. SymbolFileDWARF::DebugRanges is
split into GetDebugRanges and GetDebugRngLists (the first one is renamed
mainly so we can catch all incorrect usages).

I tried to structure the code similarly to how llvm handles this logic
(hence DWARFUnit::FindRnglistFromOffset/Index), but the implementations
are still relatively far from each other.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D62302

llvm-svn: 361938
2019-05-29 09:22:36 +00:00
Stefan Granitz a3388e5f9e [CMake] Folder structure for generated Xcode project to cover more targets
llvm-svn: 361799
2019-05-28 09:29:05 +00:00
Pavel Labath 5a500fd2c5 XFAIL prefer-debug-over-eh-frame.test on darwin
debug_frame does not seem to work on darwin, so there is nothing to
prefer.

Adding `-g` to the compiler command line is enough to get the
__debug_frame section added to the dsym file. Though lldb then finds the
section, and correctly assigns the section type to it, this does not
seem to be enough to get lldb to actually use this section for
unwinding.

llvm-svn: 361760
2019-05-27 13:43:01 +00:00
Pavel Labath 2b5f340bcb DWARF: Add a simple test exercising debug_loc parsing
llvm-svn: 361759
2019-05-27 13:23:23 +00:00
Pavel Labath ae4ec62cc9 FuncUnwinders: prefer debug_frame over eh_frame
The two sections usually contain the same information, and we rarely
have both kinds of entries for a single function. However, in theory the
debug_frame plan can be more complete, whereas eh_frame is only required
to be correct at places where exceptions can be thrown.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D62374

llvm-svn: 361758
2019-05-27 11:53:24 +00:00
Pavel Labath 1a0312ca0b [FuncUnwinders] Use "symbol file" unwind plans for unwinding
Summary:
Previous patch (r360409) introduced the "symbol file unwind plan"
concept, but that plan wasn't used for unwinding yet. With this patch,
we start to consider the new plan as a possible strategy for both
synchronous and asynchronous unwinding. I also add a test that asserts
that unwinding via breakpad STACK CFI info works end-to-end.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits, amccarth, markmentovai

Differential Revision: https://reviews.llvm.org/D61853

llvm-svn: 361618
2019-05-24 09:54:39 +00:00
Pavel Labath f750842c8b DWARF: Implement DW_AT_signature lookup for type unit support
Summary:
This patch implements the main feature of type units. When completing a
type, if we encounter a DW_AT_signature attribute, we use it's value to
lookup the complete definition of the type in the relevant type unit.

To enable this lookup, we build up a map of all type units in a symbol
file when parsing the units. Then we consult this map when resolving the
DW_AT_signature attribute.

I include add a couple of tests which exercise the type lookup feature,
including one that ensure we do something reasonable in case we fail to
lookup the type.

A lot of the ideas in this patch have been taken from D32167 and D61505.

Reviewers: clayborg, JDevlieghere, aprantl, alexshap

Subscribers: mgrang, lldb-commits

Differential Revision: https://reviews.llvm.org/D62246

llvm-svn: 361603
2019-05-24 08:11:12 +00:00
Pavel Labath 8ac0bc9832 DWARFContext: Make loading of sections thread-safe
Summary:
SymbolFileDWARF used to load debug sections in a thread-safe manner.
When we moved to DWARFContext, we dropped the thread-safe part, because
we thought it was not necessary.

It turns out this was only mostly correct.

The "mostly" part is there because this is a problem only if we use the
manual index, as that is the only source of intra-module paralelism.
Also, this only seems to occur for extremely simple files (like the ones
I've been creating for tests lately), where we've managed to start
indexing before loading the debug_str section. Then, two threads start
to load the section simultaneously and produce wrong results.

On more complex files, something seems to be loading the debug_str section
before we start indexing, as I haven't been able to reproduce this
there, but I have not investigated what it is.

I've tried to come up with a test for this, but I haven't been able to
reproduce the problem reliably. Still, while doing so, I created a way
to generate many compile units on demand. Given that most of our tests
work with only one or two compile units, it seems like this could be
useful anyway.

Reviewers: aprantl, JDevlieghere, clayborg

Subscribers: arphaman, lldb-commits

Differential Revision: https://reviews.llvm.org/D62316

llvm-svn: 361602
2019-05-24 08:04:03 +00:00
Pavel Labath f95b05c3df Add REQUIRES: lld to debug-types-address-ranges.s
This should fix the green dragon bots.

llvm-svn: 361481
2019-05-23 10:46:35 +00:00
Pavel Labath 324396466c DWARF: Don't compute address ranges for type units
Summary:
Type units don't describe any code, so they should never be the result
of any address lookup queries.

Previously, we would compute the address ranges for the type units for
via the line tables they reference because the type units looked a lot
like line-tables-only compile units. However, this is not correct, as
the line tables are only referenced from type units so that other
declarations can use the file names contained in them.

In this patch I make the BuildAddressRangeTable function virtual, and
implement it only for compile units.

Testing this was a bit tricky, because the behavior depends on the order
in which we add things to the address range map. This rarely caused a
problem with DWARF v4 type units, as they are always added after all
CUs. It happened more frequently with DWARF v5, as there clang emits the
type units first. However, this is still not something that it is
required to do, so for testing I've created an assembly file where I've
deliberately sandwiched a compile unit between two type units, which
should isolate us from both changes in how the compiler emits the units
and changes in the order we process them.

Reviewers: clayborg, aprantl, JDevlieghere

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D62178

llvm-svn: 361465
2019-05-23 09:07:51 +00:00
Pavel Labath 01d88e5b73 DWARF: Add debug_ranges/rnglists tests
.debug_ranges parsing is not well tested [citation needed] because this
section tends to be only used in optimized code, and we don't build
optimized executables in our tests, as they produce unpredictable
results.

This patch aims to add some very simple tests for parsing static range
data, which can serve as a first line of defense in case things break.

I also include one XFAILed test, which demonstrates that we don't
correctly handle mixed DWARF v5 and v4 ranges in a single file.

llvm-svn: 361373
2019-05-22 11:44:36 +00:00
Pavel Labath 80233daeaa DWARF: Introduce DWARFTypeUnit class
Summary:
This patch introduces the DWARFTypeUnit class, and teaches lldb to parse
type units out of both the debug_types section (DWARF v4), and from the
regular debug_info section (DWARF v5).

The most important piece of functionality - resolving DW_AT_signatures
to connect type forward declarations to their definitions - is not
implemented here, but even without that, a lot of functionality becomes
available. I've added tests for the commands that start to work after
this patch.

The changes in this patch were greatly inspired by D61505, which in turn took
over changes from D32167.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: mgorny, jankratochvil, lldb-commits

Differential Revision: https://reviews.llvm.org/D62008

llvm-svn: 361360
2019-05-22 09:09:39 +00:00
Michal Gorny f8fccb14de [lldb] [lit] Skip more tests when Python is unavailable
LocalLLDBInit.test requires Python module loading support.
CommandScriptImmediateOutput tests are specific to running scripts.
Disable all of them when Python support is disabled.

llvm-svn: 361115
2019-05-19 09:27:52 +00:00
Michal Gorny 6f356784be [lldb] [lit] Driver/TestConvenienceVariables.test requires Python
Differential Revision: https://reviews.llvm.org/D62096

llvm-svn: 361114
2019-05-19 06:05:31 +00:00
Stella Stamenova 5bac706343 [CommandInterpreter] Fix trailing blanks after `all` or [0-9]+ for bt
The change that was committed for this used \\s to match spaces which does not work correctly on all platforms. Using [:space:] makes the test pass on both Linux and Windows

llvm-svn: 361064
2019-05-17 18:52:42 +00:00
Davide Italiano d768ee2140 [CommandInterpreter] Accept blanks after `all` or [0-9]+ for bt.
Previously "bt all    " would've failed as the regex didn't match
them.

Over the shoulder review by Jonas Devlieghere.

<rdar://problem/50824935>

llvm-svn: 360966
2019-05-17 01:03:21 +00:00
Pavel Labath 1a8630ac28 DWARFContext: Return empty data extractors instead of null pointers
Summary:
There are several reasons for doing this:
- generally, there's no reason to differentiate between a section being
  absent and it being present, but empty
- it matches more closely what llvm DWARF parser is doing (which also
  doesn't differentiate the two cases)
- SymbolFileDWARF also doesn't differentiate the two cases, which makes
  porting the rest of sections easier
- it fixes a bug in how the return-null-if-empty logic was implemented
  (it returned nullptr only the second time we tried to get the
  debug_aranges section), which meant that we hit an assert when trying
  to parse an empty-but-present section

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: zturner, lldb-commits

Differential Revision: https://reviews.llvm.org/D61942

llvm-svn: 360874
2019-05-16 11:19:02 +00:00
Pavel Labath f4014e116e DWARF: Add ability to reference debug info coming from multiple sections
Summary:
This patch adds the ability to precisely address debug info in
situations when a single file can have more than one debug-info-bearing
sections (as is the case with type units in DWARF v4).

The changes here can be classified into roughly three categories:
- the code which addresses a debug info by offset gets an additional
  argument, which specifies the section one should look into.
- the DIERef class also gets an additional member variable specifying
  the section. This way, code dealing with DIERefs can know which
  section is the object referring to.
- the user_id_t encoding steals one bit from the dwarf_id field to store
  the section. This means the total number of separate object files
  (apple .o, or normal .dwo) is limited to 2 billion, but that is fine
  as it's not possible to hit that number without switching to DWARF64
  anyway.

This patch is functionally equivalent to (and inspired by) the two
patches (D61503 and D61504) by Jan Kratochvil, but there are differences
in the implementation:
- it uses an enum instead of a bool flag to differentiate the sections
- it increases the size of DIERef struct instead of reducing the amount
  of addressable debug info
- it sets up DWARFDebugInfo to store the units in a single vector
  instead of two. This sets us up for the future in which type units can
  also live in the debug_info section, and I believe it's cleaner
  because there's no need for unit index remapping

There are no tests with this patch as this is essentially NFC until
we start parsing type units from the debug_types section.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: arphaman, jankratochvil, lldb-commits

Differential Revision: https://reviews.llvm.org/D61908

llvm-svn: 360872
2019-05-16 11:07:58 +00:00
Michal Gorny 9de9b5e950 [lldb] [lit] Pass --mode=compile to fix compiler-full-path.test
Pass '--mode=compile' to fix compiler-full-path.test failure on NetBSD
buildbot (apparently due to lack of 'link' executable).

Fixes r360355.  Acked by Pavel Labath.

llvm-svn: 360761
2019-05-15 10:48:55 +00:00
Michal Gorny 3bdbd97d67 [lldb] [lit] Fix whitespace in matches for remaining AVX512 tests
llvm-svn: 360744
2019-05-15 03:32:47 +00:00
Davide Italiano 092f85a594 [lit/Register] Fix matching of the output.
llvm-svn: 360725
2019-05-14 23:17:12 +00:00
Jonas Devlieghere b40284dfb0 Disable TestEnvironment on Windows
The input source file seems to be triggering an error in the Visual
Studio headers.

> xstddef:338:2: error: ''auto' return without trailing return type;
> deduced return types are a C++14 extension

I tried converting the test to use the %build stuff Zachary added, but
that seems to be missing some Darwin support. Disabling the test on
Windows in the meantime.

llvm-svn: 360624
2019-05-13 22:02:09 +00:00
Jonas Devlieghere ae54fc9f04 Merge target and launch info environments
Before this change we were overriding the launch info environment with
the target environment. This meant that the environment variables passed
to `process launch --environment <>` were lost. Instead of replacing the
environment, we should merge them.

Differential revision: https://reviews.llvm.org/D61864

llvm-svn: 360612
2019-05-13 19:17:48 +00:00
Aleksandr Urakov 7f5318c892 [NativePDB] Fix tests after r360569
llvm-svn: 360587
2019-05-13 15:06:13 +00:00
Pavel Labath 9cba2c9650 Add REQUIRES: windows to NativePDB/stack_unwinding01.cpp
The test runs the compiled executable. As such, it can only work on
windows hosts.

llvm-svn: 360576
2019-05-13 11:32:52 +00:00
Pavel Labath 1211baa51c Breakpad: Generate unwind plans from STACK CFI records
Summary:
This patch implements the GetUnwindPlan interface (added in the previous
patch) for SymbolFileBreakpad, and uses it to generate unwind plans from
STACK CFI records in breakpad files.

We first perform a light-weight parse of the breakpad in order to build
up a map of regions covered by the unwind info so that we can later jump
to the right record when we need to unwind a specific function.

The actual parsing is relatively straight-forward, as the STACK CFI records
are just another (text) form of the eh_frame unwind instructions, and
the same goes for lldb's UnwindPlans. The newly-introduced
PostfixExpression API is used to convert the breakpad postfix
expressions into DWARF. The generated dwarf expressions are stored in a
BumpPtrAllocator, as the UnwindPlan does not take ownership of the
expression data it references (usually this is static data in an object
file, so special ownership is needed).

At this moment the generated unwind plans aren't used in the actual
unwind machinery (only in the image show-unwind command), but that is
coming in a separate patch.

Reviewers: amccarth, clayborg, markmentovai

Subscribers: aprantl, jasonmolenda, lldb-commits

Differential Revision: https://reviews.llvm.org/D61733

llvm-svn: 360574
2019-05-13 11:25:35 +00:00
Stefan Granitz 7e8be135cf Fix flakiness in lldb lit test
Messages "breakpoint locations added" and "process stopped" may come out of order.

Differential Revision: https://reviews.llvm.org/D61611#anchor-1499662

llvm-svn: 360571
2019-05-13 09:48:26 +00:00
Aleksandr Urakov 869f934d19 [NativePDB] Support member function types in PdbAstBuilder
Summary:
    This patch implements missing case in PdbAstBuilder::CreateType for
    LF_MFUNCTION. This is necessary, for example, in stack unwinding of struct
    methods.

    Reviewers: amccarth, aleksandr.urakov

    Reviewed By: amccarth

    Subscribers: abidh, teemperor, lldb-commits, leonid.mashinskiy

    Differential Revision: https://reviews.llvm.org/D61128

llvm-svn: 360569
2019-05-13 09:41:57 +00:00
Pavel Labath 33fdaed491 @skipIfLinux flaky lldb-mi tests
llvm-svn: 360564
2019-05-13 08:48:03 +00:00