Commit Graph

22916 Commits

Author SHA1 Message Date
Vedant Kumar fff3a8464d [lldb/test] Relax NSDate mock test for non-Apple platforms
On Ubuntu, a formatted date prints as "GMT" instead of "UTC", which is
ok.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/4520/steps/test/logs/stdio
2020-05-18 16:00:10 -07:00
Vedant Kumar b783f70a42 [lldb/DataFormatter] Check for overflow when finding NSDate epoch
Summary:
Fixes UBSan-reported issues where the date value inside of an
uninitialized NSDate overflows the 64-bit epoch.

rdar://61774575

Reviewers: JDevlieghere, mib, teemperor

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80150
2020-05-18 13:12:00 -07:00
Jonas Devlieghere 2084330e41 [lldb/Reproducers] Add skipIfReproducer to more tests
Mark more tests as unsupported with reproducers.
2020-05-18 10:13:01 -07:00
Hans Wennborg 525a591f0f Revert 76c5f277f2 "Re-land [Debug][CodeView] Emit fully qualified names for globals"
> Before this patch, S_[L|G][THREAD32|DATA32] records were emitted with a simple name, not the fully qualified name (namespace + class scope).
>
> Differential Revision: https://reviews.llvm.org/D79447

This causes asserts in Chromium builds:

