Commit Graph

21627 Commits

Author SHA1 Message Date
Pavel Labath 18a96fd573 [lldb/DWARF] Fix a leak in line table construction
We were creating a bunch of LineSequence objects but never deleting
them.

This fixes the leak and changes the code to use std::unique_ptr, to make
it harder to make the same mistake again.
2020-01-21 14:44:11 +01:00
Pavel Labath 3f9b6b270f [lldb] Use llvm::stable_sort in Line
This addresses some post-commit feedback on D72909.
2020-01-21 14:09:58 +01:00
Raphael Isemann 1f7b95d038 [lldb][NFC] Convert LLDB_LOGF to LLDB_LOG in ClangASTSource.cpp 2020-01-21 13:44:22 +01:00
Jonas Devlieghere d053b7a297 [lldb/Docs] Add lldb-x86_64-fedora to the CI page 2020-01-20 11:38:40 -08:00
Jonas Devlieghere 04de24e690 [lldb/IOHandler] Improve synchronization between IO handlers.
The way the IO handlers are currently managed by the debugger is wrong. The
implementation lacks proper synchronization between RunIOHandlerSync and
RunIOHandlers. The latter is meant to be run by the "main thread", while the
former is meant to be run synchronously, potentially from a different thread.

Imagine a scenario where RunIOHandlerSync is called from a different thread
than RunIOHandlers. Both functions manipulate the debugger's IOHandlerStack.
Although the push and pop operations are synchronized, the logic to activate,
deactivate and run IO handlers is not.

While investigating PR44352, I noticed some weird behavior in the Editline
implementation. One of its members (m_editor_status) was modified from another
thread. This happened because the main thread, while running RunIOHandlers
ended up execution the IOHandlerEditline created by the breakpoint callback
thread. Even worse, due to the lack of synchronization within the IO handler
implementation, both threads ended up executing the same IO handler.

Most of the time, the IO handlers don't need to run synchronously. The
exception is sourcing commands from external files, like the .lldbinit file.

I've added a (recursive) mutex to prevent another thread from messing with the
IO handlers wile another thread is running one synchronously. It has to be
recursive, because we might have to source another file when encountering a
command source in the original file.

Differential revision: https://reviews.llvm.org/D72748
2020-01-20 11:17:55 -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
Raphael Isemann 65bab53afb [lldb][NFC] Add test for iterator invalidation during code completion. 2020-01-20 15:01:39 +01:00
Raphael Isemann 22447a61d4 [lldb] Mark the implicit copy constructor as deleted when a move constructor is provided.
Summary:
CXXRecordDecls that have a move constructor but no copy constructor need to
have their implicit copy constructor marked as deleted (see C++11 [class.copy]p7, p18)
Currently we don't do that when building an AST with ClangASTContext which causes
Sema to realise that the AST is malformed and asserting when trying to create an implicit
copy constructor for us in the expression:
```
Assertion failed: ((data().DefaultedCopyConstructorIsDeleted || needsOverloadResolutionForCopyConstructor())
    && "Copy constructor should not be deleted"), function setImplicitCopyConstructorIsDeleted, file include/clang/AST/DeclCXX.h, line 828.
```

In the test case there is a class `NoCopyCstr` that should have its copy constructor marked as
deleted (as it has a move constructor). When we end up trying to tab complete in the
`IndirectlyDeletedCopyCstr` constructor, Sema realises that the `IndirectlyDeletedCopyCstr`
has no implicit copy constructor and tries to create one for us. It then realises that
`NoCopyCstr` also has no copy constructor it could find via lookup. However because we
haven't marked the FieldDecl as having a deleted copy constructor the
`needsOverloadResolutionForCopyConstructor()` returns false and the assert fails.
`needsOverloadResolutionForCopyConstructor()` would return true if during the time we
added the `NoCopyCstr` FieldDecl to `IndirectlyDeletedCopyCstr` we would have actually marked
it as having a deleted copy constructor (which would then mark the copy constructor of
`IndirectlyDeletedCopyCstr ` as needing overload resolution and Sema is happy).

