Commit Graph

21423 Commits

Author SHA1 Message Date
Jonas Devlieghere 039d4b3aa2 [lldb/Reproducers] Don't instrument SBFileSpec::GetPath
This method uses a char* and length as output arguments and the
reproducer instrumentation doesn't know how to deal with that (yet).
2019-12-04 18:20:20 -08:00
Jonas Devlieghere 6ee96ddec8 [lldb/Reproducers] Add missing instrumentation for SBFile (2/2)
Found another issue while running TestDefaultConstructorForAPIObjects.
2019-12-04 18:20:20 -08:00
Jim Ingham 3151d7af72 Clear out the python class name in OptionParsingStarted for the OptionGroupPythonClassWithDict
options class.  This value was hanging around so for instance if you made a scripted breakpoint
resolver, then went to set another breakpoint, it would still think you had passed in a class
name and the breakpoint wouldn't do what you expected.
2019-12-04 17:40:57 -08:00
Jonas Devlieghere fe5ab6d2cb [lldb/Reproducers] Add missing instrumentation for SBFile
This was properly captured by the instrumentation framework when running
TestRunCommandInterpreterAPI.py in capture-mode.
2019-12-04 17:37:21 -08:00
Jonas Devlieghere acda2bc0ad [lldb/Reproducers] Propagate LLDB_CAPTURE_REPRODUCER to the test suite 2019-12-04 16:49:11 -08:00
Jonas Devlieghere dfe9a7943b [lldb/Reproducers] Override capture with LLDB_CAPTURE_REPRODUCER env var
Make it possible to override reproducer capture with the
LLDB_CAPTURE_REPRODUCER environment variable.

The goal of this change is twofold.

(1) I want to be able to enable capturing reproducers during regular
    test runs, both locally and on the bots. To do so I need a way to
    force capture. I cannot do this through the Python API, because
    reproducer capture must be enabled *before* the debugger
    initialized, which happens automatically when doing `import lldb`.

(2) I want to provide an escape hatch for when reproducers are enabled
    by default. Downstream we have reproducer capture enabled by default
    in the driver.

This patch solves both problems by overriding the reproducer mode based
on the environment variable. Acceptable values are 0/1 and ON/OFF.
2019-12-04 16:49:11 -08:00
Jason Molenda e1a7d042c3 Add parray example for lldb, vrs. *ptr@count gdb cmd. 2019-12-04 15:44:15 -08:00
Jason Molenda e001bf6330 Add help text for parray and poarray aliases. 2019-12-04 15:33:54 -08:00
Jason Molenda e11df58580 Upstream debugserver arm64e support.
The changes are minor; primarily debugserver needs to go through
accessor functions/macros when changing pc/fp/sp/lr, and debugserver
needs to clear any existing pointer auth bits from values in two
cases.  debugserver can fetch the number of bits used for addressing
from a sysctl, and will include that in the qHostInfo reply.  Update
qHostInfo documentation to document it.
2019-12-04 15:20:56 -08:00
Martin Storsjö 276a5b2d5f [LLDB] Actually fix the win-i386-line-table.s test when executed on windows
The previous fix attempt, in 62a635e864, used too much escaping
for the backslashes.

But instead of using regexes to match both path separator forms,
remove the path altogether to unify the output from the testcase
between platforms.
2019-12-04 23:55:34 +02:00
Pavel Labath 92cd68f48e [lldb] Simplify debug_{rnglists,ranges}.s tests
Remove things irrelevant to the test.
2019-12-04 17:08:23 +01:00
Joseph Tremoulet 95b2e516bd Change Target::FindBreakpointsByName to return Expected<vector>
Summary:
Using a BreakpointList corrupts the breakpoints' IDs because
BreakpointList::Add sets the ID, so use a vector instead, and
update the signature to return the vector wrapped in an
llvm::Expected which can propagate any error from the inner
call to StringIsBreakpointName.

Note that, despite the similar name, SBTarget::FindBreakpointsByName
doesn't suffer the same problem, because it uses a SBBreakpointList,
which is more like a BreakpointIDList than a BreakpointList under the
covers.

Add a check to TestBreakpointNames that, without this fix, notices the
ID getting mutated and fails.

Reviewers: jingham, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70907
2019-12-04 09:57:15 -05:00
Raphael Isemann 5e71356393 [lldb] Fix macOS build by replacing nullptr with FileSpec()
Before we had a implicit conversion from nullptr to FileSpec
which was thankfully removed.
2019-12-04 14:37:10 +01:00
Pavel Labath 150c8dd13b [lldb] Remove some (almost) unused Stream::operator<<'s
llvm::raw_ostream provides equivalent functionality.
2019-12-04 11:07:46 +01:00
Pavel Labath 1351672eed [lldb] s/assertTrue/assertEqual in TestStepTarget.py
this improves error messages.
2019-12-04 10:56:38 +01:00
Pavel Labath 28e4942b2c [lldb] Remove FileSpec(FileSpec*) constructor
This constructor was the cause of some pretty weird behavior. Remove it,
and update all code to properly dereference the argument instead.
2019-12-04 10:49:25 +01:00
Raphael Isemann 16d2013044 [lldb] Add test for Stream::Address and Stream::AddressRange
I'm refactoring those functions, so we should have some tests for
them before doing that.
2019-12-04 10:45:30 +01:00
Pavel Labath 817d6184e7 [lldb/Editline] Fix a -Wreturn-type warning with gcc 2019-12-04 10:44:12 +01:00
Pavel Labath 532290e69f [lldb] s/FileSpec::Equal/FileSpec::Match
Summary:
The FileSpec class is often used as a sort of a pattern -- one specifies
a bare file name to search, and we check if in matches the full file
name of an existing module (for example).

These comparisons used FileSpec::Equal, which had some support for it
(via the full=false argument), but it was not a good fit for this job.

For one, it did a symmetric comparison, which makes sense for a function
called "equal", but not for typical searches (when searching for
"/foo/bar.so", we don't want to find a module whose name is just
"bar.so"). This resulted in patterns like:
    if (FileSpec::Equal(pattern, file, pattern.GetDirectory()))
which would request a "full" match only if the pattern really contained
a directory. This worked, but the intended behavior was very unobvious.

On top of that, a lot of the code wanted to handle the case of an
"empty" pattern, and treat it as matching everything. This resulted in
conditions like:
    if (pattern && !FileSpec::Equal(pattern, file, pattern.GetDirectory())
which are nearly impossible to decipher.

This patch introduces a FileSpec::Match function, which does exactly
what most of FileSpec::Equal callers want, an asymmetric match between a
"pattern" FileSpec and a an actual FileSpec. Empty paterns match
everything, filename-only patterns match only the filename component.

I've tried to update all callers of FileSpec::Equal to use a simpler
interface. Those that hardcoded full=true have been changed to use
operator==. Those passing full=pattern.GetDirectory() have been changed
to use FileSpec::Match.

There was also a handful of places which hardcoded full=false. I've
changed these to use FileSpec::Match too. This is a slight change in
semantics, but it does not look like that was ever intended, and it was
more likely a result of a misunderstanding of the "proper" way to use
FileSpec::Equal.

[In an ideal world a "FileSpec" and a "FileSpec pattern" would be two
different types, but given how widespread FileSpec is, it is unlikely
we'll get there in one go. This at least provides a good starting point
by centralizing all matching behavior.]

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: emaste, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70851
2019-12-04 10:42:32 +01:00
Raphael Isemann 4d37f18b29 [lldb][NFC] Extract single member parsing out of DWARFASTParserClang::ParseChildMembers
ParseChildMembers does a few things, only one part is actually parsing a single
member. This extracts the member parsing logic into its own function.

This commit just moves the code as-is into its own function and forwards the parameters/
local variables to it, which means it should be NFC.

The only actual changes to the code are replacing 'break's (and one very curious 'continue'
that behaves like a 'break') with 'return's.
2019-12-04 10:05:40 +01:00
Raphael Isemann c4c464f8a5 [lldb][NFC] Migrate to raw_ostream in Module::GetDescription 2019-12-04 09:35:50 +01:00
Raphael Isemann 2f1e7b3d01 [lldb][NFC] Migrate to raw_ostream in ArchSpec::DumpTriple
Reviewers: labath, davide

Reviewed By: davide

Subscribers: clayborg, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70979
2019-12-04 08:28:52 +01:00
Davide Italiano cec82634a4 [Process] GetLanguageRuntimes() takes an argument that's always constant.
And arguably `retry_if_null` isn't really descriptive of what
the flag did anyway.
2019-12-03 16:54:55 -08:00
Davide Italiano 11ae9dd657 [ClangASTContext] Remove a very old hack.
This was fixed in clang a while ago, and the rdar associated
is now closed.
2019-12-03 16:32:21 -08:00
Davide Italiano 2bb19f93f6 [TypeCategory] HasLanguage() is now unused. 2019-12-03 15:45:23 -08:00
Davide Italiano 0cfb4a6b3d [FormatManager] Provide only one variant of EnableCategory.
All the callers pass a single language anyway.
2019-12-03 15:03:25 -08:00
Davide Italiano 89618a7ce1 [DataVisualization] Simplify. NFCI. 2019-12-03 15:03:25 -08:00
Davide Italiano 15a172bebb [TypeCategory] Nothing passes down a list of languages.
Summary: This should allow further simplifications, but it's a first step.

Reviewers: teemperor, jingham, friss

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70983
2019-12-03 13:57:58 -08:00
Jonas Devlieghere 0e9b0b6d11 [EditLine] Fix RecallHistory to make it go in the right direction.
The naming used by editline for the history operations is counter
intuitive to how it's used in lldb for the REPL.

 - The H_PREV operation returns the previous element in the history,
   which is newer than the current one.
 - The H_NEXT operation returns the next element in the history, which
   is older than the current one.

This exposed itself as a bug in the REPL where the behavior of up- and
down-arrow was inverted. This wasn't immediately obvious because of how
we save the current "live" entry.

This patch fixes the bug and introduces and enum to wrap the editline
operations that match the semantics of lldb.

Differential revision: https://reviews.llvm.org/D70932
2019-12-03 08:12:10 -08:00
Jonas Devlieghere 62827737ac [lldb/Reproducer] Add version check
To ensure a reproducer works correctly, the version of LLDB used for
capture and replay must match. Right now the reproducer already contains
the LLDB version. However, this is purely informative. LLDB will happily
replay a reproducer generated with a different version of LLDB, which
can cause subtle differences.

This patch adds a version check which compares the current LLDB version
with the one in the reproducer. If the version doesn't match, LLDB will
refuse to replay. It also adds an escape hatch to make it possible to
still replay the reproducer without having to mess with the recorded
version. This might prove useful when you know two versions of LLDB
match, even though the version string doesn't. This behavior is
triggered by passing a new flag -reproducer-skip-version-check to the
lldb driver.

Differential revision: https://reviews.llvm.org/D70934
2019-12-03 07:54:42 -08:00
Pavel Labath ad5bb05405 [lldb] Remove unneeded semicolon in IOHandlerCursesGUI 2019-12-03 16:22:52 +01:00
Pavel Labath 159641d710 [lldb] Use llvm range functions in LineTable.cpp
to avoid needing to declare iterators everywhere.
2019-12-03 16:22:52 +01:00
Alexandre Ganea 1cc0ba4cbd [LLDB] Disable MSVC warning C4190: 'LLDBSwigPythonBreakpointCallbackFunction' has C-linkage specified, but returns UDT 'llvm::Expected<bool>' which is incompatible with C
Differential Revision: https://reviews.llvm.org/D70830
2019-12-03 09:53:26 -05:00
Raphael Isemann 7caa17caf8 [lldb][NFC] Move Curses interface implementation to own file
Summary:
The IOHandler class source file is currently around 4600 LOC. However only 200
of these lines are concerned with the actual IOHandler class and the rest are the
implementations for Editline, IOHandlerConfirm and the Curses interface. All these
large features also cause that the IOHandler (which is in Core) has a large set of dependencies
on other parts of LLDB.

This patch splits out the code for the curses interface into its own file. This way
the simple IOHandler code is no longer buried in-between much larger functionalities.

Next up is splitting out the other IOHandlers into their own files and then move them
to more appropriate parts of LLDB.

Reviewers: labath, clayborg, JDevlieghere

Reviewed By: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70946
2019-12-03 14:01:18 +01:00
Djordje Todorovic 409350deea Revert "[LiveDebugValues] Introduce entry values of unmodified params"
This reverts commit rG4cfceb910692 due to LLDB test failing.
2019-12-03 13:13:27 +01:00
Raphael Isemann 16c0653db1 [lldb][NFC] Extract searching for function SymbolContexts out of ClangExpressionDeclMap::LookupFunction
This code was just creating a new SymbolContextList with any found functions
in the front and orders them by how close they are to the current frame.
This refactors this code into its own function to make this more obvious.

Doesn't do any other changes to the code, so this is NFC.
2019-12-03 12:33:24 +01:00
Raphael Isemann b37a43d93d [lldb] Remove all remaining tabs from TestReturnValue.py
I assumed this was just a single typo, but it seems we actually have
a whole bunch of tabs in this file which cause Python to complain
about mixing tabs and spaces.
2019-12-03 12:14:40 +01:00
Raphael Isemann 4821d2a014 [lldb][NFC] Test going up/down one line in the multiline expression editor 2019-12-03 12:06:40 +01:00
Diana Picus 057626b439 Fixup 6d18e53: xfail TestShowLocationDwarf5.py properly
Forgot to squash this...
2019-12-03 11:53:28 +01:00
Raphael Isemann 46d0ec3a80 [lldb] Remove tab from TestReturnValue.py
Mixing tabs and spaces makes Python exit with this error:

  File "llvm/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py", line 23
    return (self.getArchitecture() == "aarch64" and self.getPlatform() == "linux")
                                                                                 ^
TabError: inconsistent use of tabs and spaces in indentation
2019-12-03 11:44:24 +01:00
Pavel Labath 2b8db387f2 [lldb] Move register info "augmentation" from gdb-remote into ABI
Summary:
Previously the ABI plugin exposed some "register infos" and the
gdb-remote code used those to fill in the missing bits. Now, the
"filling in" code is in the ABI plugin itself, and the gdb-remote code
just invokes that.

The motivation for this is two-fold:
a) the "augmentation" logic is useful outside of process gdb-remote. For
  instance, it would allow us to avoid repeating the register number
  definitions in minidump code.
