Commit Graph

25500 Commits

Author SHA1 Message Date
Vedant Kumar 5e004b03f7 [lldb/test] Update test/API/functionalities/load_lazy to macOS 12
In macOS 12, dyld switched to using chained fixups. As a result, all symbols
are bound at launch and there are no lazy pointers any more. Since we wish to
import/dlopen() a dylib with missing symbols, we need to use a weak import.
This applies to all macOS 12-aligned OS releases, e.g. iOS 15, etc.

rdar://81295101

Differential Revision: https://reviews.llvm.org/D112034
2021-10-19 13:25:14 -07:00
Lawrence D'Anna 8ac5a6641f [lldb] improve the help strings for gdb-remote and kdp-remote
The help string can be more helpful by explaining these are
aliases for 'process connect'

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D111965
2021-10-19 13:08:21 -07:00
Jim Ingham a66798cd67 Remove unneeded variable num_found. 2021-10-19 09:57:07 -07:00
Jonas Devlieghere 1529738b66 [debugserver] Fix BUILDING_FOR_ARM64_OSX
Check for TARGET_CPU_ARM64 (ARM instructions for 64-bit mode) rather
than TARGET_CPU_ARM (instructions for 32-bit mode).
2021-10-19 09:55:53 -07:00
Michał Górny b492b0be95 [lldb] [Process/Utility] Define dN regs on ARM via helper macro
Use FPU_REG macro to define dN registers, removing the wrong value_regs
while at it.  This is a piece-wise attempt of reconstructing D112066
with the goal of figuring out which part of the larger change breaks
the buildbot.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 17:06:03 +02:00
Michał Górny 28e0c34216 [lldb] [Process/Utility] Define sN regs on ARM via helper macro
This is a piece-wise attempt of reconstructing D112066 with the goal
of figuring out which part of the larger change breaks the buildbot.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 15:51:47 +02:00
Michał Górny 5cd28f71b1 [lldb] [Process/Utility] clang-format RegisterInfos_arm.h 2021-10-19 15:51:47 +02:00
Michał Górny 7df912c65d Revert "[lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM"
This reverts commit 1c2c67b46b.
Something's still wrong.
2021-10-19 15:33:39 +02:00
Michał Górny 1c2c67b46b [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM
Fix incorrect values for value_regs, and incomplete values for
invalidate_regs in RegisterInfos_arm.  The value_regs entry needs
to list only one base (i.e. larger) register that needs to be read
to get the value for this register, while invalidate_regs needs to list
all other registers (including pseudo-register) whose values would
change when this register is written to.

While at it, introduce helper macros for the definitions.

7a8ba4ffbe fixed a similar problem
for ARM64.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 14:47:46 +02:00
Michał Górny c6d7f248bd [lldb] [ABI/X86] Refactor ABIX86::AugmentRegisterInfo()
Refactor ABIX86::AugmentRegisterInfo() and helper functions for better
readability.  This also fixes listing eax & co. as potential subregs
on 32-bit systems.

Differential Revision: https://reviews.llvm.org/D108937
2021-10-19 13:36:38 +02:00
Michał Górny 39f2b05963 [lldb] [Host] Make Terminal methods return llvm::Error
Differential Revision: https://reviews.llvm.org/D111890
2021-10-19 13:31:03 +02:00
Raphael Isemann 7dfb139554 [lldb] Adjust udt-layout.test after MS mangling change
The demangled name no longer contains the redundant name since D111715.
2021-10-19 12:43:24 +02:00
Michał Górny ee11612ee1 Revert "[lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*"
This reverts commit 5352ea4a72.  It seems
to have broken the arm buildbot.
2021-10-19 12:31:25 +02:00
Pavel Labath 8bac18be0e [lldb] Reduce code duplication around inferior building
We had two sets of build<flavour> methods, whose bodies were largely
identical. This makes any kind of modification in their vicinity
repetitive and error-prone.

Replace each set with a single method taking an optional debug_info
parameter.

Differential Revision: https://reviews.llvm.org/D111989
2021-10-19 12:09:41 +02:00
Raphael Isemann 9a57d1e526 [lldb] Allow dumping the state of all scratch TypeSystems
This adds the `target dump typesystem'`command which dumps the TypeSystem of the
target itself (aka the 'scratch TypeSystem'). This is similar to `target modules
dump ast` which dumps the AST of lldb::Modules associated with a selected
target.

Unlike `target modules dump ast`, the new command is not a subcommand of `target
modules dump` as it's not touching the modules of a target at all. Also unlike
`target modules dump ast` I tried to keep the implementation language-neutral,
so this patch moves our Clang `Dump` to the `TypeSystem` interface so it will
also dump the state of any future/downstream scratch TypeSystems (e.g., Swift).
That's also why the command just refers to a 'typesystem' instead of an 'ast'
(which is only how Clang is necessarily modelling the internal TypeSystem
state).

The main motivation for this patch is that I need to write some tests that check
for duplicates in the ScratchTypeSystemClang of a target. There is currently no
way to check for this at the moment (beside measuring memory consumption of
course). It's probably also useful for debugging LLDB itself.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111936
2021-10-19 12:05:14 +02:00
Lasse Folger 134e1817f6 [lldb] change name demangling to be consistent between windows and linx
When printing names in lldb on windows these names contain the full type information while on linux only the name is contained.

This change introduces a flag in the Microsoft demangler to control if the type information should be included.
With the flag enabled demangled name contains only the qualified name, e.g:
without flag -> with flag
int (*array2d)[10] -> array2d
int (*abc::array2d)[10] -> abc::array2d
const int *x -> x

For globals there is a second inconsistency which is not yet addressed by this change. On linux globals (in global namespace) are prefixed with :: while on windows they are not.

Reviewed By: teemperor, rnk

Differential Revision: https://reviews.llvm.org/D111715
2021-10-19 12:04:37 +02:00
Raphael Isemann cfaa5c344d [lldb] Filter duplicates in Target::GetScratchTypeSystems
`Target::GetScratchTypeSystems` returns the list of scratch TypeSystems. The
current implementation is iterating over all LanguageType values and retrieves
the respective TypeSystem for each LanguageType.

All C/C++/Obj-C LanguageTypes are however mapped to the same
ScratchTypeSystemClang instance, so the current implementation adds this single
TypeSystem instance several times to the list of TypeSystems (once for every
LanguageType that we support).

The only observable effect of this is that `SBTarget.FindTypes` for builtin
types currently queries the ScratchTypeSystemClang several times (and also adds
the same result several times).

Reviewed By: bulbazord, labath

Differential Revision: https://reviews.llvm.org/D111931
2021-10-19 11:49:47 +02:00
Michał Górny 5352ea4a72 [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*
gdbserver does not expose combined ymm* registers but rather XSAVE-style
split xmm* and ymm*h portions.  Extend value_regs to support combining
multiple registers and use it to create user-friendly ymm* registers
that are combined from split xmm* and ymm*h portions.

Differential Revision: https://reviews.llvm.org/D108937
2021-10-19 10:31:07 +02:00
Jonas Devlieghere 957a5e9874 [lldb] Fix nullptr dereference in AppleObjCRuntimeV2
Fix a potential nullptr dereference in AppleObjCRuntimeV2 by checking
the result of GetClassInfoUtilityFunction and returning a failure if
it's null.

The DynamicClassInfoExtractor was already doign the right thing, but the
SharedCacheClassInfoExtractor was missing this check.
2021-10-18 23:30:31 -07:00
Jim Ingham f24532ae91 Follow-on to fix a test from c5011aed9c.
I need to set a fake default platform for the UnitTest test to run on other
systems.
2021-10-18 16:53:32 -07:00
Jim Ingham c5011aed9c Add a "command container" hierarchy to allow users to add container nodes.
The point is to allow users with a related set of script based commands
to organize their commands in a hierarchy in the command set, rather than
having to have only top-level commands.

Differential Revision: https://reviews.llvm.org/D110298
2021-10-18 15:29:24 -07:00
Michał Górny a229a4aa64 [lldb] [lldb-server] Refactor ConnectToRemote()
Refactor ConnectToRemote() to improve readability and make future
changes easier:

1. Replace static buffers with std::string.
2. When handling errors, prefer reporting the actual error over dumb
   'connection status is not success'.
3. Move host/port parsing directly into reverse_connection condition
   that is its only user, and simplify it to make its purpose (verifying
   that a valid port is provided) clear.
4. Use llvm::errs() and llvm::outs() instead of fprintf().

Differential Revision: https://reviews.llvm.org/D111963
2021-10-18 22:05:01 +02:00
Michał Górny 62293e7d33 Revert "[lldb] [lldb-server] Refactor ConnectToRemote()"
This reverts commit d8bc7e40ce.  I've
linked the wrong Differential Revision.
2021-10-18 22:04:36 +02:00
Jim Ingham 1ff367dbb0 Fix Linux error in TestBreakInLoadedDylib.py.
Adding the to be loaded dylib to the extra images causes the breakpoint
to be found in the image added to the target on Linux (though not on
Darwin).  So adjust the test for this difference.
2021-10-18 11:30:31 -07:00
Jim Ingham 9a2e9c5db6 Add tests for the other variants of BreakpointCreateBySourceRegex.
I added some tests for the case where the breakpoints take immediately
to the extant test case, and made a new test case for when the source
regex breakpoint will be set in a dlopen-ed library.

I also noticed when doing this that "lldbutil.run_to_source_breakpoint
can't handle the case where the breakpoint will be in a dlopen-ed
library, since it requires the breakpoint to have at least 1 location
before run.  I fixed that by adding a parameter to say whether a
before run location is expected.

Differential Revision: https://reviews.llvm.org/D111920
2021-10-18 10:59:04 -07:00
Kazu Hirata 8568ca789e Use llvm::erase_if (NFC) 2021-10-18 09:33:42 -07:00
Raphael Isemann 366fb53948 [lldb] Fix missing dependency on libc++ from LLDB test suite on non-Darwin platforms
Right now we only set a dependency on libc++ when the host is Darwin, which
means that libc++ in the build directory is in some undefined state when running
the test suite (it can be fully built, out-of-date or missing). Depending on
whether we have a system libc++ (which LLDB also supports running the libc++
tests against), the outcome is that we sometimes skip the libc++ tests or we run
the tests against a mix of ToT-libc++/system-libc++ (e.g., we compile against
the ToT-libc++ headers and link against the system libc++ library).

This can be demonstrated via `export LIT_FILTER=TestDataFormatterLibcxxSet ninja
check-lldb-api` (or any other libc++ test) and then gradually building parts of
libc++ in the same build (which will slowly change the test behaviour from
`UNSUPPORTED` to various failures to passing depending on how much of libcxx is
built at test time).

Note that this effectively re-enables the (unintentionally) disabled libc++
formatter tests on Linux. Don't revert this if it breaks a libc++ LLDB test,
instead please @skipIf decorate the failing test (as it was probably already
failing before this commit).

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111981
2021-10-18 15:59:34 +02:00
Pavel Labath 1ef6bd9b1b [lldb] Delete TestStandardUnwind
It's been broken (not failing, but not testing anything either) for
quite some time now, and nobody noticed. It also (by design) tests
stepping through libc code, which makes it completely non-hermetic.

It's not worth reviving such a test.
2021-10-18 15:22:10 +02:00
Pavel Labath b37efed957 [lldb] Fix PDB/compilands.test for a3939e1 2021-10-18 14:11:47 +02:00
Michał Górny d8bc7e40ce [lldb] [lldb-server] Refactor ConnectToRemote()
Refactor ConnectToRemote() to improve readability and make future
changes easier:

1. Replace static buffers with std::string.
2. When handling errors, prefer reporting the actual error over dumb
   'connection status is not success'.
3. Move host/port parsing directly into reverse_connection condition
   that is its only user, and simplify it to make its purpose (verifying
   that a valid port is provided) clear.
4. Use llvm::errs() and llvm::outs() instead of fprintf().

Differential Revision: https://reviews.llvm.org/D11196
2021-10-18 12:17:43 +02:00
Lasse Folger ee691fbc3d [lldb][NFC] clang format change
clang format on some demangling files

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D111934
2021-10-18 12:00:32 +02:00
Pavel Labath d914aa4ead [lldb] Fix SymbolFilePDBTests for a3939e1 2021-10-18 11:59:01 +02:00
Michał Górny 239b4d62b6 [lldb] [Utility] Remove Status::WasInterrupted() along with its only use
Remove Status::WasInterrupted() that checks whether the underlying error
code matches EINTR.  ProcessGDBRemote::ConnectToDebugserver() is its
only call site, and it does not seem correct there.  After all, EINTR
is precisely when we want to retry, not stop retrying.  Furthermore,
it should not really matter since we should be catching EINTR
immediately via llvm::sys::RetryAfterSignal() but that's another story.

Differential Revision: https://reviews.llvm.org/D111908
2021-10-18 10:50:25 +02:00
Pavel Labath a3939e159f [lldb] Return StringRef from PluginInterface::GetPluginName
There is no reason why this function should be returning a ConstString.

While modifying these files, I also fixed several instances where
GetPluginName and GetPluginNameStatic were returning different strings.

I am not changing the return type of GetPluginNameStatic in this patch, as that
would necessitate additional changes, and this patch is big enough as it is.

Differential Revision: https://reviews.llvm.org/D111877
2021-10-18 10:14:42 +02:00
Jonas Devlieghere c900b0a6d5 [lldb] Skip target variable test on AS 2021-10-17 19:12:24 -07:00
Raphael Isemann 60b96aa65e [lldb] Split ParseSingleMember into Obj-C property and normal member/ivar parsing code.
Right now DWARFASTParserClang::ParseSingleMember has two parts: One part parses
Objective-C properties and the other part parses C/C++ members/Objective-C
ivars. These parts are pretty much independent of each other (with one
historical exception, see below) and in practice they parse DIEs with different
tags/attributes: `DW_TAG_APPLE_property` and `DW_TAG_member`.

I don't see a good reason for keeping the different parsing code intertwined in
a single function, so instead split out the Objective-C property parser into its
own function.

Note that 90% of this commit is just unindenting nearly all of
`ParseSingleMember` which was inside a `if (tag == DW_TAG_member)` block. I.e.,
think of the old `ParseSingleMember` function as: The rest is just moving the
property parsing code into its own function and I added the ReportError
implementation in case we fail to resolve the property type (which before was
just a silent failure).

```
lang=c++
void DWARFASTParserClang::ParseSingleMember(...) {
  [...]
  if (tag == DW_TAG_member) {
    [...] // This huge block got unindented in this patch as the `if` above is gone.
  }
  if (property) {
    [...] // This is the property parsing code that is now its own function.
  }
}
```

There is one exception to the rule that the parsers are independent. Before 2012
Objective-C properties were encoded as `DW_TAG_member` with
`DW_AT_APPLE_property*` attributes describing the property. In 2012 this has
changed in a series of commits (see for example
c0449635b3 which updates the docs) so that
`DW_TAG_APPLE_property` is now used for properties. With the old format we first
created an ivar and afterwards used the `DW_AT_APPLE_property*` attributes to
create the respective property, but there doesn't seem to be any way to create
such debug info with any clang from the last 9 years. So this is technically not
NFC in case some finds debug info from that time and tries to use properties.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D111632
2021-10-16 14:20:04 +02:00
Lawrence D'\''Anna 4594f81165 Fix Xcode project for debugserver
It seems StringConvert.cpp was moved, and the Xcode project file
wasn't updated.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D111910
2021-10-15 15:08:06 -07:00
Raphael Isemann ff4c98c055 [lldb] Harden TestCompletion against new settings in 'target.process'
This test starts failing when people add a setting starting with
`target.process.t` which of course can easily happen. Make it a bit more
resistant by only requiring that `target.process.thr` has a unique completion.
2021-10-15 18:50:21 +02:00
Raphael Isemann 03a8e70a19 [lldb] Add test for struct merging in scratch ASTContext 2021-10-15 17:20:03 +02:00
Michał Górny 1583c41d07 [lldb] [test] Add TestGDBServerTargetXML tests for x86 duplicate subregs 2021-10-15 16:04:16 +02:00
Michał Górny e7418906f5 [lldb] [test] Simplify X86 TestGDBServerTargetXML logic to match AArch64 2021-10-15 14:15:50 +02:00
Michał Górny f70f9620d9 [lldb] [ABI/AArch64] Do not add subregs if some of them are present
Fix a bug introduced while refactoring ABIAArch64::AugmentRegisterInfo()
that caused subregisters to be added even if they were already present.
Instead, abort immediately if at least one subregister is found
(following ABIX86).  While at it, add a test for that.

Differential Revision: https://reviews.llvm.org/D111881
2021-10-15 14:08:37 +02:00
Michał Górny 2712d18148 [lldb] [ABI/X86] Add pseudo-registers if missing
Differential Revision: https://reviews.llvm.org/D108831
2021-10-15 12:55:03 +02:00
Michał Górny 0d1705a9d6 [lldb] [DynamicRegisterInfo] Support value_regs with offset
Support specifying an offset for value_regs[0], and add the offset
to the computed derived register offset.  This makes it possible to
e.g. create the "ah" register on x86.

Differential Revision: https://reviews.llvm.org/D111489
2021-10-15 12:55:02 +02:00
Pavel Labath bc9b106a57 [lldb] Fix an include in HostTest.cpp
The previous include was too broad, and its better if the host tests do
not depend on non-host libraries.
2021-10-15 11:10:38 +02:00
Jason Molenda 35d710148b Use Module's FileSpec for limiting binaries to set dyld breakpoint in
When DynamicLoaderMacOS::SetNotificationBreakpoint sets the breakpoint
for new binaries being loaded/unloaded, it limits the scope of that
breakpoint to just dyld, so we don't re-evaluate the breakpoint for
every new binary loaded.  I wrote this to get the module's ObjectFile
FileSpec in an earlier change, but this is not correct.  If lldb
is debugging a remote system, and it had to read dyld out of memory
from the remote system, it will have no FileSpec on the lldb debugger
host.  We need to grab the Module's FileSpec, which in this case is
actually falling back to the PlatformFileSpec, the binary path on the
target system.

rdar://84199646
2021-10-14 23:58:23 -07:00
Shao-Ce SUN 7c704c0f53 [NFC] fix a typo 2021-10-15 14:51:49 +08:00
Raphael Isemann 482c53fa0d [lldb] Move ~Platform to source file
The called destructors of the members require the includes that are only
in the source file.
2021-10-14 21:36:46 +02:00
Raphael Isemann e632e900ac [lldb] Remove logging from Platform::~Platform
Platform instances are stored in a function-local static list. However, the
logging code involves locking a function-local static mutex. This only works on
some implementations where the Log mutex is by accident destroyed *after* the
Platform list is destroyed.

This fixes randomly failing tests due to `recursive_mutex lock failed: Invalid
argument`.

Reviewed By: kastiglione

Differential Revision: https://reviews.llvm.org/D111816
2021-10-14 20:42:45 +02:00
Raphael Isemann 78e17e23aa [lldb] Rewrite TestDiamond and document some bugs. 2021-10-14 20:32:07 +02:00
Dave Lee 722a2fb7f9 [lldb] Fix 'frame diagnose' docstring typo 2021-10-14 08:32:20 -07:00
Pavel Labath fa639eda65 [lldb] Fix TestStackCorefile.py for ca0ce99fc8 2021-10-14 10:38:48 +02:00
Martin Storsjö 7106f58856 [lldb] Make the thread_local g_global_boundary accessed from a single file
This makes the compiler generated code for accessing the thread local
variable much simpler (no need for wrapper functions and weak pointers
to potential init functions), and can avoid toolchain bugs regarding how
to access TLS variables.

In particular, this fixes LLDB when built with current GCC/binutils for
MinGW, see https://github.com/msys2/MINGW-packages/issues/8868.

Differential Revision: https://reviews.llvm.org/D111779
2021-10-14 11:17:20 +03:00
Pavel Labath ca0ce99fc8 [lldb] Print embedded nuls in char arrays (PR44649)
When we know the bounds of the array, print any embedded nuls instead of
treating them as terminators. An exception to this rule is made for the
nul character at the very end of the string. We don't print that, as
otherwise 99% of the strings would end in \0. This way the strings
usually come out the same as how the user typed it into the compiler
(char foo[] = "with\0nuls"). It also matches how they come out in gdb.

This resolves a FIXME left from D111399, and leaves another FIXME for dealing
with nul characters in "escape-non-printables=false" mode. In this mode the
characters cause the entire summary string to be terminated prematurely.

Differential Revision: https://reviews.llvm.org/D111634
2021-10-14 09:50:40 +02:00
Stella Stamenova 58917054c2 [lldb] Skip several lldb tests that are flaky on Windows
These tests fail every 10 or so runs on Windows causing both local failures as well as buildbot failures.

Differential Revision: https://reviews.llvm.org/D111659
2021-10-13 09:46:41 -07:00
Raphael Isemann 4019699fa5 [lldb] Add a test for CRTP 2021-10-13 17:15:02 +02:00
Raphael Isemann 0648b3c026 [lldb][NFC] for-range loop when iterating over delayed_properties 2021-10-13 15:27:23 +02:00
Raphael Isemann 7103753733 [lldb][NFC] Split out DW_TAG_inheritance parsing into own function
Just moving that block inside DWARFASTParserClang::ParseChildMembers into
its own function. Also early-exiting instead of a large if when
num_attributes is 0.
2021-10-13 13:14:57 +02:00
Fangrui Song 1b81581fee [lldb][test] Remove Intel MPX tests
Intel MPX failed to gain wide adoption and has been deprecated for a while.
GCC 9.1 removed Intel MPX support. Linux kernel removed MPX in 2019.
glibc 2.35 will remove the support.
2021-10-12 16:16:58 -07:00
Siger Yang 67f94e5a97 [lldb/lua] Supplement Lua bindings for lldb module
Add necessary typemaps for Lua bindings, together with some other files.

Signed-off-by: Siger Yang <sigeryeung@gmail.com>

Reviewed By: tammela

Differential Revision: https://reviews.llvm.org/D108090
2021-10-12 22:10:21 +08:00
Siger Yang 6de63b3ba5 [lldb/lua] Force Lua version to be 5.3
Due to CMake cache, find_package in FindLuaAndSwig.cmake
will be ignored. This commit adds EXACT and REQUIRED flags
to it and removes find_package in Lua ScriptInterpreter.

Signed-off-by: Siger Yang <sigeryeung@gmail.com>

Reviewed By: tammela, JDevlieghere

Differential Revision: https://reviews.llvm.org/D108515
2021-10-12 21:34:15 +08:00
Michał Górny bda5fe8f0c [lldb] [gdb-remote] Fix displaying i387_ext & vec regs with gdbserver
Adjust the encoding and format applied to i387_ext and vec* type
registers from gdbserver to match lldb-server.  Both types are now
displayed as vector of uint8 instead of float and integer formats used
before.  Additionally, this fixes display of STi registers when they do
not carry floating-point data (they are also used to hold MMX vectors).

Differential Revision: https://reviews.llvm.org/D108468
2021-10-12 15:16:06 +02:00
Michał Górny ec2d0ded1b [lldb] Remove "0x" prefix from hex values in dirty-pages
Remove the redudant "0x" prefix in the "dirty-pages" key of
qMemoryRegionInfo packet.  The client accepts hex values both with
and without the prefix.

Differential Revision: https://reviews.llvm.org/D110510
2021-10-11 21:04:11 +02:00
Jonas Devlieghere 070315d04c Revert "Allow signposts to take advantage of deferred string substitution"
This reverts commits f9aba9a5af and
035217ff51.

As explained in the original commit message, this didn't have the
intended effect of improving the common LLDB use case, but still
provided a marginal improvement for the places where LLDB creates a
scoped time with a string literal.

The reason for the revert is that this change pulls in the os/signpost.h
header in Signposts.h. The former transitively includes loader.h, which
contains a series of macro defines that conflict with MachO.h. There are
ways to work around that, but Adrian and I concluded that  none of them
are worth the trade-off in complicating Signposts.h even further.
2021-10-11 11:09:36 -07:00
Michał Górny 660632778f [lldb] [DynamicRegisterInfo] Support setting from vector<Register>
Add an overload of DynamicRegisterInfo::SetRegisterInfo() that accepts
a std::vector<Register> as an argument.  This moves the conversion
from DRI::Register to RegisterInfo directly into DynamicRegisterInfo,
and avoids the necessity of creating fully-compatible intermediate
RegisterInfo instances.

While the new method could technically reuse AddRegister(), the ultimate
goal is to replace AddRegister() with SetRegisterInfo() entirely.

Differential Revision: https://reviews.llvm.org/D111435
2021-10-11 17:02:27 +02:00
Michał Górny 583f67cb4e [lldb] [ABI/AArch64] Add pseudo-regs if missing
Create pseudo-registers on the AArch64 target if they are not provided
by the remote server. This is the case for gdbserver. The created
registers are:

- 32-bit wN partials for 64-bit xN registers
- double precision floating-point dN registers (overlapping with vN)
- single precision floating-point sN registers (overlapping with vN)

Differential Revision: https://reviews.llvm.org/D109876
2021-10-11 17:02:27 +02:00
Michał Górny 1afda54f19 [lldb] [Target] Make addSupplementaryRegister() work on Register vector
Move DynamicRegisterInfo::AddSupplementaryRegister() into a standalone
function working on std::vector<DynamicRegisterInfo::Register>.

Differential Revision: https://reviews.llvm.org/D111295
2021-10-11 17:02:27 +02:00
Michał Górny 5849219126 [lldb] [ABI] Apply AugmentRegisterInfo() to DynamicRegisterInfo::Registers
Call ABI::AugmentRegisterInfo() once with a vector of all defined
registers rather than calling it for every individual register.  Move
and rename RemoteRegisterInfo from gdb-remote to
DynamicRegisterInfo::Register, and use this class when augmenting
registers.

Differential Revision: https://reviews.llvm.org/D111142
2021-10-11 17:02:26 +02:00
Raphael Isemann 8249e50bf4 [lldb][NFC] Remove unnecessary reference from ParseChildMembers's default_accessibility parameter 2021-10-11 15:43:49 +02:00
Raphael Isemann f110999bf6 [lldb][NFCI] Refactor out attribute parsing from DWARFASTParserClang::ParseSingleMember
D68422 introduced `ParsedDWARFTypeAttributes` which encapsulated attribute
parsing and storage into its own small struct. This patch is doing the same for
the member type attribute parsing. One utility class is parsing normal member
attributes and the other is parsing the dedicated Objective-C property
attributes.

Right now the patch just makes the `ParseSingleMember` function a bit shorter,
but the bigger benefit is that we can now split up the function into Objective-C
property parsing and parsing of normal members (struct/class members and
Objective-C ivars). The only shared code between those two parsing logic is the
normal member attribute parsing.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111494
2021-10-11 14:41:20 +02:00
Michał Górny 270c989f6f [lldb] [test] Rewrite g/p/G/P tests not to rely on hardcoded ARM regs
Rewrite the register reading/writing tests to use explicit qRegisterInfo
packets rather than relying on ARM registers being hardcoded in LLDB.
While at it, use x86_64 for tests -- since it was easier for me to get
the register lists from that architecture.

Differential Revision: https://reviews.llvm.org/D111496
2021-10-11 14:07:28 +02:00
Raphael Isemann 3256aa8fe6 [lldb] Add support for DW_AT_calling_convention to the DWARF parser
This adds support for parsing DW_AT_calling_convention in the DWARF parser.

The generic DWARF parsing code already support extracting this attribute from A
DIE and TypeSystemClang already offers a parameter to add a calling convention
to a function type (as the PDB parser supports calling convention parsing), so
this patch just converts the DWARF enum value to the Clang enum value and adds a
few tests.

There are two tests in this patch.:

* A unit test for the added DWARF parsing code that should run on all platforms.

* An API tests that covers the whole expression evaluation machinery by trying
to call functions with non-standard calling conventions. The specific subtests
are target specific as some calling conventions only work on e.g. win32 (or, if
they work on other platforms they only really have observable differences on a
specific target).  The tests are also highly compiler-specific, so if GCC or
Clang tell us that they don't support a specific calling convention then we just
skip the test.

Note that some calling conventions are supported by Clang but aren't implemented
in LLVM (e.g. `pascal`), so there we just test that if this ever gets
implemented in LLVM that LLDB works too. There are also some more tricky/obscure
conventions that are left out such as the different swift* conventions, some
planned Obj-C conventions (`Preserve*`), AAPCS* conventions (as the DWARF->Clang
conversion is ambiguous for AAPCS and APPCS-VFP) and conventions only used for
OpenCL etc.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D108629
2021-10-11 13:44:10 +02:00
Raphael Isemann 592e89cc4e [lldb] Don't print to stderr in TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize
The current code just prints to the System's 'error log' which is usually stderr
(+ some other log backend). Printing to stderr however just interferes with
LLDB's console UI, so when this code is triggered during for example command
completion it just breaks the LLDB console interface until the next redraw.

Instead just use the normal LLDB log which is by default hidden and is what
users usually attach to bug reports.

The only known bug that triggers this is
https://bugs.llvm.org/show_bug.cgi?id=46775

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111149
2021-10-11 13:33:47 +02:00
Pavel Labath 8093c2ea57 [lldb] Make char[N] formatters respect the end of the array (PR44649)
I believe this is a more natural behavior, and it also matches what gdb
does.

Differential Revision: https://reviews.llvm.org/D111399
2021-10-11 12:47:11 +02:00
Michał Górny 36195d7d80 [lldb] [DynamicRegisterInfo] Remove non-const GetRegisterInfoAtIndex()
Differential Revision: https://reviews.llvm.org/D111408
2021-10-11 12:08:38 +02:00
Michał Górny fee461b1d8 [lldb] [ConnectionFileDescriptorPosix] Combine m_read_sp & m_write_sp
Combine m_read_sp and m_write_sp into a single m_io_sp.  In all
currently existing code paths, they are pointing to the same object
anyway.

Differential Revision: https://reviews.llvm.org/D111396
2021-10-11 12:08:08 +02:00
Muhammad Omair Javaid 483db1c706 [LLDB] Remove xfail decorator TestInferiorAssert.py AArch64/Linux
TestInferiorAssert.py test_inferior_asserting_disassemble passes after
upgrading LLDB AArch64/Linux buildbot to Ubuntu Focal.
2021-10-11 14:41:30 +05:00
Muhammad Omair Javaid c63cb0c80e [LLDB] Skip TestScriptedProcess on Arm/AArch64 Linux
This is failing on Arm and AArch64 Linux buildbots since the time it was
comitted.

https://lab.llvm.org/buildbot/#/builders/96/builds/12628

Differential Revision: https://reviews.llvm.org/D107585
2021-10-11 12:58:21 +05:00
Med Ismail Bennani c26e53e129
[lldb/test] Disable 'TestScriptedProcess.py' on macOS
This is disabling 'TestScriptedProcess.py' on macOS since it fails on
Green Dragon: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/35974

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-10 03:28:36 +02:00
Michał Górny fefd0ca31d [lldb] [DynamicRegisterInfo] Remove obsolete dwarf typedefs (NFC) 2021-10-09 15:42:34 +02:00
Raphael Isemann b5ff511048 [lldb][NFC] Early-exit in DWARFASTParserClang::ParseSingleMember
ParseSingleMember has two large ifs around the back of it's body:
`if (!is_artificial)` and `if (member_type)`. This patch just converts those
to early-exits. The patch is NFC. It even retains the curious fact that
Objective-C properties that fail to parse are silently ignored, but now there
is at least a FIXME that points this out.
2021-10-09 14:40:39 +02:00
Qiu Chaofan da0b62dfb3 Revert a LIT typo fix in a RUN line
Commit 573531f changes the behavior of the test, revert it back.
2021-10-09 11:29:44 +08:00
Qiu Chaofan 573531fb1f Fix typo of colon to semicolon in lit tests 2021-10-09 10:03:50 +08:00
Reid Kleckner 89b57061f7 Move TargetRegistry.(h|cpp) from Support to MC
This moves the registry higher in the LLVM library dependency stack.
Every client of the target registry needs to link against MC anyway to
actually use the target, so we might as well move this out of Support.

This allows us to ensure that Support doesn't have includes from MC/*.

Differential Revision: https://reviews.llvm.org/D111454
2021-10-08 14:51:48 -07:00
Med Ismail Bennani 88a941ba64 [lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)
This patch refactors Scripted Process and Scripted Thread related
classes to use LLVM_PRETTY_FUNCTION instead of the compiler macro.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 20:50:45 +02:00
Med Ismail Bennani f94c9af622 [lldb] Fix windows build failure due to undefined macro
This should fix a build failure on Windows caused by the macro
__PRETTY_FUNCTION__ not being defined.

https://lab.llvm.org/buildbot/#/builders/83/builds/10836

https://reviews.llvm.org/D107585

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 18:27:21 +02:00
Med Ismail Bennani 815c87fbe2
[lldb/test] Disable TestScriptedProcess.py unless Darwin
This patch disables TestScriptedProcess.py on Linux and Windows while I
investigate the OS specific failure:

http://lab.llvm.org:8011/#/builders/68/builds/19793

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 15:19:54 +02:00
Med Ismail Bennani a758c9f720 [lldb/Plugins] Add memory region support in ScriptedProcess
This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.

In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
  such as the memory region name, address range, permissions ...
  This is used when reading memory at some address to compute the offset
  in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
  to simplify the access to a specific memory region.

With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.

To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 14:54:07 +02:00
Med Ismail Bennani 59d8dd79e1 [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess
This patch introduces the `ScriptedThread` class with its python
interface.

When used with `ScriptedProcess`, `ScriptedThreaad` can provide various
information such as the thread state, stop reason or even its register
context.

This can be used to reconstruct the program stack frames using lldb's unwinder.

rdar://74503836

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-08 14:54:07 +02:00
Michał Górny 71fd5a735e [lldb] [test] Use secondary pty end for testing Terminal
Open and use the secondary end of a pty for testing Terminal properties
in order to fix the tests on Darwin.  While at it, streamline getting
the fd and Terminal class.

Differential Revision: https://reviews.llvm.org/D111402
2021-10-08 14:42:47 +02:00
Michał Górny 4b46a41343 [lldb] [ConnectionFileDescriptorPosix] Refactor scheme matching
Move the POSIX-specific fd:// and file:// scheme handling into
separate methods.  Replace the custom GetURLAddress() matching with
splitting into scheme and path, and matching scheme via
llvm::StringSwitch.  Use early returns.

Differential Revision: https://reviews.llvm.org/D111321
2021-10-08 11:47:57 +02:00
Michał Górny dcb0e687fa [lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile
Replace separate read and write NativeFile instances with a single
instance shared for reading and writing.  There is no clear indication
why two instances were used in the first place, and replacing them
with just one does not seem to cause any regressions in tests or manual
'process connect file://...'.

Differential Revision: https://reviews.llvm.org/D111314
2021-10-08 11:26:29 +02:00
Pavel Labath f4145c074c [lldb/gdb-remote] Refactor ReadExtFeature
replace stl and lldb apis with standard llvm ones.
2021-10-08 10:43:37 +02:00
Pavel Labath 3d7161e3c1 [lldb] Remove shared_ptr from some global Properties objects
they're unnecessary, make the code longer, and their removal actually
ensures proper initialization in multithreaded scenarios.
2021-10-08 10:43:37 +02:00
Qiu Chaofan 00c0ce0655 [NFC] [Clang] Remove pre-computed complex float types
As discussed in D109948, pre-computing all complex float types is not
necessary and brings extra overhead. This patch removes these defined
types, and construct them in-place when needed.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D111387
2021-10-08 15:52:16 +08:00
Jonas Devlieghere b225c5f786 [lldb] Parse and display reporting errors from JSON crashlogs
JSON crashlogs have an optional field named reportNotes that contains
any potential errors encountered by the crash reporter when generating
the crashlog. Parse and display them in LLDB.

Differential revision: https://reviews.llvm.org/D111339
2021-10-07 15:53:52 -07:00
Jonas Devlieghere b913065bf4 [lldb] Support missing threadState in JSON crashlogs
Gracefully deal with JSON crashlogs that don't have thread state
available and print an error saying as much: "No thread state (register
information) available".

rdar://83955858

Differential revision: https://reviews.llvm.org/D111341
2021-10-07 15:53:52 -07:00
Adrian Prantl 4651576edd Recognize the Swift compiler in DW_AT_producer
This patch adds support for Swift compiler producer strings to DWARFUnit.

Differential Revision: https://reviews.llvm.org/D111278
2021-10-07 13:54:28 -07:00
Kazu Hirata 3d7d543743 [lldb] Fix a "missing field" warning
This patch fixes:

  llvm-project/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp:204:6:
  error: missing field 'invalidate_regs' initializer
  [-Werror,-Wmissing-field-initializers]
2021-10-07 10:25:05 -07:00
David Spickett 5ecdb77fc5 [lldb] Mark abort signal test unsupported on AArch64 Linux
This has started failing since we moved our bots to Focal.
For unknown reasons the abort_caller stack is missing when
we check from the handler breakpoint.

Mark unsupported while I investigate.
2021-10-07 16:09:47 +00:00
Kazu Hirata 80e39366ee [lldb, mlir] Migrate from getNumArgOperands and arg_operands (NFC)
Note that getNumArgOperands and arg_operands are considered legacy
names.  See llvm/include/llvm/IR/InstrTypes.h for details.
2021-10-07 08:29:42 -07:00
Michał Górny ecfab0b6f5 [lldb] [DynamicRegisterInfo] Support iterating over registers()
Add DynamicRegisterInfo::registers() method that returns
llvm::iterator_range<> over RegisterInfos.  This is a convenient
replacement for GetNumRegisters() + GetRegisterInfoAtIndex().

Differential Revision: https://reviews.llvm.org/D111136
2021-10-07 16:07:04 +02:00
Raphael Isemann 322e13b91a [lldb] Rewrite/expand TestCppTypedef and document a lookup bug.
Just regrouping the checks for the same typedef together and also giving the
different typedefs unique names. We might want to have a second test with
identical names to see how LLDB handle the potential name conflict, but that
should be a separate test and not part of the main typedef test.

Also this test is actually unintentionally passing. LLDB can't lookup typedefs
in a struct/class scope, but in the test the check passes as the local variable
in the expression evaluation scope pulls in the typedef. I added a second check
that makes it clear that this is not working right now.
2021-10-07 13:30:03 +02:00
Pavel Labath 81a2f39307 [lldb/gdb-remote] Delete SendPacketsAndConcatenateResponses
ReadExtFeature provides equivalent functionality. Also fix a but in
ReadExtFeature, which prevented it from being used for auxv data (it
contains nul characters).
2021-10-07 13:09:27 +02:00
Pavel Labath 202af507fd Recommit: [lldb] Remove "dwarf dynamic register size expressions" from RegisterInfo
The previous version of the patch did not update the definitions in
conditionally compiled code. This patch includes changes to ARC and
windows targets.

Original commit message was:

These were added to support some mips registers on linux, but linux mips
support has now been removed due.

They are still referenced in the freebds mips implementation, but the
completeness of that implementation is also unknown. All other
architectures just set these fields to zero, which is a cause of
significant bloat in our register info definitions.

Arm also has registers with variable sizes, but they were implemented in
a more gdb-compatible fashion and don't use this feature.

Differential Revision: https://reviews.llvm.org/D110914
2021-10-07 11:15:00 +02:00
Jason Molenda 62d9163830 Don't register mem segments that aren't present in a corefile
A Mach-O corefile has an array of memory segments, representing
the memory of the process at the point of the capture.  Each segment
has a virtual address + size, and a file offset + size.  The file
size may be less than the virtual address size, indicating that
the memory was unavailable. When ProcessMachCore::DoLoadCore scans
this array of memory segments, it builds up a table to translate
virtual addresses to file offsets, for memory read requests.
This lookup table combines contiguous memory segments into a single
entry, to reduce the number of entries (some corefile writers will
emit a separate segement for each virtual meory page).

This contiguous check wasn't taking into account a segment that
isn't present in the corefile, e.g. filesize==0, and every contiguous
memory segment after that point would result in lldb reading the
wrong offset of the file because it didn't account for this.

I'd like to have an error message when someone tries to read memory from
one of these segments, instead of returning all zeroes, so this patch
intentionally leaves these out of the vmaddr -> fileoff table (and
avoids combining them with segments that actually do exist in the
corefile).

I'm a little unsure of writing a test for this one; I'd have to do
a yaml2obj of a corefile with the problem, or add an internal mode
to the Mach-O process save-core where it could write a filesize==0
segment while it was writing one.

rdar://83382487
2021-10-06 20:12:21 -07:00
Jason Molenda 809652c93b Update TODO noting that DriverKit should be added too
When BridgeOS and DriverKit are added to llvm Triple.
2021-10-06 20:12:21 -07:00
David Blaikie f6a561c4d6 DebugInfo: Use clang's preferred names for integer types
This reverts c7f16ab3e3 / r109694 - which
suggested this was done to improve consistency with the gdb test suite.
Possible that at the time GCC did not canonicalize integer types, and so
matching types was important for cross-compiler validity, or that it was
only a case of over-constrained test cases that printed out/tested the
exact names of integer types.

In any case neither issue seems to exist today based on my limited
testing - both gdb and lldb canonicalize integer types (in a way that
happens to match Clang's preferred naming, incidentally) and so never
print the original text name produced in the DWARF by GCC or Clang.

This canonicalization appears to be in `integer_types_same_name_p` for
GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb.

(I tested this with one translation unit defining 3 variables - `long`,
`long (*)()`, and `int (*)()`, and another translation unit that had
main, and a function that took `long (*)()` as a parameter - then
compiled them with mismatched compilers (either GCC+Clang, or
Clang+(Clang with this patch applied)) and no matter the combination,
despite the debug info for one CU naming the type "long int" and the
other naming it "long", both debuggers printed out the name as "long"
and were able to correctly perform overload resolution and pass the
`long int (*)()` variable to the `long (*)()` function parameter)

Did find one hiccup, identified by the lldb test suite - that CodeView
was relying on these names to map them to builtin types in that format.
So added some handling for that in LLVM. (these could be split out into
separate patches, but seems small enough to not warrant it - will do
that if there ends up needing any reverti/revisiting)

Differential Revision: https://reviews.llvm.org/D110455
2021-10-06 16:02:34 -07:00
Adrian Prantl 8c5f3348af Add a unit test for llvm-gcc producer strings and cleanup code. (NFC) 2021-10-06 14:56:17 -07:00
Adrian Prantl 2edb9058ea Simplify control flow (NFC) 2021-10-06 14:56:17 -07:00
Adrian Prantl 14aa3f3703 Use llvm::VersionTuple to store DWARF producer info (NFC)
This has the nice side-effect that it can actually store the quadruple version numbers that Apple's tools are using nowadays.

rdar://82982162

Differential Revision: https://reviews.llvm.org/D111200
2021-10-06 14:56:16 -07:00
Michał Górny 67231650e6 [lldb] [ABI/X86] Split base x86 and i386 classes
Split the ABIX86 class into two classes: base ABIX86 class that is
common to 32-bit and 64-bit ABIs, and ABIX86_i386 class that is the base
for 32-bit ABIs.  This removes the confusing concept that ABIX86
initializes 64-bit ABIs but is only the base for 32-bit ABIs.

Differential Revision: https://reviews.llvm.org/D111216
2021-10-06 22:21:48 +02:00
Stella Stamenova 10f16bc7b2 Revert "[lldb] [ABI/X86] Split base x86 and i386 classes"
This change broke the windows lldb bot.

This reverts commit a30a36f66a.
2021-10-06 10:56:45 -07:00
Michael Forster b2c906da19 Revert "[lldb] Remove "dwarf dynamic register size expressions" from RegisterInfo"
This reverts commit 00e704bf08.

This commit should should have updated
llvm/llvm-project/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp like the other
architectures.
2021-10-06 18:15:25 +02:00
Raphael Isemann f98df8a38b [lldb] Make 'this' substituton error more verbose. 2021-10-06 15:07:19 +02:00
Raphael Isemann 7862728cab [lldb] Rewrite and extend TestConstThis 2021-10-06 14:51:00 +02:00
Jaroslav Sevcik fd185cfc51 Reland "[lldb] Refactor variable parsing"
Separates the methods for recursive variable parsing in function
context and non-recursive parsing of global variables.

Original patch: https://reviews.llvm.org/rG601168e42037ac4433e74b920bb22f76d59ba420
Revert patch: https://reviews.llvm.org/rGca5be065c4c612554acdcae3ead01a1474eff296
Diff from the original patch: avoid using nullptr deref/ref.

Differential Revision: https://reviews.llvm.org/D110570
2021-10-06 14:25:47 +02:00
Michał Górny 02e690ba0b [lldb] [FreeBSD] Fix building on systems without PT_COREDUMP
PT_COREDUMP is a relatively recent addition.  Use an #ifdef to skip it
if the underlying system does not support it.

Differential Revision: https://reviews.llvm.org/D111214
2021-10-06 14:05:07 +02:00
Michał Górny a30a36f66a [lldb] [ABI/X86] Split base x86 and i386 classes
Split the ABIX86 class into two classes: base ABIX86 class that is
common to 32-bit and 64-bit ABIs, and ABIX86_i386 class that is the base
for 32-bit ABIs.  This removes the confusing concept that ABIX86
initializes 64-bit ABIs but is only the base for 32-bit ABIs.

Differential Revision: https://reviews.llvm.org/D111216
2021-10-06 13:59:21 +02:00
Pavel Labath 00e704bf08 [lldb] Remove "dwarf dynamic register size expressions" from RegisterInfo
These were added to support some mips registers on linux, but linux mips
support has now been removed due.

They are still referenced in the freebds mips implementation, but the
completeness of that implementation is also unknown. All other
architectures just set these fields to zero, which is a cause of
significant bloat in our register info definitions.

Arm also has registers with variable sizes, but they were implemented in
a more gdb-compatible fashion and don't use this feature.

Differential Revision: https://reviews.llvm.org/D110914
2021-10-06 13:22:38 +02:00
Muhammad Omair Javaid d2b9d0fdda Round XML register bitsize to byte boundary
This patch allows LLDB to accept register sizes which are not aligned
to 8 bits bitsize boundary. This fixes a crash in LLDB when connecting
to OpenOCD stub. GDB xml description allows for non-aligned bit lengths
but they are rounded off to nearest byte during transfer. In case of
OpenOCD some of SOC specific system registers were less than a single
byte in length and were causing LLDB to crash.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111131
2021-10-06 14:03:49 +05:00
Jonas Devlieghere 730fca46fc [lldb] Improve meta data stripping from JSON crashlogs
JSON crashlogs normally start with a single line of meta data that we
strip unconditionally. Some producers started omitting the meta data
which tripped up crashlog. Be more resilient by only removing the first
line when we know it really is meta data.

rdar://82641662
2021-10-05 12:15:54 -07:00
David Zarzycki 5bc32ad08d [lldb testing] NFC: run through clang-format 2021-10-05 13:40:27 -04:00
Keith Smiley 0f3254b29f [lldb] Improve help for platform put-file
Previously it was not clear what arguments this required, or what it would do if you didn't pass the destination argument.

Differential Revision: https://reviews.llvm.org/D110981
2021-10-05 10:29:37 -07:00
David Zarzycki 79bf032fe1 [lldb testing] Avoid subtle terminfo behavioral differences
The original "arbitrary" changes were causing EINVAL on a Fedora 34 box.
2021-10-05 10:28:02 -04:00
Raphael Isemann cf818b55e7 [lldb][NFC] Remove unnecessary include in cpp/const_this test 2021-10-05 14:39:10 +02:00
Michał Górny 214054f78a [lldb] Move DynamicRegisterInfo to public Target library
Move DynamicRegisterInfo from the internal lldbPluginProcessUtility
library to the public lldbTarget library.  This is a prerequisite
towards ABI plugin changes that are going to pass DynamicRegisterInfo
parameters.

Differential Revision: https://reviews.llvm.org/D110942
2021-10-05 12:40:55 +02:00
Pavel Labath ca5be065c4 Revert "[lldb] Refactor variable parsing"
This commit has introduced test failures in internal google tests.
Working theory is they are caused by a genuine problem in the patch
which gets tripped by some debug info from system libraries.

Reverting while we try to reproduce the problem in a self-contained
fashion.

This reverts commit 601168e420.
2021-10-05 10:46:30 +02:00
Pavel Labath 93c1b3caf0 [lldb] Remove some anonymous namespaces
.. and reduce the scope of others. They don't follow llvm coding
standards (which say they should be used only when the same effect
cannot be achieved with the static keyword), and they set a bad example.
2021-10-05 08:35:18 +02:00
Raphael Isemann 6fcb857746 [lldb][import-std-module] Prefer the non-module diagnostics when in fallback mode
The `fallback` setting for import-std-module is supposed to allow running
expression that require an imported C++ module without causing any regressions
for users (neither in terms of functionality nor performance). This is done by
first trying to normally parse/evaluate an expression and when an error occurred
during this first attempt, we retry with the loaded 'std' module.

When we run into a system with a 'std' module that for some reason doesn't build
or otherwise causes parse errors, then this currently means that the second
parse attempt will overwrite the error diagnostics of the first parse attempt.
Given that the module build errors are outside of the scope of what the user can
influence, it makes more sense to show the errors from the first parse attempt
that are only concerned with the actual user input.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D110696
2021-10-04 19:16:03 +02:00
Alfsonso Gregory 3fe771bf02 [LLDB] Fix objc_clsopt_v16_t struct
The objc_clsopt_v16_t struct does not match up with the macOS/iOS15
dyld_shared_cache ObjC runtime structures. A struct field was seemingly
omitted.

Differential revision: https://reviews.llvm.org/D110477
2021-10-04 08:55:09 -07:00
Pavel Labath fd9bc13803 [lldb] Fix a stray array access in Editline
This manifested itself as an asan failure in TestMultilineNavigation.py.
2021-10-04 14:26:02 +02:00
Michał Górny e77959cba7 [lldb] Add unit tests for Terminal API
Differential Revision: https://reviews.llvm.org/D110962
2021-10-04 14:19:34 +02:00
Michał Górny 45f9795085 [lldb] [test] Terminate "process connect" connections via kill
Fix the termination of "process connect" (and "gdb-remote") to kill
the process rather than attempting to disconnect the platform.
The latter only results in an error since we did not use "platform
connect", and apparently process-level connections (at least via
gdb-remote) do not really support disconnecting.

Differential Revision: https://reviews.llvm.org/D110996
2021-10-04 12:29:06 +02:00
Muhammad Omair Javaid 71ad0f9d4e [LLDB] Skip TestClangREPL.py on Arm/AArch64 Linux
TestClangREPL.py has been failing randomly on Arm/AArch64 Linux
buildbot. I am marking it as skipped to reduce false alarms.
2021-10-04 11:50:17 +05:00
Jaroslav Sevcik 601168e420 [lldb] Refactor variable parsing
Separates the methods for recursive variable parsing in function
context and non-recursive parsing of global variables.

Differential Revision: https://reviews.llvm.org/D110570
2021-10-04 07:58:20 +02:00
Michał Górny f8537895b9 [lldb] [Host] Sync TerminalState::Data to struct type 2021-10-01 20:34:11 +02:00
Arthur Eubanks a7b4ce9cfd [NFC][AttributeList] Replace index_begin/end with an iterator
We expose the fact that we rely on unsigned wrapping to iterate through
all indexes. This can be confusing. Rather, keeping it as an
implementation detail through an iterator is less confusing and is less
code.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D110885
2021-10-01 10:17:41 -07:00
Michał Górny bd21257bf5 [lldb] [Host] Fix flipped logic in TerminalState::Save() 2021-10-01 18:23:54 +02:00
Pavel Labath 633ac51709 [lldb] Simplify TestCompletion.py 2021-10-01 15:49:23 +02:00
Michał Górny 12ee4c9ad8 [lldb] [test] Delay pty/tty imports to fix Windows builds
Delay pty/tty module imports until they are actually used, in order
to prevent their import failures on Windows.
2021-10-01 15:25:35 +02:00
Michał Górny 8fa2394bad [lldb] Add a gdb_remote_client test for connecting to pty
Add a minimal mock server utilizing a pty, and add a client test
connecting to that server.

Differential Revision: https://reviews.llvm.org/D110878
2021-10-01 14:31:40 +02:00
Michał Górny 58b4501eea [lldb] [Host] Refactor TerminalState
Refactor TerminalState to make the code simpler.  Move 'struct termios'
to a PImpl-style subclass.  Add an RAII interface to automatically store
and restore the state.

Differential revision: https://reviews.llvm.org/D110721
2021-10-01 12:53:21 +02:00
Jonas Devlieghere b505ed9d31 [lldb] Remove support for replaying the test suite from a reproducer
This patch removes the infrastructure to replay the test suite from a
reproducer, as well as the modifications made to the individual tests.
2021-09-30 10:47:19 -07:00
Jim Ingham 2303391d1f Make "process attach -c" work correctly, and add a test for it.
The issue here was that we were not updating the interpreter's
execution context when calling HandleCommand to continue the process.
Since we had just created the process, it wasn't in the interpreter's
execution context so HandleCommand failed at CheckRequirements.  The
patch fixes that by passing the process execution context directly
to HandleCommand.

Differential Revision: https://reviews.llvm.org/D110787
2021-09-29 19:38:09 -07:00
Jim Ingham 3bf3b96629 Add the --relative-to-command-file to "command source" so you can
have linked command files in a source tree and get to them all from
one main command file.

Differential Revision: https://reviews.llvm.org/D110601
2021-09-29 19:33:41 -07:00
Alex Langford 385b2189cc [lldb] Remove Expression's dependency on CPlusPlusLanguagePlugin
This change accomplishes the following:
- Moves `IRExecutionUnit::FindBestAlternateMangledName` to `Language`.
- Renames `FindBestAlternateMangledName` to
  `FindBestAlternateFunctionMangledName`
- Changes the first parameter of said method from a `ConstString`
  representing a demangled name to a `Mangled`.
- Remove the use of CPlusPlusLanguage from Expression
2021-09-29 11:39:09 -07:00
Walter Erquinigo d35702efe7 Fix LLDB build on old Linux kernels
Usage of aux_size is guarded against elsewhere in this file, but is missing here.

Reviewed By: wallace

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

Original Author: calebzulawski
2021-09-29 09:42:32 -07:00
Raphael Isemann f939a32e5c [lldb] Fix TestImportStdModule on some setups by testing minmax instead of abs
Some downstream forks of LLDB change parts of the test setup in a way that
causes lldb to somehow resolve `std::abs` (probably to `::abs`). This patch
changes the tested function here to be `std::minmax` which (hopefully) doesn't
have any identically named functions that LLDB could find and call. Just to be
extra safe this also explicitly specified the template arguments so that in
case there is a `minmax` non-template function we still don't end up calling it
from this test.
2021-09-29 17:03:37 +02:00
Michał Górny 52b04efa01 [lldb] [Host] Remove TerminalStateSwitcher
Remove TerminalStateSwitcher class.  It is not used anywhere and its API
is really weird.  This is the first step towards cleaning up Terminal.h.

Differential Revision: https://reviews.llvm.org/D110693
2021-09-29 13:45:41 +02:00
Pavel Labath f6e3abc530 [lldb/gdb-remote] Remove last_stop_packet_mutex
This is a remnant of the non-stop mode.
2021-09-29 11:23:14 +02:00
Andrew Turner 993ada05f5 [lldb] [unittests] Fix building the FreeBSD arm64 Register Context test
Differential Revision: https://reviews.llvm.org/D110545
2021-09-28 10:51:06 -04:00
Michał Górny 86cd2369b6 [lldb] [DynamicRegisterInfo] Refactor SetRegisterInfo()
Move the "slice" and "composite" handling into separate methods to avoid
if/else hell.  Use more LLVM types whenever possible.  Replace printf()s
with llvm::Error combined with LLDB logging.

Differential Revision: https://reviews.llvm.org/D110619
2021-09-28 16:47:58 +02:00
Pavel Labath 7866dbb261 [lldb/test] Remove a check from TestLoadAfterAttach
The two module retrieval methods (qXfer:libraries-svr4 and manual list
traversal) differ in how the handle the
manually-added-but-not-yet-loaded modules. The svr4 path will remove it,
while the manual one will keep in the list.

It's likely the two paths need ought to be synchronized, but right now,
this distinction is not relevant for the test.
2021-09-28 14:47:46 +02:00
Pavel Labath 9413ead7bc [lldb/test] Add ability to specify environment when spawning processes
We only had that ability for regular debugger launches. This meant that
it was not possible to use the normal dlopen patterns in attach tests.
This fixes that.
2021-09-28 14:13:50 +02:00
Pavel Labath 156cb4cc64 [lldb] Remove non-stop mode code
We added some support for this mode back in 2015, but the feature was
never productionized. It is completely untested, and there are known
major structural lldb issues that need to be resolved before this
feature can really be supported.

It also complicates making further changes to stop reply packet
handling, which is what I am about to do.

Differential Revision: https://reviews.llvm.org/D110553
2021-09-28 14:13:50 +02:00
Pavel Labath 3dbf27e762 [lldb] A different fix for Domain Socket tests
we need to drop nuls from the end of the string.
2021-09-27 18:00:27 +02:00
Raphael Isemann be2a4216fc [lldb] Fix SocketTest.DomainGetConnectURI on macOS by stripping more zeroes from getpeername result
Apparently macOS is padding the name result with several padding zeroes at
the end. Just strip them all to pretend it's a C-string.

Thanks to Pavel for suggesting this fix.
2021-09-27 17:34:45 +02:00
Michał Górny 33031545bf [lldb] [DynamicRegisterInfo] Add a convenience method to add suppl. registers
Add a convenience method to add supplementary registers that takes care
of adding invalidate_regs to all (potentially) overlapping registers.

Differential Revision: https://reviews.llvm.org/D110023
2021-09-27 16:01:30 +02:00
Michał Górny 9da2fa277e [lldb] Move StringConvert inside debugserver
The StringConvert API is no longer used anywhere but in debugserver.
Since debugserver does not use LLVM API, we cannot replace it with
llvm::to_integer() and llvm::to_float() there.  Let's just move
the sources into debugserver.

Differential Revision: https://reviews.llvm.org/D110478
2021-09-27 14:32:42 +02:00
Michał Górny 93b82f45bc [lldb] [Host] Refactor XML converting getters
Refactor the XML converting attribute and text getters to use LLVM API.
While at it, remove some redundant error and missing XML support
handling, as the called base functions do that anyway.  Add tests
for these methods.

Note that this patch changes the getter behavior to be IMHO more
correct.  In particular:

- negative and overflowing integers are now reported as failures to
  convert, rather than being wrapped over or capped

- digits followed by text are now reported as failures to convert
  to double, rather than their numeric part being converted

Differential Revision: https://reviews.llvm.org/D110410
2021-09-27 14:26:33 +02:00
Emre Kultursay d5629b5d4d Fix rendezvous for rebase_exec=true case
When rebase_exec=true in DidAttach(), all modules are loaded
before the rendezvous breakpoint is set, which means the
LoadInterpreterModule() method is not called and m_interpreter_module
is not initialized.

This causes the very first rendezvous breakpoint hit with
m_initial_modules_added=false to accidentally unload the
module_sp that corresponds to the dynamic loader.

This bug (introduced in D92187) was causing the rendezvous
mechanism to not work in Android 28. The mechanism works
fine on older/newer versions of Android.

Test: Verified rendezvous on Android 28 and 29
Test: Added dlopen test

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D109797
2021-09-27 13:27:27 +02:00
Michał Górny f4b71e3479 [llvm] [ADT] Add a range/iterator-based Split()
Add a llvm::Split() implementation that can be used via range-for loop,
e.g.:

    for (StringRef x : llvm::Split("foo,bar,baz", ','))
      ...

The implementation uses an additional SplittingIterator class that
uses StringRef::split() internally.

Differential Revision: https://reviews.llvm.org/D110496
2021-09-27 10:43:09 +02:00
Krasimir Georgiev 92b475f0b0 [lldb] silence -Wsometimes-uninitialized warnings
No functional changes intended.

Silence warnings from
3a6ba36751.
2021-09-27 09:35:58 +02:00
Michał Górny e2f780fba9 [lldb] [gdb-remote] Use llvm::StringRef.split() and llvm::to_integer()
Replace the uses of StringConvert combined with hand-rolled array
splitting with llvm::StringRef.split() and llvm::to_integer().

Differential Revision: https://reviews.llvm.org/D110472
2021-09-26 21:23:26 +02:00
Michał Górny 3a6ba36751 [lldb] Convert misc. StringConvert uses
Replace misc. StringConvert uses with llvm::to_integer()
and llvm::to_float(), except for cases where further refactoring is
planned.  The purpose of this change is to eliminate the StringConvert
API that is duplicate to LLVM, and less correct in behavior at the same
time.

Differential Revision: https://reviews.llvm.org/D110447
2021-09-25 14:19:19 +02:00
Markus Böck 0b61f43b60 [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES
Linking against the LibXml2::LibXml2 target has the advantage of not only importing the library, but also adding the include path as well as any definitions the library requires. In case of a static build of libxml2, eg. a define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made redundant since https://reviews.llvm.org/D84563 I believe

Differential Revision: https://reviews.llvm.org/D109975
2021-09-25 13:13:11 +02:00
Jason Molenda a2e1d68fa9 Add pragma to make it easier to find "image list" impl
I couldn't find it; make this easier for next time.
2021-09-24 17:13:03 -07:00
Jonas Devlieghere c628875929 [lldb] Copy the system debugserver in LLDB.framework
When using the system debugserver for testing, copy the binary in the
LLDB.framework Resource directory instead of the build's bin directory.

rdar://82998263
2021-09-24 15:07:22 -07:00
Michał Górny 5f1c8d8a43 [lldb] [Host] Refactor Socket::DecodeHostAndPort() to use LLVM API
Refactor Socket::DecodeHostAndPort() to use LLVM API over redundant
LLDB API.  In particular, this means llvm::Regex, llvm::Error return
type and llvm::to_integer().

While at it, change the port type from int32_t to uint16_t.  The method
never returns any value outside this range, and using the correct type
allows us to rely on getAsInteger()'s implicit overflow check.

Differential Revision: https://reviews.llvm.org/D110391
2021-09-24 14:58:02 +02:00
Michał Górny c1af84ceaf Revert "[lldb] [Host] Refactor Socket::DecodeHostAndPort() to use LLVM API"
This reverts commit a6daf99228.  It causes
buildbot regressions, I'll investigate.
2021-09-24 13:33:51 +02:00
Michał Górny a6daf99228 [lldb] [Host] Refactor Socket::DecodeHostAndPort() to use LLVM API
Refactor Socket::DecodeHostAndPort() to use LLVM API over redundant
LLDB API.  In particular, this means llvm::Regex, llvm::Error return
type and llvm::to_integer().

While at it, change the port type from int32_t to uint16_t.  The method
never returns any value outside this range, and using the correct type
allows us to rely on getAsInteger()'s implicit overflow check.

Differential Revision: https://reviews.llvm.org/D110391
2021-09-24 13:24:58 +02:00
Pavel Labath cd6893a5a3 [lldb] Fix target-symbols-add-unwind.test for clang 7647a841
We need a different flag combination to produce .debug_frame.
2021-09-24 09:06:44 +02:00
Ted Woodward 953ddded1a [lldb] Handle malformed qfThreadInfo reply
If the remote gdbserver's qfThreadInfo reply has a trailing comma,
GDBRemoteCommunicationClient::GetCurrentProcessAndThreadIDs will return
an empty vector of thread ids. This will cause lldb to recurse through
three functions trying to get the list of threads, until it blows its
stack and crashes.

A trailing comma is a malformed response, but it shouldn't cause lldb to
crash. This patch will return the tids received before the malformed
response.

Reviewed By: clayborg, labath

Differential Revision: https://reviews.llvm.org/D109937
2021-09-23 17:03:47 -05:00
Augusto Noronha fbaf367217 [lldb] Show fix-it applied even if expression didn't evaluate succesfully
If we applied a fix-it before evaluating an expression and that
expression didn't evaluate correctly, we should still tell users about
the fix-it we applied since that may be the reason why it didn't work
correctly.

Differential Revision: https://reviews.llvm.org/D109908
2021-09-23 16:45:04 -03:00
Michał Górny cc3c788ad2 [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs
Switch the gdb-remote client logic to use local (LLDB) register numbers
in value_regs/invalidate_regs rather than remote regnos. This involves
translating regnos received from lldb-server.

Differential Revision: https://reviews.llvm.org/D110027
2021-09-23 20:02:01 +02:00
Michał Górny fa456505b8 [lldb] [gdb-remote] Refactor getting remote regs to use local vector
Refactor remote register getters to collect them into a local
std::vector rather than adding them straight into DynamicRegisterInfo.
The purpose of this change is to lay groundwork for switching value_regs
and invalidate_regs to use local LLDB register numbers rather than
remote numbers.

Differential Revision: https://reviews.llvm.org/D110025
2021-09-23 20:02:00 +02:00
Raphael Isemann c22329972f [lldb] Add a C language REPL to test LLDB's REPL infrastructure
LLDB has a bunch of code that implements REPL support, but all that code is
unreachable as no language in master currently has an implemented REPL backend.
The only REPL that exists is in the downstream Swift fork. All patches for this
generic REPL code therefore also only have tests downstream which is clearly not
a good situation.

This patch implements a basic C language REPL on top of LLDB's REPL framework.
Beside implementing the REPL interface and hooking it up into the plugin
manager, the only other small part of this patch is making the `--language` flag
of the expression command compatible with the `--repl` flag. The `--repl` flag
uses the value of `--language` to see which REPL should be started, but right
now the `--language` flag is only available in OptionGroups 1 and 2, but not in
OptionGroup 3 where the `--repl` flag is declared.

The REPL currently can currently only start if a running target exists. I'll add
the 'create and run a dummy executable' logic from Swift (which is requires when
doing `lldb --repl`) when I have time to translate all this logic to something
that will work with Clang.

I should point out that the REPL currently uses the C expression parser's
approach to persistent variables where only result variables and the ones
starting with a '$' are transferred between expressions. I'll fix that in a
follow up patch. Also the REPL currently doesn't work in a non-interactive
terminal. This seems to be fixed in the Swift fork, so I assume one of our many
REPL downstream changes addresses the issue.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D87281
2021-09-23 19:31:02 +02:00
Michał Górny bcb6b97cde Revert "[lldb] [gdb-remote] Refactor getting remote regs to use local vector"
This reverts commit b03e701c14.  This is
causing regressions when XML support is disabled.
2021-09-23 18:17:09 +02:00
Michał Górny 12504f5072 Revert "[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs"
This reverts commit 6fbed33d4a.
The prerequisite commit is causing regressions.
2021-09-23 18:17:09 +02:00
Michał Górny 6fbed33d4a [lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs
Switch the gdb-remote client logic to use local (LLDB) register numbers
in value_regs/invalidate_regs rather than remote regnos. This involves
translating regnos received from lldb-server.

Differential Revision: https://reviews.llvm.org/D110027
2021-09-23 17:21:56 +02:00
Michał Górny b03e701c14 [lldb] [gdb-remote] Refactor getting remote regs to use local vector
Refactor remote register getters to collect them into a local
std::vector rather than adding them straight into DynamicRegisterInfo.
The purpose of this change is to lay groundwork for switching value_regs
and invalidate_regs to use local LLDB register numbers rather than
remote numbers.

Differential Revision: https://reviews.llvm.org/D110025
2021-09-23 17:21:55 +02:00
Pavel Labath 5685eb950d [lldb] Fix DomainSocket::GetSocketName for unnamed sockets
getpeername will return addrlen = 2 (sizeof sa_family_t) for unnamed
sockets (those not assigned a name with bind(2)). This is typically true
for client sockets as well as those created by socketpair(2).

This GetSocketName used to crash for sockets which were connected to
these kinds of sockets. Now it returns an empty string.
2021-09-23 12:30:18 +02:00
Alex Langford 4355265131 [lldb] Remove IRExecutionUnit::CollectFallbackNames
The work that IRExecutionUnit::CollectFallbackNames is basically the
work that `CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments`
does already. It's also (at time or writing) specific to C++, so it can
be folded into `IRExecutionUnit::CollectCandidateCPlusPlusNames`.

Differential Revision: https://reviews.llvm.org/D109928
2021-09-22 11:01:15 -07:00
Stefan Gränitz 9689c1b7bb [lldb] JITLoaderGDB tests can use lli in ORC greedy mode
At first, lli only supported lazy mode for ORC. Greedy mode was added with e1579894d2 and is the default settings now. JITLoaderGDB tests don't rely on laziness, so we can switch them to greedy and remove some complexity.
2021-09-22 14:46:19 +02:00
Martin Storsjö 9f34f75ff8 [lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64
Based on suggestions by Eric Youngdale.

This fixes https://llvm.org/PR51673.

Differential Revision: https://reviews.llvm.org/D109777
2021-09-22 14:11:41 +03:00
Jonas Devlieghere 47f79c6057 [lldb] Add --stack option to `target symbols add` command
Currently you can ask the target symbols add command to locate the debug
symbols for the current frame. This patch add an options to do that for
the whole call stack.

Differential revision: https://reviews.llvm.org/D110011
2021-09-21 23:08:14 -07:00
David Blaikie 40e971a210 nullptr printing - update for a change to clang type printing that now uses "std::nullptr_t" 2021-09-21 11:50:24 -07:00
Nico Weber 908c115442 [lldb/win] Default to native PDB reader when LLVM_ENABLE_DIA_SDK=NO
Trying to use the DIA SDK reader only to fail with "DIA SDK wasn't enabled"
isn't very useful. The native PDB reader is missing some stuff, but it's still
better than nothing.

Reduces number of lldb-check-shell test failures with LLVM_ENABLE_DIA_SDK=NO
from 27 to 15.

Differential Revision: https://reviews.llvm.org/D110172
2021-09-21 13:02:52 -04:00
Pavel Labath 791b6ebc86 [lldb] Speculative fix to TestGuiExpandThreadsTree
This test relies on being able to unwind from an arbitrary place inside
libc. While I am not sure this is the cause of the observed flakyness,
it is known that we are not able to unwind correctly from some places in
(linux) libc.

This patch adds additional synchronization to ensure that the inferior
is in the main function (instead of pthread guts) when lldb tries to
unwind it. At the very least, it should make the test runs more
predictable/repeatable.
2021-09-21 10:01:00 +02:00
Alex Langford c4a406bbd0 [lldb][NFC] Remove outdated FIXME 2021-09-20 11:44:20 -07:00
Vedant Kumar e31b2d7d7b [lldb][crashlog] Avoid specifying arch for image when a UUID is present
When adding an image to a target for crashlog purposes, avoid specifying
the architecture of the image.

This has the effect of making SBTarget::AddModule infer the ArchSpec for
the image based on the SBTarget's architecture, which LLDB puts serious
effort into calculating correctly (in TargetList::CreateTargetInternal).

The status quo is that LLDB randomly guesses the ArchSpec for a module
if its architecture is specified, via:

```
  SBTarget::AddModule -> Platform::GetAugmentedArchSpec -> Platform::IsCompatibleArchitecture ->
GetSupportedArchitectureAtIndex -> {ARM,x86}GetSupportedArchitectureAtIndex
```

... which means that the same crashlog can fail to load on an Apple
Silicon Mac (due to the random guess of arm64e-apple-macosx for the
module's ArchSpec not being compatible with the SBTarget's (correct)
ArchSpec), while loading just fine on an Intel Mac.

I'm not sure how to add a test for this (it doesn't look like there's
test coverage of this path in-tree). It seems like it would be pretty
complicated to regression test: the host LLDB would need to be built for
arm64e, we'd need a hand-crafted arm64e iOS crashlog, and we'd need a
binary with an iOS deployment target. I'm open to other / simpler
options.

rdar://82679400

Differential Revision: https://reviews.llvm.org/D110013
2021-09-20 10:23:35 -07:00
Jonas Devlieghere a89bfc6120 [lldb] Extract adding symbols for UUID/File/Frame (NFC)
This moves the logic for adding symbols based on UUID, file and frame
into little helper functions. This is in preparation for D110011.

Differential revision: https://reviews.llvm.org/D110010
2021-09-20 09:08:04 -07:00
Jonas Devlieghere fe4b8467b5 [lldb] Fix whitespace in CommandObjectTarget (NFC) 2021-09-20 09:08:03 -07:00
Michał Górny ec50d351ff [lldb] [DynamicRegisterInfo] Unset value_regs/invalidate_regs before Finalize()
Set value_regs and invalidate_regs in RegisterInfo pushed onto m_regs
to nullptr, to ensure that the temporaries passed there are not
accidentally used.

Differential Revision: https://reviews.llvm.org/D109879
2021-09-20 15:02:20 +02:00
Michał Górny 4737dcbc83 [lldb] [test] Add unittest for DynamicRegisterInfo::Finalize()
Differential Revision: https://reviews.llvm.org/D109906
2021-09-20 15:02:20 +02:00
Michał Górny b1099120ff [lldb] [gdb-remote] Always send PID when detaching w/ multiprocess
Always send PID in the detach packet when multiprocess extensions are
enabled.  This is required by qemu's GDB server, as plain 'D' packet
results in an error and the emulated system is not resumed.

Differential Revision: https://reviews.llvm.org/D110033
2021-09-20 13:29:07 +02:00
Michał Górny f6e0edc23e [lldb] [gdb-remote] Recognize aarch64v type from gdbserver
Differential Revision: https://reviews.llvm.org/D109899
2021-09-20 10:41:38 +02:00
Michał Górny 92904cc68f [lldb] [gdb-remote] Remove unused arg from GDBRemoteRegisterContext::ReadRegisterBytes()
Differential Revision: https://reviews.llvm.org/D110020
2021-09-20 10:24:01 +02:00
Pavel Labath 966922320f [lldb] Remove two #ifndef linux from Platform.cpp
These have been here since r215992, guarding the calls to HostInfo, but
their purpose unclear -- HostInfoLinux provides these functions and they
work fine.
2021-09-20 08:30:02 +02:00