This patch sets the correct mark when we complete our CXXRecordDecls (which is the time when
we know whether a copy constructor has been declared). In theory we don't have to do this if
we had a Sema around when building our debug info AST but at the moment we don't have this
so this has to do the job for now.

Reviewers: shafik

Reviewed By: shafik

Subscribers: aprantl, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72694
2020-01-20 14:34:07 +01: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 27df2d9f55 [lldb] Don't process symlinks deep inside DWARFUnit
Summary:
This code is handling debug info paths starting with /proc/self/cwd,
which is one of the mechanisms people use to obtain "relocatable" debug
info (the idea being that one starts the debugger with an appropriate
cwd and things "just work").

Instead of resolving the symlinks inside DWARFUnit, we can do the same
thing more elegantly by hooking into the existing Module path remapping
code. Since llvm::DWARFUnit does not support any similar functionality,
doing things this way is also a step towards unifying llvm and lldb
dwarf parsers.

Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71770
2020-01-20 13:05:00 +01:00
Unnar Freyr Erlendsson 39f1335486 Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort
Summary:
Motivation: When setting breakpoints in certain projects line sequences are frequently being inserted out of order.

Rather than inserting sequences one at a time into a sorted line table, store all the line sequences as we're building them up and sort and flatten afterwards.

Reviewers: jdoerfert, labath

Reviewed By: labath

Subscribers: teemperor, labath, mgrang, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72909
2020-01-20 12:50:58 +01:00
Pavel Labath b7af1bfa6e [lldb/DWARF] Simplify DWARFDebugInfoEntry::LookupAddress
Summary:
This method was doing a lot more than it's only caller needed
(DWARFDIE::LookupDeepestBlock) needed, so I inline it into the caller,
and remove any code which is not actually used. This includes code for
searching for the deepest function, and the code for working around
incomplete DW_AT_low_pc/high_pc attributes on a compile unit DIE (modern
compiler get this right, and this method is called on function DIEs
anyway).

This also improves our llvm consistency, as llvm::DWARFDebugInfoEntry is
just a very simple struct with no nontrivial logic.

Reviewers: JDevlieghere, aprantl

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72920
2020-01-20 12:39:59 +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
Jonas Devlieghere f78f15a60e [lldb/Test] XFAIL TestRequireHWBreakpoints when HW BPs are avialable
Resolves PR44055
2020-01-18 13:15:44 -08:00
Jonas Devlieghere 2981eceec3 [debugserver] Share code between Enable/DisableHardwareWatchpoint (NFC)
This extract the common functionality of enabling and disabling hardware
watchpoints into a single function.

Differential revision: https://reviews.llvm.org/D72971
2020-01-18 11:36:56 -08:00
Fred Riss 546f8f4264 [lldb/testsuite] Modernize 2 test Makefiles
Those old Makefiles used completely ad-hoc rules for building files,
which means they didn't obey the test harness' variants.

They were somewhat tricky to update as they use very peculiar build
flags for some files. For this reason I was careful to compare the
build commands before and after the change, which is how I found the
discrepancy fixed by the previous commit.

While some of the make syntax used here might not be easy to grasp for
newcomers (per-target variable overrides), it seems better than to
have to repliacte the Makefile.rules logic for the test variants and
platform support.
2020-01-17 20:56:28 -08:00
Fred Riss 509b78883d [lldb/Makefile.rules] Force the default target to be 'all'
The test harness invokes the test Makefiles with an explicit 'all'
target, but it's handy to be able to recursively call Makefile.rules
without speficying a goal.

Some time ago, we rewrote some tests in terms of recursive invocations
of Makefile.rules. It turns out this had an unintended side
effect. While using $(MAKE) for a recursive invocation passes all the
variables set on the command line down, it doesn't pass the make
goals. This means that those recursive invocations would invoke the
default rule. It turns out the default rule of Makefile.rules is not
'all', but $(EXE). This means that ti would work becuase the
executable is always needed, but it also means that the created
binaries would not follow some of the other top-level build
directives, like MAKE_DSYM.