b) It gives more implementation freedom to the ABI classes. Now that
  these "register infos" are essentially implementation details, classes
  can use other methods to obtain dwarf/eh_frame register numbers -- for
  instance they can consult llvm MC layer.

Since the augmentation code was not currently tested anywhere, I took
the opportunity to create a simple test for it.

Reviewers: jasonmolenda, clayborg, tatyana-krasnukha

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70906
2019-12-03 11:39:20 +01:00
Djordje Todorovic 4cfceb9106 [LiveDebugValues] Introduce entry values of unmodified params
The idea is to remove front-end analysis for the parameter's value
modification and leave it to the value tracking system. Front-end in some
cases marks a parameter as modified even the line of code that modifies the
parameter gets optimized, that implies that this will cover more entry
values even. In addition, extending the support for modified parameters
will be easier with this approach.

Since the goal is to recognize if a parameter’s value has changed, the idea
at very high level is: If we encounter a DBG_VALUE other than the entry
value one describing the same variable (parameter), we can assume that the
variable’s value has changed and we should not track its entry value any
more. That would be ideal scenario, but due to various LLVM optimizations,
a variable’s value could be just moved around from one register to another
(and there will be additional DBG_VALUEs describing the same variable), so
we have to recognize such situation (otherwise, we will lose a lot of entry
values) and salvage the debug entry value.

Differential Revision: https://reviews.llvm.org/D68209
2019-12-03 11:01:45 +01:00
Diana Picus 6d18e5366c Mark some tests as xfail on AArch64 Linux
I have either opened new bug reports for these tests, or added links to
existing bugs.

This should help make the lldb-aarch64-ubuntu buildbot green (there will
still be some unexpected passes that someone should look into, but those
can be handled later).
2019-12-03 10:57:42 +01:00
Raphael Isemann 315600f480 [lldb][NFC] Remove ThreadSafeSTLVector and ThreadSafeSTLMap and their use in ValueObjectSynthetic
Summary:
ThreadSafeSTLVector and ThreadSafeSTLMap are not useful for achieving any degree of thread safety in LLDB
and should be removed before they are used in more places. They are only used (unsurprisingly incorrectly) in
`ValueObjectSynthetic::GetChildAtIndex`, so this patch replaces their use there with a simple mutex with which
we guard the related data structures. This doesn't make ValueObjectSynthetic::GetChildAtIndex
any more thread-safe, but on the other hand it at least allows us to get rid of the ThreadSafeSTL* data structures
without changing the observable behaviour of ValueObjectSynthetic (beside that it is now a few bytes smaller).

Reviewers: labath, JDevlieghere, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70845
2019-12-03 09:18:44 +01:00
Martin Storsjö 62a635e864 [LLDB] [test] Try to fix the test from 7d019d1a3b when run on Windows. 2019-12-02 23:36:36 +02:00
Jonas Devlieghere 8f2c100f6f [lldb/CMake] Add in_call_stack to the utilities package
A subset of the examples are shipped as python packages. Include the
in_call_stack utility.
2019-12-02 13:03:24 -08:00
Jonas Devlieghere e5290a06d6 [lldb/CMake] Simplify logic for adding example Python packages (NFC)
This simplifies the CMake logic for adding the Python examples to the
Python package. It unifies the use of create_python_package by adding
the NOINIT option and removes the `target` argument, which is always
`finish_swig`.
2019-12-02 13:03:24 -08:00
Martin Storsjö 7d019d1a3b [LLDB] Set the right address size on output DataExtractors from ObjectFile
If filling in a DataExtractor from an ObjectFile, e.g. via the
ReadSectionData method, the output DataExtractor gets the address
size from the m_data member.

ObjectFile's m_data member is initialized without knowledge about
the address size (so the address size is set based on the host's
sizeof(void*), and at that point within ObjectFile's constructor,
virtual methods implemented in subclasses (like GetAddressByteSize())
can't be called, therefore fix it up when filling in external
DataExtractors.

This makes sure that line tables from executables with a different
address size are parsed properly; previously this tripped up
DWARFDebugLine::LineTable::parse for 32 bit executables on a 64 bit
host, as the address size in the line table (4) didn't match the
one set in the DWARFDataExtractor.

Differential Revision: https://reviews.llvm.org/D70848
2019-12-02 22:42:00 +02:00
António Afonso afd5d91281 [lldb] Fix TestFormattersSBAPI test
Summary:
This test was broken in two ways:
* Using the wrong API (e.g.: format = instead of SetFormat)
* The hex checker was only checking "01" which will pass with 0x0000001

Reviewers: clayborg, lanza, wallace

Reviewed By: clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70884
2019-12-02 12:24:11 -08:00
Raphael Isemann d62026e2dd [lldb][NFC] Don't calculate member indices in DWARFASTParserClang::ParseChildMembers
We keep counting members and then don't do anything with the computed result.
2019-12-02 14:43:40 +01:00
Raphael Isemann 4f728bfc13 [lldb][NFC] Use raw_ostream instead of Stream in Baton::GetDescription
Removing raw_ostream here is getting us closer to removing LLDB's Stream
class.
2019-12-02 13:27:21 +01:00
Raphael Isemann f8fb3729e9 [lldb][NFC] Make Stream's IndentLevel an unsigned integers.
We expect it to be always positive values and LLVM/Clang's IndentLevel
values are already unsigned integers, so we should do the same.
2019-12-02 13:01:26 +01:00
Raphael Isemann 160a5045c6 [lldb][NFC] Add 'breakpoint command list' test
The command has zero test coverage and I'll have to touch the
code formatting the output commands, so let's start by adding a
test for it.
2019-12-02 11:57:55 +01:00
Martin Storsjö 45c843de4e [LLDB] [ARM] Use r11 as frame pointer on Windows on ARM
Extend EmulateMOVRdRm to identify "mov r11, sp" in thumb mode as
setting the frame pointer, if r11 is the frame pointer register.

Differential Revision: https://reviews.llvm.org/D70797
2019-11-29 16:06:17 +02:00
Raphael Isemann 8059188c45 [lldb][NFC] Remove unused ClangASTContext::GetBasicType(ConstString) 2019-11-29 14:11:25 +01:00
Raphael Isemann c214c92f3b [lldb][NFC] Remove ClangASTContext::GetBuiltinTypeForEncodingAndBitSize overload 2019-11-29 13:57:02 +01:00
Raphael Isemann bc7f1df6b6 [lldb][NFC] Explicitly ask for a ClangASTContext in ClangASTSource
ClangASTSource currently takes a clang::ASTContext and keeps that
around, but a lot of LLDB's functionality for doing operations
on a clang::ASTContext is in its ClangASTContext twin class. We
currently constantly recompute the respective ClangASTContext
from the clang::ASTContext while we instead could just pass and
store a ClangASTContext in the ClangASTSource. This also allows
us to get rid of a bunch of unreachable error checking for cases
where recomputation fails for some reason.
2019-11-29 13:28:55 +01:00
Raphael Isemann 76016f9b3a [lldb][NFC] Early exit in ClangASTContext::CreateInstance 2019-11-29 12:49:33 +01:00
Pavel Labath 656a8123de [lldb] Fix windows build for 38870af 2019-11-29 12:48:25 +01:00
Raphael Isemann d752b75d7f [lldb][NFC] Simplify regex_chars in CommandCompletions 2019-11-29 12:34:23 +01:00
Raphael Isemann d1d6049e9d [lldb][NFC] Remove dead logging code from DWARFASTParserClang::CompleteRecordType
This code is behind a `if (log)` that is always a nullptr as the initializer
was commented out. One could uncomment the initializer code, but then this logging
code just leads to a deadlock as it tries to aquire the module lock.
This removes the logging code until I get this working again.
2019-11-29 12:13:34 +01:00
Pavel Labath 38870af859 [lldb] Remove FileSpec->CompileUnit inheritance
Summary:
CompileUnit is a complicated class. Having it be implicitly convertible
to a FileSpec makes reasoning about it even harder.

This patch replaces the inheritance by a simple member and an accessor
function. This avoid the need for casting in places where one needed to
force a CompileUnit to be treated as a FileSpec, and does not add much
verbosity elsewhere.

It also fixes a bug where we were wrongly comparing CompileUnit& and a
CompileUnit*, which compiled due to a combination of this inheritance
and the FileSpec*->FileSpec implicit constructor.

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70827
2019-11-29 11:44:45 +01:00
Raphael Isemann a48b5e2474 [lldb][NFC] Fix header guard comment in ThreadSafeDenseMap.h 2019-11-29 11:34:18 +01:00
Konrad Kleine c671639af6 [lldb] NFC: refactor CompileUnit::ResolveSymbolContext
Summary:
I found the above named method hard to read because it had

a) many nested blocks,
b) one return statement at the end with some logic involved,
c) a duplicated while-loop with just small differences in it.

