Commit Graph

25161 Commits

Author SHA1 Message Date
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
Vedant Kumar 3b14d80ad4 [MachCore] Report arm64 thread exception state
A MachO userspace corefile may contain LC_THREAD commands which specify
thread exception state.

For arm64* only (for now), report a human-readable version of this state
as the thread stop reason, instead of 'SIGSTOP'.

As a follow-up, similar functionality can be implemented for x86 cores
by translating the trapno/err exception registers.

rdar://82898146

Differential Revision: https://reviews.llvm.org/D109795
2021-09-17 16:45:03 -07:00
Jan Kratochvil e93baded39 [nfc] [lldb] Remove unused DIEPointerSet, DeclToDIEMap and m_decl_to_die
In whole GIT history this map has been always only written but never read.
2021-09-17 21:51:36 +02:00
Augusto Noronha 8fb8601102 Revert "[lldb] Skip TestAppleSimulatorOSType if json parsing fails"
This reverts commit 47dd1f6428.
After discussing with Jim Ingham, we agreed to leave the test as-is
so we can catch any CI problems instead of silently skipping the test.
2021-09-16 17:49:59 -03:00
Vedant Kumar 79e48f3c7c Revert "[MachCore] Report arm64 thread exception state"
This reverts commit 7eb67748f9. It causes
TestMachCore.MachCoreTestCase to fail.
2021-09-16 13:43:35 -07:00
Vedant Kumar 7eb67748f9 [MachCore] Report arm64 thread exception state
A MachO userspace corefile may contain LC_THREAD commands which specify
thread exception state.

For arm64* only (for now), report a human-readable version of this state
as the thread stop reason, instead of 'SIGSTOP'.

As a follow-up, similar functionality can be implemented for x86 cores
by translating the trapno/err exception registers.

rdar://82898146

Differential Revision: https://reviews.llvm.org/D109795
2021-09-16 13:35:06 -07:00
Alex Langford a65f6aafe2 [lldb] Refactor and rename CPlusPlusLanguage::FindAlternateFunctionManglings
I have 2 goals with this change:
1. Disambiguate between CPlusPlus::FindAlternateFunctionManglings and
   IRExecutionUnit::FindBestAlternateMangledName. These are named very
   similar things, they try to do very similar things, but their
   approaches are different. This change should make it clear that one
   is generating possible alternate manglings (through some
   heuristics-based approach) and the other is finding alternate
   manglings (through searching the SymbolFile for potential matches).
2. Change GenerateAlternateFunctionManglings from a static method in
   CPlusPlusLanguage to a virtual method in Language. This will allow us
   to remove a direct use of CPlusPlusLanguage in IRExecutionUnit,
   further pushing it to be more general. This change doesn't meet this
   goal completely but allows for it to happen later.

Though this doesn't remove IRExecutionUnit's dependency on
CPlusPlusLanguage, it does bring us closer to that goal.

Differential Revision: https://reviews.llvm.org/D109785
2021-09-16 13:13:07 -07:00
Augusto Noronha 47dd1f6428 [lldb] Skip TestAppleSimulatorOSType if json parsing fails
xcodebuild, which is invoked by the apple_simulator_test decorator, may
may return a successful status even if it was unable to run due to the
authorization agent denying it. This causes the TestAppleSimulatorOSType
to run when it shouldn't, and throw an excpection when parsing the JSON
that lists the simulators available. Wrap the json parsing in a
try/except block and if it fails, skip the ttest.

