Split the read thread support from Communication into a dedicated
ThreadedCommunication subclass. The read thread support is used only
by a subset of Communication consumers, and it adds a lot of complexity
to the base class. Furthermore, having a dedicated subclass makes it
clear whether a particular consumer needs to account for the possibility
of read thread being running or not.
The modules currently calling `StartReadThread()` are updated to use
`ThreadedCommunication`. The remaining modules use the simplified
`Communication` class.
`SBCommunication` is changed to use `ThreadedCommunication` in order
to avoid changing the public API.
`CommunicationKDP` is updated in order to (hopefully) compile with
the new code. However, I do not have a Darwin box to test it, so I've
limited the changes to the bare minimum.
`GDBRemoteCommunication` is updated to become a `Broadcaster` directly.
Since it does not inherit from `ThreadedCommunication`, its event
support no longer collides with the one used for read thread and can
be implemented cleanly. The support for
`eBroadcastBitReadThreadDidExit` is removed from the code -- since
the read thread was not used, this event was never reported.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D133251
This will be used as a replacement for selecting over a pipe fd, which
does not work on windows. The posix implementation still uses a pipe
under the hood, while the windows version uses windows event handles.
The idea is that, instead of writing to a pipe, one just inserts a
callback, which does whatever you wanted to do after the bytes come out
the read end of the pipe.
Differential Revision: https://reviews.llvm.org/D131160
Fixes broken support for: `target.module[re.compile("libFoo")]`
There were two issues:
1. The type check was expecting `re.SRE_Pattern`
2. The expression to search the module path had a typo
In the first case, `re.SRE_Pattern` does not exist in Python 3, and is replaced
with `re.Pattern`.
While editing this code, I changed the type checks to us `isinstance`, which is
the conventional way of type checking.
From the docs on `type()`:
> The `isinstance()` built-in function is recommended for testing the type of an object, because it takes subclasses into account.
Differential Revision: https://reviews.llvm.org/D133130
TypeCategoryImpl has its own implementation of these, so it makes no
sense to have the same logic inlined in SBTypeCategory.
There are other methods in SBTypeCategory that are directly implemented
there, instead of delegating to TypeCategoryImpl (which IMO kinda
defeats the point of having an "opaque" member pointer in the SB type),
but they don't have equivalent implementations in TypeCategoryImpl, so
this patch only picks the low-hanging fruit for now.
This test, specifically `TwoSignalCallbacks`, can be a little bit flaky, failing in around 5/2000 runs.
POSIX says:
> If the value of pid causes sig to be generated for the sending process, and if sig is not blocked for the calling thread and if no other thread has sig unblocked or is waiting in a sigwait() function for sig, either sig or at least one pending unblocked signal shall be delivered to the sending thread before kill() returns.
The problem is that in test setup, we create a new thread with `std::async` and that is occasionally not cleaned up. This leaves that thread available to eat the signal we're polling for.
The need for this to be async does not apply anymore, so we can just make it synchronous.
This makes the test passes in 10000 runs.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D133181
Change the behavior of the libc++ `unordered_map` synthetic provider to present
children as `std::pair` values, just like `std::map` does.
The synthetic provider for libc++ `std::unordered_map` has returned children
that expose a level of internal structure (over top of the key/value pair). For
example, given an unordered map initialized with `{{1,2}, {3, 4}}`, the output
is:
```
(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, int> > >) map = size=2 {
[0] = {
__cc = (first = 3, second = 4)
}
[1] = {
__cc = (first = 1, second = 2)
}
}
```
It's not ideal/necessary to have the numbered children embdedded in the `__cc`
field.
Note: the numbered children have type
`std::__hash_node<std::__hash_value_type<Key, T>, void *>::__node_value_type`,
and the `__cc` fields have type `std::__hash_value_type<Key, T>::value_type`.
Compare this output to `std::map`:
```
(std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > >) map = size=2 {
[0] = (first = 1, second = 2)
[1] = (first = 3, second = 4)
```
Where the numbered children have type `std::pair<const Key, T>`.
This changes the behavior of the synthetic provider for `unordered_map` to also
present children as `pairs`, just like `std::map`.
It appears the synthetic provider implementation for `unordered_map` was meant
to provide this behavior, but was maybe incomplete (see
d22a94377f). It has both an `m_node_type` and an
`m_element_type`, but uses only the former. The latter is exactly the type
needed for the children pairs. With this existing code, it's not much of a
change to make this work.
Differential Revision: https://reviews.llvm.org/D117383
This patch fixes:
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h:51:5:
error: default label in switch which covers all enumeration values
[-Werror,-Wcovered-switch-default]
Add:
- most of instructions from RVI base instructions set.
- some instruction decode tests from objdump.
Further work:
- implement riscv imac extension.
Reviewed By: DavidSpickett
Differential Revision: https://reviews.llvm.org/D132789
arm64e platforms.
On arm64e-capable Apple platforms, the system libraries are always
arm64e, but applications often are arm64. When a target is created
from file, LLDB recognizes it as an arm64 target, but debugserver will
still (technically correct) report the process as being arm64e. For
consistency, set the target to arm64 here.
rdar://92248684
Differential Revision: https://reviews.llvm.org/D133069
llvm::codeview::visitMemberRecordStream in CompleteTagDecl will call
GetOrCreateType create type if not seen before, which inserts new entries
into m_decl_to_status. This may invalidates status which is a reference to
std::pair::second from DenseMapIterator.
Ensure that the ConnectionStatus and Status from
Communication::ReadThread() is correctly passed to ::Read() in order
to fix further discrepancies between ::Read() calls in non-threaded
and threaded modes.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132577
I got suspicious because of checking "ARM" for an "ARM64" plugin.
As far as I can tell these never needed an llvm target to function.
Looking at the corresponding cmake for the libraries under test they
don't reference target libraries either.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D133024
This patch makes build helper script build.py to use platform.uname for
machine/architecture detection. Visual studio environment when set using
various batch files like vcvars*.bat set PLATFORM environment variable
however VsDevCmd.bat does not set PLATFORM variable.
Differential Revision: https://reviews.llvm.org/D133011
MSYS 'uname' on windows returns "MSYS_NT*" instead of windows32 and also
MSYS 'pwd' returns non-windows path string.
This patch fixes Makefile.rules to make adjustments required to run LLDB
API tests using MSYS tools.
Differential Revision: https://reviews.llvm.org/D133002
We were splitting the string, and adding that array to cmd. But split generated
[''] which shows up later on as an empty "test directory search path". That got
extended to the CWD + "" which generally doesn't have any tests, so
lldb-dotest -p SomeRealTest.py
would fail with a no matching tests error.
Differential Revision: https://reviews.llvm.org/D133075
When a runtime is enabled through LLVM_ENABLE_RUNTIMES, it is loaded
after other projects (i.e. after LLDB). This means that the
corresponding targets don't exist when LLDB is configured. To support
runtimes being enable this way, we need to check if they're listed in
LLVM_ENABLE_RUNTIMES. For runtimes being enabled as projects (i.e.
through LLVM_ENABLE_RUNTIMES) we need to check for the target.
This patch unifies things and correctly adds compiler-rt and libcxx as
test dependencies in both scenarios.
Make the rumtimes target a test dependency. This is needed or the parts
of the test suite that rely on the libcxx and libcxxabi.
Differential revision: https://reviews.llvm.org/D133046
Previously, depending on how you constructed a UUID from data or a
StringRef, an input value of all zeros was valid (e.g. setFromData)
or not (e.g. setFromOptionalData). Since there was no way to tell
which interpretation to use, it was done somewhat inconsistently.
This standardizes the meaning of a UUID of all zeros to Not Valid,
and removes all the Optional methods and their uses, as well as the
static factories that supported them.
Differential Revision: https://reviews.llvm.org/D132191
This fixes a warning when building for Windows:
../tools/lldb/source/Host/common/TCPSocket.cpp:297:16: warning: comparison of integers of different signs: 'int' and 'const NativeSocket' (aka 'const unsigned long long') [-Wsign-compare]
if (sock != kInvalidSocketValue) {
~~~~ ^ ~~~~~~~~~~~~~~~~~~~
Differential Revision: https://reviews.llvm.org/D132841
Improve utility of `FileCheck` output when a shell test fails.
The conflict is from:
1. On failure, `FileCheck` prints 5 lines of context
2. Shell tests first source `lit-lldb-init`, having the effect of printing its contents
If a `FileCheck` failure happens at the beginning of the input, then the
context shown is the `lit-lldb-init`, as it's over 5 lines and is the first
thing printed. As the init contents are fairly static, and presumably
uninteresting to most test failures, it seems reasonable to not print it.
Unfortunately it's not possible to use the `--source-quietly` flag in the lldb
invocation, because it will quiet all other `--source` flags on the command
line, making many tests fail.
This fix is a level of indirection, where a new sibling file named
`lit-lldb-init-quiet` is created, and its static contents are:
```
command source -C --silent-run true lit-lldb-init
```
This achieves the result of loading `lit-lldb-init` quietly. The `-C` flag
loads the path relatively.
Differential Revision: https://reviews.llvm.org/D132694
While investigation slow tests, I looked into why `TestMultithreaded.py`. One
of the reasons is that it determines the architecture of lldb by running:
```
lldb -o 'file path/to/lldb' -o 'quit'
```
On my fairly fast machine, this takes 24 seconds, and `TestMultithreaded.py`
calls this function 4 times.
With this change, this command now takes less than 0.2s on the same machine.
The reason it's slow is symbol table and debug info loading, as indicated by
the new progress events printed to the console. One setting reduced the time in
half:
```
settings set target.preload-symbols false
```
Further investigation, by profiling with Instruments on macOS, showed that
loading time was also caused by looking for scripts. The setting that
eliminates this time is:
```
settings set target.load-script-from-symbol-file false
```
Differential Revision: https://reviews.llvm.org/D132803
This commit adds a new page to the LLDB HTML documentation for the LLDB
fuzzers. The page primarily explains what the fuzzers are as well as how
to build them, run them and investigate and reproduce bugs.
Differential revision: https://reviews.llvm.org/D132148
Our (TCP) socket support is in a much better state than pipes. Use that
for testing the Communication class.
Move the CreateTCPConnectedSockets function
(SocketTestUtilities.{h,cpp}) to a place where it can be used from
Communication tests.
When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:
```
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
CACHE INTERNAL STRING)
```
This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with `--libcxx-include-dir` and
`--libcxx-library-dir`. Both flags are needed by the greendragon bots.
This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.
The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with `set` or `list` or `string`
commands, which don't work with properties. As such, a temporary
variable `LLDB_TEST_COMMON_ARGS_VAR` is created.
This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.
Differential Revision: https://reviews.llvm.org/D132642
Previously this would log:
```
FindExternalLexicalDecls on (ASTContext*)0x00000005CE825200 'Expression
ASTContext for '<user expression 0>'' in 'weak_ptr'
(%sDecl*)ClassTemplateSpecialization
FindExternalLexicalDecls on (ASTContext*)0x00000005CE825200 'Expression
ASTContext for '<user expression 0>'' in '__shared_count'
(%sDecl*)CXXRecord
```
Note that the `%s` isn't actually respected. This patch fixes this
by providing the format specifiers that `lldb::formatv` supports.
Differential Revision: https://reviews.llvm.org/D132709
This patch teaches LLDB about Mach-O filesets. Filsets are Mach-O files
that contain a bunch of other Mach-O files. Unlike universal binaries,
which have a different header, Filesets use load commands to describe
the different entries it contains.
Differential revision: https://reviews.llvm.org/D132433
When fission is enabled, we were indexing the skeleton CU _and_ the .dwo CU. Issues arise when users enable compiler options that add extra data to the skeleton CU (like -fsplit-dwarf-inlining) and there can end up being types in the skeleton CU due to template parameters. We never want to index this information since the .dwo file has the real definition, and we really don't want function prototypes from this info since all parameters are removed. The index doesn't work correctly if it does index the skeleton CU as the DIE offset will assume it is from the .dwo file, so even if we do index the skeleton CU, the index entries will try and grab information from the .dwo file using the wrong DIE offset which can cause errors to be displayed or even worse, if the DIE offsets is valid in the .dwo CU, the wrong DIE will be used.
We also fix DWO ID detection to use llvm::Optional<uint64_t> to make sure we can load a .dwo file with a DWO ID of zero.
Differential Revision: https://reviews.llvm.org/D131437
When setting a breakpoint upon throwing exceptions, LLDB only
searches for the libc++abi code inside dylibs named:
1. libc++abi.dylib
2. libSystem.B.dylib
However, this fails to account for libs with a version number. For
example, when building the libcxx and libcxxabi runtimes, the following
dylibs are generated:
build/lib/libc++abi.1.0.dylib
build/lib/libc++abi.1.dylib -> libc++abi.1.0.dylib
build/lib/libc++abi.dylib -> libc++abi.1.dylib
If we are debugging a program linked against any of the "versioned"
libs, the breakpoint doesn't work. This commit adds these names to the
search list.
Differential Revision: https://reviews.llvm.org/D132598
This test simply checks whether we can print an optimized
function argument. With recent changes to Clang the assumption
that we don't generate a `DW_AT_location` attribute for the
unused funciton parameter breaks.
This patch tries harder to get Clang to drop the location
from DWARF by making it generate an `undef` for `unused1`.
Drop the check for `unused2` since it adds no benefit.
Differential Revision: https://reviews.llvm.org/D132635