I decided to refactor this function by employing an early exit strategy.
In order to capture the logic in the return statement and to not have it
repeated more than once I chose to implement a very small lamda function
that captures all the variables it needs.
I also replaced the two while-loops with just one.

This is a non-functional change (NFC).

Reviewers: jdoerfert, teemperor

Reviewed By: teemperor

Subscribers: labath, teemperor, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70774
2019-11-28 21:37:31 +01:00
Alexandre Ganea bdad3ec75a [LLDB] On Windows, force error message formatting to English
This fixes the Utility/StatusTest.ErrorWin32 unit test on non-English locales.

Differential Revision: https://reviews.llvm.org/D70442
2019-11-28 14:15:13 -05:00
Alexandre Ganea b4dfc5508f [LLDB] Fix wrong argument in CommandObjectThreadStepWithTypeAndScope
Differential Revision: https://reviews.llvm.org/D70448
2019-11-28 14:00:56 -05:00
Raphael Isemann c2dd84e396 [lldb][NFC] Remove CompilerDeclContext::IsClang
This method is only used in ClangASTContext.

Also removes the includes we only needed for the ClangASTContext RTTI check
in the CompilerDecl[Context].cpp files.
2019-11-28 15:54:11 +01:00
Raphael Isemann f39277c1d3 [lldb][NFC] Remove unused variable in ClangASTSource::CompleteType
Now that CompilerDeclContext is a trivial class, Clang started warning
that this unused variable is in fact unused. Let's remove it.
2019-11-28 15:32:56 +01:00
Raphael Isemann e0203b25af [lldb][NFC] Simplify CompilerDecl and CompilerDeclContext initialization 2019-11-28 15:27:54 +01:00
Raphael Isemann 3cd8ba0e37 [lldb][NFC] Remove unused CompilerDecl::IsClang 2019-11-28 15:11:37 +01:00
Pavel Labath b18e190b7c [lldb] refactor FileSpec::Equal
The logic of this function was quite hard to follow. Replace it with a
much simpler, equivalent, implementation.
2019-11-28 14:33:25 +01:00
Pavel Labath bf716eb807 [lldb] Add FileSpec::Equal unit tests
this is in preparation of a refactor of this method.
2019-11-28 14:31:52 +01:00
Pavel Labath d1a561d446 [lldb] Simplify and improve FileSpecTest
Summary:
A most of these tests create FileSpecs with a hardcoded style. Add
utility functions which create a file spec of a given style to simplify
things.

While in there add SCOPED_TRACE messages to tests which loop over
multiple inputs to ensure it's clear which of the inputs failed.

Reviewers: teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70814
2019-11-28 14:31:29 +01:00
Raphael Isemann 50e2ffa18d Revert "[lldb] NFC: refactor CompileUnit::ResolveSymbolContext"
This reverts commit 373e2a4f69.

This broke breakpoint setting.
2019-11-28 14:25:46 +01:00
Raphael Isemann 42c857aa47 [lldb][NFC] Remove unused STLUtil include and STLUtil.h header 2019-11-28 14:11:35 +01:00
Raphael Isemann a54ef8af89 [lldb][NFC] Use llvm::StringRef instead of C-strings as multimap key 2019-11-28 14:05:47 +01:00
Konrad Kleine 373e2a4f69 [lldb] NFC: refactor CompileUnit::ResolveSymbolContext
Summary:
I found the above named method hard to read because it had

a) many nested blocks and
b) one return statement at the end with some logic involved.

I decided to refactor this function by employing an early exit strategy.
In order to capture the logic in the return statement and to not have it
repeated more than once I chose to implement a very small lamda function
that captures all the variables it needs.

This is a non-functional change (NFC).

Reviewers: jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70774
2019-11-28 14:00:38 +01:00
Raphael Isemann 2e3c040ee0 [lldb][NFC] Remove unused CStringToDIEMap typedef 2019-11-28 13:33:19 +01:00
Raphael Isemann ee79feaec3 [lldb][NFC] Remove forward declaration of PrivateAutoCompleteMembers
That's declared directly above the actual definition, so it serves no use.
2019-11-28 12:45:48 +01:00
Raphael Isemann 9d2679152a [lldb][NFC] Make GetAsCXXRecordDecl static
All other casting functions there are static, so this should
be too.
2019-11-28 12:24:41 +01:00
Martin Storsjö f286f2dda4 [LLDB] [test] Add a missing "REQUIRES: arm" line 2019-11-28 13:18:15 +02:00
Raphael Isemann f7e31e0cfd [lldb][NFC] Split up DWARFASTParserClang::CompleteTypeFromDWARF
Moving the different parts into their own functions without any additional
cleanup/refactoring, so this is NFC.
2019-11-28 10:45:29 +01:00
Martin Storsjö f5c54f4032 [LLDB] Always interpret arm instructions as thumb on windows
Windows on ARM always uses thumb mode, and doesn't have most of the
mechanisms that are used in e.g. ELF for distinguishing between arm
and thumb.

Differential Revision: https://reviews.llvm.org/D70796
2019-11-28 11:27:00 +02:00
Martin Storsjö 934c025e9b [LLDB] [PECOFF] Look for the truncated ".eh_fram" section name
COFF section names can either be stored truncated to 8 chars, in the
section header, or as a longer section name, stored separately in the
string table.

