Commit Graph

260 Commits

Author SHA1 Message Date
David Blaikie 208a11ab3a Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3.

I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
2020-04-14 14:44:32 -07:00
Med Ismail Bennani a4da4e3292 [lldb/Reproducers] Fix typo introduced when disabling register failing tests 2020-04-10 08:37:06 +02:00
Med Ismail Bennani 98b47f447c [lldb/test] Fix typo to disable reproducer's test phase 2020-04-09 21:54:45 +02:00
Med Ismail Bennani 68c04a4f73 [lldb] Disable failing register tests for reproducers 2020-04-09 21:05:17 +02:00
Adrian Prantl 143d507c9f Preserve the owning module information from DWARF in the synthesized AST
Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
1;95;0csets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

This reapplies the previously reverted commit, but without support for
ClassTemplateSpecializations, which I'm going to look into separately.

rdar://problem/59634380

Differential Revision: https://reviews.llvm.org/D75488
2020-04-09 11:09:44 -07:00
Davide Italiano d51b38f1b3 [DWARF] Not all the constant variables are "static".
Fixes rdar://problem/61402307

Differential Revision: https://reviews.llvm.org/D77698
2020-04-08 11:07:19 -07:00
Kazuaki Ishizaki e9264b746b [lldb] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77460
2020-04-07 01:06:16 +09:00
Adrian Prantl 32672b877d Revert "Preserve the owning module information from DWARF in the synthesized AST"
This reverts commit 4354dfbdf5 while investigating bot fallout.
2020-04-01 18:58:11 -07:00
Adrian Prantl 4354dfbdf5 Preserve the owning module information from DWARF in the synthesized AST
Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
sets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

rdar://problem/59634380

Differential Revision: https://reviews.llvm.org/D75488
2020-04-01 17:46:02 -07:00
Jonas Devlieghere 015c6cd475 Re-land "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"
The FileCollector in LLDB collects every files that's used during a
debug session when capture is enabled. This ensures that the reproducer
only contains the files necessary to reproduce. This approach is not a
good fit for the dSYM bundle, which is a directory on disk, but should
be treated as a single unit.

On macOS LLDB have automatically find the matching dSYM for a binary by
its UUID. Having a incomplete dSYM in a reproducer can break debugging
even when reproducers are disabled.

This patch adds a was to specify a directory of interest to the
reproducers. It is called from SymbolVendorMacOSX with the path of the
dSYMs used by LLDB.

Differential revision: https://reviews.llvm.org/D76672
2020-03-31 12:47:12 -07:00
Davide Italiano 75cfd38220 Revert "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"
This reverts commit 38ddb49e52 as it
breaks the macOS bots.
2020-03-31 10:56:02 -07:00
Jonas Devlieghere 38ddb49e52 [lldb/Reproducers] Always collect the whole dSYM in the reproducer
The FileCollector in LLDB collects every files that's used during a
debug session when capture is enabled. This ensures that the reproducer
only contains the files necessary to reproduce. This approach is not a
good fit for the dSYM bundle, which is a directory on disk, but should
be treated as a single unit.

On macOS LLDB have automatically find the matching dSYM for a binary by
its UUID. Having a incomplete dSYM in a reproducer can break debugging
even when reproducers are disabled.

This patch adds a was to specify a directory of interest to the
reproducers. It is called from SymbolVendorMacOSX with the path of the
dSYMs used by LLDB.

Differential revision: https://reviews.llvm.org/D76672
2020-03-30 15:16:50 -07:00
Pavel Labath e22f0dabcf [lldb/breakpad] Fix register resolution on arm
In breakpad, only x86 (and mips) registers have a leading '$' in their
names. Arm architectures use plain register names.

Previously, lldb was assuming all registers have a '$'. Fix the code to
match the (unfortunately, inconsistent) reality.
2020-03-26 13:51:27 +01:00
Pavel Labath c72675394a [lldb] add lit.local.cfg for breakpad tests
The reason is to add .yaml as a valid test suffix. The test folder
contains one yaml file, which wasn't being run because of that.

Unsurprisingly the test fails, but this was not because the underlying
functionality was broken, but rather because the test was setup
incorrectly (most likely due to overly aggressive simplification of the
test data on my part).

Therefore this patch also tweaks the test inputs in order to test what
they are supposed to test, and also updates some other breakpad tests
(because they depend on the same inputs as this one) to be more
realistic -- specifically it avoids putting symbols to the first page of
the module, as that's where normally the COFF header would reside.
2020-03-25 17:00:46 +01:00
Jonas Devlieghere 1f80e51546 [lldb/Reproducers] Collect files imported by command script import
Files imported by the script interpreter aren't opened by LLDB so they
don't end up in the reproducer. The solution is to explicitly add them
to the FileCollector.

Differential revision: https://reviews.llvm.org/D76626
2020-03-24 08:54:26 -07:00
Jonas Devlieghere ae37e2285d [lldb/Reproducers] Mark reproducer test directory as unsupported on Windows
Reproducers are unsupported on Windows. Rather than having a UNSUPPORTED
line in every test, just skip the whole subdirectory.
2020-03-23 09:54:11 -07:00
Davide Italiano 696ae6f7d8 [StopHook] Use wildcard matching. Pointed out by Jim Ingham. 2020-03-20 13:57:40 -07:00
Davide Italiano 6385c2ab8f [AppleObjCRuntimeV2] Force lazily allocated class names to be resolved.
Fixes a couple of tests on new versions of the Obj-C runtime.
2020-03-20 13:43:08 -07:00
Jan Kratochvil 3481062bc6 [lldb] [testsuite] Enable forgotten -gsplit-dwarf for 2 testfiles
D63643 added these testfiles but some of the %t4dwo and %t5dwo builds
are the same as corresponding %t4 and %t5 builds. Fortunately the
testcases do PASS.

