Commit Graph

23709 Commits

Author SHA1 Message Date
Jonas Devlieghere 76e3a27c16 [lldb] Add test for CFMutableDictionaryRef
While writing a test for a change in Foundation I noticed we didn't yet
test CFMutableDictionaryRef.
2020-09-11 16:11:25 -07:00
Med Ismail Bennani 4da8fa45a0 [lldb/API] Add Breakpoint::SerializeToStructuredData to SBAPI
This patch adds a way to fetch breakpoint metadatas as a serialized
`Structured` Data format (JSON). This can be used by IDEs to update
their UI when a breakpoint is set or modified from the console.

rdar://11013798

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-09-11 20:09:55 +02:00
Jonas Devlieghere bc0a35f3b7 [lldb] Add missing LLDB_REGISTER_CONSTRUCTOR in SBPlatform
This fixes the following assertion in TestPlatformPython.py.

  Assertion failed: (id != 0 && "Forgot to add function to
  registry?")
2020-09-10 18:50:02 -07:00
Jordan Rupprecht 6040d52550 [NFC] Fix whitespace in lldb-vscode --help 2020-09-10 10:57:23 -07:00
Stella Stamenova c464f1d8f9 [lldb, tests] Correctly configure the yaml2obj paths
They are currently not being set correctly for the case of multi-config generators like XCode and VS. There's also a typo in one of the cmake files.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D87466
2020-09-10 10:10:28 -07:00
Kamil Rytarowski 52f42720b2 [lldb] [netbsd] Avoid comparison of signed and unsigned integers
Cast ProcessID to ::pid_t.
2020-09-10 15:49:15 +02:00
Jonas Devlieghere 2955a27abc [lldb] Pass the arch as part of the triple in the ARCH_CFLAGS 2020-09-09 14:41:25 -07:00
Dave Lee 55dd731b29 [debugserver] Extract function for default launch flavor
Extract a function for turning `eLaunchFlavorDefault` into a concreate `eLaunchFlavor` value.

This new function encapsulates the few compile time variables involved, and also prevents clang unused code diagnostics.

Differential Revision: https://reviews.llvm.org/D87327
2020-09-09 11:35:44 -07:00
Dave Lee 447ba60a22 [lldb/Docs] Correct LLDB_ENABLE_TESTS to LLDB_INCLUDE_TESTS
Fix references to LLDB_ENABLE_TESTS.

Differential Revision: https://reviews.llvm.org/D87345
2020-09-09 11:07:57 -07:00
Raphael Isemann b85222520f [lldb] Enable std::pair in CxxModuleHandler
This adds support for substituting std::pair instantiations with enabled
import-std-module.

With the fixes in parent revisions we can currently substitute a single pair
(however, a result that returns a second pair currently causes LLDB to crash
while importing the second template instantiation).

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D85141
2020-09-09 10:49:53 +02:00
Raphael Isemann 7866b91405 [lldb] Fix a crash when the ASTImporter is giving us two Imported callbacks for the same target decl
The ASTImporter has an `Imported(From, To)` callback that notifies subclasses
that a declaration has been imported in some way. LLDB uses this in the
`CompleteTagDeclsScope` to see which records have been imported into the scratch
context. If the record was declared inside the expression, then the
`CompleteTagDeclsScope` will forcibly import the full definition of that record
to the scratch context so that the expression AST can safely be disposed later
(otherwise we might end up going back to the deleted AST to complete the
minimally imported record). The way this is implemented is that there is a list
of decls that need to be imported (`m_decls_to_complete`) and we keep completing
the declarations inside that list until the list is empty. Every `To` Decl we
get via the `Imported` callback will be added to the list of Decls to be
completed.

There are some situations where the ASTImporter will actually give us two
`Imported` calls with the same `To` Decl. One way where this happens is if the
ASTImporter decides to merge an imported definition into an already imported
one. Another way is that the ASTImporter just happens to get two calls to
`ASTImporter::Import` for the same Decl. This for example happens when importing
the DeclContext of a Decl requires importing the Decl itself, such as when
importing a RecordDecl that was declared inside a function.

The bug addressed in this patch is that when we end up getting two `Imported`
calls for the same `To` Decl, then we would crash in the
`CompleteTagDeclsScope`.  That's because the first time we complete the Decl we
remove the Origin tracking information (that maps the Decl back to from where it
came from). The next time we try to complete the same `To` Decl the Origin
tracking information is gone and we hit the `to_context_md->getOrigin(decl).ctx
== m_src_ctx` assert (`getOrigin(decl).ctx` is a nullptr the second time as the
Origin was deleted).

This is actually a regression coming from D72495. Before D72495
`m_decls_to_complete` was actually a set so every declaration in there could
only be queued once to be completed. The set was changed to a vector to make the
iteration over it deterministic, but that also causes that we now potentially
end up trying to complete a Decl twice.

This patch essentially just reverts D72495 and makes the `CompleteTagDeclsScope`
use a SetVector for the list of declarations to be completed. The SetVector
should filter out the duplicates (as the original `set` did) and also ensure that
the completion order is deterministic. I actually couldn't find any way to cause
LLDB to reproduce this bug by merging declarations (this would require that we
for example declare two namespaces in a non-top-level expression which isn't
possible). But the bug reproduces very easily by just declaring a class in an
expression, so that's what the test is doing.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D85648
2020-09-09 10:31:39 +02:00
Raphael Isemann 32c8da41dc [lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType when trying to complete a forward decl
SemaSourceWithPriorities is a special SemaSource that wraps our normal LLDB
ExternalASTSource and the ASTReader (which is used for the C++ module loading).
It's only active when the `import-std-module` setting is turned on.

The `CompleteType` function there in `SemaSourceWithPriorities` is looping over
all ExternalASTSources and asks each to complete the type. However, that loop is
in another loop that keeps doing that until the type is complete. If that
function is ever called on a type that is a forward decl then that causes LLDB
to go into an infinite loop.

I remember I added that second loop and the comment because I thought I saw a
similar pattern in some other Clang code, but after some grepping I can't find
that code anywhere and it seems the rest of the code base only calls
CompleteType once (It would also be kinda silly to have calling it multiple
times). So it seems that's just a silly mistake.

The is implicitly tested by importing `std::pair`, but I also added a simpler
dedicated test that creates a dummy libc++ module with some forward declarations
and then imports them into the scratch AST context. At some point the
ASTImporter will check if one of the forward decls could be completed by the
ExternalASTSource, which will cause the `SemaSourceWithPriorities` to go into an
infinite loop once it receives the `CompleteType` call.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D87289
2020-09-09 10:05:57 +02:00
Raphael Isemann 4e4a3feecd [lldb][doc] Mention python3-dev instead of python2.7-dev in build docs 2020-09-09 09:31:27 +02:00
Walter Erquinigo 5c463d107d Revert "Retry of D84974"
This reverts commit 5b2b4f331d.

This caused a link error in
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18794/steps/build/logs/stdio
2020-09-08 13:41:11 -07:00
Walter Erquinigo 5b2b4f331d Retry of D84974
The test is being disabled on Linux, as lldb-vscode has a bug with
--wait-for on LInux.
I'm also fixing some compilation warnings.
2020-09-08 11:50:09 -07:00
Muhammad Omair Javaid 7695332166 Move NativeRegisterContextLinux/RegisterContextPOSIX*_arm to RegisterInfoAndSetInterface
This patch removes register set definitions and other redundant code from
NativeRegisterContextLinux/RegisterContextPOSIX*_arm. Register sets are now
moved under RegisterInfosPOSIX_arm which now uses RegisterInfoAndSetInterface.
This is similar to what we earlier did for AArch64.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86962
2020-09-07 09:06:46 +05:00
Muhammad Omair Javaid 9bee13f890 Move targetHasSVE function to lldbtest.py
targetHasSVE helper function was added to test for availability of SVE support
by connected platform. We now intend to use this function in other testcases
and I am moving it to a generic location in lldbtest.py to allow usage by
other upcoming testcases.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86872
2020-09-07 08:37:39 +05:00
Raphael Isemann 101f37a1b3 [lldb][NFC] Rewrite CPP11EnumTypes test to make it faster
TestCPP11EnumTypes is one of the most expensive tests on my system and takes
around 35 seconds to run. A relatively large amount of that time is actually
doing CPU intensive work it seems (and not waiting on timeouts like other
slow tests).

The main issue is that this test repeatedly compiles the same source files
with different compiler defines. The test is also including standard library
headers, so it will also build all system modules with the gmodules debug
info variant. This leads to the problem that this test ends up compiling all
system Clang modules 8 times (one for each subtest with a unique define). As
the system modules are quite large, this causes that this test spends most
of its runtime just recompiling all system modules on macOS.

There is also the small issue that this test is starting and start-stopping
the test process a few hundred times.

This rewrites the test to instead just use a macro to instantiate all the
enum types in a single source and uses global variables to test the values
(which means there is no more need to continue/stop or even start a process).

I kept running all the debug info variants (event though it doesn't seem really
relevant) to keep this as NFC as possible.

This reduced the test runtime by around 1.5 seconds on my system (or in relative
numbers, the runtime of this test decreases by 95%).
2020-09-04 13:45:42 +02:00
Raphael Isemann f9ad112770 [lldb] Speed up TestValueObjectRecursion by making it a no_debug_info_test
This is one of the most expensive tests and runs for nearly half a minute on
my machine. Beside this test just doing a lot of work by iterating 15k times on
one ValueObject (which seems to be the point), it also runs this for every
debug info variant which doesn't seem relevant to just iterating ValueObject.

This marks it as no_debug_info_test to only run one debug info variation
and cut down the runtime to around 7 seconds on my machine.
2020-09-04 11:25:43 +02:00
Raphael Isemann bdc4c0bc5c Revert "[lldb] avoid assert in threadsanitizer tests on linux"
This reverts commit f369d51896. The bug this
fixes was already fixed by 1c5a0cb1c3 with the
same approach and this commit is now just giving the variable a second fallback
value.
2020-09-04 09:30:56 +02:00
Luboš Luňák f369d51896 [lldb] avoid assert in threadsanitizer tests on linux
The tests are unsupported on linux, but they assert in
Thread::GetStopDescriptionRaw() because of empty stop reason
description. And it is empty because
InstrumentationRuntimeTSan::NotifyBreakpointHit() fails
to get report from InstrumentationRuntimeTSan::RetrieveReportData(),
which is possibly(?) the reason why this is unsupported on linux.
Add a dummy stop reason description for this case, which changes
the test result from failing to unsupported.
2020-09-03 21:18:17 +02:00
Walter Erquinigo ddcc7ce591 [lldb-vscode] Fix TestVSCode_module
Caused by D86662. The fix is only checking some fields when the expect_debug_info_size flag is true. For some reason this was not failing on a local linux machine.
2020-09-03 09:01:56 -07:00
David Spickett 9f18f3c858 [lldb] Improve test failure reporting for expect()
This updates the errors reported by expect()
to something like:

```
Ran command:
"help"

Got output:
Debugger commands:
<...>

Expecting start string: "Debugger commands:" (was found)
Expecting end string: "foo" (was not found)
```
(see added tests for more examples)

This shows the user exactly what was run,
what checks passed and which failed. Along with
whether that check was supposed to pass.
(including what regex patterns matched)

These lines are also output to the test
trace file, whether the test passes or not.

Note that expect() will still fail at the first failed
check, in line with previous behaviour.

Also I have flipped the wording of the assert
message functions (.*_MSG) to describe failures
not successes. This makes more sense as they are
only shown on assert failures.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86792
2020-09-03 13:35:05 +01:00
Med Ismail Bennani bf8f6e89c8 [lldb/Interpreter] Fix language detection for the REPL InitFile
Previously, before loading the REPL language-specific init file, lldb
checked the selected target language in which case it returned an unknown
language type with the REPL target.

Instead, the patch calls `Language::GetLanguagesSupportingREPLs` and
look for the first element of that set. In case lldb was not configured
with a REPL language, then, it will just stop sourcing the REPL init
file and fallback to the original logic (continuing with the default
init file).

rdar://65836048

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-09-03 10:57:56 +02:00
Raphael Isemann 5b354d204d [lldb] Make symbol list output from `image dump symtab` not depend on internal ordering of DenseMap
`image dump symtab` seems to output the symbols in whatever order they appear in
the DenseMap that is used to filter out symbols with non-unique addresses. As
DenseMap is a hash map this order can change at any time so the output of this
command is pretty unstable. This also causes the `Breakpad/symtab.test` to fail
with enabled reverse iteration (which reverses the DenseMap order to find issues
like this).

This patch makes the DenseMap a std::vector and uses a separate DenseSet to do
the address filtering. The output order is now dependent on the order in which
the symbols are read (which should be deterministic). It might also avoid a bit
of work as all the work for creating the Symbol constructor parameters is only
done when we can actually emplace a new Symbol.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D87036
2020-09-03 10:27:19 +02:00
Martin Storsjö 13cde6733b [lldb] Remove a stray semicolon, fixing pedantic GCC warnings. NFC. 2020-09-03 11:19:40 +03:00
Raphael Isemann e123959e94 [lldb] Remove debugserver specific string from TestAbortExitCode check
The test only checks the exit code that the debug server sends back, but
not the following explanation which is different for debugserver and lldb-server.
2020-09-03 10:03:02 +02:00
Raphael Isemann f0699d9109 [debugserver] Fix that debugserver's stop reply packets always return signal code 0
If our process terminates due to an unhandled signal, we are supposed to get the
signal code via WTERMSIG. However, we instead try to get the exit status via
WEXITSTATUS which just ends up always calculating signal code 0 (at least on the
macOS implementation where it just shifts the signal code bits away and we're
left with only 0 bits).

The exit status calculation on the LLDB side also seems a bit off as it claims
an exit status that is just the signal code (instead of for example 128 + signal
code), but that will be another patch.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D86336
2020-09-03 09:47:03 +02:00
Jonas Devlieghere 3746906193 [lldb] Add reproducer verifier
Add a reproducer verifier that catches:

 - Missing or invalid home directory
 - Missing or invalid working directory
 - Missing or invalid module/symbol paths
 - Missing files from the VFS

The verifier is enabled by default during replay, but can be skipped by
passing --reproducer-no-verify.

Differential revision: https://reviews.llvm.org/D86497
2020-09-02 22:00:00 -07:00
Jonas Devlieghere fa95e35593 [lldb] Pass -fno-objc-exceptions for objcxx targets
When compiling an Objective-C++ file, __has_feature(cxx_exceptions) will
return true with -fno-exceptions but without -fno-objc-exceptions. This
was causing LLVM_ENABLE_EXCEPTIONS to be defined for a subset of files.
2020-09-02 21:59:48 -07:00
Jonas Devlieghere 426fa35b65 [lldb] Always record both the working and home directory.
Treat the home directory like the current working directory and always
capture both in the VFS.
2020-09-02 20:53:11 -07:00
Jordan Rupprecht f7e04b710d [lldb/Gui] zero-initialize children_stop_id
This is currently causing msan warnings in the API tests when run under msan, e.g. `commands/gui/basic/TestGuiBasic.py`.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D86825
2020-09-02 20:05:17 -07:00
Walter Erquinigo 5f6ca065a5 Revert de6caf871b and 51128b670d (https://reviews.llvm.org/D84974)
The tests seem to be timing out in all linux bots. Need further analysis.

Revert "run in terminal"

This reverts commit de6caf871b.
2020-09-02 17:06:48 -07:00
Walter Erquinigo 51128b670d Fix de6caf871b
Failure found in
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/16855

The issue is a header not being included
2020-09-02 15:05:33 -07:00
Walter Erquinigo de6caf871b run in terminal 2020-09-02 14:38:00 -07:00
Med Ismail Bennani 0e86f39045
[lldb/test] Fix TestPlatform*.py Windows failures (NFC)
This patch fixes the windows failures introduced by `addb514`:
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18671/steps/test/logs/stdio

This macro, used in the test to check the platform, was missing a `_`,
making the test behave like it was run from a UNIX platform.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-09-02 21:41:35 +02:00
Jordan Rupprecht c5aa63dd56 [lldb/Host] Add missing proc states
The /proc/<pid>/status parsing is missing a few cases:
- Idle
- Parked
- Dead

If we encounter an unknown proc state, this leads to an msan warning. In reality, we only check that the state != Zombie, so it doesn't really matter that we handle all cases, but handle them anyway (current list: [1]). Also explicitly set it to unknown if we encounter an unknown state. There will still be an msan warning if the proc entry has no `State:` line, but that should not happen.

Use a StringSwitch to make the handling of proc states a little more compact.

[1] https://github.com/torvalds/linux/blob/master/fs/proc/array.c

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86818
2020-09-02 08:24:06 -07:00
Med Ismail Bennani addb5148f5 [lldb/Target] Add custom interpreter option to `platform shell`
This patch adds the ability to use a custom interpreter with the
`platform shell` command. If the user set the `-s|--shell` option
with the path to a binary, lldb passes it down to the platform's
`RunShellProcess` method and set it as the shell to use in
`ProcessLaunchInfo to run commands.

Note that not all the Platforms support running shell commands with
custom interpreters (i.e. RemoteGDBServer is only expected to use the
default shell).

This patch also makes some refactoring and cleanups, like swapping
CString for StringRef when possible and updating `SBPlatformShellCommand`
with new methods and a new constructor.

rdar://67759256

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-09-02 16:36:10 +02:00
Jonas Devlieghere 9390b346fc [lldb] Move ScriptCommand and RegexCommand under Commands (NFC)
Move the CommandObjectScript and CommandObjectRegexCommand under
Commands where all the other CommandObject implementations live.

Although neither implementations currently use the TableGen-generated
CommandOptions.inc, this move would have been necessary anyway if they
were to in the future.
2020-09-01 17:33:39 -07:00
Yifan Shen 82139b8770 Simplify Symbol Status Message to Only Debug Info Size
The Symbol Status in modules view is simplified so that only when the module has debug info and its size is non-zero, will the status message be displayed. The symbol status message is renamed to debug info size and flag message like "Symbols not found" and "Symbols loaded" is deleted.

Differential Revision: https://reviews.llvm.org/D86662
2020-09-01 16:25:20 -07:00
Med Ismail Bennani 0224738c1a [lldb/interpreter] Improve REPL init file compatibility
This patch changes the command interpreter sourcing logic for the REPL
init file. Instead of looking for a arbitrary file name, it standardizes
the REPL init file name to match to following scheme:

                          `.lldbinit-<language>-repl`

This will make the naming more homogenous and the sourcing logic future-proof.

rdar://65836048

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-09-02 01:21:22 +02:00
Raphael Isemann 7c80f2da81 Revert "[lldb] Add reproducer verifier"
This reverts commit 297f69afac. It broke
the Fedora 33 x86-64 bot. See the review for more info.
2020-09-01 12:21:44 +02:00
Petr Hosek 3c7bfbd683 [CMake] Use find_library for ncurses
Currently it is hard to avoid having LLVM link to the system install of
ncurses, since it uses check_library_exists to find e.g. libtinfo and
not find_library or find_package.

With this change the ncurses lib is found with find_library, which also
considers CMAKE_PREFIX_PATH. This solves an issue for the spack package
manager, where we want to use the zlib installed by spack, and spack
provides the CMAKE_PREFIX_PATH for it.

This is a similar change as https://reviews.llvm.org/D79219, which just
landed in master.

Patch By: haampie

Differential Revision: https://reviews.llvm.org/D85820
2020-08-31 20:06:21 -07:00
Jonas Devlieghere 297f69afac [lldb] Add reproducer verifier
Add a reproducer verifier that catches:

 - Missing or invalid home directory
 - Missing or invalid working directory
 - Missing or invalid module/symbol paths
 - Missing files from the VFS

The verifier is enabled by default during replay, but can be skipped by
passing --reproducer-no-verify.

Differential revision: https://reviews.llvm.org/D86497
2020-08-31 15:14:18 -07:00
Gongyu Deng 1cd99fe9d4 [lldb] tab completion for class `CommandObjectTypeFormatterDelete`
1. Added a dedicated completion to class `CommandObjectTypeFormatterDelete`
   which can be used by these commands: `type filter/format/summary/synthetic delete`;
2. Added a related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84142
2020-08-31 14:18:07 +02:00
Raphael Isemann da0d43d90a [lldb][NFC] Remove trailing whitespace in TestCompletion 2020-08-31 12:24:25 +02:00
Raphael Isemann b51321ccc8 [lldb] Fix TestCompletion's pid completion failing randomly
TestCompletion is randomly failing on some bots. The error message however states
that the computed completions actually do contain the expected pid we're
looking for, so there shouldn't be any test failure.

The reason for that turns out to be that complete_from_to is actually used
for testing two different features. It can be used for testing what the
common prefix for the list of completions is and *also* for checking all the
possible completions that are returned for a command. Which one of the two
things should be checked can't be defined by a parameter to the function, but
is instead guessed by the test method instead based on the results that were
returned. If there is a common prefix in all completions, then that prefix
is searched and otherwise all completions are searched.

For TestCompletion's pid test this behaviour leads to the strange test failures.
If all the pid's that our test LLDB can see have a common prefix (e.g., it
can only see pids [123, 122, 10004, 10000] -> common prefix '1'), then
complete_from_to check that the common prefix contains our pid, which is
always fails ('1' doesn't contain '123' or any other valid pid). If there
isn't a common prefix (e.g., pids are [123, 122, 10004, 777]) then
complete_from_to will check the list of completions instead which works correctly.

This patch is fixing this by adding a simple check method that doesn't
have this behaviour and is simply searching the returned list of completions.
This should get the bots green while I'm working on a proper fix that fixes
complete_from_to.
2020-08-31 12:22:41 +02:00
Raphael Isemann 1c5a0cb1c3 [lldb] Don't crash when LLDB can't extract the tsan report
Right now all tsan tests are crashing on Linux. The tests were already marked as
expected failures, but since commit 20ce8affce added an assert that every
StopInfo needs a non-empty stop description the tests actually started crash
(which is even with an expectedFailure a failed test).

The reason for that is that we never had any stop description when hitting tsan
errors on Linux. Before the assert that just made the test fail, but now the
empty description is hitting the assert. This patch just adds a generic stop
description mentioning tsan to prevent that we hit that assert on platforms
where we don't support extracting the tsan report.

Reviewed By: friss

Differential Revision: https://reviews.llvm.org/D86593
2020-08-31 11:13:11 +02:00
Xing GUO 1d01fc100b [Test] Simplify DWARF test cases. NFC.
The Length, AbbrOffset and Values fields of the debug_info section are
optional. This patch helps remove them and simplify test cases.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D86857
2020-08-31 14:03:48 +08:00
Jonas Devlieghere 2965e9bd5e [lldb] Hoist --framework argument out of LLDB_TEST_COMMON_ARGS (NFC)
Give the framework argument its own variable (LLDB_FRAMEWORK_DIR) so
that we can configure it in lit.site.cfg.py if we so desire.
2020-08-28 18:15:33 -07:00
Jonas Devlieghere 3f2fb0132f [lldb] Make the lit configuration values optional for the API tests
LIT uses a model where the test suite is configurable trough a
lit.site.cfg file. Most of the time we use the lit.site.cfg with values
that match the current build configuration, generated by CMake.

Nothing prevents you from running the test suite with a different
configuration, either by overriding some of these values from the
command line, or by passing a different lit.site.cfg.

The latter is currently tedious. Many configuration values are optional
but they still need to be set because lit.cfg.py is accessing them
directly. This patch changes the code to use getattr to return the
attribute if it exists. This makes it possible to specify a minimal
lit.site.cfg with only the mandatory/desired configuration values.

Differential revision: https://reviews.llvm.org/D86821
2020-08-28 18:08:22 -07:00
Jonas Devlieghere 141c8475b6 [lldb] Get rid of LLDB_LIB_DIR and LLDB_IMPLIB_DIR in dotest
This patch removes the rather confusing LLDB_LIB_DIR and LLDB_IMPLIB_DIR
environment variables. They are confusing because LLDB_LIB_DIR would
point to the bin subdirectory in the build root while LLDB_IMPLIB_DIR
would point to the lib subdirectory. The reason far this was
LLDB.framework, which gets build under bin.

This patch replaces their uses with configuration.lldb_framework_path
and configuration.lldb_libs_dir respectively.

Differential revision: https://reviews.llvm.org/D86817
2020-08-28 15:45:54 -07:00
Jonas Devlieghere 55e7d91072 [lldb] Dervice dotest.py path from config.lldb_src_root (NFC) 2020-08-28 15:45:54 -07:00
Jordan Rupprecht 031554ed46 Reland "[test] Exit with an error if no tests are run."
This reverts commit a06c28df3e (reland adb5c23f8c).

The issue with PExpect tests on Windows should be fixed with e5e05ecf65.
2020-08-28 14:27:37 -07:00
Jordan Rupprecht 8bd895cac0 [lldb/test] Use shorter test case names in TestStandardUnwind
TestStandardUnwind uses the full absolute path to a set of C/C++ files as the test case name, which in turn is used in the name of a log file. When the source file is long, and the directory where log files are stored is also long, this causes an OSError because the log filename is too long.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D86752
2020-08-28 11:49:50 -07:00
Jonas Devlieghere cdc18163cd [lldb] Fix typo in disassemble_options_line description 2020-08-28 11:41:59 -07:00
Jordan Rupprecht e5e05ecf65 [lldb/test] Use @skipIfWindows for PExpectTest
Annotating `PExpectTest` with `@skipIfWindows` instead of marking it as an empty class will make the test runner recognize it as a test class, which should allow me to reland adb5c23f8c.

I don't have a windows machine to verify this works, but I did some tests using `@skipIfLinux` and they all worked as expected. In case the `pexpect` import is not at all available on windows, I moved it to within the method where it's used.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86745
2020-08-28 11:41:07 -07:00
Pavel Labath 9b50546b0b [lldb/Utility] Polish the Scalar class
This patch is mostly about removing the "Category" enum, which was
very useful when the Type enum contained a large number of types, but
now the two are completely identical.

It also removes some other artifacts like unused typedefs and macros.
2020-08-28 11:51:25 +02:00
Pavel Labath 1f9595ede4 [lldb] Reduce intentation in SymbolFileDWARF::ParseVariableDIE
using early exits. NFC.
2020-08-28 11:44:03 +02:00
Harmen Stoppels cdcb9ab10e Revert "Use find_library for ncurses"
The introduction of find_library for ncurses caused more issues than it solved problems. The current open issue is it makes the static build of LLVM fail. It is better to revert for now, and get back to it later.

Revert "[CMake] Fix an issue where get_system_libname creates an empty regex capture on windows"
This reverts commit 1ed1e16ab8.

Revert "Fix msan build"
This reverts commit 34fe9613dd.

Revert "[CMake] Always mark terminfo as unavailable on Windows"
This reverts commit 76bf26236f.

Revert "[CMake] Fix OCaml build failure because of absolute path in system libs"
This reverts commit 8e4acb82f7.

Revert "[CMake] Don't look for terminfo libs when LLVM_ENABLE_TERMINFO=OFF"
This reverts commit 495f91fd33.

Revert "Use find_library for ncurses"
This reverts commit a52173a3e5.

Differential revision: https://reviews.llvm.org/D86521
2020-08-27 17:57:26 -07:00
Jonas Devlieghere 7f717b6d1f [lldb] Fix "no matching std::pair constructor" on Ubuntu 16.04 (NFC)
Fixes error: no matching constructor for initialization of
'std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >'
with older toolchain (clang/libcxx) on Ubuntu 16.04. The issue is the
StringRef-to-std::string conversion.
2020-08-27 17:23:44 -07:00
Jonas Devlieghere a7e4a17735 [lldb] Make lldb-argdumper a dependency of liblldb
Always make lldb-argdumper a dependency of liblldb. Currently it is only
a dependency of the python swig target because of the relative symlink
in the python resource directory. That means that the dependency won't
be there when LLDB_ENABLE_PYTHON is disabled.

Differential revision: https://reviews.llvm.org/D86722
2020-08-27 09:31:02 -07:00
Jonas Devlieghere b981924bdd [lldb] Move triple construction out of getArchCFlags in DarwinBuilder (NFC)
Move the construction of the triple out of getArchCFlags in the
DarwinBuilder.
2020-08-27 09:31:01 -07:00
Pavel Labath dd635062d8 [lldb/cmake] Fix linking of lldbSymbolHelpers for 9cb222e7
I didn't find this locally because I have a /usr/include/gtest which is
similar enough to the bundled one to make things appear to work.
2020-08-27 16:40:17 +02:00
Pavel Labath 5b2b754565 [lldb/cmake] Fix linking of lldbUtilityHelpers for 9cb222e74 2020-08-27 16:06:59 +02:00
Pavel Labath 0de1463373 [lldb] Fix Type::GetByteSize for pointer types
The function was returning an incorrect (empty) value on the first
invocation. Given that this only affected the first invocation, this
bug/typo went mostly unaffected. DW_AT_const_value were particularly
badly affected by this as the GetByteSize call is
SymbolFileDWARF::ParseVariableDIE is likely to be the first call of this
function, and its effects cannot be undone by retrying.

Depends on D86348.

Differential Revision: https://reviews.llvm.org/D86436
2020-08-27 15:37:49 +02:00
Pavel Labath 9cb222e749 [cmake] Make gtest include directories a part of the library interface
This applies the same fix that D84748 did for macro definitions.
Appropriate include path is now automatically set for all libraries
which link against gtest targets, which avoids the need to set
include_directories in various parts of the project.

Differential Revision: https://reviews.llvm.org/D86616
2020-08-27 15:35:57 +02:00
Pavel Labath 9f5927e42b [lldb/DWARF] Fix handling of variables with both location and const_value attributes
Class-level static constexpr variables can have both DW_AT_const_value
(in the "declaration") and a DW_AT_location (in the "definition")
attributes. Our code was trying to handle this, but it was brittle and
hard to follow (and broken) because it was processing the attributes in
the order in which they were found.

Refactor the code to make the intent clearer -- DW_AT_location trumps
DW_AT_const_value, and fix the bug which meant that we were not
displaying these variables properly (the culprit was the delayed parsing
of the const_value attribute due to a need to fetch the variable type.

Differential Revision: https://reviews.llvm.org/D86615
2020-08-27 15:05:47 +02:00
Pavel Labath 219ccdfdde [lldb/Utility] Use APSInt in the Scalar class
This enables us to further simplify some code because it no longer needs
to switch on the signedness of the type (APSInt handles that).
2020-08-27 15:05:47 +02:00
David Spickett c1e6f1a7b1 [lldb] Fix gcc 5.4.0 compile error
Specify type when constructing PromotionKeys,
this fixes error:
"chosen constructor is explicit in copy-initialization"
when compiling lldb with GCC 5.4.0.

This is due to std::tuple having an explicit
default constructor, see:
http://cplusplus.github.io/LWG/lwg-defects.html#2193

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86690
2020-08-27 10:23:05 +01:00
Greg Clayton c55db4600b Load correct module for linux and android when duplicates exist in minidump.
Breakpad creates minidump files that can a module loaded multiple times. We found that when a process mmap's the object file for a library, this can confuse breakpad into creating multiple modules in the module list. This patch fixes the GetFilteredModules() to check the linux maps for permissions and use the one that has execute permissions. Typically when people mmap a file into memory they don't map it as executable. This helps people to correctly load minidump files for post mortem analysis.

Differential Revision: https://reviews.llvm.org/D86375
2020-08-26 15:48:34 -07:00
Raphael Isemann 4a15f51a4f [lldb][NFC] Simplify string literal in GDBRemoteCommunicationClient 2020-08-26 16:25:11 +02:00
Benjamin Kramer 642cb7865f Copy m_plan_is_for_signal_trap member.
Otherwise it would stay uninitialized. Found by msan.
2020-08-26 13:27:01 +02:00
Pavel Labath 82982304d7 [lldb/DWARF] More DW_AT_const_value fixes
This fixes several issues in handling of DW_AT_const_value attributes:
- the first is that the size of the data given by data forms does not
  need to match the size of the underlying variable. We already had the
  case to handle this for DW_FORM_(us)data -- this extends the handling
  to other data forms. The main reason this was not picked up is because
  clang uses leb forms in these cases while gcc prefers the fixed-size
  ones.
- The handling of DW_AT_strp form was completely broken -- we would end
  up using the pointer value as the result. I've reorganized this code
  so that it handles all string forms uniformly.
- In case of a completely bogus form we would crash due to
  strlen(nullptr).

Depends on D86311.

Differential Revision: https://reviews.llvm.org/D86348
2020-08-26 13:17:26 +02:00
David Spickett 9ad5d37fd9 [lldb] Correct wording of EXP_MSG
EXP_MSG generates a message to show on assert
failure. Currently it looks like:
AssertionError: False is not True : '<cmd>'
returns expected result, got '<actual output>'

Which seems to say that the test failed but
also got the expected result.

It should say:
AssertionError: False is not True : '<cmd>'
returned unexpected result, got '<actual output>'

Reviewed By: teemperor, #lldb

Differential Revision: https://reviews.llvm.org/D86603
2020-08-26 11:52:30 +01:00
Raphael Isemann 7518006d75 [lldb] XFAIL TestMemoryHistory on Linux
This test appears to have never worked on Linux but it seems none of the current
bots ever ran this test as it required enabling compiler-rt (otherwise it
would have just been skipped).

This just copies over the XFAIL decorator that are already on all other sanitizer
tests.
2020-08-26 10:24:13 +02:00
Jason Molenda b1e856d3a9 Ah, one test too many updated. This one should be unmodified. 2020-08-25 21:03:39 -07:00
Jason Molenda 99d187a003 Update UnwindPlan dump to list if it is a trap handler func; also Command
Update the "image show-unwind" command output to show if the function
being shown is listed as a user-setting or platform trap handler.

Update the individual UnwindPlan dumps to show whether the unwind plan
is registered as a trap handler.
2020-08-25 20:53:59 -07:00
Dave Lee 66c4880291 Remove unused/misnamed SetObjectModificationTime
Remove `SetObjectModificationTime` which is not currently used, and assigns to the wrong member.

Differential Revision: https://reviews.llvm.org/D86493
2020-08-25 14:49:34 -07:00
Jonas Devlieghere 521220690a [lldb] Make Reproducer compatbile with SubsystemRAII (NFC)
Make Reproducer compatbile with SubsystemRAII and use it in
LocateSymbolFileTest.
2020-08-25 13:00:04 -07:00
Raphael Isemann ef76686916 [lldb] Initialize reproducers in LocateSymbolFileTest
Since a842950b62 this test started using
the reproducer subsystem but we never initialized it in the test. The
Subsystem takes an argument, so we can't use the usual SubsystemRAII at the
moment to do this for us.

This just adds the initialize/terminate calls to get the test passing again.
2020-08-25 20:26:43 +02:00
Raphael Isemann 7de7fe5d0e [lldb] Don't ask for QOS_CLASS_UNSPECIFIED queue in TestQueues
TestQueues is curiously failing for me as my queue for QOS_CLASS_UNSPECIFIED
is named "Utility" and not "User Initiated" or "Default". While debugging, this
I noticed that this test isn't actually using this API right from what I understand. The API documentation
for `dispatch_get_global_queue` specifies for the parameter: "You may specify the value
QOS_CLASS_USER_INTERACTIVE, QOS_CLASS_USER_INITIATED, QOS_CLASS_UTILITY, or QOS_CLASS_BACKGROUND."

QOS_CLASS_UNSPECIFIED isn't listed as one of the supported values. swift-corelibs-libdispatch
even checks for this value and returns a DISPATCH_BAD_INPUT. The
libdispatch shipped on macOS seems to also check for QOS_CLASS_UNSPECIFIED and seems to
instead cause a "client crash", but somehow this doesn't trigger in this test and instead we just
get whatever queue

This patch just removes that part of the test as it appears the code is just incorrect.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D86211
2020-08-25 20:13:33 +02:00
Raphael Isemann 2501e911a5 [lldb] Don't depend on psutil in TestCompletion.py
psutil isn't reall a dependency of the test suite so this shouldn't be
unconditionally be imported here. Instead just check for the process name
by looking for the "a.out" string to get the bots green again.
2020-08-25 08:30:33 +02:00
Muhammad Omair Javaid 4283320b72 [LLDB] Fix SVE offset calculation in NativeRegisterContextLinux_arm64
There was typo left from changes in CalculateSVEOffset where we moved
FPSR/FPCR offset calculation into WriteRegister and ReadRegister.

Differential Revision: https://reviews.llvm.org/D79699
2020-08-25 03:54:41 +05:00
shafik 93b255142b [LLDB] Fix how ValueObjectVariable handles DW_AT_const_value when the DWARFExpression holds the data that represents a constant value
In some cases when we have a DW_AT_const_value and the data can be found in the
DWARFExpression then ValueObjectVariable does not handle it properly and we end
up with an extracting data from value failed error.

The test is a very stripped down assembly file since reproducing this relies on the results of compiling with -O1 which may not be stable over time.

Differential Revision: https://reviews.llvm.org/D86311
2020-08-24 15:17:27 -07:00
Jonas Devlieghere a842950b62 [lldb] Add a SymbolFileProvider to record and replay calls to dsymForUUID
When replaying a reproducer captured from a core file, we always use
dsymForUUID for the kernel binary. When enabled, we also use it to find
kexts. Since these files are already contained in the reproducer,
there's no reason to call out to an external tool. If the tool returns a
different result, e.g. because the dSYM got garbage collected, it will
break reproducer replay. The SymbolFileProvider solves the issue by
mapping UUIDs to module and symbol paths in the reproducer.

Differential revision: https://reviews.llvm.org/D86389
2020-08-24 15:09:08 -07:00
Greg Clayton 0e6c9a6e79 Add hashing of the .text section to ProcessMinidump.
Breakpad will always have a UUID for binaries when it creates minidump files. If an ELF files has a GNU build ID, it will use that. If it doesn't, it will create one by hashing up to the first 4096 bytes of the .text section. LLDB was not able to load these binaries even when we had the right binary because the UUID didn't match. LLDB will use the GNU build ID first as the main UUID for a binary and fallback onto a 8 byte CRC if a binary doesn't have one. With this fix, we will check for the Breakpad hash or the Facebook hash (a modified version of the breakpad hash that collides a bit less) and accept binaries when these hashes match.

Differential Revision: https://reviews.llvm.org/D86261
2020-08-24 11:43:50 -07:00
Gongyu Deng 188f1ac301 [lldb] type category name common completion
1. Added a new common completion TypeCategoryNames to provide a list of category names for completion;
2. Applied the completion to these commands: type category delete/enable/disable/list/define;
3. Added a related test case;
4. Bound the completion to the arguments of the type 'eArgTypeName'.

Reviewed By: teemperor, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84124
2020-08-24 19:54:23 +02:00
Gongyu Deng 3cd8d7b172 [lldb] Remote disk file/directory completion for platform commands
1. Extended the gdb-remote communication related classes with disk file/directory
   completion functions;
2. Added two common completion functions RemoteDiskFiles and
   RemoteDiskDirectories based on the functions above;
3. Added completion for these commands:
   A. platform get-file <remote-file> <local-file>;
   B. platform put-file <local-file> <remote-file>;
   C. platform get-size <remote-file>;
   D. platform settings -w <remote-dir>;
   E. platform open file <remote-file>.
4. Added related tests for client and server;
5. Updated docs/lldb-platform-packets.txt.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85284
2020-08-24 17:55:54 +02:00
Gongyu Deng 19311f5c3e [lldb] common completion for process pids and process names
1. Added two common completions: `ProcessIDs` and `ProcessNames`, which are
refactored from their original dedicated option completions;
2. Removed the dedicated option completion functions of `process attach` and
`platform process attach`, so that they can use arg-type-bound common
completions instead;
3. Bound `eArgTypePid` to the pid completion, `eArgTypeProcessName` to the
process name completion in `CommandObject.cpp`;
4. Added a related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D80700
2020-08-24 17:30:43 +02:00
Pavel Labath 0e301fd023 [lldb/Utility] Remove some Scalar type accessors
Now that the number of Scalar "types" has been reduced, these don't make
sense anymore.
2020-08-24 11:45:30 +02:00
António Afonso 52381938bc Create ${swig_target}-scripts target instead of lldb-python-scripts
This addresses the issue raised here https://reviews.llvm.org/rG02bf5632a94da6c3570df002804f8d3f79c11bfc
The `finish_swig_python` function might be called more than once so we need to create the distribution
component target based on the swig target.

Differential Revision: https://reviews.llvm.org/D86402
2020-08-22 19:36:37 -07:00
António Afonso 5d8eedee91 Move Py_buffer_RAII to .h file so SWIG 2 doesnt have to parse it
`struct Py_buffer_RAII` definition uses explicit deleted functions which are not supported by SWIG 2 (only 3).
To get around this I moved this struct to an .h file that is included to avoid being parsed by swig.

Reviewed By: lawrence_danna

Differential Revision: https://reviews.llvm.org/D86381
2020-08-22 10:43:50 -07:00
Jonas Devlieghere bb894b9782 [lldb] Extract reproducer providers & co into their own header.
Extract all the provider related logic from Reproducer.h and move it
into its own header ReproducerProvider.h. These classes are seeing most
of the development these days and this reorganization reduces
incremental compilation from ~520 to ~110 files when making changes to
the new header.
2020-08-22 10:04:27 -07:00
Dimitry Andric 1ce07cd614 Instantiate Error in Target::GetEntryPointAddress() only when necessary
When `Target::GetEntryPointAddress()` calls `exe_module->GetObjectFile()->GetEntryPointAddress()`, and the returned
`entry_addr` is valid, it can immediately be returned.

However, just before that, an `llvm::Error` value has been setup, but in this case it is not consumed before returning, like is done further below in the function.

In https://bugs.freebsd.org/248745 we got a bug report for this, where a very simple test case aborts and dumps core:

```
* thread #1, name = 'testcase', stop reason = breakpoint 1.1
    frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5
   1	int main(int argc, char *argv[])
   2	{
-> 3	    return 0;
   4	}
(lldb) p argc
Program aborted due to an unhandled Error:
Error value was Success. (Note: Success values must still be checked prior to being destroyed).

Thread 1 received signal SIGABRT, Aborted.
thr_kill () at thr_kill.S:3
3	thr_kill.S: No such file or directory.
(gdb) bt
#0  thr_kill () at thr_kill.S:3
#1  0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52
#2  0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
#3  0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112
#4  0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267
#5  0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67
#6  0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114
#7  0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97
#8  0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604
#9  0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347
#10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383
#11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301
#12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331
#13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190
#14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372
#15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414
#16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646
#17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003
#18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762
#19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760
#20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548
#21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903
#22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946
#23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169
#24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675
#25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890```

Fix the incorrect error catch by only instantiating an `Error` object if it is necessary.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D86355
2020-08-22 12:47:13 +02:00
Jonas Devlieghere 86fc193309 [lldb] Don't pass --rerun-all-issues on Windows.
The functionality has been removed for a while and now the dotest
argument has been removed asll.
2020-08-21 19:58:24 -07:00
António Afonso 02bf5632a9 Fix swig scripts install target name
LLVM install component targets needs to be in the form of: install-{target}[-stripped]

I tested with:
```
cmake ... -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_DISTRIBUTION_COMPONENTS="lldb;liblldb;lldb-python-scripts;" ...
DESTDIR=... ninja install-distribution
```

@JDevlieghere `finish_swig_python_scripts` is a really weird name for a distribution component, any reason that it has to be this way?

Differential Revision: https://reviews.llvm.org/D86235
2020-08-21 14:41:52 -07:00
Jonas Devlieghere d3a49b03a5 [lldb] Remove --rerun-all-issues as its functionality no longer exists
The logic behind --rerun-all-issues was removed when we switched to LIT
as the test driver. This patch just removes the dotest option and
corresponding entry in configuration.py.
2020-08-21 14:28:08 -07:00
Jonas Devlieghere 52e758f352 [lldb] Fix build error in TestSimulatorPlatform.py
Before e5d08fcbac the Makefile would always compute the min-version,
even if it wasn't set in the triple. This nuance got lost when passing
the ARCH_CFLAGS directly from TestSimulatorPlatform.
2020-08-21 13:35:26 -07:00
Jonas Devlieghere 57e0ef131b [lldb] Make it a fatal error when %lldb cannot be substituted
Refuse to run the shell tests when %lldb cannot be substituted. This
prevents the test from silently running again the `lldb` in your PATH.

I noticed because when this happens, %lldb-init gets substituted with
lldb-init, which does not exists.
2020-08-21 11:18:21 -07:00
Jonas Devlieghere 08249d7f72 [lldb] Fix TestAPILog.py for reproducer replay
With the log file being a build artifact we don't need to clean it up.
If this happens before the reproducer is captured, the file will be
missing from the reproducer root but being part of the mapping.
2020-08-21 10:35:35 -07:00
Jonas Devlieghere 2799031a14 [lldb] Skip PDB and NativePDB tests with reproducers 2020-08-21 09:09:45 -07:00
Gongyu Deng e1cd7cac8a [lldb] Tab completion for process load/unload
1. Complete `process load` with the common disk file completion, so there is not test provided for it;
2. Complete `process unload` with the tokens of valid loaded images.

Thanks for Raphael's help on the test for `process unload`.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D79887
2020-08-21 10:36:39 +02:00
Jonas Devlieghere 6ad3de350c [lldb] Fix a new -Wdocumetnation issues (NFC) 2020-08-20 22:59:13 -07:00
Jonas Devlieghere e0b220d22e [lldb] Remove redundant call to FindBacktrace (NFC)
We're not using any of the Backtrace_* CMake variables set by
FindBacktrace in LLDB.
2020-08-20 22:41:49 -07:00
Jonas Devlieghere c1bc4fb95e [lldb] Simplify CMake logic with LLVM's append_if function
Use the append_if CMake function from HandleLLVMOptions. Since we
include this file in LLDBStandalone it should work in both for in-tree
and out-of-tree builds.
2020-08-20 22:35:31 -07:00
Xing GUO 290e399f96 [DWARFYAML] Add support for emitting multiple abbrev tables.
This patch adds support for emitting multiple abbrev tables. Currently,
compilation units will always reference the first abbrev table.

Reviewed By: jhenderson, labath

Differential Revision: https://reviews.llvm.org/D86194
2020-08-21 10:12:08 +08:00
Jonas Devlieghere 73af341beb [lldb] Capture and load home directory from the reproducer.
When replaying the reproducer, lldb should source the .lldbinit file
that was captured by the reproducer and not the one in the current home
directory. This requires that we store the home directory as part of the
reproducer. By returning the virtual home directory during replay, we
ensure the correct virtual path gets constructed which the VFS can then
find and remap to the correct file in the reproducer root.

This patch adds a new HomeDirectoryProvider, similar to the existing
WorkingDirectoryProvider. As the home directory is not part of the VFS,
it is stored in LLDB's FileSystem instance.
2020-08-20 18:08:59 -07:00
Jonas Devlieghere c90ca0c8e4 [lldb] Implement WorkingDirectoryProvider in terms of DirectoryProvider (NFC)
Add an abstract base class that can be used to create other directory
providers.
2020-08-20 18:08:59 -07:00
Eric Leese 4e266eaf13 Make DWARFExpression::GetLocationExpression public
This method is used to get the DataExtractor when the expression is a location list.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86090
2020-08-20 15:12:28 -07:00
Jonas Devlieghere ed17b6f630 [lldb] Extract FileSystem initialization code into helper (NFC)
The FileSystem initialization depends on the reproducer mode. It has
been growing organically to the point where it deserves its own helper
function. This also allows for early returns to simplify the code.
2020-08-20 15:10:38 -07:00
Fangrui Song b587ca93be [test] Replace `yaml2obj >` with `yaml2obj -o` and remove unneeded input redirection 2020-08-20 15:01:09 -07:00
Jonas Devlieghere 921c1b7df3 [lldb] Provide GetHomeDirectory wrapper in Host::FileSystem (NFC)
Provider a wrapper around llvm::sys::path::home_directory in the
FileSystem class. This will make it possible for the reproducers to
intercept the call in a central place.
2020-08-20 14:07:05 -07:00
Gongyu Deng 22e63cba17 [lldb] tab completion for breakpoint names
1. created a common completion for breakpoint names;
2. bound the breakpoint name common completion with eArgTypeBreakpointName;
3. implemented the dedicated completion for breakpoint read -N.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D80693
2020-08-20 20:56:34 +02:00
Jordan Rupprecht 0de3d0c612 [lldb][asan] Mark destructor as virtual to allow subclasses.
`lldb_private::ScriptInterpreterPython::CommandDataPython` inherits from `lldb_private::BreakpointOptions::CommandData`, but the latter does not have a virtual destructor. This leads to a new-delete-type-mismatch error when running certain tests (such as `functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py`) under asan.
2020-08-20 09:21:33 -07:00
Pavel Labath 8a8a2dd316 [lldb/Utility] Simplify Scalar handling of float types
Similarly to D85836, collapse all Scalar float types to a single enum
value, and use APFloat semantics to differentiate between. This
simplifies the code, and opens to door to supporting other floating
point semantics (which would be needed for fully supporting
architectures with more interesting float types such as PPC).

Differential Revision: https://reviews.llvm.org/D86220
2020-08-20 16:26:02 +02:00
Pavel Labath 9109311356 [lldb] Forcefully complete a type when adding typedefs
This is very similar to D85968, only more elusive to since we were not
adding the typedef type to the relevant DeclContext until D86140, which
meant that the DeclContext was populated (and the relevant assertion
hit) only after importing the type into the expression ast in a
particular way.

I haven't checked whether this situation can be hit in the gmodules
case, but my money is on "yes".

Differential Revision: https://reviews.llvm.org/D86216
2020-08-20 15:19:10 +02:00
Jonas Devlieghere a6eb70c052 [lldb] Return empty string from getExtraMakeArgs when not implemented
No return statement means the method returns None which breaks a list
comprehension down the line that expects a str instance.
2020-08-19 17:52:50 -07:00
Jonas Devlieghere 09ca3f41bb [lldb] Update TestSimulatorPlatform.py to set ARCH_CFLAGS instead of TRIPLE
I move the triple (de)composition logic into the builder in e5d08fcbac
but this test is relying on Make to construct the set the ARCH,
ARCH_CFLAGS and SDKROOT based on the given TRIPLE. This patch updates
the test to pass these variables directly.

Differential revision: https://reviews.llvm.org/D86244
2020-08-19 15:42:44 -07:00
Med Ismail Bennani 868b45b5b3 [lldb/interpreter] Add REPL-specific init file
This patch adds the infrastructure to have language specific REPL init
files. It's the foundation work to a following patch that will introduce
Swift REPL init file.

When lldb is launched with the `--repl` option, it will look for a REPL
init file in the home directory and source it. This overrides the
default `~/.lldbinit`, which content might make the REPL behave
unexpectedly. If the REPL init file doesn't exists, lldb will fall back
to the default init file.

rdar://65836048

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-08-20 00:36:32 +02:00
Jonas Devlieghere a3fc61c80f [lldb] Move Xcode SDK helper functions into lldbutil
This allows the logic to be reused by both the builders and the tests.
2020-08-19 13:30:27 -07:00
Jonas Devlieghere 9f5210aacf [lldb] Print the load command that wasn't found in TestSimulatorPlatform
Print which load command we were looking for when the sanity check
fails:

  AssertionError: 0 != 1 : wrong number of load commands for
  LC_VERSION_MIN_MACOSX
2020-08-19 12:42:59 -07:00
Jonas Devlieghere b40a3814b6 [lldb] Code sign binaries with entitlements
Binaries need to be code signed with entitlements to run on device.

Differential revision: https://reviews.llvm.org/D86237
2020-08-19 11:55:36 -07:00
Jonas Devlieghere e5d08fcbac [lldb] Extend Darwin builder to pass the ARCH_CFLAGS spec to Make.
Construct the ARCH_CFLAGS in Python rather than in Make by disassembling
the TRIPLE.

Differential revision: https://reviews.llvm.org/D85539
2020-08-19 11:47:29 -07:00
Jonas Devlieghere 074c591a7e [lldb] Add getExtraMakeArgs to Builder (NFC)
Instead of a new method for each variable any subclass might want to
set, have a method getExtraMakeArgs that each subclass can use to return
whatever extra Make arguments it wants.

As per Pavel's suggestion in D85539.
2020-08-19 09:47:25 -07:00
Jonas Devlieghere 804691adc9 [lldb] Fix buildDsym signature in Builder base class
The method was missing the optional argument `testname`.
2020-08-19 09:47:25 -07:00
Jonas Devlieghere b623f3c0b4 [lldb] Move builders under lldbsuite.test as they import lldbtest (NFC) 2020-08-19 09:07:51 -07:00
Jonas Devlieghere 1922bf12e1 [lldb] Convert builders to use inheritance (NFC)
Rather than have different modules for different platforms, use
inheritance so we can have a Builer base class and optional child
classes that override platform specific methods.

Differential revision: https://reviews.llvm.org/D86174
2020-08-19 08:44:29 -07:00
Pavel Labath 9cc2f13dee [lldb] Clean up DW_AT_declaration-with-children.s test
Address some post-commit feedback on D85968.
2020-08-19 14:58:50 +02:00
Pavel Labath d7363397c6 [lldb] Add typedefs to the DeclContext they are created in
TypeSystemClang::CreateTypedef was creating a typedef in the right
DeclContext, but it was not actually adding it as a child of the
context. The resulting inconsistent state meant that we would be unable
to reference the typedef from an expression directly, but we could use
them if they end up being pulled in by some previous subexpression
(because the ASTImporter will set up the correct links in the expression
ast).

This patch adds the typedef to the decl context it is created in.

Differential Revision: https://reviews.llvm.org/D86140
2020-08-19 14:57:43 +02:00
Raphael Isemann c1b1868f35 [lldb] Make error messages in TestQueues more helpfull 2020-08-19 13:30:31 +02:00
Muhammad Omair Javaid bd791e97f8 [LLDB] Minor fix in TestSVERegisters.py for AArch64/Linux buildbot
This adds a minor test case fix to previously submitted AArch64 SVE
ptrace support. This was failing on LLDB/AArch64 Linux buildbot.

Differential Revision: https://reviews.llvm.org/D79699
2020-08-19 15:47:59 +05:00
Muhammad Omair Javaid 567ba6c468 [LLDB] Add ptrace register access for AArch64 SVE registers
This patch adds NativeRegisterContext_arm64 ptrace routines to access
AArch64 SVE register set. This patch also adds a test-case to test
AArch64 SVE register access and dynamic size configuration capability.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D79699
2020-08-19 15:11:01 +05:00
Muhammad Omair Javaid af4f40c376 [LLDB] NativeThreadLinux invalidate register cache on stop
In our discussion D79699 SVE ptrace register access support we decide to
invalidate register context cached data on every stop instead of doing
at before Step/Resume.

InvalidateAllRegisters was added to facilitate flushing of SVE register
context configuration and cached register values. It now makes more
sense to move invalidation after every stop where we initiate SVE
configuration update if needed by calling ConfigureRegisterContext.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D84501
2020-08-19 12:30:38 +05:00
Muhammad Omair Javaid 090306fc80 Convert SVE macros into c++ constants and inlines
This patch updates LLDB's in house version of SVE ptrace/sig macros by
converting them into constants and inlines. They are housed under sve
namespace and are used by process elf-core for reading SVE register data.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85641
2020-08-19 12:28:16 +05:00
Jonas Devlieghere 514bcb325d [lldb] Remove unused function getArchFlag (NFC) 2020-08-18 15:20:57 -07:00
Greg Clayton 08748d15b8 Fix a check that was attempting to see if an object file was in memory.
Checking if an object file is in memory should use the ObjectFile::IsInMemory(), not test ObjectFile::BaseAddress(). ObjectFile::BaseAddress() is designed to be overridden by all classes and is for mach-o, ELF and COFF plug-ins. They find the header base adddress and return that as a section offset address. The default implementation of ObjectFile::BaseAddress() does try and make an Address() from the ObjectFile::m_memory_addr, but I switched it to a correct function call.

Differential Revision: https://reviews.llvm.org/D86122
2020-08-18 13:24:22 -07:00
David Blaikie f7a49d2aa6 [WIP][DebugInfo] Lazily parse debug_loclist offsets
Parsing DWARFv5 debug_loclist offsets when a CU is parsed is weighing
down memory usage of symbolizers that don't need to parse this data at
all. There's not much benefit to caching these anyway - since they are
O(1) lookup and reading once you know where the offset list starts (and
can do bounds checking with the offset list size too).

In general, I think it might be time to start paying down some of the
technical debt of loc/loclist/range/rnglist parsing to try to unify it a
bit more.

eg:

* Currently DWARFUnit has: RangeSection, RangeSectionBase, LocSection,
  LocSectionBase, LocTable, RngListTable, LoclistTableHeader (be nice if
  these were all wrapped up in two variables - one for loclists, one for
  rnglists)

* rnglists and loclists are handled differently (see:
  LoclistTableHeader, but no RnglistTableHeader)

* maybe all these types could be less stateful - lazily parse what they
  need to, even reparsing rather than caching because it doesn't seem
  too expensive, for instance. (though admittedly so long as it's
  constantcost/overead per compilatiton that's probably adequate)

* Maybe implementing and using a DWARFDataExtractor that can be
  sub-ranged (so we could slice it up to just the single contribution) -
  though maybe that's not so useful because loc/ranges need to refer to
  it by absolute, not contribution-relative mechanisms

Differential Revision: https://reviews.llvm.org/D86110
2020-08-18 10:49:39 -07:00
Jan Kratochvil 7baed769c7 [lldb] [testsuite] Add split-file for check-lldb dependencies
D85968 started to use `split-file` and while buildbots run fine while
doing `make check-lldb` by hand I get:

.../llvm-monorepo-clangassert/tools/lldb/test/SymbolFile/DWARF/Output/DW_AT_declaration-with-children.s.script: line 2: split-file: command not found
failed:
  lldb-shell :: SymbolFile/DWARF/DW_AT_declaration-with-children.s

Differential Revision: https://reviews.llvm.org/D86144
2020-08-18 18:10:55 +02:00
Luboš Luňák dcd4589a0d [lldb][gui] use left/right in the source view to scroll
I intentionally decided not to reset the column automatically
anywhere, because I don't know where and if at all that should happen.
There should be always an indication of being scrolled (too much)
to the right, so I'll leave this to whoever has an opinion.

Differential Revision: https://reviews.llvm.org/D85290
2020-08-18 13:25:01 +02:00
Harmen Stoppels a52173a3e5 Use find_library for ncurses
Currently it is hard to avoid having LLVM link to the system install of
ncurses, since it uses check_library_exists to find e.g. libtinfo and
not find_library or find_package.

With this change the ncurses lib is found with find_library, which also
considers CMAKE_PREFIX_PATH. This solves an issue for the spack package
manager, where we want to use the zlib installed by spack, and spack
provides the CMAKE_PREFIX_PATH for it.

This is a similar change as https://reviews.llvm.org/D79219, which just
landed in master.

Differential revision: https://reviews.llvm.org/D85820
2020-08-17 19:52:52 -07:00
Adrian Prantl a1a3b86910 Convert to early exit (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl fc1464c6df Simplify error reporting (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl a615ec9a1b Convert if cascade to switch (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl 8bb81c29b9 Convert to early exit (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl 1d5e9d37c3 Convert to early exit (NFC) 2020-08-17 14:42:24 -07:00
Jonas Devlieghere 9c5e25a696 [lldb] Skip test_launch_simple with reproducers
The test checks the inferior's output. During replay the binary doesn't
actually run and the output isn't captured by the reproducers.
2020-08-17 11:47:07 -07:00
Jonas Devlieghere 5a7b61b183 [lldb] Skip TestMultipleDebuggers on Windows 2020-08-17 11:34:25 -07:00
Jonas Devlieghere 24d3210e62 [lldb] Skip the Apple Simulator tests with reproducers 2020-08-17 11:29:37 -07:00
Jonas Devlieghere 6dabd267bd [lldb] Skip TestError.test with reproducers
This tests the driver, which is bypassed by the reproducer during
replay.
2020-08-17 10:42:58 -07:00
Jonas Devlieghere e095e98a3a [lldb] Add missing LLDB_REGISTER for GarbageCollectAllocatedModules
Add the missing LLDB_REGISTER_STATIC_METHOD macro and format the file.
2020-08-17 10:14:41 -07:00
Jonas Devlieghere e9b0994012 [lldb] Replace unittest2.expectedFailure with expectedFailure (NFC)
Rename the existing expectedFailure to expectedFailureIfFn to better
describe its purpose and provide an overload for
unittest2.expectedFailure in decorators.py.
2020-08-17 10:05:49 -07:00
Raphael Isemann c6cc566c8a [lldb] Use os.path.sep in TestInvalidArgsLog.py to fix Windows bot 2020-08-17 19:03:27 +02:00
Jonas Devlieghere 8b67b707b0 [lldb] Add missing signal include for TestMultipleDebuggers.py
Fixes multi-process-driver.cpp:221:19: error: use of undeclared
identifier 'SIG_IGN'
2020-08-17 09:41:45 -07:00
Jonas Devlieghere 6cc0b00f4d [lldb] Only link against Python 3 when LLDB_ENABLE_PYTHON is set.
Only link against Python3_LIBRARY when LLDB_ENABLE_PYTHON is true. We
have to be more strict now becuase Python3_LIBRARY might be set to
NOTFOUND instead of being not set at all.
2020-08-17 09:31:52 -07:00
Jonas Devlieghere a0a328ed4f [lldb] Fix and re-enable TestMultipleDebuggers
The comment says that TestMultipleDebuggers was XFAILed because it was
failing nondeterministically in which case it should be skipped not
failed (as XPASS will cause the test suite to fail).

The reason it fails is because it was not marked as a no-debug-info test
case. I've ran the test in a loop and it has been passing consistently.
Let's enable it and see if the bots agree, if not we can skip it.
2020-08-17 09:20:20 -07:00
Walter Erquinigo 99614d410c [lldb-vscode] NFC: clang format
Run clang-format on all the c++ file of this project.
2020-08-17 09:18:01 -07:00
Jonas Devlieghere 75966ee241 [lldb] Get rid of helper CMake variables for Python
This patch is a big sed to rename the following variables:

  s/PYTHON_LIBRARIES/Python3_LIBRARIES/g
  s/PYTHON_INCLUDE_DIRS/Python3_INCLUDE_DIRS/g
  s/PYTHON_EXECUTABLE/Python3_EXECUTABLE/g
  s/PYTHON_RPATH/Python3_RPATH/g

I've also renamed the CMake module to better express its purpose and for
consistency with FindLuaAndSwig.

Differential revision: https://reviews.llvm.org/D85976
2020-08-17 08:47:52 -07:00
Raphael Isemann f5f22f0448 [lldb] Skip TestSimulatorPlatform with sanitized builds
The test executable crashes when ran on a simulator. Skipping until this is
fixed.

rdar://67238668
2020-08-17 15:06:48 +02:00
Raphael Isemann cfb773c676 [lldb][NFC] Use StringRef in CreateFunctionDeclaration/GetDeclarationName
CreateFunctionDeclaration should just take a StringRef. GetDeclarationName is
(only) used by CreateFunctionDeclaration so that's why now also takes a
StringRef.
2020-08-17 14:17:20 +02:00
Raphael Isemann 7e6c437fb4 [lldb][NFC] Remove name parameter from CreateFunctionTemplateDecl
It's unused and not documented.
2020-08-17 13:44:10 +02:00
Raphael Isemann 42b9a68352 [lldb][NFC] Use expect_expr in more tests 2020-08-17 13:14:57 +02:00
Raphael Isemann cd2139a527 [lldb][NFC] Use the proper type for the 'storage' parameter of CreateFunctionDeclaration
All the callers pass an enum and we cast the int anyway back to the actual type,
so we might as well just use the type for the parameter.
2020-08-17 12:53:58 +02:00
Raphael Isemann 6b97fa0bfe [lldb] Remove OS-specific string from TestInvalidArgsLog
This is the error message from the OS, so we shouldn't check against the
OS-specific part of the string.

Fixes the test on Windows which returns a different error message.
2020-08-17 11:57:43 +02:00
Raphael Isemann 24c74f5e8c [lldb] Don't delete orphaned shared modules in SBDebugger::DeleteTarget
In D83876 the consensus seems that LLDB should never deleted orphaned modules
implicitly. However, SBDebugger::DeleteTarget is currently doing exactly that.
This code was added in 753406221b but I don't see
any explanation in the commit, so I think we should delete it.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D83933
2020-08-17 11:30:56 +02:00
Pavel Labath 67cdb899c6 [lldb/Utility] Simplify and generalize Scalar class
The class contains an enum listing all host integer types as well as
some non-host types. This setup is a remnant of a time when this class
was actually implemented in terms of host integer types. Now that we are
using llvm::APInt, they are mostly useless and mean that each function
needs to enumerate all of these cases even though it treats most of them
identically.

I only leave e_sint and e_uint to denote the integer signedness, but I
want to remove that in a follow-up as well.

Removing these cases simplifies most of these functions, with the only
exception being PromoteToMaxType, which can no longer rely on a simple
enum comparison to determine what needs to be promoted.

This also makes the class ready to work with arbitrary integer sizes, so
it does not need to be modified when someone needs to add a larger
integer size.

Differential Revision: https://reviews.llvm.org/D85836
2020-08-17 11:09:56 +02:00
Pavel Labath 2d89a3ba12 [lldb] Forcefully complete a type when adding nested classes
With -flimit-debug-info, we can run into cases when we only have a class
as a declaration, but we do have a definition of a nested class. In this
case, clang will hit an assertion when adding a member to an incomplete
type (but only if it's adding a c++ class, and not C struct).

It turns out we already had code to handle a similar situation arising
in the -gmodules scenario. This extends the code to handle
-flimit-debug-info as well, and reorganizes bits of other code handling
completion of types to move functions doing similar things closer
together.

Differential Revision: https://reviews.llvm.org/D85968
2020-08-17 11:09:13 +02:00
Raphael Isemann c2f9454a16 [lldb] Add SBModule::GarbageCollectAllocatedModules and clear modules after each test run
Right now the only places in the SB API where lldb:: ModuleSP instances are
destroyed are in SBDebugger::MemoryPressureDetected (where it's just attempted
but not guaranteed) and in SBDebugger::DeleteTarget (which will be removed in
D83933). Tests that directly create an lldb::ModuleSP and never create a target
therefore currently leak lldb::Module instances. This triggers the sanity checks
in lldbtest that make sure that the global module list is empty after a test.

This patch adds SBModule::GarbageCollectAllocatedModules as an explicit way to
clean orphaned lldb::ModuleSP instances. Also we now start calling this method
at the end of each test run and move the sanity check behind that call to make
this work. This way even tests that don't create targets can pass the sanity
check.

This fixes TestUnicodeSymbols.py when D83865 is applied (which makes that the
sanity checks actually fail the test).

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83876
2020-08-17 11:00:19 +02:00
Raphael Isemann 867c347c32 [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file
We didn't do anything with the llvm::Error we get from `Open`, so when we end up in the
error case we just crash due to the llvm::Error sanity check. Also add the missing newline
behind the error message so it no longer messes with the next (lldb) prompt.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85970
2020-08-17 10:43:00 +02:00
Raphael Isemann c57ea1b48f [lldb] Get lldb-server platform's --socket-file working again
`lldb-server platform --socket-file /any/path` currently always fails to create
the socket file.  This stopped working after D67424 which changed the
input variables of `writeFileAtomically` slightly. We're expected to
pass in a temporary path template (`/tmp/foo-%%%%%`) and the final
path we want to write. Instead we currently pass in the never set
`temp_file_path` as the temporary path (which will make this function always
fail) and pass in the temp_file_spec's path as the final path (which is actually
the template path such as `/tmp/foo-%%%%%`) instead of the actual path
we want to write (e.g. `/tmp/foo`).

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85890
2020-08-17 10:29:06 +02:00
Raphael Isemann 5913f2591c [lldb][NFC] Remove stride parameter from GetArrayElementType
This parameter isn't used anywhere in LLDB nor the Swift downstream branch. It
also doesn't really fit into the TypeSystem APIs that usually don't return
additional related functionality via some output parameters. Also the
implementations already states that the calculated value there is wrong.

Let's remove it. If we need this functionality at some point then Swift's much
nicer `GetByteStride` function seems like the way to go.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D84299
2020-08-17 10:19:51 +02:00
Raphael Isemann 24fc3177c1 [lldb] Print the exception traceback when hitting cleanup errors
Right now if the test suite encounters a cleanup error it just prints "CLEANUP
ERROR:" but not any additional information.

This patch just prints the exception that caused the cleanup error. This should
make debugging the failing tests for D83865 easier (and seems in general nice to
have).

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D83874
2020-08-17 09:53:52 +02:00
Raphael Isemann 7208cb1ac4 [lldb] Remove XFAIL from now passing TestPtrRefs/TestPtreRefsObjC
8fcfe2862f and
0cceb54366 fixed those tests.
2020-08-15 08:14:44 +02:00
Davide Italiano 0cceb54366 [TestPtrRefsObjC] Prefer `command script import`. 2020-08-14 15:31:02 -07:00
Davide Italiano 8fcfe2862f [TestPtrRefs] Prefer `command script import`. 2020-08-14 15:30:31 -07:00
Jim Ingham b6db0a544d Add python enumerators for SBTypeEnumMemberList, and some tests for this API.
Differential Revision: https://reviews.llvm.org/D85951
2020-08-14 09:57:46 -07:00
Jonas Devlieghere ce439cb1c9 [lldb] Remove Python 2 fallback and only support Python 3
This removes the fallback to Python 2 and makes Python 3 the only
supported configuration. This is the first step to fully migrate to
Python 3 over the coming releases as discussed on the mailing list.

http://lists.llvm.org/pipermail/lldb-dev/2020-August/016388.html

As a reminder, for the current release the test suite and the generated
bindings should remain compatible with Python 2.

Differential revision: https://reviews.llvm.org/D85942
2020-08-14 08:50:11 -07:00
Jonas Devlieghere 37ec83fcfc [lldb] Use file to synchronize TestDeepBundle and TestBundleWithDotInFilename
Currently these two tests use an arbitrary wait of 5 seconds for the
inferior to finish setting up. When the test machine is under heavy load
this sometimes is insufficient leading to spurious test failures. This
patch adds synchronization trough a token on the file system. In
addition to making the test more reliable it also makes it much faster
because we no longer have to wait the full 5 seconds if the setup was
completed faster than that.

Differential revision: https://reviews.llvm.org/D85915
2020-08-14 08:32:21 -07:00
Raphael Isemann 46ed27ff1b [lldb] Make packetlog_get_dylib_info returns the last full response
In sanitized builds the last packet this function finds for the
TestMacCatalyst and TestPlatformSimulator tests is for the asan runtime.

```
 <  69> send packet: $jGetLoadedDynamicLibrariesInfos:{"solib_addresses":[4296048640]}]#3a <
 715> read packet: ${"images":[{"load_address":4296048640,"mod_date":0,"pathname":
 "/Users/buildslave/jenkins/workspace/lldb-cmake-sanitized/host-compiler/lib/clang/12.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib",
 "uuid":"8E38A2CD-753F-3E0F-8EB0-F4BD5788A5CA",
 "min_version_os_name":"macosx","min_version_os_sdk":"10.9",
 "mach_header":{"magic":4277009103,"cputype":16777223,"cpusubtype":3,"filetype":6,
 "flags":43090053}],"segments":[{"name":"__TEXT","vmaddr":0,"vmsize":565248,"fileoff":0,
 "filesize":565248,"maxprot":5}],{"name":"__DATA","vmaddr":565248,"vmsize":13152256,"fileoff":565248,
 "filesize":20480,"maxprot":3}],{"name":"__LINKEDIT","vmaddr":13717504,"vmsize":438272,"fileoff":585728,
 "filesize":435008,"maxprot":1}]]}]]}]#00
```

This just fetches the last package which has fetch_all_solibs and we know
it will contain the image of our test executable to get the tests running again.
2020-08-14 14:51:13 +02:00
Raphael Isemann bb4efab9a4 [lldb] Use SBProcess::Continue instead of 'run' command in TestTargetAPI.py
This test is flaky on Green Dragon as it often fails when the process state
is "Invalid" in the assert:
    self.assertEqual(process.GetState(), lldb.eStateExited)
It seems this is related to just doing "run" which apparently invalidates
the Target's process in case it's still running and needs to be restarted.
Just doing 'continue' on the process (and ignoring the error in case it already
finished) prevents that and makes this consistently pass for me.

Just pushing this out to get Green Dragon back online.
2020-08-14 13:12:52 +02:00
Pavel Labath fdc6aea3fd [lldb] Check Decl kind when completing -flimit-debug-info types
The search for the complete class definition can also produce entries
which are not of the expected type. This can happen for instance when
there is a function with the same name as the class we're looking up
(which means that the class needs to be disambiguated with the
struct/class tag in most contexts).

Previously we were just picking the first Decl that the lookup returned,
which later caused crashes or assertion failures if it was not of the
correct type. This patch changes that to search for an entry of the
correct type.

Differential Revision: https://reviews.llvm.org/D85904
2020-08-14 12:31:37 +02:00
Pavel Labath e6b1b61054 [lldb] Fix py3 incompatibility in gdbremote_testcase.py
This didn't cause test failures since this variable is only used during
connection shutdown.
2020-08-14 12:15:25 +02:00
Raphael Isemann f974d64b37 [lldb] Deduplicate copy-pasted TypeSystemMap::GetTypeSystemForLanguage
There are two implementations for `TypeSystemMap::GetTypeSystemForLanguage`
which are both identical beside one taking a `Module` and one taking a `Target`
(and then passing that argument to the `TypeSystem::CreateInstance` function).

This merges both implementations into one function with a lambda that wraps the
different calls to `TypeSystem::CreateInstance`.

Reviewed By: #lldb, JDevlieghere

Differential Revision: https://reviews.llvm.org/D82537
2020-08-14 11:58:54 +02:00
Shu Anzai de9e85026f [lldb] Display autosuggestion part in gray if there is one possible suggestion
This is relanding D81001. The patch originally failed as on newer editline
versions it seems CC_REFRESH will move the cursor to the start of the line via
\r and then back to the original position. On older editline versions like
the one used by default on macOS, CC_REFRESH doesn't move the cursor at all.
As the patch changed the way we handle tab completion (previously we did
REDISPLAY but now we're doing CC_REFRESH), this caused a few completion tests
to receive this unexpected cursor movement in the output stream.
This patch updates those tests to also accept output that contains the specific
cursor movement commands (\r and then \x1b[XC). lldbpexpect.py received an
utility method for generating the cursor movement escape sequence.

Original summary:

I implemented autosuggestion if there is one possible suggestion.
I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called.
Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k.
Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it.

Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now.

Reviewed By: teemperor, JDevlieghere, #lldb

Differential Revision: https://reviews.llvm.org/D81001
2020-08-14 11:37:49 +02:00
Pavel Labath 40d774265b [lldb/Utility] Simplify Scalar::PromoteToMaxType
The function had very complicated signature, because it was trying to
avoid making unnecessary copies of the Scalar object. However, this
class is not hot enough to worry about these kinds of optimizations. My
making copies unconditionally, we can simplify the function and all of
its call sites.

Differential Revision: https://reviews.llvm.org/D85906
2020-08-14 11:09:16 +02:00
Raphael Isemann bbe3c479a6 [lldb] Fix a crash when tab-completion an empty line in a function with only one local variable
When LLDB sees only one possible completion for an input, it will add a trailing
space to the completion to signal that to the user. If the current argument is
quoted, that also means LLDB needs to add the trailing quote to finish the
current argument first.

In case the user is in a function with only one local variable and is currently
editing an empty line in the multiline expression editor, then we are in the
unique situation where we can have a unique completion for an empty input line.
(In a normal LLDB session this would never occur as empty input would just list
all the possible commands).

In this special situation our check if the current argument needs to receive a
trailing quote will crash LLDB as there is no current argument and the
completion code just unconditionally tries to access the current argument. This
just adds the missing check if we even have a current argument before we check
if we need to add a terminating quote character.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85903
2020-08-14 09:06:52 +02:00
Jonas Devlieghere 3da939686c [lldb] Improve diagnostics in lldb-repro when replay fails
- Print the replay invocation.
 - Keep the reproducer around.
 - Return the "opposite" exit code so we don't have to rely on FileCheck
   to fail the test when the expected exit code is non-zero.
2020-08-13 14:38:34 -07:00
shafik 25bbceb047 [LLDB] Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()
When bit-field data was stored in a Scalar in ValueObjectChild during UpdateValue()
it was extracting the bit-field value. Later on in lldb_private::DumpDataExtractor(…)
we were again attempting to extract the bit-field. Which would then not obtain the
correct value. This will remove the extra extraction in UpdateValue().
We hit this specific case when values are passed in registers, which we could only
reproduce in an optimized build.

Differential Revision: https://reviews.llvm.org/D85376
2020-08-13 11:53:14 -07:00
Jonas Devlieghere 2ddba09e06 [lldb] Set the launch flags to GetLaunchInfo().GetLaunchFlags()
Instead of clearing the launch flags, always pass the target's current
launch flags.
2020-08-13 10:24:35 -07:00
Jonas Devlieghere 180d6ed667 [lldb] Skip TestStepScripted with reproducers
Some of the test methods were already skipped because of an unexpected
packet. The test started failing after it was expanded. Skip the whole
test with reproducers so we don't have to add the decorator for every
method.
2020-08-13 09:46:52 -07:00
Raphael Isemann 8af160b0b8 [lldb][NFC] Use llvm::is_contained instead of std::find in a few places 2020-08-13 14:11:28 +02:00
Raphael Isemann ac2b7f8ac1 [lldb][NFC] Fix indentation in TCPSocket::CloseListenSockets 2020-08-13 12:29:24 +02:00
Jonas Devlieghere fbfd831dda [lldb] Fix relative imports and set the appropriate include dirs
After moving python.swig and lua.swig into their respective
subdirectories, the relative paths in these files were out of date. This
fixes that and ensures the appropriate include paths are set in the SWIG
invocation.

Differential revision: https://reviews.llvm.org/D85859
2020-08-12 16:28:46 -07:00
Adrian McCarthy 7ddfb956e1 [lldb] Fix unit test parsing to handle CR+LF as well as LF
Apparently when the strings are created, the `'\n'` is converted to the
platform's natural new line indicator, which is CR+LF on Windows.  But
upon reading back with `sscanf`, the CRs caused a matching failure.
2020-08-12 13:56:16 -07:00
Vedant Kumar d49aedd315 Build a flat LLDB.framework for embedded Darwin targets
This patch configures LLDB.framework to build as a flat unversioned
framework on non-macOS Darwin targets, which have never supported the
macOS framework layout.

This patch also renames the 'IOS' cmake variable to 'APPLE_EMBEDDED' to
reflect the fact that lldb is built for several different kinds of embedded
Darwin targets, not just iOS.

Differential Revision: https://reviews.llvm.org/D85770
2020-08-12 13:34:29 -07:00
Raphael Isemann cff880b0c9 Revert "[lldb] Display autosuggestion part in gray if there is one possible suggestion"
This reverts commit 246afe0cd1. This broke
the following tests on Linux it seems:
  lldb-api :: commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
2020-08-12 13:52:03 +02:00
Shu Anzai 246afe0cd1 [lldb] Display autosuggestion part in gray if there is one possible suggestion
I implemented autosuggestion if there is one possible suggestion.
I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called.
Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k.
Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it.

Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now.

Reviewed By: teemperor, JDevlieghere, #lldb

Differential Revision: https://reviews.llvm.org/D81001
2020-08-12 13:11:20 +02:00
Raphael Isemann dd0fdf8030 [lldb] Add support for checking children in expect_expr
expect_expr currently can't verify the children of the result SBValue.

This patch adds the ability to check them. The idea is to have a CheckValue
class where one can specify what attributes of a SBValue should be checked.
Beside the properties we already check for (summary, type, etc.) this also
has a list of children which is again just a list of CheckValue object (which
can also have children of their own).

The main motivation is to make checking the children no longer based
on error-prone substring checks that allow tests to pass just because
for example the error message contains the expected substrings by accident.

I also expect that we can just have a variant of `expect_expr` for LLDB's
expression paths (aka 'frame var') feature.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D83792
2020-08-12 12:11:24 +02:00
Petr Hosek 31e5f7120b [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-08-11 20:22:11 -07:00
Adrian McCarthy 479f5bfdb0 [LLDB] Improve PDB discovery
When loading a PE/COFF target, the associated PDB file often wasn't
found.  The executable module contains a path for the associated PDB
file, but people often debug from a different directory than the one
their build system uses.  (This is especially common in post-mortem
and cross platform debugging.)

Suppose the COFF executable being debugged is `~/proj/foo.exe`, but
it was built elsewhere and refers to `D:\remote\build\env\foobar.pdb`,
LLDB wouldn't find it.

With this change, if no file exists at the PDB path, LLDB will look
in the executable directory for a PDB file that matches the name of
the one it expected (e.g., `~/proj/foobar.pdb`).  If found, the PDB
is subject to the same matching criteria (GUIDs and age) as would
have been used had it been in the original location.

This same-directory-as-the-binary rule is commonly used by debuggers
on Windows.

Differential Review: https://reviews.llvm.org/D84815
2020-08-11 13:44:14 -07:00
Jonas Devlieghere 254e0abf5b [lldb] Fix the last remaining tests not inheriting TCC permissions
After this patch all test should have the inferior inheriting the TCC
permissions from its parent.
2020-08-11 12:50:36 -07:00
Jonas Devlieghere 61afdf0ab4 [lldb] Enable inheriting TCC permissions in lldb-test
Like the rest of the test suite, also set the target.inherit-tcc option
to true in lldb-test.
2020-08-11 11:37:14 -07:00
Jonas Devlieghere 7adf5bd181 [lldb] Look beyond the first line to find the PID in TestAppleSimulatorOSType
The current code fails when the first stderr line doesn't match the
given regex to parse the PID. This patch changes the code to read the
first 10 lines before giving up. It also adds tracing for the simctl
commands.
2020-08-11 11:07:04 -07:00
Jonas Devlieghere c135744b1d [lldb/CMake] Separate CMake code for Lua and Python (NFC)
Separate the CMake logic for Lua and Python to clearly distinguish
between code specific to either scripting language and the code shared
by both.

What this patch does is:

 - Move Python specific code into the bindings/python subdirectory.
 - Move the Lua specific code into the bindings/lua subdirectory.
 - Add the _python suffix to Python specific functions/targets.
 - Fix a dependency issue that would check the binding instead of
   whether the scripting language is enabled.

Note that this patch also changes where the bindings are generated,
which might affect downstream projects that check them in.

Differential revision: https://reviews.llvm.org/D85708
2020-08-11 09:04:18 -07:00
Pavel Labath bb91c9fe7b [cmake] Make gtest macro definitions a part the library interface
These definitions are needed by any file which uses gtest. Previously we
were adding them in the add_unittest function, but over time we've
accumulated libraries (which don't go through add_unittest) building on
gtest and this has resulted in proliferation of the definitions.

Making this a part of the library interface enables them to be managed
centrally. This follows a patch for -Wno-suggest-override (D84554) which
took a similar approach.

Differential Revision: https://reviews.llvm.org/D84748
2020-08-11 15:22:44 +02:00
Raphael Isemann 950f1bf976 [lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes
Like the other type sugar removed by RemoveWrappingTypes, SubstTemplateTypeParm
is just pure sugar that should be ignored. If we don't ignore it (as we do now),
LLDB will fail to read values from record fields that have a
SubstTemplateTypeParm type.

Only way to produce such a type in LLDB is to either use the `import-std-module`
setting to get a template into the expression parser or just create your own
template directly in the expression parser which is what we do in the test.

Reviewed By: jarin

Differential Revision: https://reviews.llvm.org/D85132
2020-08-11 14:31:47 +02:00
Gongyu Deng 4f3559db1f [lldb] watchpoint ID common completion for commands `watchpoint delete/enable/disable/modify/ignore`
1. Added a common completion WatchPointIDs to complete with a list of the IDs of the current watchpoints;
2. Applied the completion to these commands: watchpoint delete/enable/disable/modify/ignore;
3. Added a correlated test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84104
2020-08-11 14:25:09 +02:00
Gongyu Deng a952fe236f [lldb] thread index common completion for commands like `thread select/step-over`
1. Added a common completion completing with a list of the threads of the current process;
2. Apply the common completion above to these commands: thread
   continue/info/exception/select/step-in/step-inst/step-inst-over/step-out/step-over/step-script​
3. Correlated test case test_common_completion_thread_index.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84088
2020-08-11 13:27:13 +02:00
Gongyu Deng b2b7dbb47a [lldb] stop-hook ID common completion for commands `target stop-hook enable/disable/delete'
1. Added a common completion StopHookIDs to provide completion with a list of stop hook ids;
2. Applied the common completion to commands: `target stop-hook delete/enable/disable';
3. Added an related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84123
2020-08-11 13:14:27 +02:00
Raphael Isemann 33d0031edb [lldb] Fix unhandled switch case for GOFF in GDBRemoteCommunicationClient
Just implementing the default case that emits an error to supress the compiler
warning.
2020-08-11 12:57:18 +02:00
Gongyu Deng 419f1be7b5 [lldb] tab completion for `target modules load -u`
1. Added a common completion ModuleUUIDs to provide a list of the UUIDs of modules for completion;
2. Added a new enumeration item eArgTypeModuleUUID to CommandArgumentType which is set as the option argument type of OptionGroupUUID;
3. Applied the module UUID completion to the argument of the type eArgTypeModuleUUID in lldb/source/Interpreter/CommandObject.cpp;
4. Added an related test case in lldb/test/API/functionalities/completion/TestCompletion.py.
2020-08-11 12:35:36 +02:00
Gongyu Deng 66fa73fa27 [lldb] move the frame index completion into a common completion and apply it to `thread backtrace -s`
Commands frame select and thread backtrace -s can be completed in the same way.
Moved the dedicated completion of frame select into a common completion and
apply it to the both commands, along with the test modified.
2020-08-11 12:25:39 +02:00
Gongyu Deng 24bc8afd4b [lldb] tab completion for `target modules search-paths insert​`
Dedicated completion for the command `target modules search-paths insert​` with a test case.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83309
2020-08-11 11:58:14 +02:00
Gongyu Deng 3ce57e0121 [lldb] type language common completion
1. Added a new common completion TypeLanguages to provide a list of supporting languages;
2. Bound the completion to eArgTypeLanguage;
3. Added a related test case.
2020-08-11 11:07:19 +02:00
Gongyu Deng 31fd64ac57 [lldb] tab completion for 'command delete/unalias'
Provided dedicated tab completions for `command delete/unalias`.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D81128
2020-08-11 10:27:04 +02:00
Raphael Isemann df916062c8 [lldb][NFC] Fix warning in Thread::AutoCompleteThreadPlans 2020-08-11 10:26:01 +02:00
Gongyu Deng f99a18bbaa [lldb] tab completion for `thread plan discard`
Dedicated completion for the command `thread plan discard` with a corresponding
test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D83234
2020-08-11 10:08:16 +02:00
Raphael Isemann 51117e3c51 [lldb][NFC] Remove unused custom reimplementation of realpath for Windows
No one is calling this function it seems and according to
https://bugs.llvm.org/show_bug.cgi?id=47088 this can leak memory, so let's just
remove it:

Quote from the bug report:
> Before return on line 146, the memory allocated on line 130 is not freed.

Reviewed By: amccarth

Differential Revision: https://reviews.llvm.org/D85633
2020-08-11 10:04:42 +02:00
Gongyu Deng 8a5e296975 [lldb] tab completion for `disassemble -F`
1.Added a new common completion DisassemblyFlavors;

2. Bound DisassemblyFlavors to argument of type eArgTypeDisassemblyFlavor in
CommandObject.cpp;

3. Added a related test case.
2020-08-11 10:01:45 +02:00
Gongyu Deng 2e653327e3 [lldb] tab completion for `watchpoint set variable`
1. Applied the common completion `eVariablePathCompletion` to command
`watchpoint set variable`;

2. Added a related test case.

Reviewed By: teemperor, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84177
2020-08-11 09:51:55 +02:00
Jonas Devlieghere a22301ef98 [lldb] Remove redundant add_definitions() in CMake (NFC)
Remove the unused LLDB_CONFIGURATION_RELEASE and move LLDB_USE_OS_LOG
under debugserver which is the only one using it.
2020-08-10 22:45:33 -07:00
Jonas Devlieghere bca43666e7 [lldb] Use modern CMake to avoid repetition (NFC)
Use the target variants of include_directories and add_definitions to
avoid repetition.
2020-08-10 22:29:40 -07:00
Jonas Devlieghere c4701c9c62 [lldb] Add missings moves where appropiate (NFC)
Manually curated list of things found by clang-tidy's
performance-unnecessary-value-param.
2020-08-10 21:02:11 -07:00
Jonas Devlieghere b448eda406 [lldb] Fix typo in AppleDWARFIndex
apple_names_table_up appeared twice in the binary expression, while the
second instance was meant to check apple_namespaces_table_up.

Fixes PR47101
2020-08-10 19:22:52 -07:00
Gongyu Deng e3820570d4 [lldb] tab completion for `platform target-install`
1. Applied the common completion `eDiskFileCompletion` to the first argument of
the command `platform target-install`.
2. Added a related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84179
2020-08-10 20:14:46 +02:00
Jonas Devlieghere 3162c6aa45 [lldb] Skip TestSimulatorPlatform with out-of-tree debugserver 2020-08-10 10:00:45 -07:00
Jonas Devlieghere b8ff0daeac [lldb] Fix NSArray0 data formatter and add test
Fixes PR47089
2020-08-10 09:38:37 -07:00
Raphael Isemann 8119d6c146 [lldb][NFC] Remove dead code in BreakpointResolverAddress 2020-08-10 11:29:40 +02:00
Eric Christopher b529c5270c Add override to fix -Winconsistent-missing-override warning. 2020-08-09 22:12:10 -07:00
Petr Hosek a4d78d23c5 Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit ccbc1485b5 which
is still failing on the Windows MLIR bots.
2020-08-08 17:08:23 -07:00
Petr Hosek ccbc1485b5 [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-08-08 16:44:08 -07:00
Muhammad Omair Javaid c888694a8e [LLDB] Fix timeout value on expect_gdbremote_sequence
D83904 seems to have changed timeout value on expect_gdbremote_sequence which
was 120 previously. This seems to be causing intermittent failures on
lldb-aarch64-ubuntu buildbot.

This patch fixes the timeout value to see the impact on test suite.

Example:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/7401/steps/test/logs/stdio

Differential Revision: https://reviews.llvm.org/D85514
2020-08-08 23:57:08 +05:00
Jonas Devlieghere a97dfdc30b [lldb] Assert the process has exited before we gets its output. 2020-08-07 15:06:38 -07:00
Jim Ingham d3dfd8cec4 Add a setting to force stepping to always run all threads.
Also allow ScriptedThreadPlans to set & get their StopOthers
state.

<rdar://problem/64229484>

Differential Revision: https://reviews.llvm.org/D85265
2020-08-07 14:47:31 -07:00
Adrian Prantl 38b419eb93 Factor out reference-counting code from PlatformApple*
into PlatformAppleSimulator. This is legal because that is the only
entry point for the Terminate/Initialize functions.
2020-08-07 14:25:32 -07:00
Adrian Prantl 968cba8e89 lldbutil: add a retry mechanism for the ios simulator
We've been seeing this failure on green dragon when the system is
under high load. Unfortunately this is outside of LLDB's control.

Differential Revision: https://reviews.llvm.org/D85542
2020-08-07 13:28:46 -07:00
Jonas Devlieghere e3eb3cf550 [lldb] Only check for --apple-sdk argument on Darwin 2020-08-07 13:05:42 -07:00
Jonas Devlieghere f1d525734f [lldb] Store the Apple SDK in dotest's configuration.
This patch stores the --apple-sdk argument in the dotest configuration.
When it's set, use it instead of the triple to determine the current
platform.

Differential revision: https://reviews.llvm.org/D85537
2020-08-07 11:13:18 -07:00
Christian Kühnel f3cc4df51d Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit 1adc494bce.
This patch broke the Windows compilation on buildbot and pre-merge testing:
http://lab.llvm.org:8011/builders/mlir-windows/builds/5945
https://buildkite.com/llvm-project/llvm-master-build/builds/780
2020-08-07 09:36:49 +02:00
Jonas Devlieghere dbf44b8330 [LLDB] Mark test_launch_simple as a no-debug-info test
No need to run this test with the multiple variants.
2020-08-06 23:18:37 -07:00
Adrian Prantl 243903f326 Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)
The implementation of these classes was copied & pasted from the
iPhone simulator plugin with only a handful of configuration
parameters substituted. This patch moves the redundant implementations
into the base class PlatformAppleSimulator.

Differential Revision: https://reviews.llvm.org/D85243
2020-08-06 16:36:58 -07:00
Adrian Prantl 0fa520af67 Unify the code that updates the ArchSpec after finding a fat binary
with how it is done for a lean binary

In particular this affects how target create --arch is handled — it
allowed us to override the deployment target (a useful feature for the
expression evaluator), but the fat binary case didn't.

rdar://problem/66024437

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

(cherry picked from commit 470bdd3caaab0b6e0ffed4da304244be40b78668)
2020-08-06 13:30:17 -07:00
Adrian Prantl f406a90a08 Add missing override to Makefile 2020-08-06 13:07:16 -07:00
Jonas Devlieghere ba37b144e6 [LLDB] Skip test_launch_simple from TestTargetAPI.py when remote 2020-08-06 13:03:18 -07:00
Adrian Prantl 05df9cc703 Correctly detect legacy iOS simulator Mach-O objectfiles
The code in ObjectFileMachO didn't disambiguate between ios and
ios-simulator object files for Mach-O objects using the legacy
ambiguous LC_VERSION_MIN load commands. This used to not matter before
taught ArchSpec that ios and ios-simulator are no longer compatible.

rdar://problem/66545307

Differential Revision: https://reviews.llvm.org/D85358
2020-08-06 12:40:45 -07:00
Jonas Devlieghere 86aa8e6363 [lldb] Use target.GetLaunchInfo() instead of creating an empty one.
Update tests that were creating an empty LaunchInfo instead of using the
one coming from the target. This ensures target properties are honored.
2020-08-06 11:51:26 -07:00
Fred Riss 99298c7fc5 [lldb/testsuite] Change get_debugserver_exe to support Rosetta
In order to be able to run the debugserver tests against the Rosetta
debugserver, detect the Rosetta run configuration and return the
system Rosetta debugserver.
2020-08-06 10:38:30 -07:00
Sterling Augustine 9dbdaea9a0 Remove unused variable "saved_opts".
wattr_get is a macro, and the documentation states:
"The parameter opts is reserved for  future use,
applications must supply a null pointer."

In practice, passing a variable there is harmless, except
that it is unused inside the macro, which causes unused
variable warnings.

The various places where
2020-08-06 10:20:21 -07:00
Raphael Isemann f6913e7440 [lldb][NFC] Document and encapsulate OriginMap in ASTContextMetadata
Just adds the respective accessor functions to ASTContextMetadata instead
of directly exposing the OriginMap to the whole world.
2020-08-06 17:37:29 +02:00
Fangrui Song a6db64ef4a [ELF] Allow sections after a non-SHF_ALLOC section to be covered by PT_LOAD
GNU ld allows sections after a non-SHF_ALLOC section to be covered by PT_LOAD
(PR37607) and assigns addresses to non-SHF_ALLOC output sections (similar to
SHF_ALLOC NOBITS sections. The location counter is not advanced).

This patch tries to fix PR37607 (remove a special case in
`Writer<ELFT>::createPhdrs`). To make the created PT_LOAD meaningful, we cannot
reset dot to 0 for a middle non-SHF_ALLOC output section. This results in
removal of two special cases in LinkerScript::assignOffsets. Non-SHF_ALLOC
non-orphan sections can have non-zero addresses like in GNU ld.

The zero address rule for non-SHF_ALLOC sections is weakened to apply to orphan
only. This results in a special case in createSection and findOrphanPos, respectively.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D85100
2020-08-06 08:27:15 -07:00