libunwind locates the .eh_frame section by runtime introspection,
which only works for section names stored in the section header (as
the string table isn't mapped at runtime). To support this behaviour,
lld always truncates the section names for sections that will be
mapped, like .eh_frame.

Differential Revision: https://reviews.llvm.org/D70745
2019-11-28 11:27:00 +02:00
Martin Storsjö 2e5bb6d8d9 [LLDB] [PECOFF] Factorize mapping section names to types using StringSwitch. NFCI.
Keep the existing special cases based on combinations of section name,
flags and sizes/offsets.

Differential Revision: https://reviews.llvm.org/D70778
2019-11-28 11:27:00 +02:00
Raphael Isemann b44e91a472 [lldb] Remove debugging code used for LLDB_DWARF_DONT_COMPLETE_TYPENAMES
Reviewers: labath, clayborg, shafik

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70802
2019-11-28 10:21:58 +01:00
Raphael Isemann 92d5ea5d16 [lldb][NFC] Move TypeSystem RTTI to static variable to remove swift reference 2019-11-27 10:28:02 +01:00
Raphael Isemann f1b117394d [lldb][NFC] Remove unused CompilerType memory functions
Summary:
All these functions are unused from what I can see. Unless I'm missing something here, this code
can go the way of the Dodo.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70770
2019-11-27 09:51:50 +01:00
Martin Storsjö 344bdeb797 [LLDB] Avoid using InitializeContext for zero-initializing a CONTEXT. NFC.
InitializeContext is useful for allocating a (potentially variable
size) CONTEXT struct in an unaligned byte buffer. In this case, we
already have a fixed size CONTEXT we want to initialize, and we only
used this as a very roundabout way of zero initializing it.

Instead just memset the CONTEXT we have, and set the ContextFlags field
manually.

This matches how it is done in NativeRegisterContextWindows_*.cpp.

This also makes LLDB run successfully in Wine (for a trivial tested
case at least), as Wine hasn't implemented the InitializeContext
function.

Differential Revision: https://reviews.llvm.org/D70742
2019-11-27 10:44:42 +02:00
Raphael Isemann 3a280422b6 [lldb][NFC] Early exit in DWARFASTParserClang::ParseArrayType 2019-11-27 09:28:01 +01:00
Eric Christopher fd39b1bb20 Revert "Revert "As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.""
This reapplies: 8ff85ed905

Original commit message:

As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.

This change doesn't include any change to move from selection dag to fast isel
and that will come with other numbers that should help inform that decision.
There also haven't been any real debuggability studies with this pipeline yet,
this is just the initial start done so that people could see it and we could start
tweaking after.

Test updates: Outside of the newpm tests most of the updates are coming from either
optimization passes not run anymore (and without a compelling argument at the moment)
that were largely used for canonicalization in clang.

Original post:

http://lists.llvm.org/pipermail/llvm-dev/2019-April/131494.html

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410

This reverts commit c9ddb02659.
2019-11-26 20:28:52 -08:00
Michał Górny 3cd9a8b7dc [lldb] [test] Un-XFAIL lldb-server tests fixed on NetBSD 2019-11-26 16:46:21 +01:00
Pavel Labath 5871cba861 [lldb] Avoid snprintf in PlatformRemoteDarwinDevice
This quashes a -Wformat-truncation warning.
2019-11-26 15:16:26 +01:00
Raphael Isemann 16144d2b21 [lldb][NFC] Modernize string handling in DWARFASTParserClang::ParseTypeModifier 2019-11-26 15:04:54 +01:00
Pavel Labath 290e43ddb6 [lldb] Use llvm::format in AppleObjCRuntimeV2.cpp
Crushing a "sprintf" buffer is null warning.
2019-11-26 15:04:13 +01:00
Pavel Labath 12284e54b4 [lldb] fix a -Wcast-qual warning 2019-11-26 14:49:16 +01:00
Pavel Labath 6612fabc47 [lldb] remove a superfluous semicolon 2019-11-26 14:49:16 +01:00
Pavel Labath 957d9a0335 [lldb] remove unsigned Stream::operator<< overloads
Summary:
I recently re-discovered that the unsinged stream operators of the
lldb_private::Stream class have a surprising behavior in that they print
the number in hex. This is all the more confusing because the "signed"
versions of those operators behave normally.

Now that, thanks to Raphael, each Stream class has a llvm::raw_ostream
wrapper, I think we should delete most of our formatting capabilities
and just delegate to that. This patch tests the water by just deleting
the operators with the most surprising behavior.

Most of the code using these operators was printing user_id_t values. It
wasn't fully consistent about prefixing them with "0x", but I've tried
to consistenly print it without that prefix, to make it more obviously
different from pointer values.

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70241
2019-11-26 14:24:28 +01:00
Pavel Labath 9b06897009 [lldb/symbolvendorelf] Copy more sections from separate debug files
Include the fancier DWARF5 sections too.
2019-11-26 14:19:46 +01:00
Raphael Isemann cdfecb82ee [lldb][NFC] Remove no longer unused variable in DWARFASTParserClang::ParseTypeFromDWARF 2019-11-26 14:17:06 +01:00
Raphael Isemann 0181338dda [lldb][NFC] Simplify structure parsing code in DWARFASTParserClang::ParseTypeFromDWARF
This way it looks more like the code around it. The assert is also gone as it just
checks that the variables we declare directly above were not initialized by anyone.
That made more sense when this was one large function.
2019-11-26 14:01:12 +01:00
Pavel Labath 4023bd05fc [lldb] Add boilerplate to recognize the .debug_rnglists.dwo section 2019-11-26 13:58:26 +01:00
Raphael Isemann 30fc94be23 [lldb][NFC] Extract type modifier parsing from DWARFASTParserClang::ParseTypeFromDWARF
Part of the work to split up this monolithic parsing function.
2019-11-26 13:53:06 +01:00
Raphael Isemann 8f2b57d257 [lldb][NFC] Extract enum parsing from DWARFASTParserClang::ParseTypeFromDWARF
Part of the work to split up this monolithic parsing function.
2019-11-26 12:30:06 +01:00
Raphael Isemann 94939650b6 [lldb][NFCI] Extract subroutine parsing from DWARFASTParserClang::ParseTypeFromDWARF
Part of the work to split up this monolithic parsing function.

Should be NFC but due to the kafkaesque control flow in this case statement this might
have some unintended side effects.
2019-11-26 12:14:40 +01:00
Raphael Isemann e8013ef53a [lldb][NFC] Extract array type parsing from DWARFASTParserClang::ParseTypeFromDWARF
Part of the work to split up this monolithic parsing function.
2019-11-26 11:46:25 +01:00
Raphael Isemann 7047a3a729 [lldb][NFC] Extract pointer to member type parsing from DWARFASTParserClang::ParseTypeFromDWARF
Part of the work to split up this monolithic parsing function.
2019-11-26 11:07:59 +01:00
Raphael Isemann cfd9d39567 [lldb][NFC] NULL -> nullptr in DWARFASTParserClang::UpdateSymbolContextScopeForType 2019-11-26 10:35:30 +01:00
Michał Górny 7644d8ba4d [lldb] [Process/NetBSD] Fix handling concurrent watchpoint events
Fix handling concurrent watchpoint events so that they are reported
correctly in LLDB.

If multiple watchpoints are hit concurrently, the NetBSD kernel reports
them as series of SIGTRAPs with a thread specified, and the debugger
investigates DR6 in order to establish which watchpoint was hit.  This
is normally fine.

However, LLDB disables and reenables the watchpoint on all threads after
each hit, which results in the hit status from DR6 being wiped.
As a result, it can't establish which watchpoint was hit in successive
SIGTRAP processing.

In order to workaround this problem, clear DR6 only if the breakpoint
is overwritten with a new one.  More specifically, move cleaning DR6
from ClearHardwareWatchpoint() to SetHardwareWatchpointWithIndex(),
and do that only if the newly requested watchpoint is different
from the one being set previously.  This ensures that the disable-enable
logic of LLDB does not clear watchpoint hit status for the remaining
threads.

This also involves refactoring of watchpoint logic.  With the old logic,
clearing watchpoint involved wiping dr6 & dr7, and setting it setting
dr{0..3} & dr7.  With the new logic, only enable bit is cleared
from dr7, and the remaining bits are cleared/overwritten while setting
new watchpoint.

Differential Revision: https://reviews.llvm.org/D70025
2019-11-25 20:11:59 +01:00
Michał Górny d970d4d4aa [lldb] [Process/NetBSD] Copy watchpoints to newly-created threads
NetBSD ptrace interface does not populate watchpoints to newly-created
threads.  Solve this via copying the watchpoints from the current thread
when new thread is reported via TRAP_LWP.

Add a test that verifies that when the user does not have permissions
to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully
and thread monitoring does not crash on being unable to copy watchpoints
to new threads.

Differential Revision: https://reviews.llvm.org/D70023
2019-11-25 20:11:59 +01:00
Michał Górny 8d9400b65b [lldb] [Process/NetBSD] Improve threading support
Implement major improvements to multithreaded program support.  Notably,
support tracking new and exited threads, associate signals and events
with correct threads and support controlling individual threads when
resuming.

Firstly, use PT_SET_EVENT_MASK to enable reporting of created and exited
threads via SIGTRAP.  Handle TRAP_LWP events to keep track
of the currently running threads.

Secondly, update the signal (both generic and SIGTRAP) handling code
to account for per-thread signals correctly.  Signals delivered
to the whole process are reported on all threads, while per-thread
signals and events are reported only to the specific thread.
The remaining threads are marked as 'stopped with no reason'.  Note that
NetBSD always stops all threads on debugger events.

Thirdly, implement the ability to set every thread as running, stopped
or single-stepping separately while continuing the process.  This also
provides the ability to send a signal to the whole process or to one
of its thread while resuming.

Differential Revision: https://reviews.llvm.org/D70022
2019-11-25 20:11:58 +01:00
Michał Górny 6a7f6145d0 [lldb] [test] XFAIL ASAN tests on NetBSD 2019-11-25 20:03:41 +01:00
Raphael Isemann d1782133d9 [lldb][NFC] Allow range-based for-loops on VariableList
Summary:
Adds support for doing range-based for-loops on LLDB's VariableList and
modernises all the index-based for-loops in LLDB where possible.

Reviewers: labath, jdoerfert

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70668
2019-11-25 15:03:46 +01:00
Raphael Isemann 7a6588abf8 [lldb] Remove lldb's own ASTDumper
Summary:
LLDB's ASTDumper is just a clone of Clang's ASTDumper but with some scary code and
some unrelated functionality (like dumping name/attributes of types). This removes LLDB's ASTDumper
and replaces its uses with the `ClangUtils::DumpDecl` method that just calls Clang's ASTDumper
and returns the result as a string.

The few uses where we just want a textual representation of a type (which will print their name/attributes but not
dump any AST) are now also in ClangUtil under a `ToString` name until we find a better home for them.

Reviewers: labath

Reviewed By: labath

Subscribers: mgorny, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70663
2019-11-25 13:27:51 +01:00
Pavel Labath aa16bf15fe [lldb-vscode] Fix a race in test_extra_launch_commands
Summary:
The test used a non-stopping "run" command to launch the process. This
is different from the regular launch with no extra launch commands,
which uses eLaunchFlagStopAtEntry to ensure that the process stops
straight away.

I'm not really sure what's supposed to happen in non-stop-at-entry mode,
or if that's even supported, but what ended up happening was the launch
packet got a reply while the process was running. Then the test case did
a continue_to_next_stop(), which queued a *second* resume request
(along with the internal "resumes" which were being issued as a part of
normal process startup). These two resumes ended up chasing each other's
tails inside lldb in a way which produced hilarious log traces.
Surprisingly, the test ended up passing most of the time, but it did
cause spurious failures when the test seemed to miss a breakpoint.

This changes the test to use stop-at-entry mode in the manual launch
sequence too, which seems to be enough to make the test pass reliably.

Reviewers: clayborg, kusmour, jankratochvil

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70127
2019-11-25 10:07:38 +01:00
Raphael Isemann 1e0d395480 [lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass 2019-11-23 22:48:09 +01:00
Raphael Isemann 46883f46dc [lldb][NFC] NFC refactoring for ClangExpressionDeclMap::LookupInModulesDeclVendor
Early exiting and deduplicating copy-pasted code.
2019-11-23 20:31:13 +01:00
Raphael Isemann 7a0c548444 [lldb][NFC] NFC refactoring ClangExpressionDeclMap::LookupLocalVariable
Adding an early exits and moving variable declarations closer to their
actual use.
2019-11-23 18:41:23 +01:00
Raphael Isemann 7af53d75c6 [lldb][NFC] Fix LLDB build after ModuleManager->ASTReader rename
That happened in 20d51b2f14 but LLDB wasn't updated.
2019-11-23 17:56:23 +01:00
Jonas Devlieghere b6ae524cd2 [Examples] Move structured-data unpacking out of the loop. (NFC)
There's no need to repeat this work in the loop.
2019-11-22 15:43:39 -08:00
Jonas Devlieghere 1b099c1df0 [Examples] Add in_call_stack breakpoint function.
The in_call_stack Python script makes it possible to modify the last
breakpoint to only stop if a given function is present in the call
stack. It will check both the symbol name and the function name (coming
from the debug info, in case the binary is stripped).

To use this, you have to:

1. Import the script into lldb.

(lldb) command script import in_call_stack.py

2. Set a breakpoint and use the in_call_stack alias.

(lldb) b foo
(lldb) in_call_stack bar

Note that this alias operates on the last set breakpoint. You can re-run
the in_call_stack command to modify the condition.
2019-11-22 15:36:42 -08:00
Jason Molenda 45098b6809 Remove extraneous log enabling. 2019-11-22 14:13:35 -08:00
Vedant Kumar 4fdbc0728d [DWARF] Handle call sites with indirect call targets
Split CallEdge into DirectCallEdge and IndirectCallEdge. Teach
DWARFExpression how to evaluate entry values in cases where the current
activation was created by an indirect call.

rdar://57094085

Differential Revision: https://reviews.llvm.org/D70100
2019-11-22 11:50:22 -08:00
Jordan Rupprecht 506144da04 [lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.
Summary:
When built w/ `-funsigned-char`, `std::string` becomes equivalent to `std::basic_string<unsigned char>`, causing these formatters to not match. This patch adds overloads for both libstdc++ and libc++ string formatters that accepts unsigned char.

Motivated by the following example:

```
$ cat pretty_print.cc

template <typename T>
void print_val(T s) {
  std::cerr << s << '\n';  // Set a breakpoint here!
}

int main() {
  std::string val = "hello";
  print_val(val);
  return 0;
}
$ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
$ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
...
(lldb) fr v
(std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >) s = {
  __r_ = {
    std::__1::__compressed_pair_elem<std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__rep, 0, false> = {
      __value_ = {
         = {
          __l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 0x0000000000000000)
          __s = {
             = (__size_ = '\n', __lx = '\n')
            __data_ = {
              [0] = 'h'
              [1] = 'e'
              [2] = 'l'
              [3] = 'l'
              [4] = 'o'
              [5] = '\0'
...
```

Reviewers: labath, JDevlieghere, shafik

Subscribers: christof, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70517
2019-11-22 10:25:03 -08:00
Adrian Prantl 8b40bdbd7e Reformat code for readability. 2019-11-22 10:03:25 -08:00
Adrian Prantl 539117616d Complete complete types early when importing types from Clang module DWARF.
This affects -gmodules only.

Under normal operation pcm_type is a shallow forward declaration
that gets completed later. This is necessary to support cyclic
data structures. If, however, pcm_type is already complete (for
example, because it was loaded for a different target before),
the definition needs to be imported right away, too.
Type::ResolveClangType() effectively ignores the ResolveState
inside type_sp and only looks at IsDefined(), so it never calls
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(),
which does extra work for Objective-C classes. This would result
in only the forward declaration to be visible.

An alternative implementation would be to sink this into Type::ResolveClangType ( 88235812a7/lldb/source/Symbol/Type.cpp (L5809)) though it isn't clear to me how to best do this from a layering perspective.

rdar://problem/52134074

Differential Revision: https://reviews.llvm.org/D70415
2019-11-22 09:58:16 -08:00
Adrian Prantl c0eeea5d74 Register Objective-C property accessors with their property decls.
This is a correctness fix for the Clang DWARF parser that primarily
matters for swift-lldb's ability to import Clang types that were
reconstructed from DWARF into Swift.

rdar://problem/55025799

Differential Revision: https://reviews.llvm.org/D70580
2019-11-22 09:55:25 -08:00
Michał Górny 06e03bce80 [lldb] [test] XFAIL TestExpressionEvaluation on NetBSD 2019-11-22 13:03:40 +01:00
Martin Svensson 0b0dca9f6f [lldb] Fix exception breakpoint not being resolved when set on dummy target
Summary: Ensure that breakpoint ivar is properly set in exception breakpoint resolver so that exception breakpoints set on dummy targets are resolved once real targets are created and run.

Reviewers: jingham

Reviewed By: jingham

Subscribers: teemperor, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69880
2019-11-22 11:20:09 +01:00
Raphael Isemann b30dabfe90 [lldb] Don't enable expression log in TestEmptyStdModule.py
Thanks for pointing this out Jason!
2019-11-22 08:34:08 +01:00
Adrian Prantl bc8e88e974 Early-exitify ClangASTContext::AddObjCClassProperty() (NFC) 2019-11-21 15:41:22 -08:00
Jonas Devlieghere 6c2e4e8801 [Driver] Fix newline at the end of help output
Print a regular newline at the end of the help output. The current
string literal seems to throw off shells.
2019-11-21 13:36:39 -08:00
Jonas Devlieghere bb090bb1ca [Reproducer] Make 'reproducer xcrash' behave the same during capture & replay
There's no point in preventing this command from running during replay.
We should simulate the same crash as during capture.
2019-11-21 13:34:04 -08:00
Jonas Devlieghere b26d9e417d [Reproducer] Instruct users to replay reproducer
Improve the message printed when LLDB crashes by asking the user to
replay the reproducer before attaching it to a bugreport..

********************
Crash reproducer for lldb version 10.0.0 (git@github.com:llvm/llvm-project.git revision ...)
  clang revision ...
  llvm revision ...

Reproducer written to '/path/to/reproducer'

Before attaching the reproducer to a bug report:
 - Look at the directory to ensure you're willing to share its content.
 - Make sure the reproducer works by replaying the reproducer.

Replay the reproducer with the following command:
./bin/lldb -replay /path/to/reproducer
********************
2019-11-21 13:25:53 -08:00
Jonas Devlieghere 44fe1f024d [test] Mark TestEditline as skipped with ASan.
As discussed in https://reviews.llvm.org/D70324.
2019-11-21 13:09:40 -08:00
Jonas Devlieghere f5759d5dbc [Test] Split up TestIntegerTypes.py
The unsplit test is timing out on GreenDragon's sanitized bot. By
splitting the test we avoid this issue and increase parallelism.
2019-11-21 11:24:14 -08:00
Jonas Devlieghere bb775bee21 [Docs] Generate the LLDB man page with Sphinx
This patch replaces the existing out-of-date man page for lldb and
replaces it with an RST file from which sphinx generates the actual
troff file. This is similar to how man pages are generated for the rest
of the LLVM utilities.

The man page is generated by building the `docs-lldb-man` target.

Differential revision: https://reviews.llvm.org/D70514
2019-11-21 10:04:11 -08:00
Adrian McCarthy 3b69f0c555 [NFC] Refactor and improve comments in CommandObjectTarget
Made small improvements while debugging through
CommandObjectTarget::AddModuleSymbols.

1.  Refactored error case for an early out, reducing the indentation of
the rest of this long function.
2.  Clarified some comments by correcting spelling and punctuation.
3.  Reduced duplicate code at the end of the function.

Tested with `ninja check-lldb`

Differential Review: https://reviews.llvm.org/D70458
2019-11-21 08:37:35 -08:00
Raphael Isemann 8cf8ec40a1 [lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl 2019-11-21 14:59:47 +01:00
Raphael Isemann 5fb7dd8a40 [lldb][NFC] Move searching functions in ClangExpressionDeclMap to own function 2019-11-21 14:31:31 +01:00
Raphael Isemann 24e9886793 [lldb][NFC] Reduce scope of some variables in ClangExpressionDeclMap::FindExternalVisibleDecls 2019-11-21 13:43:48 +01:00
Tatyana Krasnukha ffc4ff868f [lldb][NFC] Remove test directory completely
The test was moved to "completion-in-lambda-and-unnamed-class" by D66175.

+ Fix typo in the directory name.
2019-11-21 15:03:37 +03:00
Raphael Isemann 7fa976d57a [lldb][NFC] Move searching local variables into own function 2019-11-21 12:45:38 +01:00
Raphael Isemann a0408ab7f9 [lldb][NFC] Move searching the ClangModulesDeclVendor into own function 2019-11-21 12:04:43 +01:00
Raphael Isemann 337151f41e [lldb][NFC] Move searching for the local variable namespace into own function 2019-11-21 11:03:24 +01:00
Raphael Isemann 2cada1e4da [lldb][NFC] Early exit in ClangExpressionDeclMap::FindExternalVisibleDecls 2019-11-21 10:29:50 +01:00
Jonas Devlieghere 25f33d8318 [Reproducer] Limit signals to macro define sin <csignal>
SIGBUS is not part of the signal macros defined in the header <csignal>.
2019-11-20 14:28:37 -08:00
Jason Molenda f24ed3a051 Handle the case where the 'g' packet doesn't get all regs.
lldb would silently accept a response to the 'g' packet
(read all registers) which was too large; this handles the
case where it is too small.

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

<rdar://problem/34916465>
2019-11-20 14:15:08 -08:00
Jonas Devlieghere b03374584d [Driver] Fix missing space in lldb --help output. 2019-11-20 13:49:22 -08:00
Jonas Devlieghere 0ebb7803e6 [Docs] Fix Sphinx warning (treated as error)
Fixes "undefined label" warning: if the link has no caption the label
must precede a section header.
2019-11-20 13:49:22 -08:00
Jonas Devlieghere c8dfe90729 [Reproducer] Generate LLDB reproducer on crash
This patch hooks the reproducer infrastructure with the signal handlers.
When lldb crashes with reproducers capture enabled, it will now generate
the reproducer and print a short message the standard out. This doesn't
affect the pretty stack traces, which are still printed before.

This patch also introduces a new reproducer sub-command that
intentionally raises a given signal to test the reproducer signal
handling.

Currently the signal handler is doing too much work. Instead of copying
over files into the reproducers in the signal handler, we should
re-invoke ourselves with a special command line flag that looks at the
VFS mapping and performs the copy.

This is a NO-OP when reproducers are disabled.

Differential revision: https://reviews.llvm.org/D70474
2019-11-20 13:14:16 -08:00
Davide Italiano 6f4398d1b9 [lldb] Fix NSURL data formatter truncation issue
Remove hardcoded string prefix length assumption causing issues when
concatenating summary for NSURL in NSURLSummaryProvider. Provider relies
on concatenation of NSStringProvider results for summary, and while the
strings are prefixed with '@' in Objective-C, that is not the case in
Swift causing part of the description to be truncated.

This will be tested in the downstream fork.

Patch by Martin Svensson!
2019-11-20 12:28:14 -08:00
Michał Górny 923afb4a61 [lldb] [test] Un-XFAIL one lldb-server test on NetBSD 2019-11-20 21:16:34 +01:00
Vedant Kumar af331cbe14 [debugserver] Set arch based on TARGET_TRIPLE
Use TARGET_TRIPLE instead of LLVM_DEFAULT_TARGET_TRIPLE, as the latter
isn't exported by LLVMConfig.cmake, which means arch detection fails if
lldb is built separately from llvm.
2019-11-20 12:12:47 -08:00
Raphael Isemann 51ad025ff3 [lldb][NFC] Move searching for $__lldb_objc_class into its own function
Same as in commit e7cc833dda but with $__lldb_objc_class.
2019-11-20 16:10:24 +01:00
Raphael Isemann e7cc833dda [lldb][NFC] Move searching for $__lldb_class into its own function in ClangExpressionDeclMap 2019-11-20 15:12:31 +01:00
Raphael Isemann c34478f5f6 [lldb][NFC] Move ClangExpressionDeclMap's persistent decl search into its own function
Searching persistent decls is a small subset of the things
FindExternalVisibleDecls does. It should be its own function instead
of being encapsulated in this `do { } while(false);` pattern.
2019-11-20 14:17:35 +01:00
Raphael Isemann 54b86b010b [lldb][NFC] Remove unused ClangASTContext::GetUnknownAnyType 2019-11-20 13:07:43 +01:00
Raphael Isemann c502bae524 [lldb][NFC] Simplify ClangASTContext::GetBasicTypes
static convenience methods that do the clang::ASTContext -> ClangASTContext
conversion and handle errors by simply ignoring them are not a good idea.
2019-11-20 12:47:14 +01:00
Raphael Isemann 82800df4de [lldb][NFC] Remove ClangASTContext::GetAsDeclContext
Everything we pass to this function is already a DeclContext.
2019-11-20 12:28:16 +01:00
Raphael Isemann 02e9113665 [lldb][NFC] Remove ClangASTContext::FieldIsBitfield overload 2019-11-20 12:15:25 +01:00
Raphael Isemann 6640f2e7d4 [lldb][NFC] Remove ClangASTContext::GetUniqueNamespaceDeclaration overload
This overload is only used in one place and having static overloads for
all methods that only do an additional clang::ASTContext -> ClangASTContext
conversion is just not sustainable.
2019-11-20 12:02:38 +01:00
Djordje Todorovic ce1f95a6e0 Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"
It turns out that the ExprMutationAnalyzer can be very slow when AST
gets huge in some cases. The idea is to move this analysis to the LLVM
back-end level (more precisely, in the LiveDebugValues pass). The new
approach will remove the performance regression, simplify the
implementation and give us front-end independent implementation.

Differential Revision: https://reviews.llvm.org/D68206
2019-11-20 10:08:07 +01:00
Jonas Devlieghere 36eea5c31f [Reproducer] Namespace the reproducer dump options.
Make it clear that the current reproducer options are for dumping.
2019-11-19 16:19:43 -08:00
Jordan Rupprecht 327a18ca0a [lldb][test] Prevent \n in calls to lldb's expect() test helper.
Summary:
expect() forwards its command to sendline(). This can be problematic if the command already contains a newline: sendline() unconditionally adds a newline to the command, which causes the command to run twice (hitting enter in lldb runs the previous command). The expect() helper looks for the prompt and finds the first one, but because the command has run a second time, the buffer will contain the contents of the second time the command ran, causing potential erroneous matching.

Simplify the editline test, which was using different commands to workaround this misunderstanding.

Reviewers: labath

Reviewed By: labath

Subscribers: merge_guards_bot, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70324
2019-11-19 15:17:35 -08:00
Adrian Prantl 77f8a3324b Add a "Using LLDB" section to the welcome page of the website
This is an attempt to feature the user-facing resources more
prominently on the LLDB website by calling out the tutorial and the
GDB command map wight on the start page.

I also moved the "Why a new debugger" section to the "Goals"
subpage. Given that LLDB's first release is almost a decade in the
past now, the title is a bit of an anachronism.

Lastly, I moved the Architecture sub-page from "use" to "resources",
since end-users do not care about the source code layout.

Differential Revision: https://reviews.llvm.org/D70449
2019-11-19 10:55:50 -08:00
Jonas Devlieghere b117ec8be0 [LLDB] Fix formatting in the driver (NFC) 2019-11-19 10:23:56 -08:00
Raphael Isemann 4a6d03ad0e [lldb] Add logging to IRExecutionUnit::GetStaticInitializers 2019-11-19 15:52:01 +01:00
Raphael Isemann c54d21c848 [lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers 2019-11-19 15:06:30 +01:00
Raphael Isemann f6ffe6fc9d [lldb] Also test Get[De]mangledName of SBType in TestSBTypeClassMembers.py
I just used the mangled names as this test is anyway a Darwin-only ObjC++ test.
We probably should also test this on other platforms but that will be
another commit as we need to untangle the ObjC and C++ parts first.
2019-11-19 14:04:02 +01:00
Raphael Isemann 96d814a5fe [lldb] Remove ClangExpressionDeclMap::ResolveUnknownTypes
Summary:
This is some really shady code. It's supposed to kick in after an expression already failed and then try to look
up "unknown types" that for some undocumented reason can't be resolved during/before parsing. Beside the
fact that we never mark any type as `EVUnknownType` in either swift-lldb or lldb (which means this code is unreachable),
this code doesn't even make the expression evaluation succeed if if would ever be executed but instead seems
to try to load more debug info that maybe any following expression evaluations might succeed.

This patch removes ClangExpressionDeclMap::ResolveUnknownTypes and the related data structures/checks/calls.

Reviewers: davide

Reviewed By: davide

Subscribers: aprantl, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70388
2019-11-19 12:44:27 +01:00
Diana Picus bb7c8e984f Mark PR44037 tests as XFAIL on AArch64 Linux dwo
These tests are failing with various assertion failures, but they all
throw the following error message first:

error: a.out 0x0000002d: adding range [0x14-0x24) which has a base that
is less than the function's low PC 0x40060c.

See llvm.org/pr44037.

Differential Revision: https://reviews.llvm.org/D70381
2019-11-19 10:49:00 +01:00
Martin Storsjö 926d283893 [lldb-server] Use LLDB_LOG_ERROR to consume Error<> even if logging is disabled
Differential Revision: https://reviews.llvm.org/D70386
2019-11-19 09:12:50 +02:00
Jonas Devlieghere a921f587f7 Revert "[CMake] Re-enable -Wno-gnu-anonymous-struct & -Wno-nested-anon-types."
Whoops, they should be enabled, not disabled.
2019-11-18 17:00:35 -08:00
Jonas Devlieghere 755afc0af8 [CMake] Re-enable -Wno-gnu-anonymous-struct & -Wno-nested-anon-types.
We're checking for support but we're discarding the result. My best
guess is that these warnings were disabled in the past. However, I don't
see a reason to keep it that way.
2019-11-18 16:58:40 -08:00
Jonas Devlieghere f19ea6ea5f [Docs] Add reproducer documentation
This adds a page about LLDB reproducers. It describes how to use the
reproducers on the command line and lists some of the known
issues/limitations.

Differential revision: https://reviews.llvm.org/D70409
2019-11-18 16:03:06 -08:00
Michał Górny 0854867798 [lldb] [test] XFAIL more lldb-server tests on NetBSD 2019-11-18 22:36:04 +01:00
Michał Górny 4539a2d20c [lldb] [test] Mark segv-related tests XFAIL on NetBSD
There seems to be a regression in the kernel causing those tests
to fail.  Mark them XFAIL, to be addressed later.
2019-11-18 22:36:03 +01:00
Michał Górny b59af82805 [lldb] [unittest] Skip TestStopReplyContainsThreadPcs on NetBSD 2019-11-18 22:36:02 +01:00
Michał Górny d82dd6ac9a [lldb] [unittest] Reenable MainLoopTest.DetectsEOF on NetBSD
The underlying issue is already fixed in the NetBSD kernel for some
time, so we can finally reenable the test.
2019-11-18 22:36:01 +01:00
Vedant Kumar 4624e83ce7 [Signal] Allow llvm clients to opt into one-shot SIGPIPE handling
Allow clients of the llvm library to opt-in to one-shot SIGPIPE
handling, instead of forcing them to undo llvm's SIGPIPE handler
registration (which is brittle).

The current behavior is preserved for all llvm-derived tools (except
lldb) by means of a default-`true` flag in the InitLLVM constructor.

This prevents "IO error" crashes in long-lived processes (lldb is the
motivating example) which both a) load llvm as a dynamic library and b)
*really* need to ignore SIGPIPE.

As llvm signal handlers can be installed when calling into libclang
(say, via RemoveFileOnSignal), thereby overriding a previous SIG_IGN for
SIGPIPE, there is no clean way to opt-out of "exit-on-SIGPIPE" in the
current model.

Differential Revision: https://reviews.llvm.org/D70277
2019-11-18 10:27:27 -08:00
Adrian Prantl d4f18f11d3 Replace bitfield in lldb::Type with byte-sized members. (NFC)
Due to alginment and packing using separate members takes up the same
amount of space, but makes it far less cumbersome to deal with it in
constructors etc.
2019-11-18 10:00:26 -08:00
Jonas Devlieghere 0aed648649 [Docs] Add Python caveats under the development section
This adds a page named Caveats with a section on some of the things to
be aware of related to Python. It's a question we've seen more than once
pop up and I think it's good to have it documentation on the website.
Even though some of it might be useful to users, I still put it under
"development" because it requires some understanding of how LLDB is
built.

Differential revision: https://reviews.llvm.org/D70252
2019-11-18 09:15:00 -08:00
Alex Cameron 10b8514343 [lldb] Fix JSON parser to allow empty arrays
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=39405
```
alexc@kitty:~/work/wiredtiger/build_posix$ cat breakpoint.json
[{"Breakpoint" : {"BKPTOptions" : {"AutoContinue" : false,"ConditionText" : "","EnabledState" : true,"IgnoreCount" : 0,"OneShotState" : false},"BKPTResolver" : {"Options" : {"NameMask" : [56],"Offset" : 0,"SkipPrologue" : true,"SymbolNames" : ["__wt_btcur_search"]},"Type" : "SymbolName"},"Hardware" : false,"SearchFilter" : {"Options" : {},"Type" : "Unconstrained","Foo" : []}}}]
```
**Before**
```
(lldb) breakpoint read --file breakpoint.json
error: Invalid JSON from input file: /home/alexc/work/wiredtiger/build_posix/breakpoint.json.
```
**After**
```
(lldb) breakpoint read --file breakpoint.json
New breakpoints:
Breakpoint 1: where = libwiredtiger-3.2.2.so`__wt_btcur_search + 15 at bt_cursor.c:522:5, address = 0x00007ffff576ab2f
```

Reviewers: xbolva00, davide, labath

Reviewed By: davide, labath

Subscribers: mgorny, jingham, labath, davide, JDevlieghere, lldb-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D68179
2019-11-18 15:12:55 +01:00
Raphael Isemann 869d904df7 [lldb][NFC] Cleanup comments in ClangASTSource.h
The current file doesn't follow the 80 character limit and uses this
cramped comment style that is hard to read.
2019-11-18 14:17:35 +01:00
Michał Górny 23a766dcad [lldb] [Process/NetBSD] Implement thread name getting
Implement thread name getting sysctl() on NetBSD.  Also fix
the incorrect type in pthread_setname_np() in the relevant test.

Differential Revision: https://reviews.llvm.org/D70363
2019-11-18 11:21:17 +01:00
Michał Górny e8924d6403 [lldb] [test] Enable lldb-server tests on NetBSD, and set XFAILs
Differential Revision: https://reviews.llvm.org/D70335
2019-11-18 11:21:16 +01:00
Sylvestre Ledru 9b40a7f3bf Remove +x permission on some files 2019-11-16 14:47:20 +01:00
Walter Erquinigo 2c7c528d7a [lldb-vscode] support the completion request
Summary:
The DAP has a completion request that has been unimplemented. It allows showing autocompletion tokens inside the Debug Console.
I implemented it in a very simple fashion mimicking what the user would see when autocompleting an expression inside the CLI.
There are two cases: normal variables and commands. The latter occurs when a text is prepepended with ` in the Debug Console.
These two cases work well and have tests.

Reviewers: clayborg, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69873
2019-11-15 17:37:55 -08:00
Reid Kleckner 979da9a4c3 Avoid including Builtins.h in Preprocessor.h
Builtins are rarely if ever accessed via the Preprocessor. They are
typically found on the ASTContext, so there should be no performance
penalty to using a pointer indirection to store the builtin context.
2019-11-15 16:45:16 -08:00
Reid Kleckner 4d23764ddd Fix -Wunused-result warnings in LLDB
Three uses of try_lock intentionally ignore the result, as explained in
the comment. Make that explicit with a void cast.

Add what appears to be a missing return in the clang expression parser
code. It's a functional change, but presumably the right one.

Differential Revision: https://reviews.llvm.org/D70281
2019-11-15 16:38:00 -08:00
Adrian Prantl 0304360a40 Add a testcase for Clang modules being updated within one LLDB session.
This actually works as expected, but wasn't explicitly tested before.
2019-11-15 16:27:14 -08:00
Fred Riss a578adc1bc dotest: Add a way for the run_to_* helpers to register dylibs
Summary:
To run the testsuite remotely the executable needs to be uploaded to
the target system. The Target takes care of this by default.

When the test uses additional shared libraries, those won't be handled
by default and need to be registered with the target using
test.registerSharedLibrariesWithTarget(target, dylib).

Calling this API requires a target, so it doesn't mesh well with the
run_to_* helpers that we've been advertising as the right way to write
tests.

This patch adds an extra_images argument to all the helpers and does
the registration automatically when running a remote
testsuite. TestWeakSymbols.py was converted to use this new scheme.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70134
2019-11-15 15:17:27 -08:00
Adrian Prantl 1cbe003894 [-gmodules] Let LLDB log a warning if the Clang module hash mismatches.
This feature is mostly there to aid debugging of Clang module issues,
since the only useful actual the end-user can to is to recompile their
program.

Differential Revision: https://reviews.llvm.org/D70272
2019-11-15 11:52:13 -08:00
Adrian Prantl 7d71dd928d Add RTTI support to the SymbolFile class hierarchy
Differential Revision: https://reviews.llvm.org/D70322
2019-11-15 11:52:13 -08:00
Adrian Prantl 2f95b6488b Rename posix/FileSystem.cpp to FileSystemPosix.cpp
to avoid a linker warning on Darwin about two files having the same name.
2019-11-15 11:48:46 -08:00
Jonas Devlieghere 81104ea9ab [CMake] Configure the Info.plist so it contains a real version number.
Use CMake to configure the Info.plist file so that we have a real
version number in things like crash reporter.
2019-11-15 09:50:42 -08:00
Adrian Prantl 3bc71193bd Comment the fact that DWARFDebugInfoEntry isn't copyable. 2019-11-15 09:14:48 -08:00
Diana Picus 5f0c3bad2f Fix TestFormatters.py stepping too far
TestFormatters.py has a sequence of three 'next' commands to get past
all the initializations in the test function. On AArch64 (and
potentially other platforms), this was one 'next' too many and we ended
up outside our frame.

This patch replaces the sequence with a 'thread until ' the line of the
return from the function, so we should stop after all the
initializations but before actually returning.

Differential Revision: https://reviews.llvm.org/D70303
2019-11-15 14:20:25 +01:00
Davide Italiano 95c770fbfb [Utility] Remove a dead header [PPC64LE_ehframe_Registers.h] 2019-11-14 15:29:47 -08:00
Jonas Devlieghere 3b142bc9ff [LLDB] Fix more -Wdocumentation issues (NFC) 2019-11-14 14:31:44 -08:00
Jonas Devlieghere f4f47da530 [Reproducer] Enable crash reports for reproducer tests
For some reason the reproducer tests seem really proficient at
uncovering structural issues in LLDB related to how we tear down things,
but of course only on the bots.

The pretty stack trace helps a bit, but what I really want is the crash
reports which contain much more information, such as what other threads
we doing.

Crash reports are automatically suppressed by lit. This patch
(temporarily) disables that for the reproducer tests.
2019-11-14 14:16:41 -08:00
Jordan Rupprecht f2e65447b3 [lldb][Editline] Support ctrl+left/right arrow word navigation.
Summary:
This adds several 5C/5D escape codes that allow moving forward/backward words similar to bash command line navigation.

On my terminal, `ctrl+v ctrl+<left arrow>` prints `^[[1;5D`. However, it seems inputrc also maps other escape variants of this to forward/backward word, so I've included those too. Similar for 5C = ctrl+right arrow.

Reviewers: JDevlieghere, labath

Reviewed By: JDevlieghere, labath

Subscribers: merge_guards_bot, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70137
2019-11-14 11:41:11 -08:00
Adrian Prantl dcb5bd9109 Fix incorrect comment. 2019-11-14 09:55:24 -08:00
Adrian Prantl 268e11f95d Convert condition to early exit (NFC) 2019-11-14 09:38:49 -08:00
Adrian Prantl 0352007fdb Convert UpdateExternalModuleListIfNeeded to use early exits. 2019-11-14 09:35:06 -08:00
Adrian Prantl 83f5287567 Rename DWO -> Clang module to avoid confusion. (NFC) 2019-11-14 09:13:49 -08:00
Jonas Devlieghere 4229f70d22 [LLDB] Make a clear distinction between usage & development docs
This renames the "Goals & Status" section to "Project" and the
"Resources" section to "Development". To better match this layout I've
moved the releases page under "Project".
2019-11-14 09:04:28 -08:00
Adrian Prantl 0e45e60c6f Use ForEachExternalModule in ParseTypeFromClangModule (NFC)
I wanted to further simplify ParseTypeFromClangModule by replacing the
hand-rolled loop with ForEachExternalModule, and then realized that
ForEachExternalModule also had the problem of visiting the same leaf
node an exponential number of times in the worst-case. This adds a set
of searched_symbol_files set to the function as well as the ability to
early-exit from it.

Differential Revision: https://reviews.llvm.org/D70215
2019-11-14 08:58:31 -08:00
Pavel Labath 6e3ecd1884 [lldb] Fix dwo variant of TestLibCxxFunction
The test was failing due to a bug in SymbolFileDWARF::FindFunctions --
the function was searching the main dwarf unit for DW_TAG_subprograms,
but the main unit is empty in case of split dwarf.  The fix is simple --
search the non-skeleton unit instead.

This bug went unnoticed because this function is expensive, and so one
generally avoids calling it.
2019-11-14 16:29:36 +01:00
Diana Picus e03a06b348 Fix typos in docs. NFC 2019-11-14 12:11:57 +01:00
Raphael Isemann 8715ffdf1a [lldb] Fix that trailing backslashes in source lines break the Clang highlighter
Summary:
Clang's raw Lexer doesn't produce any tokens for trailing backslashes in a line. This doesn't work with
LLDB's Clang highlighter which builds the source code to display from the list of tokens the Lexer returns.
This causes that lines with trailing backslashes are lacking the backslash and the following newline when
rendering source code in LLDB.

This patch removes the trailing newline from the current line we are highlighting. This way Clang doesn't
drop the backslash token and we just restore the newline after tokenising.

Fixes rdar://57091487

Reviewers: JDevlieghere, labath

Reviewed By: JDevlieghere, labath

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70177
2019-11-14 11:11:20 +01:00
Raphael Isemann ea2ba51b0b [lldb][NFC] Simplify IOHandler constructor/destructor setup
We only need a default constructor because of DISALLOW_COPY_AND_ASSIGN,
but the non-virtual destructor isn't needed.
2019-11-14 09:59:00 +01:00
Muhammad Omair Javaid f9f30f2ecb [LLDB] Fix whitespace/tabs mismatch in lldbsuite Makefile.rules
This patch fixes whitespace/tabs mismatch in
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Legacy make files always used tabs though modern make version can
work with white-spaces I have chosen the legacy just to be safe.

Signed-off-by: Muhammad Omair Javaid <omair.javaid@linaro.org>

Differential Revision: https://reviews.llvm.org/D70154
2019-11-14 13:53:58 +05:00
Jonas Devlieghere fa6984a3de [LLDB] Don't install the pretty stack trace handler twice.
I noticed that currently we are printing LLVM's pretty stack trace
twice. The reason is that we're calling PrintStackTraceOnErrorSignal in
addition to InitLLVM, which besides some other useful things, also
register LLVM's pretty stack trace handler.

Differential revision: https://reviews.llvm.org/D70216
2019-11-13 17:35:58 -08:00
Reid Kleckner 5565d365f2 Revert "Forward declare Optional<T> in STLExtras.h"
This reverts commit a36f316390.

I did not intend to push this with the InitializePasses.h change.
2019-11-13 16:36:21 -08:00
Reid Kleckner a36f316390 Forward declare Optional<T> in STLExtras.h
WIP stats
2019-11-13 16:34:00 -08:00
Jonas Devlieghere 8ac053eea2 [LLDB] Cleanup the DataEncoder utility. (NFC)
This commit removes unused methods from the DataEncoder class and cleans
up the API by making all the internal methods private.
2019-11-13 15:44:51 -08:00
Reid Kleckner bfe663ce22 Revert a hunk from 9634064cfa
This causes errors when building LLDB because the Windows implementation
doesn't implement this method:

C:\src\llvm-project\lldb\source\Plugins\ScriptInterpreter\Python\ScriptInterpreterPython.cpp(915,19): error: allocating an object of abstract class type 'lldb_private::ConnectionGenericFile'
              new ConnectionGenericFile(read_file, true));
                  ^
C:\src\llvm-project\lldb\include\lldb/Utility/Connection.h(174,28): note: unimplemented pure virtual method 'GetReadObject' in 'ConnectionGenericFile'
  virtual lldb::IOObjectSP GetReadObject() = 0;
                           ^
2019-11-13 15:43:54 -08:00
Jonas Devlieghere 33c3e0b96c [LLDB] Implement pure virtual method in MockConnection
I made GetReadObject pure virtual in the base class and forgot to add
the method to the mock class.
2019-11-13 15:37:57 -08:00
Jonas Devlieghere 9634064cfa [LLDB] Fix another set of -Wdocumentation warnings
At this point I'm just fixing issues as I see them pop up locally in
incremental builds.
2019-11-13 15:13:06 -08:00
Jonas Devlieghere 95807cb039 [LLDB] Remove dead code from StreamFile 2019-11-13 15:08:51 -08:00
Davide Italiano 294ef766e8 [RegisterContext] Remove now unneded vestiges. 2019-11-13 14:53:13 -08:00
Jonas Devlieghere 8df482e51c [LLDB] Fix a bunch of -Wdocumentation warnings in ExpressionParser 2019-11-13 14:40:55 -08:00
Adrian Prantl 9072f0103b Remove redundant check. (NFC) 2019-11-13 14:19:01 -08:00
Adrian Prantl 7f9d36e2db Use cheaper, equivalent predicate. (NFC) 2019-11-13 14:16:40 -08:00
Adrian Prantl 3d30c142e1 Rename clang-module-related *DWO* functions to *ClangModule* (NFC)
This avoids confusing them with fission-related functionality.

I also moved two accessor functions from DWARFDIE into static
functions in DWARFASTParserClang were their only use is located.
2019-11-13 14:07:20 -08:00
Adrian Prantl 78586775f7 Rename ParseTypeFromDWO to ParseTypeFromClangModule (NFC)
Because that is what this function really does. The old name is
misleading.
2019-11-13 13:37:43 -08:00
Jonas Devlieghere ad882774fe [LLDB] Fix a bunch of -Wdocumentation warnings 2019-11-13 12:28:10 -08:00
Jonas Devlieghere 7ba28644a1 [Reproducer] Discard reproducer directory if not generated.
If lldb was run in capture mode, but no reproducer was generated, make
sure we clean up the reproducer directory.
2019-11-12 20:16:33 -08:00
Muhammad Omair Javaid 9b95835698 [LLDB] Add core definition for armv8l and armv7l
This patch adds core definitions in lldb ArchSpecs for armv8l and armv7l cores.

This was needed because on Linux running on 32-bit Arm v8 we are returned
armv8l in case we are running 32-bit sysroot on 64bit kernel. In case of 32-bit
kernel and 32-bit sysroot running on arm v8 hardware we are returned armv7l.
This is quite common when we run 32 bit arm using docker container.

Signed-off-by: Muhammad Omair Javaid <omair.javaid@linaro.org>

Differential Revision: https://reviews.llvm.org/D69904
2019-11-13 05:40:09 +05:00
Jonas Devlieghere 056c319769 [LLDB] Only set FRAMEWORK when we're actually building a framework. 2019-11-12 15:42:07 -08:00
Jonas Devlieghere 34ca6e1fbe [LLDB] Remove debug message in AddLLDB.cmake 2019-11-12 15:33:03 -08:00
Jonas Devlieghere a247bd1f27 [LLDB] Fix/silence CMake developer warning for LLDB framework.
This fixes the following warning for developers:

  Target 'liblldb' was changed to a FRAMEWORK sometime after install().  This
  may result in the wrong install DESTINATION.  Set the FRAMEWORK property
  earlier.

The solution is to pass the FRAMEWORK flag to add_lldb_library and set
the target property before install(). For now liblldb is the only
customer.
2019-11-12 14:17:19 -08:00
Jonas Devlieghere fbb228c7d2 [LLDB] Always remove debugserver from LLVM_DISTRIBUTION_COMPONENTS
Centralize the logic to remove debugserver from
LLVM_DISTRIBUTION_COMPONENTS when LLDB_USE_SYSTEM_DEBUGSERVER is
enabled. Now this happens regardless of whether the tests are enabled.
2019-11-12 12:58:26 -08:00
shafik 91e94a7015 [LLDB][Formatters] Re-enable std::function formatter with fixes to improve non-cached lookup performance
Performance issues lead to the libc++ std::function formatter to be disabled. We addressed some of those performance issues by adding caching see D67111
This PR fixes the first lookup performance by not using FindSymbolsMatchingRegExAndType(...) and instead finding the compilation unit the std::function wrapped callable should be in and then searching for the callable directly in the CU.

Differential Revision: https://reviews.llvm.org/D69913
2019-11-12 11:30:18 -08:00
Davide Italiano 96915495f9 [ObjectFileMachO] Fix the build for __arm64__.
Catch up with an API change.
2019-11-12 11:10:36 -08:00
Adrian Prantl 3b73dcdc96 Performance: Add a set of visited SymbolFiles to the other FindFiles variant.
This is basically the same bug as in r260434.

SymbolFileDWARF::FindTypes has exponential worst-case when digging
through dependency DAG of .pcm files because each object file and .pcm
file may depend on an already-visited .pcm file, which may again have
dependencies. Fixed here by carrying a set of already visited
SymbolFiles around.

rdar://problem/56993424

Differential Revision: https://reviews.llvm.org/D70106
2019-11-12 09:38:37 -08:00
Muhammad Omair Javaid a6c40f56ae Revert "Fix lookup of symbols at the same address with no size vs. size"
This reverts commit 3f594ed168.

This change has cause LLDB expression evaluation to fail on Arm Linux.

Differential Revision: https://reviews.llvm.org/D63540
2019-11-12 19:02:17 +05:00
Pavel Labath 6aa60b0514 [lldb] Fix more -Wdeprecated-copy warnings
This warning triggers when a class defines a copy constructor but not a
copy-assignment operator (which then gets auto-generated by the
compiler). Fix the warning by deleting the other operator too, as the
default implementation works just fine.
2019-11-12 14:39:47 +01:00
Pavel Labath 1dfb1a85e7 [lldb] Fix some warnings in the python plugin 2019-11-12 14:39:34 +01:00
Michał Górny 77cc246412 [lldb] [Process/NetBSD] Use PT_STOP to stop the process [NFCI]
Differential Revision: https://reviews.llvm.org/D70060
2019-11-12 12:35:02 +01:00
Tatyana Krasnukha 3130a88137 [lldb][test] Macros in expressions require DWARF 5 2019-11-12 13:58:06 +03:00
Raphael Isemann ec4c96d685 [lldb][NFC] Simplify a return in ThreadPlanStepInRange::DefaultShouldStopHereCallback
We know should_stop_here is false here, so we might as well return false directly.
2019-11-12 10:58:54 +01:00
Raphael Isemann 874b6495b5 [lldb] Add missing include to ObjCLanguage.cpp to fix build 2019-11-12 10:21:49 +01:00
Raphael Isemann 52f3a2faf9 [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable
Summary:
swift-lldb currently has to patch the ExpressionKind enum to add support for Swift expressions. If we implement LLVM's RTTI
with a static ID variable instead of a centralised enum we can drop that patch.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D70070
2019-11-12 10:04:32 +01:00
Raphael Isemann 6cc853b416 [lldb][NFC] Remove unused CompilerType::IsPossibleCPlusPlusDynamicType
Reviewers: davide, xiaobai

Reviewed By: davide, xiaobai

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70074
2019-11-12 10:02:59 +01:00
Raphael Isemann bd7d9a85b8 [lldb] Check if we actually have a Clang type in ObjCLanguage::GetPossibleFormattersMatches
We call IsPossibleDynamicType but we also need to check if this is a Clang type,
otherwise other languages with dynamic types (like Swift) might end up being interpreted
as potential Obj-C dynamic types.
2019-11-12 09:59:04 +01:00
António Afonso 31ea714e9a Add rpath to liblldb so vendors can ship their own python framework (or others)
Summary:
I want to be able to specify which python framework to use for lldb in macos. With python2.7 we could just rely on the MacOS one but python3.7 is not shipped with the OS.
An alternative is to use the one shipped with Xcode but that could be path dependent or maybe the user doesn't have Xcode installed at all.
A definite solution is to just ship a python framework with lldb. To make this possible I added "@loader_path/../../../" to the rpath so it points to the same directory as the LLDB.framework, this way we can just drop any frameworks there.

Reviewers: hhb, sgraenitz, xiaobai, smeenai, beanz, labath

Reviewed By: labath

Subscribers: beanz, labath, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69931
2019-11-11 19:23:10 -08:00
Jonas Devlieghere 0b8dfb5762 [lldb] Re-enable VSCode tests
The VSCode tests were all disabled on macOS because the implementation
had some issues that resulted in flakiness on Darwin. It seems most of
these issues have been addressed. I've re-enabled all the tests that
consistently passed locally.
2019-11-11 15:59:54 -08:00