After just adding -gsplit-dwarf these both skeleton files:
  tools/lldb/test/SymbolFile/DWARF/Output/debug-types-expressions.test.tmp4dwo
  tools/lldb/test/SymbolFile/DWARF/Output/debug-types-expressions.test.tmp5dwo

were referencing to this one non-skeleton file:
  tools/lldb/test/SymbolFile/DWARF/debug-types-expressions.dwo

Surprisingly it does not affect the other test debug-types-basic.test
probably because it compiles to .o and then links it. While
debug-types-expressions.test compiles directly to an executable.

So fixed that while keeping the direct executable compilation.

Differential Revision: https://reviews.llvm.org/D76316
2020-03-18 15:49:24 +01:00
Pavel Labath c5ff3df839 [lldb] Hardcode target in dwo-type-in-main-file.s test 2020-03-16 13:25:10 +01:00
Pavel Labath 5abfa3226d [lldb/DWARF] Fix crash when a dwo compile unit refers to a non-dwo type
In this case dwo_num can be None => stop assuming it can't.
2020-03-16 12:12:59 +01:00
Jonas Devlieghere 4016c6b07f [lldb/Reproducer] Prevent crash when GDB multi-loader can't be created.
Check that the multi loader isn't null and print an error otherwise.
This patch also extends the test to cover these error paths.
2020-03-10 23:16:55 -07:00
Pavel Labath 1ca1e08e75 [lldb] Break up CommandObjectDisassemble::DoExecute
The function consisted of a complicated set of conditions to compute the
address ranges which are to be disassembled (depending on the mode
selected by command line switches). This patch creates a separate
function for each mode, so that DoExecute is only left with the task of
figuring out how to dump the relevant ranges.

This is NFC-ish, except for one change in the error message, which is
actually an improvement.
2020-03-10 14:03:16 +01:00
Pavel Labath 3245dd59b1 [lldb] Reduce duplication in CommandObjectDisassemble
This command had nearly identical code for the "then" and "else"
branches of the "if (m_options.num_instructions != 0)" condition.

This patch factors out the common parts of the two blocks to reduce
duplication.
2020-03-04 13:47:35 +01:00
Pavel Labath 573e077699 [lldb] Add detailed tests for the "disassemble" command
While we have some tests for this command already, they are very vague.
This is not surprising -- it's hard to make strict assertions about the
assembly if your input is a c++ source file. This means that the tests
can more-or-less only detect when the command breaks completely, and not
when there is a subtle change in meaning due to e.g. a code refactor --
which is something that I am getting ready to do.

This tests in this patch create binaries with well known data (via assembler
and yaml2obj). This means that we are able to make precise assertions
about the text that lldb is supposed to print. As some of the features
of this command are only available with a real process, I use a minidump
core file to create a sufficiently realistic process object.
2020-03-03 16:40:27 +01:00
Pavel Labath 4deea65249 [lldb] Make sure we don't drop asynchronous output when sourcing files
Summary:
If a command from a sourced file produces asynchronous output, this
output often does not make its way to the user. This happens because the
asynchronous output machinery relies on the iohandler stack to ensure
the output does not interfere with the things the iohandler is doing.

However, if this happens near the end of the command stream then by the
time the asynchronous output is produced we may already have already
started tearing down the sourcing session. Specifically, we may already
pop the relevant iohandler, leaving the stack empty.

This patch makes sure this kind of output gets printed by adding a
fallback to IOHandlerStack::PrintAsync to print the output directly if
the stack is empty. This is safe because if we have no iohandlers then
there is nothing to synchronize.

Reviewers: JDevlieghere, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75454
2020-03-03 11:18:41 +01:00
Pavel Labath eefbff0082 [lldb] s/CHECK-NEXT/CHECK-DAG in dwp-debug-types.s
These can come out nondeterministically for two reasons:
- sorting based on ConstStringified pointer values
- different relative speeds of the indexing threads

