Commit Graph

22600 Commits

Author SHA1 Message Date
Jonas Devlieghere 13062d0fb7 [lldb/Test] Skip more tests that are not expected to work with passive replay
This skips some tests that pass with active replay (which doesn't check
the output) but fail with passive replay. Valid reasons for this
include:

 - Checking the output of the process (which doesn't run during replay),
 - Checking files that cannot be captured in the VFS (non-existing or
   unreadable files or files that are removed during test),

Unfortunately there's no good way to mark a test as supported for active
replay but unsupported for passive replay because the number and order
of API calls needs to be identical during capture and replay. I don't
think this is a huge loss however.
2020-05-07 15:16:52 -07:00
Jonas Devlieghere e6fbce675d [lldb/Test] Fix typo in find-and-replace. 2020-05-07 11:54:29 -07:00
Adrian Prantl dec1c94e80 Add a function to detect whether an Xcode SDK supports Swift
Differential Revision: https://reviews.llvm.org/D79535
2020-05-07 11:29:31 -07:00
Jonas Devlieghere 8c0ff17c3b [lldb/Test] Add @skipIfReproducer to tests using lldb::FileSP.
lldb::FileSP is a typedef for std::shared_ptr<lldb_private::File> and
the reproducers cannot instrument a lldb_private constructor.
2020-05-07 11:17:00 -07:00
Adrian Prantl 6e95d51ecf Add an XcodeSDK::GetSDKTypeForTriple function
This is something used in swift-lldb, but of general usefulness.

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

<rdar://problem/62684906>
2020-05-07 11:12:42 -07:00
Adrian Prantl 4356aa20bc Reuse existing functionality in XcodeSDK::SDKSupportsModules (NFC)
Differential Revision: https://reviews.llvm.org/D79533
2020-05-07 10:46:51 -07:00
Jonas Devlieghere 34a57dc972 [lldb/Reproducers] Make DoConnectRemote connect to the replay server.
All entry points into ProcessGDBRemote that connect to the debug server
should connect to the replay server instead during reproducer replay.
This patch adds the necessary logic for ConnectRemote, which is
accessible from the SB API. This fixes active replay for
TestRecognizeBreakpoint.py as described in D78588.
2020-05-07 10:09:09 -07:00
Gongyu Deng a14f4a7531 tab completion for register read/write
Summary:
1. Created a new common completion for the registers of the current context;
2. Apply this new common completion to the commands register read/write;
3. Unit test.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79490
2020-05-07 18:14:27 +02:00
Raphael Isemann d7c2c2ed79 [lldb][NFC] Also initialize language_flags in ValueObject::Dereference
We currently rely on the TypeSystem implementation to initialize this value
with 0 in the GetChildCompilerTypeAtIndex call below. Let's just initialize
this variable like the rest.
2020-05-07 17:52:12 +02:00
Med Ismail Bennani f058d397ff
[lldb/test] Reformat Objective-C data-formatter source file (NFC)
The source file used to test Objective-C data-formatters didn't respected
any formatting (mixed tab and spaces, lines exceed column 80, etc...).

This patch reformats the file using clang-format to make it easier to
work with.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-05-07 05:51:52 +02:00
Adrian Prantl 01fc85dc96 ParseXcodeSDK: Register both the CU module and the SymbolFile module.
For Swift LLDB (but potentially also for module support in Clang-land)
we need a way to accumulate the path remappings produced by
Module::RegisterXcodeSDK(). In order to make this work for
SymbolFileDebugMaps, registering the search path remapping with both
modules is necessary.

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

<rdar://problem/62750529>
2020-05-06 16:46:22 -07:00
Jonas Devlieghere 7c6420e431 [lldb/Test] Run dotest.py with the Python LLDB was built with.
The Python used to run lit can be different from the Python LLDB was
build with. One scenario where this happens is when LLVM can find the
Python 3 interpreter, but not the Python 3 libraries, in which case LLDB
build and links against Python 3. Without this change, you end up with
an ModuleNotFoundError because of the mismatch.

Instead of looking at the Python interpreter that's used to run lit,
lldbtest should use the interpreter that matches the Python version LLDB
was build against.

Differential revision: https://reviews.llvm.org/D79519
2020-05-06 14:57:44 -07:00
Adrian Prantl f0c08b7eac Move the Xcode SDK path caching to HostInfo
When debugging a remote platform, the platform you get from
GetPlatformForArchitecture doesn't inherit from PlatformDarwin.
HostInfoMacOSX seems like the right place to have a global store of
local paths.

Differential Revision: https://reviews.llvm.org/D79364
2020-05-06 13:43:50 -07:00
Adrian Prantl 5935227e11 Add an explicit API to read the Xcode SDK DWARF attribute from compile units
When debugging from a SymbolMap the creation of CompileUnits for the
individual object files is so lazy that RegisterXcodeSDK() is not
invoked at all before the Swift TypeSystem wants to read it. This
patch fixes this by introducing an explicit
SymbolFile::ParseXcodeSDK() call that can be invoked deterministically
before the result is required.

<rdar://problem/62532151+62326862>

https://reviews.llvm.org/D79273
2020-05-06 13:16:16 -07:00
Raphael Isemann dee4cbcd47 [lldb][NFC] Remove some redundant comment containing just the file name 2020-05-06 13:58:25 +02:00
Raphael Isemann aaf68cd9ce [lldb] Warn the user about starting the --func-regex parameter with an asterisk
Summary:
Sometimes users think that setting a function regex for all function that contain the word 'needle' in their
name looks like this: `*needle*`. However, LLDB only searches the function name and doesn't fully match
it against the regex, so the leading and trailing '*' operators don't do anything and actually just cause the
regex engine to reject the regular expression with "repetition-operator operand invalid".

This patch makes this a bit more obvious to the user by printing a warning that a leading '*' before this
regular expression here doesn't have any purpose (and will cause an error). This doesn't attempt to detect
a case where there is only a trailing '*' as that would involve parsing the regex and it seems the most
common way to end up in this situation is by doing `rbreak *needle*`.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D78809
2020-05-06 12:37:52 +02:00
Jaroslav Sevcik cf5ed6dc59 Fix error handling after [<index>] in 'frame variable'
Summary:
This fixes a bug where

frame var a[0]+5

returns the value a[0] without any warning because the current logic simply ignores everything after ']' as long as there is no '.', '-' or '[' in the rest of the string.

The fix simplifies the termination condition of the expression path parsing loop to check if have a non-empty remaining string to parse. Previously, the condition checked if a separator was found. That condition coincided with the remaining string-to-parse condition except for the buggy indexed case where non-empty string was left ("+5" in the example above), but the separator index was 'npos'.

Reviewed By: teemperor, labath

Differential Revision: https://reviews.llvm.org/D79404
2020-05-06 11:03:46 +02:00
Jonas Devlieghere 0274c797c6 [lldb/Utils] Serialize exit code in lldb-repro.py
After 61d5b0e663 more shell test are expected to exit with a non-zero
status code. Because the exit status is computed in the driver and not
behind the SB API layer, reproducers don't know about it and always
return 0 unless replay failed.

This discrepancy means that these tests don't work with lldb-repro.py
and skipping them for this reason would be a pity. To solve this
problem, the script now serializes the exit code during capture and
returns that during replay.

These is an assert that ensures that replay exits with a zero exit
status to prevent replay failures from being silently ignored.
2020-05-05 16:05:49 -07:00
Jason Molenda 5034102b24 Log the NSError str and object description on app launch fail
Update CallBoardSystemServiceOpenApplication to unconditionally log
the NSError's localizedDescription to Console on app launch failure
(as it was already doing), and also to log the NSError object's
full description to the console, which may contain additional nested
error messages.  I'm experimenting to find cases where we will get
more detailed information from app launch failures and will start
by logging both to the console.

<rdar://problem/62709160>
2020-05-05 15:51:50 -07:00
Jonas Devlieghere 11af2bf0e0 [lldb/Test] Update expressions.test for non-zero exit code
Updates Windows test for 61d5b0e663.
2020-05-05 14:06:47 -07:00
Davide Italiano d606dcc652 [TestIndirectSymbol] This tests an Apple-specific feature.
Remove a redundant check.
2020-05-05 13:14:05 -07:00
Davide Italiano 48e5eedab3 [TestIndirectSymbols] This now runs and works on iOS (arm64). 2020-05-05 13:14:05 -07:00
Jonas Devlieghere 61d5b0e663 [lldb/Driver] Exit with a non-zero exit code in case of error in batch mode.
We have the option to stop running commands in batch mode when an error
occurs. When that happens we should exit the driver with a non-zero exit
code.

Differential revision: https://reviews.llvm.org/D78825
2020-05-05 11:01:44 -07:00
Vedant Kumar c05f35443c [lldb/unittest] Avoid relying on compiler character encoding in unicode test
This is a speculative fix for a unit test failure on a Win/MSVC2017 bot
(http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/16106/steps/test/logs/stdio).
2020-05-05 09:18:35 -07:00
Adrian Prantl 36183811fb Clarify comment 2020-05-04 18:15:30 -07:00
Reid Kleckner 58c7bf246e Update LLDB filespec tests for remove_dots change
It looks like the new implementation is correct, since there were TODOs
here about getting the new behavior.

I am not sure if "C:..\.." should become "C:" or "C:\", though. The new
output doesn't precisely match the TODO message, but it seems
appropriate given the specification of remove_dots and how .. traversals
work at the root directory.
2020-05-04 17:27:16 -07:00
Vedant Kumar 9e35498046 [lldb/Expression] Make Language() const, NFC
Allow Language() to be called from const methods within UserExpression.
2020-05-04 14:42:01 -07:00
Jonas Devlieghere 97db238c17 [lldb] Fix -Wdtor-name warnings
Fix warning: ISO C++ requires the name after '::~' to be found in the
same scope as the name before '::~' [-Wdtor-name]
2020-05-04 14:32:28 -07:00
Davide Italiano 6951fe3989 [arm64] Remove an old special case that's not needed anymore.
Debug info generation & codegen now steps onto the correct line.
2020-05-04 14:18:51 -07:00
Vedant Kumar a37caebc2d [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper
Summary:
Languages can have different ways of formatting special characters.
E.g. when debugging C++ code a string might look like "\b", but when
debugging Swift code the same string would look like "\u{8}".

To make this work, plugins override GetStringPrinterEscapingHelper.
However, because there's a large amount of subtly divergent work done in
each override, we end up with large amounts of duplicated code. And all
the memory smashers fixed in one copy of the logic (see D73860) don't
get fixed in the others.

IMO the GetStringPrinterEscapingHelper is overly general and hard to
use. I propose deleting it and replacing it with an EscapeStyle enum,
which can be set as needed by each plugin.

A fix for some swift-lldb memory smashers falls out fairly naturally
from this deletion (https://github.com/apple/llvm-project/pull/1046). As
the swift logic becomes really tiny, I propose moving it upstream as
part of this change. I've added unit tests to cover it.

rdar://61419673

Reviewers: JDevlieghere, davide

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77843
2020-05-04 14:06:55 -07:00
Vedant Kumar 47e9fd47c7 Revert "[lldb/Expression] Make Language() const, NFC"
This reverts commit 88d9e4326f. Revert an
accidental commit.
2020-05-04 14:03:22 -07:00
Vedant Kumar 88d9e4326f [lldb/Expression] Make Language() const, NFC
Allow Language() to be called from const methods within UserExpression.
2020-05-04 14:02:43 -07:00
shafik 4ad53177db [LLDB] Fix overloaded operator new cases in TestCppOperators.py which currently work by accident
The overloaded new operator in TestCppOperators.py are working by accident because of how
we currently deal with artificial methods.

Differential Revision: https://reviews.llvm.org/D79251
2020-05-04 13:57:42 -07:00
Med Ismail Bennani 6b8d6f4459 [lldb/test] Fix wrong target command failure message on Windows
This patch fixes the test failure happening on Windows introduced by
`015117411e11458f9816ba4359246132164a4297`.

Since the failure message comes from the OS, the test needs to support both
UNIX and Windows messages.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-05-04 19:22:34 +02:00
Med Ismail Bennani 015117411e
[lldb/Host] Improve error messages on unowned read files
When trying to read a core file that is not owned by the user running lldb
and that doesn't have read permission on the file, lldb shows a misleading
error message:

```
Unable to find process plug-in for core file
```

This is due to the fact that currently, lldb doesn't check the file
ownership. And when trying to to open and read a core file, the syscall
fails, which prevents a process to be created.

Since lldb already have a portable `open` syscall interface, lets take
advantage of that and delegate the error handling to the syscall
itself. This way, no matter if the file exists or if the user has proper
ownership, lldb will always try to open the file, and behave accordingly
to the error code returned.

rdar://42630030

https://reviews.llvm.org/D78712

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-05-04 17:33:55 +02:00
Pavel Labath 283658c978 [lldb/DWARF] Remove dead code in DWARFDebugInfoEntry
The dumping code is not used by anyone, and is a source of
inconsistencies with the llvm dwarf parser, as dumping is implemented at
a different level (DWARFDie) there.
2020-05-04 15:37:22 +02:00
Davide Italiano 30ddd4ce19 [ARM64] Remove more dead code. NFC. 2020-05-01 15:05:42 -07:00
Davide Italiano 68f8e0264e [ARM64] Remove dead code. 2020-05-01 15:04:44 -07:00
Jonas Devlieghere 4c67b11918 [lldb/API] Add SBCommandInterpreterRunResult
This adds an RunCommandInterpreter overload that returns an instance of
SBCommandInterpreterRunResults. The goal is to avoid having to add more
and more overloads when we need more output arguments.

Differential revision: https://reviews.llvm.org/D79120
2020-05-01 13:55:38 -07:00
Jonas Devlieghere 232ef38713 [lldb/CommandInterpreter] Fix typo in CommandInterpreterResult::IsResult
A missing `=` turned a comparison into an assignment.
2020-05-01 12:07:21 -07:00
Jonas Devlieghere 1bff0928f5 [lldb/CommandInterpreter] Add CommandInterpreterRunResult (NFC)
This patch adds a new class CommandInterpreterRunResult which will be
backing the SBCommandInterpreterRunResult. It keeps track of the number
of errors as well as the result which is an enum, as proposed by Pavel
in D79120. The command interpreter now populates the results directly,
instead of its own member variables.

Differential revision: https://reviews.llvm.org/D79209
2020-05-01 11:29:28 -07:00
Jonas Devlieghere c286665af3 [lldb] Remove lldb/lldb subdirectory
A patch command with the wrong -p value (strip prefix) created the
nested lldb folder.
2020-04-30 14:55:24 -07:00
Jonas Devlieghere 4b35403942 [lldb/API] Move SBCommandInterpreterRunOption in its own header. (NFC)
Currently, `SBCommandInterpreterRunOptions` is defined in
`SBCommandInterpreter.h`. Given that the options are always passed by
reference, a forward declaration is sufficient.

That's not the case for `SBCommandInterpreterRunResults`, which we need
for a new overload for `RunCommandInterpreter` and that returns this new
class by value. We can't include `SBCommandInterpreter.h` because
`SBCommandInterpreter::GetDebugger()` returns SBDebugger by value and
therefore needs a full definition.

This patch moves the definition of `SBCommandInterpreterRunOptions` into
a new header. In a later patch,  `SBCommandInterpreterRunResults` will
be defined in there as well, solving the aforementioned problem.

Differential revision: https://reviews.llvm.org/D79115
2020-04-30 13:41:21 -07:00
Jonas Devlieghere 32c3224612 [lldb/CommandInterpreter] Move everything into CommandInterpreterRunOptions
This implements Greg's suggestion from D78825 to include "auto handle
events" and "spawn thread" in CommandInterpreterRunOptions. This change
is in preparation for adding a new overload for RunCommandInterpreter
that takes only SBCommandInterpreterRunOptions and returns
SBCommandInterpreterRunResults.

Differential revision: https://reviews.llvm.org/D79108
2020-04-30 13:20:06 -07:00
Jonas Devlieghere 21afeddfb2 [lldb/CMake] Use INSTALL_RPATH for tools and BUILD_RPATH for unittests.
It seems like only the unittests are building with
BUILD_WITH_INSTALL_RPATH set to OFF. Of course when I did my last change
I only ran check-lldb-unit. Not sure why this difference exists, why
would you even install the unittest?

For the LLDB framework we do need different build and install RPATHs.
Currently that logic lives downstream. I plan to upstream that in the
near future. For now I'm just trying to make it possible to run the
test.
2020-04-30 13:20:06 -07:00
Raphael Isemann 8e9fb845fc [lldb] Also set owning module for template specializations
Summary:
This was originally commented out as it broke the data-formatter-stl/libcxx/
tests. However this was fixed by commit ef423a3ba5
(Add Objective-C property accessors loaded from Clang module DWARF to lookup)
which sets the HasExternalVisibleStorage flag for the template specializations.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D79168
2020-04-30 20:40:13 +02:00
Jonas Devlieghere 8539588783 [lldb/CMake] Set the PYTHON_RPATH for the unit tests
The API and Python script interpreter unit tests also link against
Python and therefore need to set the RPATH when applicable.
2020-04-30 11:05:50 -07:00
Jonas Devlieghere 397e69dbcb [lldb/CMake] Don't make PYTHON_RPATH a required variable. 2020-04-30 10:54:47 -07:00
Jonas Devlieghere ae6d2ff633 [lldb] fix RPATH when linking against Python3.framework
The install name for the Python 3 framework in Xcode is relative to
the framework's location and not the dylib itself.

  @rpath/Python3.framework/Versions/3.x/Python3

This means that we need to compute the path to the Python3.framework
and use that as the RPATH instead of the usual dylib's directory.
2020-04-30 10:42:03 -07:00
Raphael Isemann b3180d6a1a [lldb] Re-add deleted RUN line in module-ownership.mm
This was deleted in 681466f5e6 by accident.
2020-04-30 19:29:50 +02:00