CodeViewDebug.cpp:2997: void llvm::CodeViewDebug::emitDebugInfoForUDTs(const std::vector<std::pair<std::string, const DIType *>> &):
Assertion `OriginalSize == UDTs.size()' failed.

I will follow up on the Phabricator issue.
2020-05-18 11:26:30 +02:00
Med Ismail Bennani 4e9e0488ab [lldb/Commands] Add ability to run shell command on the host.
This patch introduces the `(-h|--host)` option to the `platform shell`
command. It allows the user to run shell commands from the host platform
(always available) without putting lldb in the background.

Since the default behaviour of `platform shell` is to run the command of
the selected platform, having such a choice can be quite handy when
debugging remote targets, for instances.

This patch also introduces a `shell` alias, to improve the command
discoverability and make it more convenient to use for the user.

rdar://62856024

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-05-15 22:14:39 +02:00
Med Ismail Bennani 0eba9de71e [lldb/Dataformatter] Add support to CF{Dictionary,Set}Ref types
This patch improves data formatting for CFDictionaryRef and CFSetRef.
It uses the same data-formatter as NSCFDictionaries and NSCFSets introduced
previously but did require some adjustments in Core::ValueObject.

Since the "Ref" types are opaque pointers to the actual CF containers, if the
value object has a synthetic value, lldb will use the opaque pointer's pointee
type to create the new ValueObjectChild needed to dereference the ValueObject.
This allows the "Ref" types to behaves the same as CF containers when used with
the `frame variable` command, the SBAPI or in Xcode's variable inspector.

This patch also adds support for incomplete types in ValueObject.

rdar://53104287

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-05-15 22:14:39 +02:00
Alexandre Ganea 76c5f277f2 Re-land [Debug][CodeView] Emit fully qualified names for globals
Before this patch, S_[L|G][THREAD32|DATA32] records were emitted with a simple name, not the fully qualified name (namespace + class scope).

Differential Revision: https://reviews.llvm.org/D79447
2020-05-15 10:37:09 -04:00
Pavel Labath 36b9b1e617 [lldb] Fixup command-disassemble-process.yaml test
Increase the function size to account for the changed threshold in
8b845ac5ed.
2020-05-15 12:35:44 +02:00
Pavel Labath 8b845ac5ed Recommit "[lldb] Don't dissasemble large functions by default"
This recommits f665e80c02 which was reverted in 1cbd1b8f69 for breaking
TestFoundationDisassembly.py. The fix is to use --force in the test to avoid
bailing out on large functions.

I have also doubled the large function limit to 8000 bytes (~~ 2000 insns), as
the foundation library contains a lot of large-ish functions. The intent of this
feature is to prevent accidental disassembling of enormous (multi-megabyte)
"functions", not to get in people's way.

The original commit message follows:

If we have a binary without symbol information (and without
LC_FUNCTION_STARTS, if on a mac), then we have to resort to using
heuristics to determine the function boundaries. However, these don't
always work, and so we can easily end up thinking we have functions
which are several megabytes in size. Attempting to (accidentally)
disassemble these can take a very long time spam the terminal with
thousands of lines of disassembly.

This patch works around that problem by adding a sanity check to the
disassemble command. If we are about to disassemble a function which is
larger than a certain threshold, we will refuse to disassemble such a
function unless the user explicitly specifies the number of instructions
to disassemble, uses start/stop addresses for disassembly, or passes the
(new) --force argument.

The threshold is currently fairly aggressive (4000 bytes ~~ 1000
instructions). If needed, we can increase it, or even make it
configurable.

Differential Revision: https://reviews.llvm.org/D79789
2020-05-15 11:57:48 +02:00
Raphael Isemann d48ef7cab5 [lldb] Print full Clang diagnostics when the ClangModulesDeclVendor fails to compile a module
Summary:
When the ClangModulesDeclVendor currently fails it just prints very basic and often incomplete diagnostics without any source locations:
```
(lldb) p @import Foundation
error: while importing modules:
'foo/bar.h' file not found
could not build module 'Darwin'
[...]
```
or even just
```
(lldb) p @import Foundation
error: while importing modules:
could not build module 'Darwin'
[...]
```

These diagnostics help neither the user nor us with figuring out what is the reason for the failure.

This patch wires up a full TextDiagnosticPrinter in the ClangModulesDeclVendor and makes
sure we always return the error stream to the user when we fail to compile our modules.

Fixes rdar://63216849

Reviewers: aprantl, jdoerfert

Reviewed By: aprantl

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D79947
2020-05-15 10:11:03 +02:00
Gongyu Deng 7c89297cf7 Correct the argument list of command `breakpoint read`
Summary: Command `breakpoint read` should not accept breakpoint ids as
arguments, and in fact, it is not implemented to deal with breakpoint id
arguments either. So this patch is to correct the argument list of this
command so that the help text won't misguide users.

Reviewers: teemperor, JDevlieghere, jingham

Reviewed By: teemperor, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79722
2020-05-15 09:00:05 +02:00
Jonas Devlieghere bf02bcffcf [lldb/Test] Modify more tests for API replay
Skip tests or parts thereof that aren't expected to work when run from a
reproducer. Also improve the doc comments in configuration.py to prevent
mistakes in the future.
2020-05-14 17:58:27 -07:00
Jonas Devlieghere 9fde516032 [lldb/Test] Replace assertTrue with more specific checks (NFC)
Use assertEqual(a, b) instead of assertTrue(a == b) etc.
2020-05-14 15:48:48 -07:00
shafik 1cbd1b8f69 Revert "[lldb] Don't dissasemble large functions by default"
This reverts commit f665e80c02.

Reverting because it breaks TestFoundationDisassembly.py
2020-05-14 14:15:51 -07:00
Ryan Mansfield 5144e48c14 [lldb] Update stop info override callback comment.
In D31172 GetStopInfoOverrideCallback was moved and renamed.

Differential revision: https://reviews.llvm.org/D79953
2020-05-14 13:08:56 -07:00
Jonas Devlieghere 2d6f4fec07 [lldb/Test] Skip test using files to synchronize.
Files written by the inferior are not captured by the reproducers and
the inferior doesn't actually run during replay.
2020-05-14 13:08:56 -07:00
Jonas Devlieghere e7c91e3124 [lldb/Test] Skip remaining 'side_effect' tests with reproducers.
The side_effect Python package bypasses the reproducer instrumentation
and therefore these tests are not expected to replay from a reproducer.
2020-05-14 10:38:56 -07:00
Jonas Devlieghere e29cae1e53 [lldb/Test] Skip TestExpressionInSyscall with reproducers
Skip this test because it relies on a timeout.
2020-05-14 10:38:56 -07:00
Levon Ter-Grigoryan 631048e811 Moving executable module symbols parsing to target creation method.
Summary:
In our project we are using remote client-server LLDB configuration.
We want to parse as much debugging symbols as we can before debugger starts attachment to the remote process.
To do that we are passing the path of the local executable module to CreateTarget method at the client.
But, it seems that this method are not parsing the executable module symbols.
To fix this I added PreloadSymbols call for executable module to target creation method.

This patch also fixes a problem where the DynamicLoader would reset a
module when launching the target. We fix it by making sure
Platform::ResolveExecutable returns the module object obtained from the
remote platform.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D78654
2020-05-14 16:54:14 +02:00
Pavel Labath eb50b643fe [lldb/PDB] Make "native" pdb tests host-independent
These test don't execute the binaries they build, and so they don't need
to build for the host. By hardcoding the target, we don't have do xfail
or skip them for targets which don't have the appropriate support in
clang(-cl).
2020-05-14 16:01:23 +02:00
Pavel Labath dac6e9ca21 [lldb] Fix a "missing return" warning in XcodeSDK 2020-05-14 13:31:49 +02:00
Pavel Labath 638efe3929 [lldb] Use llvm::MC for register numbers in AArch64 ABIs
Summary:
This is equivalent to previous patches (e.g. 07355c1c0) for the x86 ABIs.

One name fixup is needed -- lldb refers to the floating/vector registers by
their vector name (vN). Llvm does not use this name, so we map it to qN,
representing the register as a single 128 bit value (this choice is fairly
arbitrary -- any other name would also work fine as they all have the same
DWARF number).

Reviewers: JDevlieghere, jasonmolenda, omjavaid

Reviewed By: omjavaid

Subscribers: clayborg, danielkiss, aprantl, kristof.beyls, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75607
2020-05-14 13:31:48 +02:00
Pavel Labath deea174ee5 [lldb/gdb-remote] Change default value of use-libraries-svr4 to true
This setting was added last year, defaulting to false. There have been
no bug reports about the svr4 code path since then, and the using this
packet is definitely faster than walking the module list from lldb.

Set the default value of the setting to true, as that is a better
default. Users can still change it back if encountering problems, or we
can revert the change as well, in case of bigger issues.

I also add a note to the setting description that it is only effective
if lldb is built with xml support.
2020-05-14 12:17:37 +02:00
Pavel Labath 3a16829748 [lldb] Switch Section-dumping code to raw_ostream
Also, add a basic test for dumping sections.
2020-05-14 11:59:18 +02:00
Pavel Labath f665e80c02 [lldb] Don't dissasemble large functions by default
Summary:
If we have a binary without symbol information (and without
LC_FUNCTION_STARTS, if on a mac), then we have to resort to using
heuristics to determine the function boundaries. However, these don't
always work, and so we can easily end up thinking we have functions
which are several megabytes in size. Attempting to (accidentally)
disassemble these can take a very long time spam the terminal with
thousands of lines of disassembly.

This patch works around that problem by adding a sanity check to the
disassemble command. If we are about to disassemble a function which is
larger than a certain threshold, we will refuse to disassemble such a
function unless the user explicitly specifies the number of instructions
to disassemble, uses start/stop addresses for disassembly, or passes the
(new) --force argument.

The threshold is currently fairly aggressive (4000 bytes ~~ 1000
instructions). If needed, we can increase it, or even make it
configurable.

Differential Revision: https://reviews.llvm.org/D79789
2020-05-14 11:52:54 +02:00
Gabor Greif 20db891cef Fix typo in error message 2020-05-14 07:23:59 +02:00
Jonas Devlieghere 6671a81bc7 [lldb/Reproducers] Add test-specific API to set the test CWD
The reproducers' working directory is set to the current working
directory when they are initialized. While this is not optimal, as the
cwd can change during a debug session, it has been sufficient so far.

The current approach doesn't work for the API test suite however because
dotest temporarily changes the directory to where the test's Python file
lives.

This patch adds an API to tell the reproducers what to set the CWD to.
This is a NO-OP in every mode but capture.

Differential revision: https://reviews.llvm.org/D79825
2020-05-13 09:00:07 -07:00
Raphael Isemann 5f7a5e3bdb [lldb][NFC] Early-exit in SetupDeclVendor
Also removed the unnecessary element-by-element copy of the std::vector
hand_imported_modules to modules_for_macros.
2020-05-13 16:54:38 +02:00
Raphael Isemann 2fe6672498 [lldb][NFC] Don't specify a default argument when creating a TextDiagnosticPrinter 2020-05-13 15:55:51 +02:00
Pavel Labath e072b20bde [lldb] Merge PlatformXXX::ResolveExecutable
The near-identical implementations of this function for posix-y
platforms were merged in r293910. PlatformWindows was left out of this
merge because at the time we did not have a suitable base class to sink
the code into. That is no longer true, so this commit finishes the job
by moving the code into RemoteAwarePlatform::ResolveExecutable.
2020-05-13 13:28:19 +02:00
Mathias LANG e16111ce2f [lldb] Also recognize DWARF UTF base types using their size
Summary:
The D programming language has 'char', 'wchar', and 'dchar' as base types,
which are defined as UTF-8, UTF-16, and UTF-32, respectively.

It also has type constructors (e.g. 'const' and 'immutable'),
that leads to D compilers emitting DW_TAG_base_type with DW_ATE_UTF
and name 'char', 'immutable(wchar)', 'const(char)', etc...

Before this patch, DW_ATE_UTF would only recognize types that
followed the C/C++ naming, and emit an error message for the rest, e.g.:
```
error: need to add support for DW_TAG_base_type 'immutable(char)'
encoded with DW_ATE = 0x10, bit_size = 8
```

The code was changed to check the byte size first,
then fall back to the old name-based check.

Reviewers: clayborg, labath

Reviewed By: labath

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79559
2020-05-13 12:56:13 +02:00
Muhammad Omair Javaid 67087a7b76 [LLDB] Fix typo in xfail decorator assert.test
Fix a typo in earlier xfailed assert.test replace // with #.
2020-05-13 08:53:56 +05:00
Muhammad Omair Javaid 6805a77eb6 [LLDB] Mark some xfails for arm-linux
This patch marks following tests as xfail for arm-linux target.

lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py
lldb/test/API/python_api/thread/TestThreadAPI.py
lldb/test/Shell/Recognizer/assert.test

Bugs have been filed for all of them for the corresponding failing
component.
2020-05-13 08:05:27 +05:00
Muhammad Omair Javaid 302c492cc5 [LLDB] Fix minidebuginfo-set-and-hit-breakpoint.test for arm 32-bit
This patch fixes minidebuginfo-set-and-hit-breakpoint.test for arm-linux
targets. 32-bit elf executables use .rel.dyn and 64-bit uses .rela.dyn for
relocation entries for dynamic symbols.
2020-05-13 07:17:40 +05:00
Muhammad Omair Javaid 0796b170fb Fix error in TestNumThreads.py when frame.GetFunctionName returns none
Summary:
This patch fixes an error happening in TestNumThreads.py when it encounters frame.GetFunctionName none for address only locations in stripped libc.

This error was showing up on arm-linux docker container running lldb buildbot.

Reviewers: labath

Reviewed By: labath

Subscribers: kristof.beyls, lldb-commits

Differential Revision: https://reviews.llvm.org/D79777
2020-05-13 05:13:46 +05:00
Jonas Devlieghere ab22f71dd7 [lldb/Reproducers] Also record directories FileSystem::Collect.
Now that the FileCollector knows how to deal with directories we no
longer have to ignore them in the FileSystem class.
2020-05-12 15:59:24 -07:00
Fred Riss d9166ad272 [lldb/Driver] Support terminal resizing
Summary:
The comment in the Editine.h header made it sound like editline was
just unable to handle terminal resizing. We were not ever telling
editline that the terminal had changed size, which might explain why
it wasn't working.

This patch threads a `TerminalSizeChanged()` callback through the
IOHandler and invokes it from the SIGWINCH handler in the driver. Our
`Editline` class already had a `TerminalSizeChanged()` method which
was invoked only when editline was configured.

This patch also changes `Editline` to not apply the changes right away
in `TerminalSizeChanged()`, but instead defer that to the next
character read. During my testing, it happened once that the signal
was received while our `ConnectionFileDescriptor::Read` was allocating
memory. As `el_resize` seems to allocate memory too, this crashed.

Reviewers: labath, teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79654
2020-05-12 11:55:25 -07:00
Jonas Devlieghere bad61548b2 [Reproducers] Serialize process arguments in ProcessInfo
While debugging why TestProcessList.py failed during passive replay, I
remembered that we don't serialize the arguments for ProcessInfo. This
is necessary to make the test pass and to make platform process list -v
behave the same during capture and replay.

Differential revision: https://reviews.llvm.org/D79646
2020-05-12 11:12:37 -07:00
Kristof Beyls 5d7f5ca0e3 Add Linux SVE Ptrace macros.
Differential Revision: https://reviews.llvm.org/D79623
2020-05-12 15:24:24 +02:00
Muhammad Omair Javaid 054ed1fd0b [LLDB] Disable TestBasicEntryValues.py for arm
TestBasicEntryValues.py fails on arm 32 bit. Currently running on silent master here:
http://lab.llvm.org:8014/builders/lldb-arm-ubuntu/
2020-05-12 11:32:58 +05:00
Jason Molenda 2b8b783b1a Quote error string from qLaunchSuccess
If the error message from qLaunchSucess included a gdb RSP
metacharacter, it could crash lldb.  Apply the binary
escaping to the string before sending it to lldb; lldb
promiscuously applies the binary escaping protocol on
packets it receives.

Also fix a small bug in cstring_to_asciihex_string where
a high bit character (eg utf-8 chars) would not be
quoted correctly due to signed char fun.

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

rdar://problem/62873581
2020-05-11 20:05:57 -07:00
Eric Christopher 8d7796cf94 Fix a few clang-tidy warnings about auto * and const auto. 2020-05-11 15:33:17 -07:00
Eric Christopher cd7cb1f4ce Update lldb for rG10658691951f to avoid Werror messages around
new unhandled matrix types.
2020-05-11 13:45:21 -07:00
Vedant Kumar f807d0b4ac [lldb/test] Fix for flakiness in TestNSDictionarySynthetic
Summary:
TestNSDictionarySynthetic sets up an NSURL which does not initialize its
_baseURL member. When the test runs and we print out the NSURL, we print
out some garbage memory pointed-to by the _baseURL member, like:

```
_baseURL = 0x0800010020004029 @"d��qX"
```

and this can cause a python unicode decoding error like:

```
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position
10309: invalid start byte
```

There's a discrepancy here because lldb's StringPrinter facility tries
to only print out "printable" sequences (see: isprint32()), whereas python
rejects the StringPrinter output as invalid utf8. For the specific error
seen above, lldb's `isprint32(0xa0) = true`, even though 0xa0 is not
really "printable" in the usual sense.

The problem is that lldb and python disagree on what exactly is
"printable". Both have dismayingly hand-rolled utf8 validation code
(c.f. _Py_DecodeUTF8Ex), and I can't really tell which one is more
correct.

I tried replacing lldb's isprint32() with a call to libc's iswprint():
this satisfied python, but broke emoji printing :|.

Now, I believe that lldb (and python too) ought to just call into some
battle-tested utf library, and that we shouldn't aim for compatibility
with python's strict unicode decoding mode until then.

FWIW I ran this test under an ASanified lldb hundreds of times but
didn't turn up any other issues.

rdar://62941711

Reviewers: JDevlieghere, jingham, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79645
2020-05-11 09:53:48 -07:00
Pavel Labath caa2408cbe [lldb] Speculative fix for the entry values test on arm64
The bot fails with a message which seems to indicate a problem in option
parsing. Avoid grouping the options to see if that helps.
2020-05-11 17:54:34 +02:00
Pavel Labath ba898282bc [lldb/test] Make "inline" tests handle multiple statements at the same location
Summary:
The test machinery translates each continuous block of "//%" comments
into a single breakpoint. If there's no code between the blocks the
breakpoints will end up at the same location in the program. When the
process stops at a breakpoint lldb correctly reports all breakpoint IDs,
but the test machinery only looks at the first one. This results in a
very dangerous situation as it means some checks can be silently
stopped.

This patch fixes that by making the test machinery iterate through all
breakpoints at a given location and execute all commands.

Reviewers: vsk, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79563
2020-05-11 16:37:34 +02:00
Pavel Labath a5c2317982 [lldb] Revive TestBasicEntryValuesX86_64
Summary:
This function rewrites the test to be (hopefully) less susceptible to
codegen changes and re-enables it.

The most interesting changes are:
- use an __attribute__((optnone)) function instead of a volatile asm to
  "use" a value. This isn't strictly necessary, but it makes the
  function simpler while achieving the same effect.
- use a call to a function with the exact same signature instead of a
  volatile asm to "destroy" arguments. This makes the independent of the
  ABI, and (together with avoiding the usage of the arguments after the
  call) ensures that the compiler has no reason to move the argument
  from its initial register (previously we needed to guess where will
  the compiler store the arguments).

Reviewers: vsk, djtodoro, dblaikie

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79491
2020-05-11 16:31:02 +02:00
Raphael Isemann f8af9f5fca [lldb] Add missing nullptr checks to AppleObjCRuntime::GetBacktraceThreadFromException
Summary:
We got a few crash reports where LLDB crashes while derefencing the `frames_value` shared_ptr in the AppleObjCRuntime::GetBacktraceThreadFromException. `GetChildMemberWithName` returns a nullptr when an error occurs, so this seems to be just a missing nullptr check.

This patch adds that nullptr check and the other ones in the similar code directly below.

Fixes rdar://62174039

Reviewers: jingham, kubamracek

Reviewed By: jingham

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D78798
2020-05-11 16:02:51 +02:00
Gongyu Deng e87362e689 Tab completion for breakpoint write and breakpoint name add/delete
Summary: Apply the common completion created in [[ https://reviews.llvm.org/D75418 | Revision D75418 ]] to the commands  `breakpoint write` and `breakpoint name add/delete`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79686
2020-05-11 15:55:11 +02:00
Gongyu Deng 0e50b9a43b Complete breakpoint enable/disable/delete/modify with a list of breakpoint IDs
Summary:
1. A new common completion `CommandCompletions::Breakpoints` to provide a list of the breakpoints of the current context;
2. Apply the completion above to the commands breakpoint enable/disable/delete/modify;
3. Unit test.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79666
2020-05-11 15:21:51 +02:00
Muhammad Omair Javaid 20629ca949 [LLDB] Fix broken testsuite due to Xfail decorators
Following test cases need minor adjustment in order to accomodate xfail
decorator:
  lldb/test/Shell/SymbolFile/NativePDB/break-by-line.cpp
  lldb/test/Shell/SymbolFile/NativePDB/source-list.cpp
2020-05-11 10:25:04 +05:00
Muhammad Omair Javaid 8e63f35f86 [LLDB] Decorate tests failing on arm-linux buildbot
Tests impacted by these decorators fail on arm-linux-gnueabihf.

These have been triaged and appropriate bugs have been filed.
2020-05-11 07:31:18 +05:00
Muhammad Omair Javaid e179e7234f Remove XFAIL arm-linux decorator from passing tests 2020-05-11 07:31:18 +05:00
Muhammad Omair Javaid 634b359cf2 XFAIL NativePDB tests on arm-linux
NativePDB tests fail on arm-linux buildbot. clang-cl driver crashes with
-m32 option. Bug files http://llvm.org/pr45867
2020-05-11 07:31:18 +05:00
Fred Riss c9537b9cc8 [lldb/debugserver] Include TargetConditionals.h where needed
MachProcess.mm uses a TARGET_OS_ macro without directly including
TargetConditionals.h. This currently works as we get the header
as an indirect dependency, but might not in the future.

I just spent some time investigating an internal regression
caused by a similar issue, so I audited the codebase for such
cases.
2020-05-09 10:12:17 -07:00
Jan Kratochvil 68a9356bde [lldb] [testsuite] TestReproducerAttach.py: Fix dependency on external symbol files
D55859 and D63339 prevented needless dependencies on system symbol
files. This testcase was checked-in afterwards and it brings back one
such unwanted dependency. Under some circumstances it may cause false
FAILs and/or excessive resource usage to run the testcase.

clang-format does not support .py so I have formatted it as I found most
compatible.

Also this is not a full testcase-style initialization, for example
--no-lldbinit ignores env("NO_LLDBINIT") setting which lldbtest.py does
implement:
  # If we spawn an lldb process for test (via pexpect), do not load the
  # init file unless told otherwise.
  if os.environ.get("NO_LLDBINIT") != "NO":
      self.lldbOption += " --no-lldbinit"

But this is what lldbpexpect.py does - it also ignores
env("NO_LLDBINIT"). Sure one could also fix lldbpexpect.py to unify the
initialization more with lldbtest.py but I find that outside of the
scope of this patch.

Differential Revision: https://reviews.llvm.org/D79649
2020-05-09 09:06:37 +02:00
Jonas Devlieghere eb7d32e46f [lldb/Test] Update TestProcessList.py for reproducer replay
Because LLDB isn't the one spawning the subprocess, the PID is different
during replay. Exclude it form the substring check during replay.

Depends on D79646 to pass with reproducer replay.
2020-05-08 13:14:18 -07:00
Raphael Isemann 7b1f1cf1cf [lldb] Remove 'use_synthetic' parameters in ValueObject code
Summary:
`CalculateSyntheticValue` and `GetSyntheticValue` have a `use_synthetic` parameter
that makes the function do nothing when it's false. We obviously always pass true
to the function (or check that the value we pass is true), because there really isn't
any point calling with function with a `false`. This just removes all of this.

Reviewers: labath, JDevlieghere, davide

Reviewed By: davide

Subscribers: davide

Differential Revision: https://reviews.llvm.org/D79568
2020-05-08 21:17:32 +02:00
Lawrence D'Anna 52712d3ff7 Re-land "get rid of PythonInteger::GetInteger()"
This was reverted due to a python2-specific bug.  Re-landing with a fix
for python2.

Summary:
One small step in my long running quest to improve python exception handling in
LLDB.  Replace GetInteger() which just returns an int with As<long long> and
friends, which return Expected types that can track python exceptions

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn, omjavaid

Reviewed By: labath, omjavaid

Subscribers: omjavaid, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78462
2020-05-08 10:57:10 -07:00
Adrian Prantl ae920a81ff Add an API to construct an XcodeSDK from an SDK type.
Also, this moves numSDKs out of the actual enum, as to not mess with
the switch-cases-covered warning.

Differential Revision: https://reviews.llvm.org/D79603
2020-05-08 10:47:13 -07:00
Vedant Kumar 8cb86ead77 [lldb/test][Darwin] Ask dyld where the real python is
Summary:
On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
python binary as the ASan interceptors get loaded too late. Find the
"real" python binary, copy it, and invoke it.

Hopefully this makes the GreenDragon and swift-ci sanitizer bots
happy...

I tested this out by running `../llvm-macosx-x86_64/bin/llvm-lit test
--filter TestNSDictionarySynthetic.py` in an ASanified swift-lldb build
directory and it worked (i.e. no more "interceptors loaded too late"
messages).

Reviewers: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79607
2020-05-08 10:22:58 -07:00
Raphael Isemann 7cf4ab13af [lldb][modules] Disable Clang Modules in source/Host directory on macOS
Summary:
The arpa/inet.h header in macOS is providing an incorrect htonl
function with enabled local submodule visibility while building LLDB. This
caused several networking tests to fail as the IP addresses are now flipped
in LLDB.

This patch disables building with modules when local submodule visibility is
active and the current system is macOS for the source/Host directory (which
is the *only directory that includes arpa/inet.h).

* debugserver also includes arpa/inet.h but there we already disabled
modules.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: mgorny, JDevlieghere

Differential Revision: https://reviews.llvm.org/D79632
2020-05-08 18:13:58 +02:00
Raphael Isemann 7283ec0170 [lldb] Fix RecordDecl match string in module-ownership.mm to get the test running again
The relevant output FileCheck is scanning in this test is as follows:

    CXXRecordDecl 0x7f96cf8239c8 <<invalid sloc>> <invalid sloc> imported in A.B <undeserialized declarations> struct definition
    <<DefinitionData boilerplate>>
    `-FieldDecl 0x7f96cf823b90 <<invalid sloc>> <invalid sloc> imported in A.B anon_field_b 'int'
    (anonymous struct)
    CXXRecordDecl 0x7f96cf823be8 <<invalid sloc>> <invalid sloc> imported in A.B struct