Making these nondeterministic without incurring performance penalties is
hard, so I just make the test expect them in any order (the order is not
important in this test anyway.
2020-02-25 10:04:09 +01:00
Pavel Labath c08a1c7071 [lldb] Mark ObjectFileBreakpad test inputs as non-text
These are technically text files, but the object file layer treats them
as binary, and the relevant tests verify the parsed contents byte for
byte. Git's crlf conversion can make those tests fail. Marking the files
as non-text disables that.
2020-02-25 08:29:41 +01:00
Jonas Devlieghere 841be9854c [lldb] Color the line marker
Highlight the color marker similar to what we do for the column marker.
The default color matches the color of the current PC marker (->) in the
default disassembly format.

Differential revision: https://reviews.llvm.org/D75070
2020-02-24 15:40:31 -08:00
Jonas Devlieghere 7f9f027c62 [lldb/Test] Update TestDisassemblyFormat for new format 2020-02-24 14:08:16 -08:00
Pavel Labath c9c09ef836 [lldb/DWARF] Fix dwp search path in the separate-debug-file case
The convention is that the dwp file name is derived from the name of the
file holding the executable code, even if the linked portion of the
debug info is elsewhere (objcopy --only-keep-debug).
2020-02-24 17:01:15 +01:00
Raphael Isemann c131dfefe2 [lldb] Disable auto fix-its when evaluating expressions in the test suite
Summary:
Currently the test suite runs with enabled automatically applied Clang fix-its for expressions.
This is causing that sometimes incorrect expressions in tests are still evaluated even though they
are actually incorrect. Let's disable this feature in the test suite so that we know when expressions
are wrong and leave the fix-it testing to the dedicated tests for that feature.

Also updates the `lang/cpp/operators/` test as it seems Clang needs the `struct` keywords
before C and would otherwise fail without fixits.

Reviewers: jingham, JDevlieghere, shafik

Reviewed By: JDevlieghere, shafik

Subscribers: shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74957
2020-02-24 09:31:11 +01:00
Pavel Labath be3b448c2e [lldb/test] simplify basic-elf.yaml
Explicit dynsym/dynstr sections were added in a6370d5 to compensate for
a yaml2obj change D74764. This test doesn't need those sections, so
instead I just delete the explicit section blocks, and also the
"DynamicSymbols" block, which triggers their implicit generation.
2020-02-24 09:02:18 +01:00
Pavel Labath 0f7cfb2543 [lldb/DWARF] Don't index dwp file multiple times
Summary:
When we added support for type units in dwo files, we changed the
"manual" dwarf index to index _all_ dwarf units in the dwo file instead
of just the split unit belonging to our skeleton unit. This was fine for
dwo files, as they contain only a single compile units and type units do
not have a split type unit which would point to them.

However, this does not work for dwp files because, these files do
contain multiple split compile units, and the current approach means
that each unit gets indexed multiple times (once for each split unit =>
n^2 complexity).

This patch teaches the manual dwarf index to treat dwp files specially.
Any type units in the dwp file added to the main list of compile units
and indexed with them in a single batch. Split compile units in dwp
files are still indexed as a part of their skeleton unit -- this is done
because we need the DW_AT_language attribute from the skeleton unit to
index them properly.

Handling of dwo files remains unchanged -- all units (type and skeleton)
are indexed when we reach the dwo file through the split unit.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74964
2020-02-24 08:50:51 +01:00
Georgii Rymar a6370d5798 [lldb][test] - Update basic-elf.yaml to fix build bot.
D74764 (https://reviews.llvm.org/rG31f2ad9c368d47721508cbd0d120d626f9041715)
changed the behavior of the yaml2obj. Now it assigns virtual addresses
for allocatable sections.

SymbolFile/Breakpad/symtab.test started to fail after this change:
(http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/5520/steps/test/logs/stdio)

Command Output (stderr):
--
/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/Breakpad/symtab.test:6:10: error: CHECK: expected string not found in input
# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
         ^
<stdin>:15:1: note: scanning from here
Symtab, file = /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/tools/lldb/test/SymbolFile/Breakpad/Output/symtab.out, num_symbols = 6:
^
<stdin>:15:99: note: possible intended match here
Symtab, file = /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/tools/lldb/test/SymbolFile/Breakpad/Output/symtab.out, num_symbols = 6:

For now I've updated the basic-elf.yaml so that now it produce the same layout as before D74764.
Breakpad/symtab.test should be updated it seems.
2020-02-22 16:09:24 +03:00
Fangrui Song e29065a105 [lldb][test] Fix sh_flags and sh_entsize of .debug_str.dwo
sh_flags: SHF_MERGE | SHF_STRINGS | SHF_EXCLUDE
sh_entsize: 1

Incorrect sh_flags or sh_entsize is an error after the assembler change made by D73999.
2020-02-21 18:51:05 -08:00
Fangrui Song ebee131259 [lldb][test] Fix sh_type of .debug_cu_index and .debug_tu_index
They do not have the SHF_EXCLUDE flag.
After D73999, MC errors `changed section type for .debug_cu_index, expected: 0x0`
2020-02-21 17:38:39 -08:00
Ivan Hernandez c47e0e2d37 [lldb-vscode] Use libOption with tablegen to parse command line options.
This change will bring lldb-vscode in line with how several other llvm
tools process command line arguments and make it easier to add future
options.

Differential revision: https://reviews.llvm.org/D74798
2020-02-21 08:15:06 -08:00
Pavel Labath de8793b918 [lldb/DWARF] Add support for type units in dwp files
all that was needed was to teach lldb's DWARF context about the
debug_tu_index section.
2020-02-21 16:01:17 +01:00
Pavel Labath 7b59ff2fa0 [lldb] Add boilerplate to recognize the .debug_tu_index section
It's just like debug_cu_index, only for type units.
2020-02-20 13:44:21 +01:00
Raphael Isemann fdea9a4ec9 [lldb] Remove license headers from all test source files
Summary:
Around a third of our test sources have LLVM license headers. This patch removes those headers from all test
sources and also fixes any tests that depended on the length of the license header.

The reasons for this are:

* A few tests verify line numbers and will start failing if the number of lines in the LLVM license header changes. Once I landed my patch for valid SourceLocations in debug info we will probably have even more tests that verify line numbers.
* No other LLVM project is putting license headers in its test files to my knowledge.
* They make the test sources much more verbose than they have to be. Several tests have longer license headers than the actual test source.

For the record, the following tests had their line numbers changed to pass with the removal of the license header:
    lldb-api :: functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
    lldb-shell :: Reproducer/TestGDBRemoteRepro.test
    lldb-shell :: Reproducer/TestMultipleTargets.test
    lldb-shell :: Reproducer/TestReuseDirectory.test
    lldb-shell :: ExecControl/StopHook/stop-hook-threads.test
    lldb-shell :: ExecControl/StopHook/stop-hook.test
    lldb-api :: lang/objc/exceptions/TestObjCExceptions.py

Reviewers: #lldb, espindola, JDevlieghere

Reviewed By: #lldb, JDevlieghere

Subscribers: emaste, aprantl, arphaman, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74839
2020-02-20 08:32:01 +01:00
Pavel Labath 8131cb6e18 [lldb/DWARF] Add support for location lists in package files
The only thing needed was to account for the offset from the
debug_cu_index section when searching for the location list.

This patch also fixes a bug in the Module::ParseAllDebugSymbols
function, which meant that we would only parse the variables of the
first compile unit in the module. This function is only used from
lldb-test, so this does not fix any real issue, besides preventing me
from writing a test for this patch.
2020-02-19 14:33:58 +01:00
Raphael Isemann 785df61680 [lldb] Let TypeSystemClang::GetDisplayTypeName remove anonymous and inline namespaces.
Summary:
Currently when printing data types we include implicit scopes such as inline namespaces or anonymous namespaces.
This leads to command output like this (for `std::set<X>` with X being in an anonymous namespace):

```
(lldb) print my_set
(std::__1::set<(anonymous namespace)::X, std::__1::less<(anonymous namespace)::X>, std::__1::allocator<(anonymous namespace)::X> >) $0 = size=0 {}
```

This patch removes all the implicit scopes when printing type names in TypeSystemClang::GetDisplayTypeName
so that our output now looks like this:

```
(lldb) print my_set
(std::set<X, std::less<X>, std::allocator<X> >) $0 = size=0 {}
```

As previously GetDisplayTypeName and GetTypeName had the same output we actually often used the
two as if they are the same method (they were in fact using the same implementation), so this patch also
fixes the places where we actually want the display type name and not the actual type name.

Note that this doesn't touch the `GetTypeName` class that for example the data formatters use, so this patch
is only changes the way we display types to the user. The full type name can also still be found when passing
'-R' to see the raw output of a variable in case someone is somehow interested in that.

Partly fixes rdar://problem/59292534

Reviewers: shafik, jingham

Reviewed By: shafik

Subscribers: christof, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74478
2020-02-19 10:30:11 +01:00
Pavel Labath 00539d8b64 [lldb/DWARF] Support the debug_str_offsets section in dwp files
Summary:
In dwp files a constant (from the debug_cu_index section) needs to be
added to each reference into the debug_str_offsets section.

I've tried to implement this to roughly match the llvm flow: I've
changed the DWARFormValue to stop resolving the indirect string
references directly -- instead, it calls into DWARFUnit, which resolves
this for it (similar to how it already resolves indirect range and
location list references). I've also done a small refactor of the string
offset base computation code in DWARFUnit in order to make it easier to
access the debug_cu_index base offset.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74723
2020-02-18 11:02:34 +01:00
Pavel Labath 67f63f3f7c [lldb/DWARF] Re-enable basic dwp support
Summary:
This patch removes the bitrotted SymbolFileDWARF(Dwo)Dwp classes, and
replaces them with dwp support implemented directly inside
SymbolFileDWARFDwo, in a manner mirroring the implementation in llvm.
This patch does:
- add support for the .debug_cu_index section to our DWARFContext
- adds a llvm::DWARFUnitIndex argument to the DWARFUnit constructors.
  This argument is used to look up the offsets of the debug_info and
  debug_abbrev contributions in the sections of the dwp file.
- makes sure the creation of the DebugInfo object as well as the initial
  discovery of DWARFUnits is thread-safe, as we can now call this
  concurrently when doing parallel indexing.

This patch does not:
- use the DWARFUnitIndex to search for other kinds of contributions
  (debug_loc, debug_ranges, etc.). This means that units which reference
  these sections will not work correctly. These will be handled by
  follow-up patches, but even the present level of support is sufficient
  to enable basic functionality.
- Make the llvm::DWARFContext thread-safe. Right now, it just avoids this
  problem by ensuring everything is initialized ahead of time. However,
  this is something we will run into more often as we try to use more of
  llvm, and so I plan to start looking into our options here.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: mgorny, mgrang, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73783
2020-02-17 14:10:36 +01:00
Paolo Severini c1121908aa [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Add a dynamic loader plug-in class for WebAssembly modules.

Differential Revision: https://reviews.llvm.org/D72751
2020-02-17 12:42:23 +01:00
Jason Molenda 83bea6d99d Remove 'process launch failed:' message prefix in Target::Launch
SB API clients can describe the failure message in a more natural
way for their UI, this doesn't add information for them.

Differential Revision: https://reviews.llvm.org/D74585
<rdar://problem/49953304>
2020-02-14 18:42:38 -08:00
Ted Woodward cecc185166 Add REQUIRES: x86 so this won't be run if x86 is not available. 2020-02-13 11:17:27 -06:00
Med Ismail Bennani cb0c4ee3eb [lldb/test] Add alternate symbol to StackFrame Recognizer
This reimplements commit 6b2979c123 and updates
the tests to reflect the addition of the alternate symbol attribute.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-11 11:44:37 +01:00
Davide Italiano 6b2979c123 Revert "[lldb] Fix+re-enable Assert StackFrame Recognizer on Linux"
This reverts commit 1a39f1b966 as
it breaks macOS.
2020-02-10 13:27:35 -08:00
Jan Kratochvil 1a39f1b966 [lldb] Fix+re-enable Assert StackFrame Recognizer on Linux
D73303 was failing on Fedora Linux and so it was disabled by Skip the
AssertFrameRecognizer test for Linux.

I find no easy way how to find out if it gets recognized as
`__assert_fail` or `__GI___assert_fail` as during `Process` ctor
libc.so.6 is not yet loaded by the debuggee.

DWARF symbol `__GI___assert_fail` overrides the ELF symbol `__assert_fail`.
While external debug info (=DWARF) gets disabled for testsuite (D55859)
that sure does not apply for real world usage.

Differential Revision: https://reviews.llvm.org/D74252
2020-02-10 10:29:32 +01:00
Jan Kratochvil 6ef4786dbc Revert "[lldb] Fix+re-enable Assert StackFrame Recognizer on Linux"
This reverts commit cf1046c716.
Reverted: https://reviews.llvm.org/D74252

It fixed testsuite but broke real world functionality where is not used:
	settings set symbols.enable-external-lookup false
2020-02-08 05:08:48 +01:00
Davide Italiano 5858c9d69f Revert "[TestConvienceVariable] Clean the directory before running the test."
This reverts commit 9bce9d2d65, as
it breaks the bots.
2020-02-07 14:32:30 -08:00
Davide Italiano 9bce9d2d65 [TestConvienceVariable] Clean the directory before running the test. 2020-02-07 13:52:40 -08:00
Jan Kratochvil cf1046c716 [lldb] Fix+re-enable Assert StackFrame Recognizer on Linux
D73303 was failing on Fedora Linux and so it was disabled by Skip the
AssertFrameRecognizer test for Linux.

On Fedora 30 x86_64 I have:
        $ readelf -Ws /lib64/libc.so.6 |grep '^Symbol\|.*assert_fail'
        Symbol table '.dynsym' contains 2362 entries:
           630: 0000000000030520    70 FUNC    GLOBAL DEFAULT   14 __assert_fail@@GLIBC_2.2.5
        Symbol table '.symtab' contains 22711 entries:
           922: 000000000002275a    15 FUNC    LOCAL  DEFAULT   14 __assert_fail_base.cold
         18044: 0000000000030520    70 FUNC    LOCAL  DEFAULT   14 __GI___assert_fail
         20081: 00000000000303a0   370 FUNC    LOCAL  DEFAULT   14 __assert_fail_base
         21766: 0000000000030520    70 FUNC    GLOBAL DEFAULT   14 __assert_fail

The patch should never expect __GI___assert_fail:

.symtab can be present or not but that should not change that
__assert_fail always wins - it is always present from .dynsym and it can
never be overriden by __GI___assert_fail as __GI___assert_fail has only
local binding. Global binding is preferred since D63540.

External debug info symbols do not matter since D55859 (and DWARF should
never be embedded in system libc.so.6).

Differential Revision: https://reviews.llvm.org/D74252
2020-02-07 22:24:56 +01:00
Med Ismail Bennani 2e005c64f3 [lldb/test] Skip the AssertFrameRecognizer test for Linux
This patch skips the AssertFrameRecognizer test for Linux since it appears to
fail on certain distributions (AFAIK Fedora & ArchLinux).

The failure happen because the thread don't set the current frame to
the most relevant one. So the stopped location doesn't match with what
the test is expecting.

The test will be enabled again after I'll be able to reproduce the failure
on one of those platform and fix the issue.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-07 18:49:35 +01:00
Jonas Devlieghere 4fe839ef3a [CMake] Rename EXCLUDE_FROM_ALL and make it an argument to add_lit_testsuite
EXCLUDE_FROM_ALL means something else for add_lit_testsuite as it does
for something like add_executable. Distinguish between the two by
renaming the variable and making it an argument to add_lit_testsuite.

Differential revision: https://reviews.llvm.org/D74168
2020-02-06 15:33:18 -08:00
Med Ismail Bennani 7ebe9cc4fc [lldb/Target] Add Assert StackFrame Recognizer
When a thread stops, this checks depending on the platform if the top frame is
an abort stack frame. If so, it looks for an assert stack frame in the upper
frames and set it as the most relavant frame when found.

To do so, the StackFrameRecognizer class holds a "Most Relevant Frame" and a
"cooked" stop reason description. When the thread is about to stop, it checks
if the current frame is recognized, and if so, it fetches the recognized frame's
attributes and applies them.

rdar://58528686

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-06 18:27:48 +01:00
Pavel Labath 40efa65de8 Revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"
This patch has a couple of outstanding issues. The test is not python3
compatible, and it also seems to fail with python2 (at least under some
circumstances) due to an overambitious assertion.

This reverts the patch as well as subsequent fixup attempts:
014ea93376,
f5f70d1c8f.
4697e701b8.
5c15e8e682.
3ec28da6d6.
2020-02-05 16:22:19 -08:00
Jonas Devlieghere 97edc0dc93 [lldb/Test] Mark heap-cstr.test as requiring Python 2020-02-05 16:05:54 -08:00
Pavel Labath 98b273c893 Revert "[lldb/Target] Add Assert StackFrame Recognizer"
This reverts commit 2b7f32892b because of test
failures due to dangling pointers.
2020-02-05 15:51:38 -08:00
Paolo Severini 3ec28da6d6 [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Add a dynamic loader plug-in class for WebAssembly modules.

Differential Revision: https://reviews.llvm.org/D72751
2020-02-05 14:49:36 -08:00
Fangrui Song 77519b60d9 [test] yaml2obj -docnum => --docnum= 2020-02-05 10:25:04 -08:00
Med Ismail Bennani 2b7f32892b [lldb/Target] Add Assert StackFrame Recognizer
When a thread stops, this checks depending on the platform if the top frame is
an abort stack frame. If so, it looks for an assert stack frame in the upper
frames and set it as the most relavant frame when found.

To do so, the StackFrameRecognizer class holds a "Most Relevant Frame" and a
"cooked" stop reason description. When the thread is about to stop, it checks
if the current frame is recognized, and if so, it fetches the recognized frame's
attributes and applies them.

rdar://58528686

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-05 17:49:13 +01:00
Vedant Kumar 14135f50a0 [lldb/Value] Avoid reading more data than the host has available
Value::GetValueByteSize() reports the size of a Value as the size of its
underlying CompilerType. However, a host buffer that backs a Value may
be smaller than GetValueByteSize().

This situation arises when the host is only able to partially evaluate a
Value, e.g. because the expression contains DW_OP_piece.

The cleanest fix I've found to this problem is Greg's suggestion, which
is to resize the Value if (after evaluating an expression) it's found to
be too small. I've tried several alternatives which all (in one way or
the other) tried to teach the Value/ValueObjectChild system not to read
past the end of a host buffer, but this was flaky and impractical as it
isn't easy to figure out the host buffer's size (Value::GetScalar() can
point to somewhere /inside/ a host buffer, but you need to walk up the
ValueObject hierarchy to try and find its size).

This fixes an ASan error in lldb seen when debugging a clang binary.
I've added a regression test in test/functionalities/optimized_code. The
point of that test is not specifically to check that DW_OP_piece is
handled a particular way, but rather to check that lldb doesn't crash on
an input that it used to crash on.

Testing: check-lldb, and running the added tests using a sanitized lldb

--

Thanks to Jim for pointing out that an earlier version of this patch,
which simply changed the definition of Value::GetValueByteSize(), would
interact poorly with the ValueObject machinery.

Thanks also to Pavel who suggested a neat way to test this change
(which, incidentally, caught another ASan issue still present in the
original version of this patch).

rdar://58665925

Differential Revision: https://reviews.llvm.org/D73148
2020-01-31 16:33:12 -08:00
Jonas Devlieghere 457a6d49d5 [lldb/Reproducers] Fix typo in CMake so we actually replay.
The CMakeLists.txt had a typo which meant that check-lldb-repro was
capturing twice instead of capturing and then replaying. This also
uncovered a missing import in lldb-repro.py. This patch fixes both
issues.
2020-01-30 15:51:29 -08:00
Ayke van Laethem 727ed11b24
[AVR] Recognize the AVR architecture in lldb
This commit adds AVR support to lldb. With this change, it can load a
binary and do basic things like dump a line table.

Not much else has been implemented, that should be done in later
changes.

Differential Revision: https://reviews.llvm.org/D73539
2020-01-30 13:40:31 +01:00
Michał Górny 6dea61215d [lldb] [test] Restrict x86-64-write register test to x86-64 2020-01-28 22:15:23 +01:00
Med Ismail Bennani 954d04295b Revert "[lldb/Target] Add Assert StackFrame Recognizer"
This reverts commit 03a6b858fd.

The test doesn't pass on Debian.
2020-01-28 18:40:08 +01:00
Med Ismail Bennani 03a6b858fd [lldb/Target] Add Assert StackFrame Recognizer
When a thread stops, this checks depending on the platform if the top frame is
an abort stack frame. If so, it looks for an assert stack frame in the upper
frames and set it as the most relavant frame when found.

To do so, the StackFrameRecognizer class holds a "Most Relevant Frame" and a
"cooked" stop reason description. When the thread is about to stop, it checks
if the current frame is recognized, and if so, it fetches the recognized frame's
attributes and applies them.

rdar://58528686

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-01-28 18:21:29 +01:00
Pavel Labath d8de349951 Revert "[lldb/DWARF] Only match mangled name in full-name function lookup (with accelerators)"
This reverts commit 1b12766883 because of
breaking the mac test suite.

I'm not certain this is the cause because of a concurrent build breakage
which masked this problem, but the failure messages are related to
symbol lookup, which makes this very likely.
2020-01-28 13:46:43 +01:00
Jaroslav Sevcik 1b12766883 [lldb/DWARF] Only match mangled name in full-name function lookup (with accelerators)
Summary:
In the spirit of https://reviews.llvm.org/D70846, we only return functions with matching mangled name from Apple/DebugNamesDWARFIndex::GetFunction if eFunctionNameTypeFull is requested.

This speeds up lookup in the presence of large amount of class methods of the same name (a typical examples would be constructors of templates with many instantiations or overloaded operators).

Reviewers: labath

Reviewed By: labath

Subscribers: aprantl, arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73191
2020-01-28 12:16:02 +01:00
Jonas Devlieghere 223a209027 [lldb/Commands] Make column available through _regexp-break
Update _regexp-break to interpret main.c:8:21 as:

  breakpoint set --line 8 --column 21

Differential revision: https://reviews.llvm.org/D73314
2020-01-27 15:11:00 -08:00
Jonas Devlieghere 94ec56b6d5 [lldb/Test] Use lit.local.cfg to mark whole directory as (un)supported.
Mark the whole Python or Lua test directory as unsupported when the
corresponding language is not available.
2020-01-27 15:11:00 -08:00
Jonas Devlieghere 1ed561aa4b [lldb/Test] Update minidebuginfo-set-and-hit-breakpoint.test
Update test to account for the new 'hardware' field between 'resolved'
and 'hit count'.
2020-01-24 20:47:31 -08:00
Jonas Devlieghere 8d508c597a [lldb/Test] Disallow using substituted binaries in shell test.
Explicitly disallow using lldb instead of %lldb in the shell tests. This
is a clever trick that is used by Swift to achieve the same results.

Differential revision: https://reviews.llvm.org/D73289
2020-01-23 14:39:27 -08:00
Jonas Devlieghere d8acf8852d [lldb/Test] Disable command-breakpoint-col.test on Windows
I guess PDB doesn't have column information?
2020-01-23 14:17:50 -08:00
Jonas Devlieghere 6672a4f5b6 [lldb/Commands] Fix, rename and document column number arg to breakpoint set.
We were incorrectly parsing the -C argument to breakpoint set as the
column breakpoint, even though according to the help this should be the
breakpoint command. This fixes that by renaming the option to -u, adding
it to help, and adding a test case.

Differential revision: https://reviews.llvm.org/D73284
2020-01-23 12:34:24 -08:00
Jonas Devlieghere 794b8a0329 [lldb] s/lldb/%lldb in another test
As explained in Pavel's previous commit message: %lldb is the proper
substitution. Using "lldb" can cause us to execute the system lldb
instead of the one we are testing. This happens at least in standalone
builds.
2020-01-23 11:17:24 -08:00
Martin Storsjö 1db1b8b8b3 [lldb/Test] Don't add a check-* target as dependency in add_lit_testsuite
This causes the toplevel "test-depends" target, which should only build
all the dependencies necessary for running tests, to suddenaly also run
the check-lldb-repro-capture tests.

Instead add check-lldb-repro-capture as a dependency to check-lldb-repro
with a separate explicit add_dependencies call.
2020-01-23 09:45:14 +02:00
Jonas Devlieghere 9b5a9f2fab [lldb/Test] Fix type in add_lit_testsuite
The new test suite should be called check-lldb-repro rather than
check-lldb.
2020-01-22 17:51:58 -08:00
Jonas Devlieghere 9be5c13538 [lldb/Test] Add check-lldb-repro target
This adds a new target check-lldb-repro which runs the shell tests with
the lldb-repo utility. It runs the shell tests twice, once while
capturing a reproducer and then again by replaying that reproducer.
2020-01-22 17:35:45 -08:00
Jonas Devlieghere 83a093b8ec [lldb/Reproducer] Mark some driver tests as unsupported for lldb-repro
These test are checking for diagnostics printed by the driver. During
replay we only replay the SB API calls made by the driver, so it's
expected that these messages aren't displayed.
2020-01-22 17:18:06 -08:00
Jonas Devlieghere 6ae61f7675 [lldb/Test] Skip script interpreter tests reading from stdin for lldb-repro
The reproducers currently only shadow the command interpreter. It would
be possible to make it work for the Lua interpreter which uses the
IOHandlerEditline under the hood, but the Python one runs a REPL in
Python itself so there's no (straightforward) way to shadow that.

Given that we already capture any API calls, this isn't super high on my
list of priorities.
2020-01-22 15:22:25 -08:00
Jonas Devlieghere 536612df4b [lldb/Test] Use lit's capabilities to skip lldb-repro tests.
This allows us to skip the reproducer tests themselves as a whole as
well as individual tests with the UNSUPPORTED keyword.
2020-01-22 13:24:12 -08:00
Pavel Labath 889a4f55c9 [lldb] s/lldb/%lldb in two tests
%lldb is the proper substitution. Using "lldb" can cause us to execute
the system lldb instead of the one we are testing. This happens at least
in standalone builds.
2020-01-22 11:02:29 +01:00
Jonas Devlieghere aa91ce3e1d [lldb/CMake] Add check-lldb-shell and check-lldb-api targets for Xcode
The Xcode generator does not provide the auto-generated targets where
you can append a folder name to check-lldb. Instead add two custom lit
targets to run just the shell and api tests.
2020-01-21 13:22:33 -08:00
Jonas Devlieghere a17ad3592f [lldb/Test] Check that attribute exists before comparing its value 2020-01-20 10:48:42 -08:00
Jonas Devlieghere 67420f1b0e [lldb/Util] Add a utility to run transparently capture and replay tests.
This patch introduces a small new utility (lldb-repro) to transparently
capture and replay debugger sessions through the command line driver.
Its used to test the reproducers by running the test suite twice.

During the first run, it captures a reproducer for every lldb invocation
and saves it to a well-know location derived from the arguments and
current working directory. During the second run, the test suite is run
again but this time every invocation of lldb replays the previously
recorded session.

Differential revision: https://reviews.llvm.org/D72823
2020-01-20 10:30:19 -08:00
Pavel Labath 468ca490c6 [lldb] Allow loading of minidumps with no process id
Summary:
Normally, on linux we retrieve the process ID from the LinuxProcStatus
stream (which is just the contents of /proc/%d/status pseudo-file).

However, this stream is not strictly required (it's a breakpad
extension), and we are encountering a fair amount of minidumps which do
not have it present. It's not clear whether this is the case with all
these minidumps, but the two known situations where this stream can be
missing are:
- /proc filesystem not mounted (or something to that effect)
- process crashing after exhausting (almost) all file descriptors (so
  the minidump writer may not be able to open the /proc file)

Since this is a corner case which will become less and less relevant
(crashpad-generated minidumps should not suffer from this problem), I
work around this problem by hardcoding the PID to 1 in these cases.
The same thing is done by the gdb plugin when talking to a stub which
does not report a process id (e.g. a hardware probe).

Reviewers: jingham, clayborg

Subscribers: markmentovai, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70238
2020-01-20 13:08:58 +01:00
Pavel Labath 06e73f071a [lldb/DWARF] Change how we construct a llvm::DWARFContext
Summary:
The goal of this patch is two-fold. First, it fixes a use-after-free in
the construction of the llvm DWARFContext. This happened because the
construction code was throwing away the lldb DataExtractors it got while
reading the sections (unlike their llvm counterparts, these are also
responsible for memory ownership). In most cases this did not matter,
because the sections are just slices of the mmapped file data. But this
isn't the case for compressed elf sections, in which case the section is
decompressed into a heap buffer. A similar thing also happen with object
files which are loaded from process memory.

The second goal is to make it explicit which sections go into the llvm
DWARFContext -- any access to the sections through both DWARF parsers
carries a risk of parsing things twice, so it's better if this is a
conscious decision. Also, this avoids loading completely irrelevant
sections (e.g. .text). At present, the only section that needs to be
present in the llvm DWARFContext is the debug_line_str. Using it through
both APIs is not a problem, as there is no parsing involved.

The first goal is achieved by loading the sections through the existing
lldb DWARFContext APIs, which already do the caching. The second by
explicitly enumerating the sections we wish to load.

Reviewers: JDevlieghere, aprantl

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72917
2020-01-20 11:45:53 +01:00
Adrian Prantl ec9a3cccd4 Update testcase for LLVM IR change (sysroot) 2020-01-17 11:04:55 -08:00
Sam McCall d035c832c3 [lldb] Try to fix writing outside temp dir from 4bafceced6 2020-01-17 17:30:12 +01:00
Pavel Labath ee05138515 [lldb/test] Revert changes to debug-names-compressed.cpp
With the changes in 15a6df52ef, the test is failing in some
configurations. Reverting while I investigate
2020-01-16 18:56:26 +01:00
Paolo Severini 9b3254dbf9 [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging
Add plugin class SymbolVendorWasm, with the logic to manage debug symbols
for Wasm modules.

Reviewers: clayborg, labath, aprantl, sbc100, teemperor

Reviewed By: labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72650
2020-01-16 09:36:17 -08:00
Pavel Labath 15a6df52ef [lldb/DWARF/test] Freshen up debug_names tests
These tests used "clang -mllvm -accel-tables=Dwarf" as a way to
guarantee that clang will emit the debug_names table. Unfortunately,
a change it clang made that insufficient (-gpubnames is required now
too), which rendered these tests ineffective. Since lldb automatically
falls back to the manual index, the tests didn't fail and this change
went largely unnoticed.

This patch updates the tests to really use debug_names (-gdwarf-5
-gpubnames) is the combination that works now, and it adds additional
checks to ensure the section is actually emitted.

Fortunately, no regressions crept in while these tests were disabled.
2020-01-16 16:25:49 +01:00
Jonas Devlieghere 982a77b694 [lldb/Reproducers] Print more info for reproducer status
Reproducer status now prints the capture/replay path. It will also print
the status of auto generation when enabled.
2020-01-15 20:25:44 -08:00
Jonas Devlieghere 066e817b42 [lldb/Reproducers] Add a flag to always generating a reproducer
Add a flag which always generates a reproducer when normally it would be
discarded. This is meant for testing purposes to capture a debugger
session without modification the session itself.
2020-01-15 19:45:54 -08:00
Paolo Severini 4bafceced6 [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging
Summary:
This is the first in a series of patches to enable LLDB debugging of
WebAssembly targets.

Current versions of Clang emit (partial) DWARF debug information in WebAssembly
modules and we can leverage this debug information to give LLDB the ability to
do source-level debugging of Wasm code that runs in a WebAssembly engine.

A way to do this could be to use the remote debugging functionalities provided
by LLDB via the GDB-remote protocol. Remote debugging can indeed be useful not
only to connect a debugger to a process running on a remote machine, but also to
connect the debugger to a managed VM or script engine that runs locally,
provided that the engine implements a GDB-remote stub that offers the ability to
access the engine runtime internal state.

To make this work, the GDB-remote protocol would need to be extended with a few
Wasm-specific custom query commands, used to access aspects of the Wasm engine
state (like the Wasm memory, Wasm local and global variables, and so on).
Furthermore, the DWARF format would need to be enriched with a few Wasm-specific
extensions, here detailed: https://yurydelendik.github.io/webassembly-dwarf.

This CL introduce classes **ObjectFileWasm**, a file plugin to represent a Wasm
module loaded in a debuggee process. It knows how to parse Wasm modules and
store the Code section and the DWARF-specific sections.

Reviewers: jasonmolenda, clayborg, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71575
2020-01-15 16:25:35 -08:00
Pavel Labath 4b5bc38802 [lldb/DWARF] Move location list sections into DWARFContext
These are the last sections not managed by the DWARFContext object. I
also introduce separate SectionType enums for dwo section variants, as
this is necessary for proper handling of single-file split dwarf.
2020-01-14 15:19:29 +01:00