Forcing 'all' to be the default target seems easier than making sure
all the invocations are correct going forward. This patch does this
using the .DEFAULT_GOAL directive rather than hoisting the 'all' rule
to be the first one of the file. It seems like this explicit approach
will be less prone to be broken in the future. Hopefully all the make
implementations we use support it.
2020-01-17 20:34:16 -08:00
Jonas Devlieghere a93aa53476 [lldb/Docs] Fix formatting for the variable formatting page 2020-01-17 14:17:26 -08:00
Vedant Kumar 510758dae2 debugserver: Pass -arch flags to mig invocation as needed
Specify -isysroot and any necessary -arch flags in the `mig` invocation
when CMAKE_OSX_ARCHITECTURES is set (needed for the bridgeOS build).
2020-01-17 13:11:54 -08:00
Adrian Prantl 7b30370e5b Move the sysroot attribute from DIModule to DICompileUnit
[this re-applies c0176916a4
 with the correct commit message and phabricator link]

This addresses point 1 of PR44213.
https://bugs.llvm.org/show_bug.cgi?id=44213

The DW_AT_LLVM_sysroot attribute is used for Clang module debug info,
to allow LLDB to import a Clang module from source. Currently it is
part of each DW_TAG_module, however, it is the same for all modules in
a compile unit. It is more efficient and less ambiguous to store it
once in the DW_TAG_compile_unit.

This should have no effect on DWARF consumers other than LLDB.

Differential Revision: https://reviews.llvm.org/D71732
2020-01-17 12:55:40 -08:00
Adrian Prantl c17aee67f1 Revert "Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot"
This reverts commit 12e479475a.

I accidentally landed this patch with the wrong commit message ...
2020-01-17 12:52:36 -08:00
Adrian Prantl ec9a3cccd4 Update testcase for LLVM IR change (sysroot) 2020-01-17 11:04:55 -08:00
Davide Italiano c1bc094f36 [TestQuoting] Use the fully qualified path for remote platforms.
Patch by Jason Molenda, fixes a test failure on arm64 devices.
2020-01-17 10:57:35 -08:00
Adrian Prantl 12e479475a Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot
This is a purely cosmetic change that is NFC in terms of the binary
output. I bugs me that I called the attribute DW_AT_LLVM_isysroot
since the "i" is an artifact of GCC command line option syntax
(-isysroot is in the category of -i options) and doesn't carry any
useful information otherwise.

This attribute only appears in Clang module debug info.

Differential Revision: https://reviews.llvm.org/D71722
2020-01-17 09:36:48 -08:00
Sam McCall d035c832c3 [lldb] Try to fix writing outside temp dir from 4bafceced6 2020-01-17 17:30:12 +01:00
Raphael Isemann 791f132132 [lldb] Remove out of order OperatingSystemPython::Terminate call in SystemInitializerFull
We already call it later in the method (which is in the right order as we Initialize it
at the of the constructor).
2020-01-17 13:02:15 +01:00
Raphael Isemann f2d41ad0e7 [lldb] Add missing terminate calls to Python/Lua subsystems 2020-01-17 12:49:57 +01:00
Raphael Isemann c3ab790c8f [lldb][NFC] Resynchronize Init/Terminate calls in SystemInitializerFull/Test.cpp files.
These files should do the more or less the same initialize/terminate calls in the
same order. This just reverts all the differences that have piled up over time
in the SystemInitializerTest that people keep forgetting about.
2020-01-17 11:34:59 +01:00
Raphael Isemann 6b840834cd [lldb][NFC] Delete unused lldb/source/Plugins/LanguageRuntime/Go/CMakeLists.txt 2020-01-17 09:57:44 +01:00
Raphael Isemann 5ac610668a [lldb] Re-add NSDate formatter
This test had been overwritten by accident in ff75262f70.
This just readds the test with the correct content.
2020-01-17 08:56:05 +01:00
Alex Langford 9dbd395b9b [lldb] Remove ClangASTContext.h inclusion in Target.cpp
Target doesn't use ClangASTContext, it just needs
PersistentExpressionState. Replace ClangASTContext.h with
ExpressionVariable.h
2020-01-16 22:43:10 -08:00
Jonas Devlieghere e1f6b68d1f [lldb/Cmake] Add a CMakeLists.txt to the utils directory...
... and include it from the main CMakeLists.txt instead of including the
utility subdirectories directly. This is consistent with the other
subdirectories and limits the scope of future changes.
2020-01-16 22:31:01 -08:00
Jonas Devlieghere 911a4c4dda [lldb/Test] Fix API tests for mutli-config generators
The build configuration wasn't properly substituted for the
config.lldb_executable variable. This broke when the variable was
extracted from config.dotest_args_str which was properly substituted.
2020-01-16 22:25:55 -08:00
Jonas Devlieghere d3d7666678 [lldb/CMake] Remove duplicate entry 2020-01-16 20:08:55 -08:00
Jonas Devlieghere 25cf941275 [lldb/CMake] Set LLVM_HOST_TRIPLE from TARGET_TRIPLE in standalone builds.
LLVMConfig doesn't export LLVM_HOST_TRIPLE, but it sets the
TARGET_TRIPLE based on this variable. So use that again for the compiler
invocations in the shell tests.
2020-01-16 20:06:25 -08:00
Cyndy Ishida 24fca5cd71 [lldb] add to gdb to lldb doc
Summary: * enabling and disabling a breakpoint were missing.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: merge_guards_bot, jingham, dexonsmith, ributzka, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72898
2020-01-16 19:56:45 -08:00
Adrian Prantl f55ab6f90b Fix a buffer-size bug when the first DW_OP_piece is undefined
and document the shortcomings of LLDB's partially defined DW_OP_piece
handling.