Before 710fa2c4ee this test was passing by
accident as it had a -DAG suffix in the checks changed by this patch,
causing FileCheck to first match the last line of the output above
(instead of the first one), and then finding the FieldDecl above.
When I removed the -DAG suffix, FileCheck actually enforced the ordering
and started failing as the FieldDecl comes before the CXXRecordDecl match
we get.

This patch fixes the CXXRecordDecl check to find the first line of the output
above which caused FileCheck to also find the FieldDecl that follows. Also
gives the FieldDecl a more unique name to make name collisions less likely.
2020-05-08 15:05:19 +02:00
Raphael Isemann 13a1b3c1e6 [lldb] Prevent objc-root-class warning when compiling module-ownership.mm test
This test was generating the following false-positive warning when being compiled:
 warning: class 'SomeClass' defined without specifying a base class [-Wobjc-root-class]
2020-05-08 14:41:01 +02:00
Raphael Isemann 710fa2c4ee [lldb] Make module-ownership.mm test more robust against AST node ordering
The current test is checking both the anonymous structs and the template
specializations in one FileCheck run, but the anonymous struct line can
partially match the AST dump of a template specialization, causing that
FileCheck won't match that same line later against the template specialization
check and incorrectly fails on that check. This only happens when the
template specialization node somehow ends up before the anonymous struct node.

This patch just puts the checks for the anonymous structs in their own FileCheck
run to prevent them from partially matching any other record decl.

Fixes rdar://62997926
2020-05-08 13:44:13 +02:00
Jason Molenda 2ea7187ab9 Add a new lockdownd plist for launching posix processes
Similar to
com.apple.debugserver.plist & com.apple.debugserver.internal.plist
com.apple.debugserver.applist.plist & com.apple.debugserver.applist.internal.plist
add a variant of the posix plist.

<rdar://problem/62995567>
2020-05-07 18:53:51 -07:00
Jonas Devlieghere 13062d0fb7 [lldb/Test] Skip more tests that are not expected to work with passive replay
This skips some tests that pass with active replay (which doesn't check
the output) but fail with passive replay. Valid reasons for this
include:

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

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

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

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

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

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

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

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

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

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

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

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

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

<rdar://problem/62532151+62326862>

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

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

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

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

frame var a[0]+5

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

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

Reviewed By: teemperor, labath

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

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

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

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

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

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

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

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

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

rdar://61419673

Reviewers: JDevlieghere, davide

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

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

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

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

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

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

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

rdar://42630030

https://reviews.llvm.org/D78712

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

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

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

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

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

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

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

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

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: abidh, JDevlieghere

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

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

This means that we need to compute the path to the Python3.framework
and use that as the RPATH instead of the usual dylib's directory.
2020-04-30 10:42:03 -07:00
Raphael Isemann b3180d6a1a [lldb] Re-add deleted RUN line in module-ownership.mm
This was deleted in 681466f5e6 by accident.
2020-04-30 19:29:50 +02:00
Martin Storsjö 613d866374 [lldb] Remove a redundant semicolon, fixing GCC warnings. NFC. 2020-04-29 21:00:43 +03:00
Pavel Labath 2cf69684fb [lldb/DWARF] Fix a split-dwarf crash while parsing compile units
The cause of this crash is relatively simple -- we are using a
SymbolFileDWARFDwo to parse a (skeleton) dwarf unit. This cause the
CompileUnit to be created with the wrong ID, which later triggers an
assertion in SymbolFile::SetCompileUnitAtIndex. The fix is also simple
-- ensure we use the right symbol file for parsing.

However, a fairly elaborate setup is needed trigger this bug, because
ParseCompileUnit is normally called very early on (and with the right
symbol file object) during the process of accessing a compile unit.
The only way this can be triggered is if the DWARF unit is
"accidentally" pulled into scope during expression evaluation
This can happen if the "this" object used for the context of an
expression is in a namespace, and that namespace is also present in
other compile units

The included test recreates this setup.
2020-04-29 16:21:11 +02:00
Jonas Devlieghere bb7bde5bba Revert "[lldb/Platform] Return a std::string from GetSDKPath"
This reverts commit b14c37a29a.
2020-04-29 01:26:24 -07:00
Muhammad Omair Javaid e35dbb3c88 Fix LLDB elf core dump register access for ARM/AArch64
Summary:
This patch adds support to access AArch64 FP SIMD core dump registers and adds a test case to verify registers.

This patches fixes a bug where doing "register read --all" causes lldb to crash.

Reviewers: labath

Reviewed By: labath

Subscribers: kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77793
2020-04-29 09:24:39 +05:00
Saleem Abdulrasool 7c8fa95395 lldb: use the newer `find_package` if available
Now that the rest of LLVM prefers python3 over python2, the LLDB path
should follow suite.  Add a fallback path to python2 for non-Windows
targets.
2020-04-29 03:54:33 +00:00
Muhammad Omair Javaid 9f8b4472fb Extend max register size to accommodate AArch64 SVE vector regs
Summary: This patch increases maximum register size to 256 bytes to accommodate AArch64 SVE registers maximum possible size of 256 bytes.

Reviewers: labath, jankratochvil, rengolin

Reviewed By: labath

Subscribers: tschuett, kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77044
2020-04-29 07:51:30 +05:00
Jonas Devlieghere 6e693386af [lldb/Host] Pass a StringRef to the FileSpec ctor
The FileSpec constructor takes a StringRef so there's no point in going
through a C string.
2020-04-28 19:21:58 -07:00
Jonas Devlieghere 75c3d6f49c [lldb/Platform] Synchronize access to SDK String Map.
The SwiftASTContext queries this function in parallel and requires
synchronization.
2020-04-28 19:21:58 -07:00
Jonas Devlieghere b14c37a29a [lldb/Platform] Return a std::string from GetSDKPath
Nothing guarantees that the objects in the StringMap remains at the same
address when the StringMap grows. Therefore we shouldn't return a
reference into the StringMap but return a copy of the string instead.
2020-04-28 19:21:58 -07:00
Walter Erquinigo 83725822c5 [lldb-vscode] Add an option for loading core files
Summary:
Currently loading core files on lldb-vscode is broken because there's a check in the attach workflow that asserts that the PID is valid, which of course fails for this case.
Hence, I'm adding a "coreFile" argument for the attach request, which does the work correctly.

I don't know how to test it effectively so that it runs on the buildbots and the debugger can in fact makes sense of it. Anyway, the change has been relatively simple.

Reviewers: labath, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78839
2020-04-28 13:03:02 -07:00
Pavel Labath f07f2cee9b [lldb/unittest] Adjust CheckIPSupport function to avoid double-consume of llvm::Error
The problem caught by clang-tidy and reported by Tobias Bosch.
2020-04-28 13:35:07 +02:00
Pavel Labath 5cee8ddcc7 [lldb-vscode] A couple of small style fixes
to make the code conform to llvm style better:
- avoid use of auto where the type is not obivous
- avoid StringRef::data where it is not needed

No functional change intended.
2020-04-28 13:35:07 +02:00
Craig Topper a58b62b4a2 [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().
This method has been commented as deprecated for a while. Remove
it and replace all uses with the equivalent getCalledOperand().

I also made a few cleanups in here. For example, to removes use
of getElementType on a pointer when we could just use getFunctionType
from the call.

Differential Revision: https://reviews.llvm.org/D78882
2020-04-27 22:17:03 -07:00
Eric Christopher 4d40d66402 Fix up a clang-tidy nit about using empty rather than size == 0. 2020-04-27 15:22:44 -07:00
Med Ismail Bennani 8f5beb4c4b
[lldb/Dataformatter] Add support for CoreFoundation Dictionaries and Sets.
This patch improves data formatting for CoreFoundation containers:
CFDictionary and CFSet.

These data formatters make the containers and their children appear in Xcode's
variables view (and on the command line) without having to expand the
data structure.

Previous implementation only supported showing the container's element count.

```
(lldb) frame var dict
(__NSCFDictionary *) dict = 0x00000001004062b0 2 key/value pairs

(lldb) frame var set
(__NSCFSet *) set = 0x0000000100406330 2 elements
```
Now the variable can be dereferenced to dispaly the container's children:

```
(lldb) frame var *dict
(__NSCFDictionary) *dict = {
  [0] = {
    key = 0x0000000100004050 @"123"
    value = 0x0000000100004090 @"456"
  }
  [1] = {
    key = 0x0000000100004030 @"abc"
    value = 0x0000000100004070 @"def"
  }
}

(lldb) frame var *set
(__NSCFSet) *set = {
  [0] = 0x0000000100004050 @"123"
  [1] = 0x0000000100004030 @"abc"
}
```

rdar://39882287

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-04-27 22:10:11 +02:00
Pavel Labath 58435f69cb [lldb] Fix windows build break from 18e96a31 2020-04-27 19:22:44 +02:00
Pavel Labath 18e96a31fe [lldb/unittests] Skip IPv6 test on systems which don't have IPv6 configured
Sadly IPv6 is still not present anywhere. The test was attempting to
detect&skip such hosts, but the way it did that (essentially, by calling
getaddrinfo) meant that it only detected hosts which have IPv6 support
completely compiled out. It did not do anything about hosts which have
it compiled in, but lack runtime configuration even for the ::1 loopback
address.

This patch changes the detection logic to use a new method. It does it
by attempting to bind a socket to the appropriate loopback address. That
should ensure the hosts loopback interface is fully set up. In an effort
to avoid silently skipping the test on too many hosts, the test is
fairly strict about the kind of error it expects in these cases -- it
will only skip the test when receiving EADDRNOTAVAIL. If we find other
error codes that can be reasonably returned in these situations, we can
add more of them.

The (small) change in TCPSocket.cpp is to ensure that the code correctly
propagates the error received from the OS.
2020-04-27 17:33:20 +02:00
Raphael Isemann ff5264f0c6 [lldb][cmake] Move the remove_module_flags call to the right place in debugserver's CMakeLists
This code should always be executed, not just when building the debugserver
on its own. Fixes the modules build when building LLVM+LLDB together.
2020-04-27 16:04:19 +02:00
Pavel Labath 9671f6e8d5 [lldb] Remove NativeProcessDarwin
this is dead and non-functional code that hasn't been touched (modulo
refactors) since it was checked in (as an "NFC, with no review and
tests) in 2016.

Anyone interested in adding darwin support to lldb-server can look this
up in git history.
2020-04-27 15:26:57 +02:00
Raphael Isemann d00eaa082b [lldb] Adjust TestExec code to be closer to real world code
Summary:
For some reason the TestExec test on the macOS bots randomly fails with this error:
```
output: * thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x108e66000)
  * frame #0: 0x0000000108e66000
[...]
  File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 25, in test_hitting_exec
    self.do_test(False)
  File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 113, in do_test
    "Stopped at breakpoint in exec'ed process.")
AssertionError: False is not True : Stopped at breakpoint in exec'ed process.
Config=x86_64-/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-11
```

I don't know why the test program is failing and I couldn't reproduce this problem on my own.
This patch is a stab in the dark that just tries to make the test code more similar to code which
we would expect in a user program to make whatever part of macOS happy that is currently
not liking our code.