Differential Revision: https://reviews.llvm.org/D109336
2021-09-16 16:38:20 -03:00
Jonas Devlieghere c96d45700f [lldb] Remove SBExecutionContext::reset (NFC)
This is a protected function that's not implemented.
2021-09-16 11:00:12 -07:00
Alfonso Gregory a2c319fdc6 [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project
This way, we do not need to set LLVM_CMAKE_PATH to LLVM_CMAKE_DIR when (NOT LLVM_CONFIG_FOUND)

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D107717
2021-09-16 18:29:57 +02:00
Nico Weber 99ece01a0f [lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash
lit.util.which('link') picks up the wrong link.exe in git bash, leading
to this error:

  # command stderr:
  /usr/bin/link: extra operand '/LIBPATH:C:\\Progra....'
  Try '/usr/bin/link --help' for more information.

Instead, assume that link.exe is next to cl.exe.

Differential Revision: https://reviews.llvm.org/D109832
2021-09-16 07:40:54 -04:00
Michał Górny 47d57547f4 [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver
Alias the "sp" register to "x31" on AArch64 if one is present and does
not have the alt_name.  This is the case when connecting to gdbserver.

Differential Revision: https://reviews.llvm.org/D109695
2021-09-16 13:13:47 +02:00
Michał Górny 86a58f1028 [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo
Remove the name and alt_name parameters from AddRegister() and instead
pass them via RegisterInfo.name and .alt_name fields.  This makes
the API simpler and removes some duplication.

Differential Revision: https://reviews.llvm.org/D109872
2021-09-16 12:00:20 +02:00
Pavel Labath bd590a5f89 [lldb] Make Platform::DebugProcess take a Target reference
instead of a pointer. There are just two callers of this function, and
both of them have a valid target pointer, so there's no need for all
implementations to concern themselves with whether the pointer is null.
2021-09-16 11:33:47 +02:00
Jason Molenda ceded41532 Don't set executable file in ObjectFileMachO::LoadCoreFileImages
When the corefile reader is adding binaries from the "all image
infos" LC_NOTE in a Mach-O corefile, it would detect if the binary
being added was an executable binary and set it as the Target's
executable binary.  This has the side effect of clearing the Target's
image list, so if the executable was in the middle of the all image
infos, the initial images would be dropped.  There's no need to set
the executable binary in the Target for these corefile processes,
so instead of doing multiple passes over the list to find the
executable, I'm dropping that.
2021-09-16 01:38:48 -07:00
Michał Górny c208deb900 [lldb] [ABI/AArch64] Recognize special regs by their xN names too
Recognize lr/sp/fp by their numeric register names in the ABI plugin.
This is necessary to mark them appropriately when interfacing with
gdbserver.

Differential Revision: https://reviews.llvm.org/D109691
2021-09-16 10:23:31 +02:00
Michał Górny 66249323d2 [lldb] [gdb-remote] Try using <architecture/> for remote arch unconditionally
Try determining the process architecture from <architecture/> tag
unconditionally, rather than for very specific cases.  Generic gdbserver
implementations do not support LLDB-specific packets used to determine
the process architecture, therefore this fallback is necessary to
support architecture-specific behavior on these targets.  Rather than
maintaining a mapping of all known architectures, just try mapping
the GDB values into triplets, as that is going to work most of the time.

This change is confirmed to fix LLDB against gdbserver when debugging
i386 and aarch64 executables.

Differential Revision: https://reviews.llvm.org/D109272
2021-09-16 10:23:31 +02:00
Ted Woodward 17589538aa [lldb-vscode] Fix focus thread when previous thread exits
The thread that Visual Studio Code displays on a stop is called the focus thread. When the previous focus thread exits and we stop in a new thread, lldb-vscode does not tell vscode to set the new thread as the focus thread, so it selects the first thread in the thread list.

This patch changes lldb-vscode to tell vscode that the new thread is the focus thread. It also includes a test that verifies the DAP stop message for this case contains the correct values.

Reviewed By: clayborg, wallace

Differential Revision: https://reviews.llvm.org/D109633
2021-09-15 18:09:32 -05:00
Martin Storsjö b4133a21ce [lldb] [Windows] Fix an incorrect assert in NativeRegisterContextWindows_arm
This codepath hadn't been exercised in a build with asserts before.

Differential Revision: https://reviews.llvm.org/D109778
2021-09-15 15:03:20 +03:00
Vedant Kumar 66902a32c8 [StopInfoMachException] Summarize arm64e BLRAx/LDRAx auth failures
Upstream lldb support for summarizing BLRAx and LDRAx auth failures.

rdar://41615322

Differential Revision: https://reviews.llvm.org/D102428
2021-09-14 13:31:52 -07:00
Pavel Labath f22c63b41b [lldb/test] Start pexpect tests with a custom HOME
This addresses the flakyness of (at least) TestMultilineNavigation,
which was failing when the editline history of a concurrently executing
test made leaked in. Using a test-specific home directory ensures the
tests are independent.
2021-09-14 15:17:10 +02:00
Fangrui Song e69d359841 [lldb] Actually fix format specifier after D108233
And revert c4fa2c8aa4
2021-09-13 13:40:37 -07:00
Alex Langford c4fa2c8aa4 [lldb] Fix warning in MinidumpFileBuilder.cpp
Fixes the following warning:

$llvm_project/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp:744:11: warning:
format specifies type 'long' but the argument has type 'lldb::offset_t' (aka 'unsigned long long') [-Wformat]
          m_data.GetByteSize());
          ^~~~~~~~~~~~~~~~~~~~
2021-09-13 10:37:45 -07:00
Michał Górny dd58083304 [lldb] [test] Remove parent output checks from follow-child tests
Remove the parent output checks, as they make the test flaky while
serving no real purpose.  If the parent crashed/hanged, it will never
resume the child and the test would fail anyway.
2021-09-13 15:50:00 +02:00
Pavel Labath c82dbc2924 [lldb] Skip TestGuiBasicDebug due to pr51833 2021-09-13 15:11:28 +02:00
Michał Górny e3d878bdd8 [lldb] Remove redundant register alt_names
Remove redundant register alt_names that correspond to their respective
generic names.  D108554 makes it possible to query registers through
their generic names directly, therefore making repeating them via
alt_name unnecessary.

While at it, also remove alt_names that are equal to register names
on PPC.

This patch does not alter register definitions where the generic names
are listed as primary names, and other names are provided as alt_name
(e.g. ARM).

Differential Revision: https://reviews.llvm.org/D109626
2021-09-13 13:05:06 +02:00
Michał Górny 8567f4d4b9 [lldb] Support querying registers via generic names without alt_names
Update GetRegisterInfoByName() methods to support getting registers
by a generic name independently of alt_name entries in the register
context.  This makes it possible to use generic names when interacting
with gdbserver (that does not supply alt_names).  It also makes it
possible to remove some of the duplicated information from register
context declarations and/or use alt_names for another purpose.

Differential Revision: https://reviews.llvm.org/D108554
2021-09-13 13:05:06 +02:00
Pavel Labath b03126768a [lldb] Remove PluginInterface::GetPluginVersion
In all these years, we haven't found a use for this function (it has
zero callers). Lets just remove the boilerplate.

Differential Revision: https://reviews.llvm.org/D109600
2021-09-13 10:29:00 +02:00
Raphael Isemann 4b2e38d940 [lldb][NFC] Cleanup EditlineHistory 2021-09-13 09:30:31 +02:00
Jan Kratochvil ff94f60240 [lldb] [testsuite] Fix false failures on "\n" regex match
Regex is matching a binary so it needs `re.DOTALL`.
vFile:fstat packet data ATTACHMENT is not hex-encoded but it is only
escaped.

It is difficult to reproduce, it came from buildbot:
  https://lab.llvm.org/staging/#/builders/16/builds/10597

******************** TEST 'lldb-api :: tools/lldb-server/TestGdbRemotePlatformFile.py' FAILED ********************
FAIL: test_platform_file_fstat_llgs (TestGdbRemotePlatformFile.TestGdbRemotePlatformFile)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py", line 52, in test_method
    return attrvalue(self)
  File "lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py", line 259, in test_platform_file_fstat
    context = self.expect_gdbremote_sequence()
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py", line 621, in expect_gdbremote_sequence
    return expect_lldb_gdbserver_replay(
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py", line 198, in expect_lldb_gdbserver_replay
    context = sequence_entry.assert_match(
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py", line 479, in assert_match
    return self._assert_regex_match(asserter, actual_packet, context)
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py", line 446, in _assert_regex_match
    asserter.fail(
AssertionError: regex '^\$F([0-9a-fA-F]+);(.*)#[0-9a-fA-F]{2}$' failed to match against content '$F40;^@^@^@ ^@
^C<8d>^@^@<81><80>^@^@^@^A^@^@^CX^@^@^CX^@^@^@^@^@^@^@^@^@^@^@^W^@^@^@^@^@^@^P^@^@^@^@^@^@^@^@
a=XXa=XXa=XX#6b'
2021-09-13 07:35:12 +02:00
Muhammad Omair Javaid c55e021de4 [LLDB] Skip TestDyldLaunchLinux.py on Arm/Linux
TestDyldLaunchLinux.py has been recently added and is failing on LLDB
Arm/Linux buildbot. I am marking it skip till I come back and look at
it in more detail.
2021-09-11 16:18:22 +05:00
Jason Molenda 89ed21a8f8 Recognize namespaced all_image_infos symbol name from dyld
In macOS 12, the symbol name for the dyld_all_image_infos struct
in dyld has a namespace qualifier.  Search for it without qualification,
then with qualification when doing a by-name search.  (lldb will
only search for it by name when loading a user process Mach-O corefile)

rdar://76270013
2021-09-10 16:56:48 -07:00
Alex Langford 8dae35527f [lldb] Remove unused typedefs from lldb-forward.h 2021-09-10 14:16:47 -07:00
Rumeet Dhindsa 03df971012 [lldb] Add support for debugging via the dynamic linker.
This patch adds support for shared library load when the executable is
called through ld.so.

Differential Revision:https://reviews.llvm.org/D108061
2021-09-10 10:59:31 -07:00
Michał Górny 4e7ac6faca [lldb] [test] Remove parent check in Subprocess/clone-follow-child-softbp.test
Hopefully this will resolve the remaining flakiness.
2021-09-10 18:03:05 +02:00
Michał Górny d727bd6962 [lldb] [test] Skip A/vRun/QEnvironment* tests on Windows, and fix them
Skip A/vRun/QEnvironment* tests on Windows as testing for output is
known not to work there.  Add a missing output check to the vRun test.
2021-09-10 16:34:20 +02:00
Michał Górny 784281d316 [lldb] [test] Attempt to fix gdb_remote_client A/vRun tests on Windows 2021-09-10 16:27:29 +02:00
Michał Górny c362f610f8 [lldb] [test] Mark new launch/QEnvironment tests as llgs category 2021-09-10 16:23:43 +02:00
Michał Górny 9a4379c3dc [lldb] [test] Skip file permission tests on Windows 2021-09-10 16:23:42 +02:00
Pavel Labath beb768f40b [lldb] Clean up Platform/CMakeLists.txt
Remove comments looking like preprocessor directives (thankfully cmake
does not have those yet), and sort the file.
2021-09-10 14:18:41 +02:00