This would manifest as "DW_OP_piece for offset foo but top of stack is
of size bar".

rdar://problem/46262998

Differential Revision: https://reviews.llvm.org/D72880
2020-01-16 16:47:59 -08:00
Adrian Prantl 7b0d58e339 Add testing for DW_OP_piece and fix a bug with small Scalar values.
By switching to Scalars that are backed by explicitly-sized APInts we
can avoid a bug that increases the buffer reserved for a small piece
to the next-largest host integer type.

This manifests as "DW_OP_piece for offset foo but top of stack is of size bar".

Differential Revision: https://reviews.llvm.org/D72879
2020-01-16 16:47:36 -08:00
Jonas Devlieghere 2671df9bd6 [lldb/Debugger] Rename ExecuteIOHandlers to RunIOHandlers (NFC)
This improves consistency among the related methods.
2020-01-16 16:45:47 -08:00
Nico Weber fb5fafb23c Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well.
When LLVM_APPEND_VC_REV=OFF is set, the current git hash is no
longer embedded into binaries (mostly for --version output).
Without it, most binaries need to relink after every single
commit, even if they didn't change otherwise (due to, say,
a documentation-only commit).

LLVM_APPEND_VC_REV is ON by default, so this doesn't change the
default behavior of anything.

With this, all clients of GenerateVersionFromVCS.cmake honor
LLVM_APPEND_VC_REV.

Differential Revision: https://reviews.llvm.org/D72855
2020-01-16 19:04:08 -05:00
Vedant Kumar 6c4d377334 lldb: xfail TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on arm/aarch64
This effectively reverts commit
8d2f252bb8, which went a bit too far and
disabled these on all non-Darwin systems.
2020-01-16 14:48:51 -08:00
Jonas Devlieghere 5f8e412188 [lldb/test] Exted test for CMTime data formatter
Cover more cases handled by the formatter.
2020-01-16 11:58:34 -08:00
Adrian Prantl c0d909a1b1 Delete control character from comment. (NFC) 2020-01-16 10:44:07 -08: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
Derek Schuff d34e4152e3 [LLDB] Convert Plugins/ObjectFile/wasm/ObjectFileWasm.h to unix line endings 2020-01-16 09:38:37 -08: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
Jonas Devlieghere 26646761e2 [lldb/Scripts] Remove swig_bot_lib/__init__.py 2020-01-16 09:15:41 -08:00
Raphael Isemann 81eaa3ddd0 [lldb][NFC] Delete TestDataFormatterObjCNSDate.py
This test is just TestDataFormatterObjCNSData.py copied but without any changes
(and it therefore doesn't even test NSDate).

It's also failing as NSData has been changed by me in
4f244bba4f.
2020-01-16 17:28:07 +01: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