The actual changes are:
* We pass in argv[0] that is describing otherprog path instead of the current argv[0].
* We pass in a non-null envp (which anyway doesn't seem to be allowed on macOS man page).

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75241
2020-04-27 14:57:12 +02:00
Aleksandr Urakov 84c398d375 [lldb][TypeSystemClang] Desugar an elaborated type before checking if it's a typedef or getting a typedefed type
Summary:
Sometimes a result variable of some expression can be presented as an elaborated
type. In this case the methods `IsTypedefType()` and `GetTypedefedType()` of
`SBType` didn't work. This patch fixes that.

I didn't find the test for these API methods, so I added a basic test for this
too.

Reviewers: aprantl, teemperor, labath, leonid.mashinskiy

Reviewed By: teemperor

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78697
2020-04-27 11:08:19 +03:00
Raphael Isemann b58af8d254 [lldb] Improve error message when --func-regex parameter for the breakpoint command is invalid
Summary:
Currently the breakpoint command is prompting the user to file a bug report if the provided regex is invalid:
```
(lldb) rbreak *foo
error: Function name regular expression could not be compiled: "Inconvertible error value. An error has occurred that could not be converted to a known std::error_code. Please file a bug. repetition-operator operand invalid"
```

The reason is simply that we are using the wrong StringError constructor (the one with the error code as the first parameter
is also printing the string version of the error code, and the inconvertible error code is just an invalid place holder code with
that description). Switching the StringError constructor parameters will only print the error message we get from the regex
engine when we convert the error into a string.

I checked the rest of the code base and I couldn't find the same issue anywhere else.

Fixes rdar://62233561

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D78808
2020-04-27 09:55:06 +02:00
Adrian Prantl a0919ac080 Invert an #ifdef in XcodeSDKModuleTests.cpp and actually make the test work. 2020-04-24 18:39:40 -07:00
Adrian Prantl 06e4f69b22 Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)
This API is used by swift-lldb.

(Recommit with missing file git-added)
2020-04-24 17:00:34 -07:00
Adrian Prantl af015c1a33 Revert "Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)"
This reverts commit 345df863ce.

(Forgot to git-add the new file)
2020-04-24 16:59:48 -07:00
Adrian Prantl 345df863ce Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)
This API is used by swift-lldb.
2020-04-24 16:51:54 -07:00
Eric Christopher 6a9edce257 Fix a dangling-gsl warning and avoid transitively including string. 2020-04-24 16:03:17 -07:00
Adrian Prantl d8fb631d13 Relax testcase. The Clang module debug info may return additional
attributes such as __unsafe_unretained that is not present in DWARF.
2020-04-24 15:50:26 -07:00
Adrian Prantl b9c7e276bd Disable path-sensitive test on Windows. 2020-04-24 15:21:54 -07:00
Adrian Prantl 79feafa514 Add an internal bit to the XcodeSDK class.
For developing the OS itself there exists an "internal" variant of
each SDK. This patch adds support for these SDK directories to the
XcodeSDK class.

Differential Revision: https://reviews.llvm.org/D78675
2020-04-24 12:55:53 -07:00
Jonas Devlieghere 0d671dbca9 [lldb/Driver] Remove level of indentation (NFC)
Use an early return for when we couldn't create a pipe to source the
commands.
2020-04-24 12:50:53 -07:00
Adrian Prantl 304ba5d4c6 Delete cargo-cult code that doesn't affect the testsuite. 2020-04-24 11:54:52 -07:00
Adrian Prantl ef423a3ba5 Add Objective-C property accessors loaded from Clang module DWARF to lookup
This patch fixes a bug when synthesizing an ObjC property from
-gmodules debug info. Because the method declaration that is injected
via the non-modular property implementation is not added to the
ObjCInterfaceDecl's lookup pointer, a second copy of the accessor
would be generated when processing the ObjCPropertyDecl. This can be
avoided by finding the existing method decl in
ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName() and
adding it to the LookupPtr.

Differential Revision: https://reviews.llvm.org/D78333
2020-04-24 11:10:50 -07:00
Jonas Devlieghere 1fcd234ac5 [lldb/Core] Don't crash in GetSoftwareBreakpointTrapOpcode for unknown triples
This patch ensures we don't crash in GetSoftwareBreakpointTrapOpcode for
not-yet-supported architectures but rather continue with degraded
behavior.

I found the issue in the context of an invalid ArchSpec, which should be
handled further up the chain. In this patch I've also added an assert to
cover that, so we can still catch those issues.

Differential revision: https://reviews.llvm.org/D78588
2020-04-24 09:10:41 -07:00
Mircea Trofin 5948dafc69 [lldb][NFC][CallSite] Remove CallSite use
Reviewers: dblaikie, craig.topper

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78791
2020-04-23 22:24:23 -07:00
shafik def7c7f602 [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)
In ImportContext(…) we may call into CompleteDecl(…) which if FromRecrord is not
defined will start the definition of a ToRecord but from what I can tell at least
one of the paths though here don't ensure we complete the definition.
For a RecordDecl this can be problematic since this means we won’t import base
classes and we won’t have any of the methods or types we inherit from these bases.

Differential Revision: https://reviews.llvm.org/D78000
2020-04-23 15:18:48 -07:00
Puyan Lotfi 9721fbf85b [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.
This is a code clean up of the PropertyAttributeKind and
ObjCPropertyAttributeKind enums in ObjCPropertyDecl and ObjCDeclSpec that are
exactly identical. This non-functional change consolidates these enums
into one. The changes are to many files across clang (and comments in LLVM) so
that everything refers to the new consolidated enum in DeclObjCCommon.h.

2nd Landing Attempt...

Differential Revision: https://reviews.llvm.org/D77233
2020-04-23 17:21:25 -04:00
Raphael Isemann c2fec2fb17 [lldb] Make RNBSocketTest compile again after socket modernization
Commit c9e6b7010c changed the API but didn't update this
macOS-specific test.
2020-04-23 17:00:02 +02:00
Pavel Labath 9321255b88 [lldb/Core] Avoid more Communication::Disconnect races
Calling Disconnect while the read thread is running is racy because the
thread can also call Disconnect.  This is a follow-up to b424b0bf, which
reorders other occurences of Disconnect/StopReadThread I can find, and also
adds an assertion to guard against new occurences being introduced.
2020-04-23 16:36:21 +02:00
Pavel Labath 7cfa74fc69 [lldb/DWARF] Trust CU DW_AT_low/high_pc information when building address tables
Summary:
The code in DWARFCompileUnit::BuildAddressRangeTable tries hard to avoid
relying on DW_AT_low/high_pc for compile unit range information, and
this logic is a big cause of llvm/lldb divergence in the lowest layers
of dwarf parsing code.

The implicit assumption in that code is that this information (as opposed to
DW_AT_ranges) is unreliable. However, I have not been able to verify
that assumption. It is definitely not true for all present-day
compilers (gcc, clang, icc), and it was also not the case for the
historic compilers that I have been able to get a hold of (thanks Matt
Godbolt).

All compiler included in my research either produced correct
DW_AT_ranges or .debug_aranges entries, or they produced no DW_AT_hi/lo
pc at all. The detailed findings are:
- gcc >= 4.4: produces DW_AT_ranges and .debug_aranges
- 4.1 <= gcc < 4.4: no DW_AT_ranges, no DW_AT_high_pc, .debug_aranges
  present. The upper version range here is uncertain as godbolt.org does
  not have intermediate versions.
- gcc < 4.1: no versions on godbolt.org
- clang >= 3.5: produces DW_AT_ranges, and (optionally) .debug_aranges
- 3.4 <= clang < 3.5: no DW_AT_ranges, no DW_AT_high_pc, .debug_aranges
  present.
- clang <= 3.3: no DW_AT_ranges, no DW_AT_high_pc, no .debug_aranges
- icc >= 16.0.1: produces DW_AT_ranges
- icc < 16.0.1: no functional versions on godbolt.org (some are present
  but fail to compile)

Based on this analysis, I believe it is safe to start trusting
DW_AT_low/high_pc information in dwarf as well as remove the code for
manually reconstructing range information by traversing the DIE
structure, and just keep the line table fallback. The only compilers
where this will change behavior are pre-3.4 clangs, which are almost 7
years old now. However, the functionality should remain unchanged
because we will be able to reconstruct this information from the line
table, which seems to be needed for some line-tables-only scenarios
anyway (haven't researched this too much, but at least some compilers
seem to emit DW_AT_ranges even in these situations).

In addition, benchmarks showed that for these compilers computing the
ranges via line tables is noticably faster than doing so via the DIE
tree.

Other advantages include simplifying the code base, removing some
untested code (the only test changes are recent tests with overly
reduced synthetic dwarf), and increasing llvm convergence.

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78489
2020-04-23 16:12:41 +02:00
Pavel Labath f512b978b0 [lldb/Utility] Improve error_code->Status conversion
Both entities have the notion of error "namespaces". Map the errno
namespace correctly.
2020-04-23 16:12:41 +02:00
Pavel Labath c9e6b7010c [lldb/Host] Modernize some socket functions
return Expected<Socket> instead of a Status object plus a Socket*&
argument.
2020-04-23 14:20:26 +02:00
Raphael Isemann e327ea4a82 [lldb] Fix typo in breakpoint set -r description 2020-04-23 12:06:27 +02:00
Jonas Devlieghere b424b0bf73 [lldb/Target] Avoid race between Communication::Disconnect calls.
Avoid a race between the Disconnect call in `Communication::ReadThread`
and the one in `Process::ShouldBroadcastEvent` by reordering the calls
to Disconnect and StopReadThread in `Process::ShouldBroadcastEvent`.

In D77295 Pavel suggested that that might explain the broken pipe I was
seeing. Indeed, changing the order resolved the issue.
2020-04-22 16:56:42 -07:00
Muhammad Omair Javaid 478619cf9a Revert "get rid of PythonInteger::GetInteger()"
This reverts commit 7375212172.

This causes multiple test failures on LLDB AArch64 Linux buildbot.
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/3695

Differential Revision: https://reviews.llvm.org/D78462
2020-04-23 04:38:32 +05:00
Jonas Devlieghere e57361c055 [lldb/Host] Remove TaskPool and replace its uses with llvm::ThreadPool
Remove LLDB's TaskPool and replace its uses with LLVM's ThreadPool.

Differential revision: https://reviews.llvm.org/D78337
2020-04-22 09:17:49 -07:00
Christopher Tetreault 2dea3f1298 [SVE] Add new VectorType subclasses
Summary:
Introduce new types for fixed width and scalable vectors.

Does not remove getNumElements yet so as to not break code during transition
period.

Reviewers: deadalnix, efriedma, sdesmalen, craig.topper, huntergr

Reviewed By: sdesmalen

Subscribers: jholewinski, arsenm, jvesely, nhaehnle, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, kerbowa, Joonsoo, grosul1, frgossen, lldb-commits, tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D77587
2020-04-22 08:59:01 -07:00
Jan Kratochvil d482fe2add [nfc] [lldb] DWARF callbacks: DIERef -> DWARFDIE
Pavel Labath wrote in D73206:
The internal representation of DebugNames and Apple indexes is fixed by
the relevant (pseudo-)standards, so we can't really change it. The
question is how to efficiently (and cleanly) convert from the internal
representation to some common thing. The conversion from AppleIndex to
DIERef is trivial (which is not surprising as it was the first and the
overall design was optimized for that). With debug_names, the situation
gets more tricky. The internal representation of debug_names uses
CU-relative DIE offsets, but DIERef wants an absolute offset. That means
the index has to do more work to produce the common representation. And
it needs to do that for all results, even though a lot of the index
users are really interested only in a single entry. With the switch to
user_id_t, _all_ indexes would have to do some extra work to encode it,
only for their users to have to immediately decode it back. Having
a iterator/callback based api would allow us to minimize the impact of
that, as it would only need to happen for the entries that are really
used. And /I think/ we could make it interface returns DWARFDies
directly, and each index converts to that using the most direct approach
available.

Jan Kratochvil:
It also makes all the callers shorter as they no longer need to fetch
DWARFDIE from DIERef (and handling if not found by ReportInvalidDIERef)
but the callers are already served DWARFDIE which they need.
In some cases the DWARFDIE had to be fetched both by callee (DWARFIndex
implementation) and caller.

Differential Revision: https://reviews.llvm.org/D77970
2020-04-22 17:11:50 +02:00
Raphael Isemann a53874b7e4 [lldb] Fix modules build by adding missing include
This header is using FileSpec so we should at least include the forward header.
2020-04-22 09:14:09 +02:00
Lawrence D'Anna 7375212172 get rid of PythonInteger::GetInteger()
Summary:
One small step in my long running quest to improve python exception handling in
LLDB.  Replace GetInteger() which just returns an int with As<long long> and
friends, which return Expected types that can track python exceptions

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78462
2020-04-21 16:55:51 -07:00
Jonas Devlieghere b707cf096d [lldb/Test] Add decorator to the right method 2020-04-21 15:05:32 -07:00
Jonas Devlieghere 1e566f6b47 [lldb/Test] Add skipIfReproducer for tests that diverge during replay
Add the skipIfReproducer decorator to the remaining tests that fail to
replay because the GDB remote packets diverge during replay. This is
*not* expected and should be fixed, but figuring out exactly what caused
the divergence has proven pretty difficult to track down.

I've marked these tests as skipped for now so we can get clean results
and detect new regressions. I have no evidence to believe that these
failures have the same root cause, so I've not assigned them a PR.
2020-04-21 14:42:14 -07:00
Jonas Devlieghere 400b6f2bc5 [lldb/Test] Add skipIfReproducer for tests that are not expected to work
Some tests are not expected to work with reproducers, for example tests
that completely circumvent the reproducers (i.e. using the side_effects
Python module) or that rely on changes to the file system.
2020-04-21 14:42:14 -07:00
Jonas Devlieghere 116c2da4b2 [lldb/Scripts] proc.returncode is set in proc.communicate
Make sure proc.returncode has been assigned before we compare it to 0.
2020-04-21 11:30:15 -07:00
Jonas Devlieghere 2de52422ac [lldb/Test] Decode stdout and stderr in case it contains Unicode.
Lit's to_string will just return the string when it's a `str` instance,
which in Python 2 can still contain UTF-8 characters.

Differential revision: https://reviews.llvm.org/D76955
2020-04-21 08:32:30 -07:00
Jonas Devlieghere e687aa8282 [lldb/Reproducers] Fix passive replay for (char*, size_t) functions.
Several SB API functions return strings using (char*, size_t) output
arguments. During capture, we serialize an empty string for the char*
because the memory can be uninitialized.

During active replay, we have custom replay redirects that ensure that
we don't override the buffer from which we're reading, but rather write
to a buffer on the heap with the given length. This is sufficient for
the active reproducer use case, where we only care about the side
effects of the API calls, not the values actually returned.

This approach does not not work for passive replay because here we
ignore all the incoming arguments, and re-execute the current function
with the arguments deserialized from the reproducer. This means that
these function will update the deserialized copy of the arguments,
rather than whatever was passed in by the SWIG wrapper.

To solve this problem, this patch extends the reproducer instrumentation
to handle this special case for passive replay. We nog ignore the
replayer in the registry and the incoming char pointer, and instead
reinvoke the current method on the deserialized class, and populate the
output argument.

Differential revision: https://reviews.llvm.org/D77759
2020-04-20 13:26:11 -07:00
Jonas Devlieghere e128d53895 [lldb/Test] Don't friend std::make_unique
This wasn't a great idea to begin with, as you can't really rely on the
implementation, but since it also doesn't work with MSVC I've just made
the ctors public.
2020-04-20 11:48:52 -07:00
Jonas Devlieghere 950a8aa165 [lldb/Reproducers] Support new replay mode: passive replay
Support passive replay as proposed in the RFC [1] on lldb-dev and
described in more detail on the lldb website [2].

This patch extends the LLDB_RECORD macros to re-invoke the current
function with arguments deserialized from the reproducer. This relies on
the function being called in the exact same order as during replay. It
uses the same mechanism to toggle the API boundary as during recording,
which guarantees that only boundary crossing calls are replayed.

Another major change is that before this patch we could ignore the
result of an API call, because we only cared about the observable
behavior. Now we need to be able to return the replayed result to the
SWIG bindings.

We reuse a lot of the recording infrastructure, which can be a little
confusing. We kept the existing naming to limit the amount of churn, but
might revisit that in a future patch.

[1] http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html
[2] https://lldb.llvm.org/resources/reproducers.html

Differential revision: https://reviews.llvm.org/D77602
2020-04-20 09:41:40 -07:00
Jonas Devlieghere 4cfb71adba [lldb/Scripts] Add verbose and failure only mode to replay script.
Add two modes to the reproducer replay script that make debugging a
little easier. Verbose mode prints stdout and stderr, regardless of
whether replay was successful. When --failure-only is passed, output is
limited to tests that failed to replay.
2020-04-20 09:03:48 -07:00
Emre Kultursay 865996ddf6 [lldb] Remove m_last_file_sp from SourceManager
Summary:
...and replace it with m_last_file_spec instead.

When Source Cache is enabled, the value stored in m_last_file_sp is
already in the Source Cache, and caching it again in SourceManager
brings no extra benefit. All we need is to "remember" the last used
file, and FileSpec can serve the same purpose.

When Source Cache is disabled, the user explicitly requested no caching
of source files, and therefore, m_last_file_sp should NOT be used.

Bug: llvm.org/PR45310

Depends on D76805.

Reviewers: labath, jingham

Reviewed By: jingham

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76806
2020-04-20 16:27:19 +02:00
Emre Kultursay 1f820fa4fe [lldb] Fix SourceManager::SourceFileCache insertion
Summary:
Lookup and subsequent insert was done using uninitialized
FileSpec object, which caused the cache to be a no-op.

Bug: llvm.org/PR45310

Depends on D76804.

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: mgorny, jingham, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76805
2020-04-20 16:25:54 +02:00
Emre Kultursay acae69d08c [lldb] Add new LLDB setting: use-source-cache
Summary:
LLDB memory-maps large source files, and at the same time, caches
all source files in the Source Cache.

On Windows, memory-mapped source files are not writeable, causing
bad user experience in IDEs (such as errors when saving edited files).
IDEs should have the ability to disable the Source Cache at LLDB
startup, so that users can edit source files while debugging.

Bug: llvm.org/PR45310

Reviewers: labath, JDevlieghere, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76804
2020-04-20 16:24:25 +02:00
Pavel Labath 9cd9f3f1b8 [lldb] Fix gcc warnings in TypeCategory.cpp
The cleanup in 3e3701f8a0 left these variable unused.
2020-04-20 16:12:51 +02:00
Yuri Per 6afa5c407c [lldb] Prefer executable files from sysroot over files from local filesystem
Summary:
In D49685 sysroot behaviour was partially fixed. But files from local filesystem with same path still has priority over files from sysroot.

This patch fixes it by removing fallback to local filesystem from RemoteAwarePlatform::GetModuleSpec(). It is not actually required because higher level code do such fallback itself. See, for example, resolver in Platform::GetSharedModule().

Reviewers: labath, clayborg, EugeneBi

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77529
2020-04-20 16:12:51 +02:00
Jan Kratochvil 239093f30c [lldb] [testsuite] Fix a regression of TestCppScope.py
This is a regression since:
  [lldb][NFC] Modernize lang/cpp/scope test
  acb0b99c8e
  rGacb0b99c8e4f

  File "/home/jkratoch/redhat/llvm-monorepo/lldb/test/API/lang/cpp/scope/TestCppScope.py", line 19, in test
    self.assertEqual(global_var_names, expected_var_names)
  AssertionError: Lists differ: ['C::a', 'A::a', 'B::a', '::a'... != ['A::a', 'B::a', 'C::a', '::a'...
  First differing element 0:
  C::a
  A::a
  - ['C::a', 'A::a', 'B::a', '::a']
  + ['A::a', 'B::a', 'C::a', '::a']

ManualDWARFIndex using NameToDIE does not sort alphabetically:
    // This is only for uniqueness, not lexicographical ordering, so we can
    // just compare pointers.
    return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString());
2020-04-18 10:46:32 +02:00
Jan Kratochvil eef9cb1628 [lldb] [testsuite] Fix TestFixIts.py on Linux
Since D77214 there is a testsuite regression for TestFixIts.py
on Fedora 31 x86_64.
    File "/home/jkratoch/redhat/llvm-monorepo/lldb/test/API/commands/expression/fixits/TestFixIts.py", line 148, in test_with_target
      self.assertEquals(value.GetError().GetCString(), "error: No value")
  AssertionError: 'error: error: Multiple internal symbols found for \'d\'\nid = {0x00000d2a}, ran [truncated]... != 'error: No value'

That is because Fedora glibc incl. libm.so contains also ELF debug
symbols and there exists a 'd' symbol:
  (gdb) p d
  $1 = {i = {0, 1076887552}, d = 16}
  (gdb) p &d
  $2 = (const number *) 0x7ffff78e8bc0 <d>
  (gdb) info sym 0x7ffff78e8bc0
  d in section .rodata of /lib64/libm.so.6

  $ nm /lib64/libm.so.6 |grep ' d$'
  00000000000bfbc0 r d
  00000000000caa20 r d
  00000000000caa20 r d
  00000000000caa20 r d

  glibc-build$ for i in `find -name "*.o"`;do nm 2>/dev/null $i|grep ' d$' && echo $i;done
  0000000000000080 r d
  ./math/s_atan-fma4.o
  0000000000000080 r d
  ./math/s_atan-avx.o
  0000000000000080 r d
  ./math/s_atan.o
2020-04-18 08:32:12 +02:00
Adrian Prantl 681466f5e6 Allow lldb-test to combine -find with -dump-clang-ast
This patch threads an lldb::DescriptionLevel through the typesystem to
allow dumping the full Clang AST (level=verbose) of any lldb::Type in
addition to the human-readable source description (default
level=full). This type dumping interface is currently not exposed
through the SBAPI.

The application is to let lldb-test dump the clang AST of search
results. I need this to test lazy type completion of clang types in
subsequent patches.

Differential Revision: https://reviews.llvm.org/D78329
2020-04-17 11:01:20 -07:00
Erich Keane 5f0903e9be Reland Implement _ExtInt as an extended int type specifier.
I fixed the LLDB issue, so re-applying the patch.

This reverts commit a4b88c0449.
2020-04-17 10:45:48 -07:00
Jonas Devlieghere 9eaf0abebf Revert "[lldb/Utility] Provide a stringify_append overload for function pointers."
Temporarily reverts commit d10386e177
because it breaks the Windows build. MSVC complains about an ambiguous
call to an overloaded function.
2020-04-16 17:52:09 -07:00
Davide Italiano ce7790044f [DWARF] Rename a function and comment it for clarity.
Pointed out by Adrian.
2020-04-16 15:37:09 -07:00
Jonas Devlieghere d10386e177 [lldb/Utility] Provide a stringify_append overload for function pointers.
Converting a function pointer to an object pointer is illegal as nothing
requires it to be in the same address space. Add an overload for
function pointers so we don't convert do this illegal conversion, and
simply print out "function pointer".
2020-04-16 15:35:51 -07:00
Jason Molenda 7fa342bd2a Remove attach-failed-due-to-SIP checks which were not working
The SIP debugserver was calling in attach_failed_due_to_sip
haven't worked for a while; remove them.  To check this
properly we'd need debugsever to call out to codesign(1) to
inspect the entitlements, or the equivalant API,
and I'm not interested in adding that at this point.  SIP
is has been the default on macOS for a couple of releases
and it's expected behavior now.

<rdar://problem/59198052>
2020-04-16 15:22:14 -07:00
Jonas Devlieghere 9f6a308457 [lldb/Utility] Fix a bug in stringify_append for printing addresses.
The recent change in the API macros revealed that we were not printing
the pointer address for a bunch of methods, but rather the address of
the pointer. It's something I had already noticed while looking at some
reproducer traces, but hadn't made it to the top of my list yet. This
fixes the issue by providing a more specific overload.
2020-04-16 14:03:55 -07:00
Davide Italiano 1fae85a853 [DWARF] Add instructions to regenerate this test, if needed. 2020-04-16 13:31:32 -07:00
Davide Italiano 8cac6d1875 [Shell] Remove incorrectly cargo-culted UNSUPPORTED.
Let's see if this sticks on the bots.
2020-04-16 13:22:46 -07:00
Jonas Devlieghere 3a6b60fa62 [lldb/Docs] Add some more info about the test suite structure
Expand on the structure of the LLDB test suite. So far this information
has been mostly "tribal knowledge". By writing it down I hope to make it
easier to understand our test suite for anyone that's new to the
project.
2020-04-16 10:17:59 -07:00
Jonas Devlieghere a3237f861c [lldb/Reproducers] Simplify LLDB_RECORD macros
Redefine the LLDB_RECORD macros in terms of a common uber-macro to
reduce code duplication across them.

Differential revision: https://reviews.llvm.org/D78141
2020-04-16 09:55:28 -07:00
Pavel Labath d5c26f871b [lldb/unittests] Better error messages when creating sockets fails
We get failures in SocketTestUtilities on the pre-merge bots. This
might give us a clue as to what's wrong.
2020-04-16 11:59:37 +02:00
Walter Erquinigo acfee72a05 Another attempt of D77452 - da0e91fee6
[intel-pt] Improve the way the test determines whether to run

- Now I'm creating a default value for the new test parameter
- I fixed a small mistake in the skipping logic of the test

... I forgot to clear the cmake cache when testing my diff
2020-04-15 17:52:36 -07:00
Walter Erquinigo f17a85cf36 Revert "[intel-pt] Improve the way the test determines whether to run"
This reverts commit da0e91fee6.

There's a failure in
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/8584
caused by a missing python object.
2020-04-15 16:35:29 -07:00
Walter Erquinigo da0e91fee6 [intel-pt] Improve the way the test determines whether to run
Summary:
@labath raised a concern on the way I was skipping this test. I think that was
fair and I found a better way.
Now I'm skipping if the CMAKE flag LLDB_BUILD_INTEL_PT is false.
I added an enabled_plugins entry in the dotest configuration, which gets
set by lit or lldb-dotest. The only available plugin right now is
'intel-pt', but I imagine it will be useful in the future for other
kinds of plugins that get determined at configuration time. I didn't
want to add a new argument option --enable-intel-pt or something or the
sort, as it wouldn't be useful for other cases.

Reviewers: labath, clayborg

Subscribers: lldb-commits, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77452
2020-04-15 16:03:31 -07:00
Jan Kratochvil 5e04b5f2fa [nfc] [lldb] Introduce DWARF callbacks (fixed-up)
As requested by @labath in https://reviews.llvm.org/D73206#1949516
providing DWARF index callbacks refactorization.

It is a re-landing of the patch with a regression fix the previous
commit had.

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 23:40:54 +02:00
Jonas Devlieghere 1349ca4359 [lldb/Docs] Split testing in running and debugging
Separate running the tests from debugging the test. This is preparatory
for a new section coming soon.
2020-04-15 13:48:58 -07:00
Jonas Devlieghere 7ce1a93efd [lldb/Scripts] Add script to replay multiple reproducers
Script to replay reproducers in parallel using the command line driver.
This is used for active replay (stage 1 as described in the RFC on
lldb-dev [1]).

[1] http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html

Differential revision: https://reviews.llvm.org/D77608
2020-04-15 10:55:41 -07:00
Jan Kratochvil 9289f34390 Revert "[nfc] [lldb] Introduce DWARF callbacks"
This reverts commit bd47c470d1.

It broke Green Dragon, reason is unknown to me so far:
  http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/15323/consoleFull

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 15:12:59 +02:00
Pavel Labath ff18a6acea [lldb] Fix -Wparentheses in ThreadPlanStack.cpp 2020-04-15 12:47:57 +02:00
Jan Kratochvil bd47c470d1 [nfc] [lldb] Introduce DWARF callbacks
As requested by @labath in https://reviews.llvm.org/D73206#1949516
providing DWARF index callbacks refactorization.

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 10:37:38 +02:00
Raphael Isemann 3e3701f8a0 [lldb][NFC] Remove FormatterChoiceCriterion
Summary:
The formatters code has a lot of 'reason' or 'why' values that we keep or-ing FormatterChoiceCriterion
enum values into. These values are only read by a single log statement and don't have any functional
purpose. It also seems the implementation is not finished (for example, display names and type
names don't have any dedicated enum values). Also everything is of course not tested or documented.

Let's just remove all of this.

Reviewers: labath, JDevlieghere, jingham, davide, vsk

Reviewed By: labath, vsk

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D77968
2020-04-15 09:47:15 +02:00
Jason Molenda 1cd92e480c Bug where insn-based unwind plans on arm64 could be wrong
Fix a bug where UnwindAssemblyInstEmulation would confuse which
register is used to compute the Canonical Frame Address after it
had branched over a mid-function epilogue (where the CFA reg changes
from $fp to $sp in the process of epiloguing).  Reinstate the
correct CFA register after we forward the unwind rule for branch
targets.  The failure mode was that UnwindAssemblyInstEmulation
would think CFA was set in terms of $sp after one of these epilogues,
and if it sees modifications to $sp after the branch target, it would
change the CFA offset in the unwind rule -- even though the CFA is
defined in terms of $fp and the $sp changes are irrelevant to correct
calculation.

<rdar://problem/60300528>

Differential Revision: https://reviews.llvm.org/D78077
2020-04-14 16:57:25 -07:00
Adrian Prantl 81aba6cd72 Initiallize property getters as being property accessors (NFC)
This is a no-op because it is set later on unconditionally again, but
it's far less confusing this way and consistent with how the setters
are initialized.
2020-04-14 15:56:17 -07:00
Jonas Devlieghere ca99a70237 [lldb/Test] s/lldb-repo/lldb-repro/ (NFC) 2020-04-14 14:51:41 -07:00
Jonas Devlieghere cc220d4031 [lldb/Test] Use RAII for reproducer instrumentation data in unittest.
Use a RAII object to manage the lifetime of the reproducer
instrumentation data.
2020-04-14 14:46:39 -07:00
David Blaikie 208a11ab3a Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3.

I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
2020-04-14 14:44:32 -07:00
Walter Erquinigo cea112f422 [lldb] Fix a typo in a test name
Summary:
Removing the Test prefix from the file name and its usages. The standard is using only Test as a suffix.
This was correctly pointed out in https://reviews.llvm.org/D77444.

Reviewers: labath, clayborg

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77878
2020-04-14 12:18:58 -07:00
Isuru Fernando 664fda72ea Fix setting Python3_ROOT_DIR on Windows
Summary:
Previously the value of Python3_ROOT_DIR was set to the string
"PYTHON_HOME" instead of the value of the variable named
PYTHON_HOME. This commit fixes that as CMake expects
a path as the value of Python3_ROOT_DIR

Reviewers: #lldb, JDevlieghere, teemperor

Reviewed By: #lldb, JDevlieghere, teemperor

Subscribers: teemperor, JDevlieghere, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77842
2020-04-14 12:50:54 -05:00
Jonas Devlieghere ba10840eeb [lldb/Reproducers] Make static methods go through the invoke wrapper.
They don't actually have to, but it makes it easier to unify the
corresponding code and macros. NFC.
2020-04-14 10:22:04 -07:00
Jonas Devlieghere fc41013893 [lldb/Reproducers] Capture reproducers from the API test suite.
Make it possible to capture reproducers from the API test suite. Given
the symmetry between capture and replay, this patch also adds the
necessary code for replay. For now this is a NO-OP until the
corresponding reproducer instrumentation changes land.

For more info please refer to the RFC on lldb-dev:
http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html

Differential revision: https://reviews.llvm.org/D77588
2020-04-14 09:24:23 -07:00
Jonas Devlieghere c5a3991895 [lldb/Docs] Document active and passive replay.
Document reproducer replay and its two modes.

Differential revision: https://reviews.llvm.org/D77771
2020-04-14 08:40:26 -07:00
Med Ismail Bennani f0be92ebcd [lldb/test] Fix TestLoadUnload
Summary:
[lldb/test] Fix TestLoadUnload failure introduced in e0dbd02513

It seems that `env_cmd_string` is declared and used few lines under this
self.runCmd expression. I guess this is some left-over from an older
version.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Reviewers: labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78094
2020-04-14 13:53:51 +02:00
Muhammad Omair Javaid 01cfe88a17 [LLDB] Remove xfail aarch64-linux from test_step_over_load*
test_step_over_load_with_svr4 and test_step_over_load now pass on
aarch64 linux.

Fixed by change-id: e0dbd02513

Differential Revision: https://reviews.llvm.org/D77662
2020-04-14 16:21:06 +05:00
Pavel Labath e0dbd02513 [lldb/test] Make TestLoadUnload compatible with windows
Summary:
This patch introduces a header "dylib.h" which can be used in tests to
handle shared libraries semi-portably. The shared library APIs on
windows and posix systems look very different, but their underlying
functionality is relatively similar, so the mapping is not difficult.

It also introduces two new macros to wrap the functinality necessary to
export/import function across the dll boundary on windows. Previously we
had the LLDB_TEST_API macro for this purpose, which automagically
changed meaning depending on whether we were building the shared library
or the executable. While convenient for simple cases, this approach was
not sufficient for the more complicated setups where one deals with
multiple shared libraries.

Lastly it rewrites TestLoadUnload, to make use of the new APIs. The
trickiest aspect there is the handling of DYLD_LIBRARY_PATH on macos --
previously setting this variable was not needed as the test used
@executable_path-relative dlopens, but the new generic api does not
support that. Other systems do not support such dlopens either so the
test already contained support for setting the appropriate path
variable, and this patch just makes that logic more generic. In doesn't
seem that the purpose of this test was to exercise @executable_path
imports, so this should not be a problem.

These changes are sufficient to make some of the TestLoadUnload tests
pass on windows. Two other tests will start to pass once D77287 lands.

Reviewers: amccarth, jingham, JDevlieghere, compnerd

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77662
2020-04-14 11:10:59 +02:00
Muhammad Omair Javaid 29bb046fe9 [LLDB] Remove xfail aarch64/linux from TestThreadPlanCommands.py 2020-04-13 14:30:50 +05:00
Jim Ingham aa4b37b2ac Convert the ThreadPlanCommands test to use a scripted plan
that pushes a step over plan.  Relax the listing checker
so it will look past any entries after the ones listed in
the input patterns.  Then for the internal plans just check
for the StepOver plan that our scripted plan pushes, and look past
any others.

This should make the test more robust on systems that don't use the
step-in then push a step-out plan to step over a function.
2020-04-10 18:15:03 -07:00
Jim Ingham f7de4b5d6b Thread Plans pushed by a scripted plan should be private plans.
If a plan is not private, "thread plan discard" can discard it.  It would
not be hard to write reliable scripted plan if its subplans could get
removed out from under it.
2020-04-10 18:15:03 -07:00
Jonas Devlieghere f78fcd6906 [lldb/Test] Rewrite ReproducerInstrumentationTest
The instrumentation unit tests' current implementation uses global
variables to track constructor calls for the instrumented classes during
replay. This is suboptimal because it indirectly relies on how the
reproducer instrumentation is implemented. I found out when adding
support for passive replay and the test broke because we made an extra
(temporary) copy of the instrumented objects.

Additionally, the old approach wasn't very self-explanatory. It took me
a bit of time to understand why we were expecting the number of objects
in the test.

This patch rewrites the test and uses the index-to-object-mapping to
verify the objects created during replay. You can now specify the
expected objects, in order, and whether they should be valid or not. I
find that it makes the tests much easier to understand. More
importantly, this approach is resilient to implementation detail changes
in the instrumentation.
2020-04-10 16:50:44 -07:00
Adrian Prantl f5be71b445 Attempt to fix a compile error reported with older compilers and libstdc++ 2020-04-10 10:34:44 -07:00
Raphael Isemann 02d152bb1b [lldb] Make some asserts in TestFixIts more expressive 2020-04-10 19:16:33 +02:00
Raphael Isemann a0c6ebd58f [lldb] Refactor TestFixIts so that most of it can run on aarch64-linux
The final function call to `test_X` is failing on aarch64-linux with SIGILL.
Function calls to previous expressions seem to just not work on aarch64-linux
but I don't see another way to test the multiple-run Fix-Its.

This patch refactors the test that the skipIf for aarch64 Linux only covers
the part of the test that was added D77214.
2020-04-10 13:38:45 +02:00
Med Ismail Bennani a4da4e3292 [lldb/Reproducers] Fix typo introduced when disabling register failing tests 2020-04-10 08:37:06 +02:00
Med Ismail Bennani 6612b826d0 [lldb] Reformat 'Fix breakage introduced by llvm::LoadInst api change' (NFC) 2020-04-10 00:37:08 +02:00
Med Ismail Bennani 0d525ce068 [lldb] Fix breakeage introduced by llvm::LoadInst api change 2020-04-10 00:11:00 +02:00
Med Ismail Bennani 98b47f447c [lldb/test] Fix typo to disable reproducer's test phase 2020-04-09 21:54:45 +02:00
Med Ismail Bennani 68c04a4f73 [lldb] Disable failing register tests for reproducers 2020-04-09 21:05:17 +02:00
Jan Kratochvil 8fbac4e1a2 [nfc] [lldb] Unindent code
It removes some needless deep indentation and some redundant statements.
It prepares the code for a more clean next patch - DWARF index callbacks
D77327.

Differential Revision: https://reviews.llvm.org/D77326
2020-04-09 20:43:00 +02:00
Adrian Prantl 143d507c9f Preserve the owning module information from DWARF in the synthesized AST
Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
1;95;0csets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

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

rdar://problem/59634380

Differential Revision: https://reviews.llvm.org/D75488
2020-04-09 11:09:44 -07:00
Jonas Devlieghere 680082a408 [lldb/Reproducers] Add a small artificial delay before exiting
Add a small artificial delay in replay mode before exiting to ensure
that all asynchronous events have completed. This should reduce the
level of replay flakiness on some of the slower bots.
2020-04-09 11:03:24 -07:00
Pavel Labath 9aa5fbb3af [lldb] Disable the new Communication test on windows
The ConnectionFileDescriptor class on windows does not support
interruption (see the BytesAvailable method). Therefore this test makes
no sense there.
2020-04-09 15:19:24 +02:00
Pavel Labath a9406daaa6 [lldb] Add parts accidentally left out of 769d704: Recommit "[lldb/Core] Fix a race in the Communication class"
I went to a great length to explain the reason why these changes were
needed, but I did not actually ammend the patch to include them. :(
2020-04-09 14:45:23 +02:00
Pavel Labath 769d7041cc Recommit "[lldb/Core] Fix a race in the Communication class"
The synchronization logic in the previous had a subtle bug. Moving of
the "m_read_thread_did_exit = true" into the critical section made it
possible for some threads calling SynchronizeWithReadThread call to get
stuck. This could happen if there were already past the point where they
checked this variable. In that case, they would block on waiting for the
eBroadcastBitNoMorePendingInput event, which would never come as the
read thread was blocked on getting the synchronization mutex.

The new version moves that line out of the critical section and before
the sending of the eBroadcastBitNoMorePendingInput event, and also adds
some comments to explain why the things need to be in this sequence:
- m_read_thread_did_exit = true: prevents new threads for waiting on
  events
- eBroadcastBitNoMorePendingInput: unblock any current thread waiting
  for the event
- Disconnect(): close the connection. This is the only bit that needs to
  be in the critical section, and this is to ensure that we don't close
  the connection while the synchronizing thread is mucking with it.

Original commit message follows:

Communication::SynchronizeWithReadThread is called whenever a process
stops to ensure that we process all of its stdout before we report the
stop. If the process exits, we first call this method, and then close
the connection.

However, when the child process exits, the thread reading its stdout
will usually (but not always) read an EOF because the other end of the
pty has been closed. In response to an EOF, the Communication read
thread closes it's end of the connection too.

This can result in a race where the read thread is closing the
connection while the synchronizing thread is attempting to get its
attention via Connection::InterruptRead.

The fix is to hold the synchronization mutex while closing the
connection.

I've found this issue while tracking down a rare flake in some of the
vscode tests. I am not sure this is the cause of those failures (as I
would have expected this issue to manifest itself differently), but it
is an issue nonetheless.

The attached test demonstrates the steps needed to reproduce the race.
It will fail under tsan without this patch.

Reviewers: clayborg, JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77295
2020-04-09 13:39:00 +02:00
Pavel Labath 76975c744d Revert "[lldb/Core] Fix a race in the Communication class"
This reverts commit ebb071345c -- it seems
to introduce a deadlock in some circumstances.
2020-04-09 12:49:56 +02:00
Pavel Labath ebb071345c [lldb/Core] Fix a race in the Communication class
Summary:
Communication::SynchronizeWithReadThread is called whenever a process
stops to ensure that we process all of its stdout before we report the
stop. If the process exits, we first call this method, and then close
the connection.

However, when the child process exits, the thread reading its stdout
will usually (but not always) read an EOF because the other end of the
pty has been closed. In response to an EOF, the Communication read
thread closes it's end of the connection too.

This can result in a race where the read thread is closing the
connection while the synchronizing thread is attempting to get its
attention via Connection::InterruptRead.

The fix is to hold the synchronization mutex while closing the
connection.

I've found this issue while tracking down a rare flake in some of the
vscode tests. I am not sure this is the cause of those failures (as I
would have expected this issue to manifest itself differently), but it
is an issue nonetheless.

The attached test demonstrates the steps needed to reproduce the race.
It will fail under tsan without this patch.

Reviewers: clayborg, JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77295
2020-04-09 12:06:47 +02:00
Shu Anzai 1d3b7370c4 [lldb] Fixing the bug that the "log timer" has no tab completion
I fixed the bug that the "log timer" has no tab command.

Original code has the only CommandObjectLogTimer class, but it is not
sufficient. Thus I divided the content of CommandObjectLog class into
CommandObjectLogEnable class, CommandObjectLogDisable class,
CommandObjectLogDump class, CommandObjectLogReset class,
CommandObjectLogIncrement class.

Reviewed by: teemperor

Differential Revision: https://reviews.llvm.org/D76906
2020-04-09 08:58:52 +02:00
Jonas Devlieghere e7db1aec3b [lldb/Docs] Elaborate on reproducer testing 2020-04-08 20:10:52 -07:00
Jonas Devlieghere b0bdaf9ba2 [lldb/Python] Add lldbconfig module to make the lldb module configurable
Using the approach suggested by Pavel in D77588, this patch introduces a
new lldbconfig module that lives next to the lldb module. It makes it
possible to make the lldb module configurable before importing it. More
specifically it makes it possible to delay initializing the debugger,
which is needed for testing the reproducer.

Differential revision: https://reviews.llvm.org/D77661
2020-04-08 15:59:24 -07:00
Eric Christopher ff1658b167 Fix -Wdeprecated-copy warning in XcodeSDK. 2020-04-08 15:12:53 -07:00
Davide Italiano d51b38f1b3 [DWARF] Not all the constant variables are "static".
Fixes rdar://problem/61402307

Differential Revision: https://reviews.llvm.org/D77698
2020-04-08 11:07:19 -07:00
Walter Erquinigo be3f8a8e1b [commands] Support autorepeat in SBCommands
Summary:
This adds support for commands created through the API to support autorepeat.
This covers the case of single word and multiword commands.

Comprehensive tests are included as well.

Reviewers: labath, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77444
2020-04-08 10:54:14 -07:00
Walter Erquinigo 8e40987e18 Fix e796c77b26
Failure:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/14556/testReport/junit/lldb-api/tools_lldb-vscode_breakpoint-events/TestVSCode_breakpointEvents_py/

Diff:
[lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request
https://reviews.llvm.org/D76968

It failed a test TestVSCode_breakpointEvents that only runs Darwin that needed to be updated to match the current logic.
The change is simple.
2020-04-08 10:48:01 -07:00
Walter Erquinigo e796c77b26 [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request
Summary:
When using source maps for a breakpoint, in order to find the actual source that breakpoint has resolved, we
need to use a query similar to what CommandObjectSource::DumpLinesInSymbolContexts does, which is the logic
used by the CLI to display the source line at a given breakpoint. That's necessary because from a breakpoint
location you only have an address, which points to the original source location, not the source mapped one.

in the setBreakpoints request handler, we haven't been doing such query and we were returning the original
source location, which was breaking the UX of VSCode, as many breakpoints were being set but not displayed
in the source file next to each line. Besides, clicking the source path of a breakpoint in the breakpoints
view in the debug tab was not working for this case, as VSCode was trying to open a non-existent file, thus
showing an error to the user.

Ideally, we should do the query mentioned above to find the actual source location to respond to the IDE,
however, that query is expensive and users can have an arbitrary number of breakpoints set. As a simpler fix,
the request sent by VSCode already contains the full source path, which exists because the user set it from
the IDE itself, so we can simply reuse it instead of querying from the SB API.

I wrote a test for this, and found out that I had to move SetSourceMapFromArguments after RunInitCommands in
lldb-vscode.cpp, because an init command used in all tests is `settings clear -all`, which would clear the
source map unless specified after initCommands. And in any case, I think it makes sense to have initCommands
run before anything the debugger would do.

Reviewers: clayborg, kusmour, labath, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76968
2020-04-08 09:52:59 -07:00
Davide Italiano f30ebf4378 [ManualDWARFIndex] Remove dead code, in preparation for moving this function. 2020-04-07 16:28:13 -07:00
Benjamin Kramer 873b79b867 Don't access reference to a vector after pop_back
This is undefined behavior. Found by asan's detect_container_overflow.
2020-04-07 23:10:58 +02:00
Lawrence D'Anna c8de17bca6 Fix illegal early call to PyBuffer_Release in swig typemaps
Summary:
The buffer protocol does not allow us to just call PyBuffer_Release
and assume the buffer will still be there.   Most things that implement the
buffer protocol will let us get away with that, but not all.   We need
to release it at the end of the SWIG wrapper.

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77480
2020-04-07 13:31:29 -07:00
Davide Italiano 30a292c25d [ScriptInterpreterPython] Remove buggy code to save/restore stdin.
Discussed on lldb-dev with Pavel Labath. This doesn't work for
background processes [causes Python to be stuck forever], and it's
unclear whether it's needed. There's no test, also. If this turns
out to be useful, it can be recommitted with a functional implementation
and a test.
2020-04-07 12:43:25 -07:00
Raphael Isemann 95054aeb07 [lldb][NFC] Fix typo in 'watchpoint delete' error message 2020-04-07 16:11:32 +02:00
Muhammad Omair Javaid e609fe68b2 Revert "[lldb-server] jThreadsInfo returns stack memory"
This reverts commit a53bf9b7c8.
2020-04-07 17:11:22 +05:00
Muhammad Omair Javaid 2a436a07ae Mark TestFixIts.py xfail for LLDB AArch64/Linux 2020-04-07 17:11:22 +05:00
Fred Riss 06ea05a3fb [lldb/test] Fix TestDSYMSourcePathRemapping in the presence of symlnks
My main work directory is on a separate partition, but I usually access
it through a symlink in my home directory. When running the tests,
either Clang or make resolves the symlink, and the real path of the
test directory ends up in the debug information.

This confuses this test as LLDB is trying to remap the real path, but
the remapping description uses the path with the symlink in
it. Calling realpath on the source path when constructing the
remapping description fixes it.
2020-04-06 19:50:34 -07:00
Saleem Abdulrasool 3775be2d8e Target: correct the return value for `GetImageAddrFromToken`
We would return `LLDB_INVALID_IMAGE_TOKEN` for the address rather than
the correct value of `LLDB_IMAGE_ADDRESS`.  This would result in the
check for the return value to silently pass on x64 as the invalid
address and invalid token are of different sizes (`size_t` vs
`uintprr_t`).  This corrects the return value to `LLDB_INVALID_ADDRESS`
and addresses the rest to reset the mapped address to the invalid value.

This was found by inspection when trying to implement module support for
Windows.
2020-04-06 17:37:57 -07:00
Adrian Prantl 469580a967 Add missing include 2020-04-06 17:29:31 -07:00
Jonas Devlieghere 29beabbe51 [lldb/API] Add missing LLDB_REGISTER_METHOD macros
Add LLDB_REGISTER_METHOD macros for GetRetriesWithFixIts and
SetRetriesWithFixIts.
2020-04-06 16:09:40 -07:00
Adrian Prantl 1e05d7b3d3 Remap the target (Xcode) SDK directory to the host SDK directory.
This is mostly useful for Swift support; it allows LLDB to substitute
a matching SDK it shipped with instead of the sysroot path that was
used at compile time.

The goal of this is to make the Xcode SDK something that behaves more
like the compiler's resource directory, as in that it ships with LLDB
rather than with the debugged program. This important primarily for
importing Swift and Clang modules in the expression evaluator, and
getting at the APINotes from the SDK in Swift.

For a cross-debugging scenario, this means you have to have an SDK for
your target installed alongside LLDB. In Xcode this will always be the
case.

rdar://problem/60640017

Differential Revision: https://reviews.llvm.org/D76471
2020-04-06 15:51:30 -07:00
Davide Italiano 41610d6650 [gdb-remote] Moving prevents copy elision. Found by clang. 2020-04-06 14:59:27 -07:00
Jonas Devlieghere 1b7560b877 [lldb/Test] Enable TestGdbRemoteThreadsInfoMemory.py on Windows.
This test is currently XFAILed but is passing on the Windows bot.
2020-04-06 14:29:09 -07:00
Jason Molenda 836534f997 Add more detailed symbol type categorization, based on a swift patch by
Greg Clayton a few years ago.

My patch to augment the symbol table in Mach-O files with the
dyld trie exports data structure only categorized symbols as code
or data, but Greg Clayton had a patch to do something similar to
swift a few years ago that had a more extensive categorization of
symbols, as well as extracting some objc class/ivar names from the
entries. This patch is basically just Greg's, updated a bit and
with a test case added to it.

<rdar://problem/50791451>

Differential Revision: https://reviews.llvm.org/D77369
2020-04-06 14:05:33 -07:00
Davide Italiano 6f9ea26002 [debugserver] Get rid of `else` after `return`. NFC. 2020-04-06 13:35:48 -07:00
Kazuaki Ishizaki e9264b746b [lldb] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77460
2020-04-07 01:06:16 +09:00
Konrad Kleine 9072df8ac1 [lldb][nfc] remove overriden funcs with default impl
Summary:
These `SearchFilter` methods all return `true` by their default
implementation:

```lang=c++
virtual bool ModulePasses(const FileSpec &spec);
virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
virtual bool AddressPasses(Address &addr);
virtual bool CompUnitPasses(FileSpec &fileSpec);
virtual bool CompUnitPasses(CompileUnit &compUnit);
```

That's why I've documented the default behavior and remove the overrides
(except for `AddressPasses`) in these `SearchFilter`-subclasses which all just
repeated the default implementation: `SearchFilterByModule`,
`SearchFilterByModuleList`.

Reviewers: jankratochvil, labath

Reviewed By: jankratochvil, labath

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77376
2020-04-06 10:05:59 -04:00
Jaroslav Sevcik a53bf9b7c8 [lldb-server] jThreadsInfo returns stack memory
This patch adds parts of the stack that should be useful for unwinding
to the jThreadsInfo reply from lldb-server. We return the top of the
stack (12 words), and we also try to walk the frame pointer linked list
and return the memory containing frame pointer and return address pairs.
The idea is to cover the cases with and without frame pointer omission.

Differential Revision: https://reviews.llvm.org/D74398
2020-04-06 15:43:19 +02:00
Raphael Isemann 203a8adb65 [lldb] Add option to retry Fix-Its multiple times to failed expressions
Summary:
Usually when Clang emits an error Fix-It it does two things. It emits the diagnostic and then it fixes the
currently generated AST to reflect the applied Fix-It. While emitting the diagnostic is easy to implement,
fixing the currently generated AST is often tricky. That causes that some Fix-Its just keep the AST as-is or
abort the parsing process entirely. Once the parser stopped, any Fix-Its for the rest of the expression are
not detected and when the user manually applies the Fix-It, the next expression will just produce a new
Fix-It.

This is often occurring with quickly made Fix-Its that are just used to bridge temporary API changes
and that often are not worth implementing a proper API fixup in addition to the diagnostic. To still
give some kind of reasonable user-experience for users that have these Fix-Its and rely on them to
fix their expressions, this patch adds the ability to retry parsing with applied Fix-Its multiple time to
give the normal Fix-It experience where things Clang knows how to fix are not causing actual expression
error (at least when automatically applying Fix-Its is activated).

The way this is implemented is just by having another setting in the expression options that specify how
often we should try applying Fix-Its and then reparse the expression. The default setting is still 1 for everyone
so this should not affect the speed in which we fail to parse expressions.

Reviewers: jingham, JDevlieghere, friss, shafik

Reviewed By: shafik

Subscribers: shafik, abidh

Differential Revision: https://reviews.llvm.org/D77214
2020-04-06 11:25:36 +02:00
Raphael Isemann 3c2dc28d81 [lldb] Also apply Fix-Its in "note:" diagnostics that belong to an error diagnostic
Summary:
LLDB currently applies Fix-Its if they are attached to a Clang diagnostic that has the
severity "error". Fix-Its connected to warnings and other severities are supposed to
be ignored as LLDB doesn't seem to trust Clang Fix-Its in these situations.

However, LLDB also ignores all Fix-Its coming from "note:" diagnostics. These diagnostics
are usually emitted alongside other diagnostics (both warnings and errors), either to keep
a single diagnostic message shorter or because the Fix-It is in a different source line. As they
are technically their own (non-error) diagnostics, we currently are ignoring all Fix-Its associated with them.

For example, this is a possible Clang diagnostic with a Fix-It that is currently ignored:
```
error: <user expression 1>:2:10: too many arguments provided to function-like macro invocation
ToStr(0, {,})
         ^
<user expression 1>:1:9: macro 'ToStr' defined here
#define ToStr(x) #x
        ^
<user expression 1>:2:1: cannot use initializer list at the beginning of a macro argument
ToStr(0, {,})
^        ~~~~
```

We also don't store "note:" diagnostics at all, as LLDB's abstraction around the whole diagnostic
concept doesn't have such a concept. The text of "note:" diagnostics is instead
appended to the last non-note diagnostic (which is causing that there is no "note:" text in the
diagnostic above, as all the "note:" diagnostics have been appended to the first "error: ..." text).

This patch fixes the ignored Fix-Its in note-diagnostics by appending them to the last non-note
diagnostic, similar to the way we handle the text in these diagnostics.

Reviewers: JDevlieghere, jingham

Reviewed By: JDevlieghere

Subscribers: abidh

Differential Revision: https://reviews.llvm.org/D77055
2020-04-06 10:37:33 +02:00
Pavel Labath 4f644ff9e8 [lldb] XFAIL TestThreadPlanCommands _only_ on aarch64
The test works fine on x86-linux.
2020-04-06 10:36:02 +02:00
Raphael Isemann acb0b99c8e [lldb][NFC] Modernize lang/cpp/scope test 2020-04-06 09:36:54 +02:00
Igor Kudrin a0249fe91c [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.
This is a preparation for an upcoming patch which adds support for
DWARFv5 unit index sections. The patch adds tag "_EXT_" to identifiers
which reference sections that are deprecated in the DWARFv5 standard.
See D75929 for the discussion.

Differential Revision: https://reviews.llvm.org/D77141
2020-04-06 13:28:06 +07:00
Muhammad Omair Javaid b6cd964ac7 Fix typo in xfail decorator for lldb thread plan list tests 2020-04-05 20:16:46 +05:00
Jim Ingham 3270748127 The thread plan list test is failing at least on Ubuntu Linux.
Mark it expected fail for now.

The test output shows that the "internal" thread listing isn't showing the
step out plan that we use to step back out of a function we're stepping into.
The internal plan listing code has nothing platform specific in it, so that
isn't the problem.

I am pretty sure the difference is that on MacOS we step into the function and then need to
step back out again so we push the internal plan the test is checking for.  But on Linux we
are able to step past the function without stepping into it.

So nothing is actually going wrong here, I just need to find a better test case where I
can ensure we are going to have to push a private plan.  It's probably better to test this
using a custom thread plan, then I can control the state of the plan stack better.

That's for Monday...
2020-04-03 20:06:11 -07:00
Walter Erquinigo 966122524b Fix LLDB debug builds
Summary:
A recent change in ThreadPlans introduced this little compilation error.
Seems to be related to the work around https://reviews.llvm.org/D76814.

Reviewers: clayborg, labath, jingham

Reviewed By: jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77450
2020-04-03 19:49:38 -07:00
Walter Erquinigo ca47ac3d5f [source maps] Fix remove, insert-after and replace
Summary:
In this diff of mine D77186 I introduce a bug in the replace operation, where I was failing fast by mistake.
Besides, a similar problem existed in the insert-after operation, where it was failing fast.

Finally, the remove operation was wrong, as it was not using the indices provided by the users.

I fixed those issues and added some tests account for cases with multiple elements in these requests.

Reviewers: labath, clayborg

Reviewed By: labath

Subscribers: mgrang, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77324
2020-04-03 19:15:56 -07:00
Jim Ingham 48ba745eac This test is failing on the Ubuntu bot but the bot log doesn't
capture the test stdout, so put the info I need to see in the error
message instead.
2020-04-03 18:04:02 -07:00
Eric Christopher 3ccd454c10 Fix unused variable, format, and format string warnings.
NFC.
2020-04-03 17:58:59 -07:00
Walter Erquinigo 725579379d [intel-mpx] Delete an unnecessary license header
Summary:
@labath mentioned to me that test files shouldn't have a license header.
I saw this one some days ago, so I'm doing some cleaning.

Reviewers: labath, clayborg

Subscribers: lldb-commits, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77328
2020-04-03 17:27:37 -07:00
Jim Ingham 2d658c56d5 Disable two new tests on Windows. They are failing but the logs are not helpful.
Also turn on the command trace unconditionally for TestThreadPlanCommands.py as the
tests for the Ubuntu bot don't seem to run with -t making it hard to see why this is
failing remotely.
2020-04-03 17:14:56 -07:00
Jan Kratochvil fcab66d5fe [lldb] Findtypes -gmodules fix for too many matches
Apparently the intention was to copy the condition above:
  if (types.GetSize() >= max_matches)
    break;

So that if the iteration stopped because of too many matches we do not
add even more matches in this 'Clang modules' block downward.

It was implemented by:
  SymbolFileDWARF: Unconditionally scan through clang modules. NFCish
  fe9eaadd68

Differential Revision: https://reviews.llvm.org/D77336
2020-04-04 00:15:06 +02:00
Jim Ingham 1893065d7b Allow the ThreadPlanStackMap to hold the thread plans for threads
that were not reported by the OS plugin.  To facilitate this, move
adding/updating the ThreadPlans for a Thread to the ThreadPlanStackMap.
Also move dumping thread plans there as well.

Added some tests for "thread plan list" and "thread plan discard" since
I didn't seem to have written any originally.

Differential Revision: https://reviews.llvm.org/D76814
2020-04-03 14:56:28 -07:00
Jim Ingham 61e8e6882d Move thread plan stacks into the Process, indexed by TID.
Differential Revision: https://reviews.llvm.org/D75880
2020-04-03 14:56:28 -07:00
Jim Ingham 2c1c57a1df Make ThreadPlanTracers use TID & Process rather than Thread *.
Differential Revision: https://reviews.llvm.org/D75720
2020-04-03 14:56:28 -07:00
Jim Ingham e4598dc04a Make ThreadPlans use TID and Process, rather than Thread *.
Differential Revision: https://reviews.llvm.org/D75711
2020-04-03 14:56:28 -07:00
Jan Kratochvil 8023752319 [nfc] [lldb] Unindent code - obvious part
It is an obvious part of D77326.

It removes some needless deep indentation and some redundant statements.
It prepares the code for a more clean next patch - DWARF index callbacks
in D77327.
2020-04-03 21:58:11 +02:00
Jonas Devlieghere d144087c96 [lldb/Support] Treat empty FileSpec as an invalid file.
LLDB relies on empty FileSpecs being invalid files, for example, they
don't exists. Currently this assumption does not always hold during
reproducer replay, because we pass the result of GetPath to the VFS.
This is an empty string, which the VFS converts to an absolute directory
by prepending the current working directory, before looking it up in the
YAML mapping. This means that an empty FileSpec will exist when the
current working directory does. This breaks at least one test
(TestAddDsymCommand.py) when ran from replay.

This patch special cases empty FileSpecs and returns a sensible result
before calling GetPath and forwarding the call.

Differential revision: https://reviews.llvm.org/D77351
2020-04-03 09:29:22 -07:00
Jonas Devlieghere 63bfb3a81b [lldb/Symbol] Reimplement Symbols::FindSymbolFileInBundle to use the VFS
This reimplements Symbols::FindSymbolFileInBundle to use the VFS-aware
recursive directory iterator. This is needed for reproducer replay.

Differential revision: https://reviews.llvm.org/D77337
2020-04-03 09:29:22 -07:00
Konrad Kleine 107200ae0a [lldb][nfc] early exit/continue
Summary:
This commit just tries to invert some `if`'s logic to
`return`/`continue` early.

Reviewers: jankratochvil, teemperor

Reviewed By: jankratochvil, teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77377
2020-04-03 14:50:08 +02:00
Igor Kudrin f13ce15d44 [DebugInfo] Rename getOffset() to getContribution(). NFC.
The old name was a bit misleading because the functions actually return
contributions to the corresponding sections.

Differential revision: https://reviews.llvm.org/D77302
2020-04-03 14:15:53 +07:00
Greg Clayton 5998aceda9 Have lldb-vscode update the currently selecte thread and frame when it receives a "scopes" request.
Summary: The IDE has no packets that are sent to lldb-vscode that say which thread and frame are selected. The only way we know is we get a request for variables for a stack frame via a "scopes" request. When we receive this packet we make that thread and frame the selected thread and frame in lldb. This way when people execute lldb commands in the debug console by prefixing the expression with the backtick character, we will have the right thread and frame selected. Previously this was not updated as new stack frames were selected.

Reviewers: labath, aadsm, wallace, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77347
2020-04-02 18:35:17 -07:00
Walter Erquinigo b78157c88b [intel-pt] Implement a basic test case
* This is a reattempted commit due to a previous builtbot failure

- Now using a env var to determine whether to run the test, as
someone might have built liblldbIntelFeatures.so without intelPT
support, which would make this test fail.

Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77107
2020-04-02 11:36:05 -07:00
Shivam Mittal 51b3874629 Convert for loops to entry-based iteration
Summary: Convert index-based loops marked TODO in CommandObjectSettings and CommandObjectTarget to entry-based.

Reviewers: labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76729
2020-04-02 18:56:29 +02:00
scentini 183fba635d Add OMPIterator case in switch statement to silence warnings 2020-04-02 16:16:11 +02:00
Ed Maste 55e32e92cd [lldb] update eArgTypeScriptLang description to mention lua
--script-language python and --script-language lua are both valid now.

Reviewed by:	JDevlieghere

Differential Revision:	https://reviews.llvm.org/D77241
2020-04-02 09:43:01 -04:00
Pavel Labath 451741a9d7 [lldb] Change Communication::SetConnection to take a unique_ptr
The function takes ownership of the object. This makes that explicit,
and avoids unowned pointers floating around.
2020-04-02 14:42:25 +02:00
Pavel Labath 62be83463a Recommit "[lldb] Fix TestSettings.test_pass_host_env_vars on windows"
This patch was reverted because it introduced a failure in
TestHelloWorld.py. The reason for that was running "ls" shell command
failed as it was evaluated in an environment with an empty path. This
has now been fixed with D77123, which ensures that all shell commands
inherit the host environment, so this patch should be safe to recommit.

The original commit message was:

A defensive check in ProcessLauncherWindows meant that we would never
attempt to launch a process with a completely empty environment -- the
host environment would be used instead. Instead, I make the function add
an extra null wchar_t at the end of an empty environment. The
documentation on this is a bit fuzzy, but it seems to be what is needed
to make windows accept these kinds of environments.

Reviewers: amccarth, friss

Differential Revision: https://reviews.llvm.org/D76835
2020-04-02 11:52:56 +02:00
Ed Maste af1b7d06d9 Correct copy-pasteo in lua script language description 2020-04-02 00:12:24 -04:00
Adrian Prantl 32672b877d Revert "Preserve the owning module information from DWARF in the synthesized AST"
This reverts commit 4354dfbdf5 while investigating bot fallout.
2020-04-01 18:58:11 -07:00
Adrian Prantl 4354dfbdf5 Preserve the owning module information from DWARF in the synthesized AST
Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
sets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

rdar://problem/59634380

Differential Revision: https://reviews.llvm.org/D75488
2020-04-01 17:46:02 -07:00
Vedant Kumar f203100ebe Reapply: [Host.mm] Check for the right macro instead of inlining it
Previously, this was reverted in bf65f19b becuase it checked whether
TARGET_OS_EMBEDDED is defined, but that macro is always defined.

Update the condition to check that TARGET_OS_OSX is true.
2020-04-01 15:23:07 -07:00
Walter Erquinigo 064c634ef3 Revert "[intel-pt] Implement a basic test case"
This reverts commit c911cc6c49.
2020-04-01 14:08:19 -07:00
Walter Erquinigo c911cc6c49 [intel-pt] Implement a basic test case
Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77107
2020-04-01 13:44:03 -07:00