Commit Graph

25795 Commits

Author SHA1 Message Date
Dave Lee 06c7bdc8f1 [lldb] Specify LLVM target requirements in TestLaunchProcessPosixSpawn 2022-01-11 19:00:47 -08:00
Zequan Wu 945aa520ef [LLDB][NativePDB] Add support for inlined functions
This adds inline function support to NativePDB by parsing S_INLINESITE records
to retrieve inlinee line info and add them into line table at `ParseLineTable`.

Differential Revision: https://reviews.llvm.org/D116845
2022-01-11 16:10:39 -08:00
Shafik Yaghmour c0e4154711 Fix clang-tidy bugprone-argument-comment that was mixed up
Several of the comments were annotating the wrong argument.

I caught this while reviewing this clean-up: 8afcfbfb8f

which was changing booleans to use true and false and in the this case the comment and the type looked mismatched.

Differential Revision: https://reviews.llvm.org/D116982
2022-01-11 11:12:28 -08:00
David Spickett 88fdce5be6 [lldb] Remove non address bits from memory read arguments
Addresses on AArch64 can have top byte tags, memory tags and pointer
authentication signatures in the upper bits.

While testing memory tagging I found that memory read couldn't
read a range if the two addresses had different tags. The same
could apply to signed pointers given the right circumstance.

(lldb) memory read mte_buf_alt_tag mte_buf+16
error: end address (0x900fffff7ff8010) must be greater than the start
address (0xa00fffff7ff8000).

Or it would try to read a lot more memory than expected.

(lldb) memory read mte_buf mte_buf_alt_tag+16
error: Normally, 'memory read' will not read over 1024 bytes of data.
error: Please use --force to override this restriction just once.
error: or set target.max-memory-read-size if you will often need a
larger limit.

Fix this by removing non address bits before we calculate the read
range. A test is added for AArch64 Linux that confirms this by using
the top byte ignore feature.

This means that if you do read with a tagged pointer the output
does not include those tags. This is potentially confusing but I think
overall it's better that we don't pretend that we're reading memory
from a range that the process is unable to map.

(lldb) p ptr1
(char *) $4 = 0x3400fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) p ptr2
(char *) $5 = 0x5600fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) memory read ptr1 ptr2+16
0xfffffffff140: 80 f1 ff ff ff ff 00 00 38 70 bc f7 ff ff 00 00  ........8p......

Reviewed By: omjavaid, danielkiss

Differential Revision: https://reviews.llvm.org/D103626
2022-01-11 13:24:09 +00:00
Pavel Labath 6d8d1c5ea3 [lldb/qemu] Implement GetMmapArgumentList
By forwarding it to the host platform.
2022-01-11 14:08:03 +01:00
Lirong Yuan 1267506ea5 [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess"
While running heap checker on a test that uses LLDB API, the following memory leak is found:

RAW: HeapChecker started...
RAW: Leak check _main_ detected leaks of 34 bytes in 4 objects
RAW: The 2 largest leaks:
RAW: Leak of 17 bytes in 2 objects allocated from:
@ 0x7fb93bd20166 NewHook()
@ 0x7fb929372a73 absl::base_internal::MallocHook::InvokeNewHookSlow()
@ 0x5600d1046093 libc_malloc
@ 0x7fb974529c03 xmlStrdup
@ 0x7fb9744c2a0b xmlGetProp
@ 0x7fb9749d9ed6 lldb_private::XMLNode::GetAttributeValue()
@ 0x7fb979043001 std::u::function::policy_invoker<>::__call_impl<>()
@ 0x7fb9749da06d lldb_private::XMLNode::ForEachChildElement()
@ 0x7fb97903c54d lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess()
@ 0x7fb97902cfe4 lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfo()
@ 0x7fb97902c1d0 lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo()
@ 0x7fb97902e92a lldb_private::process_gdb_remote::ProcessGDBRemote::SetThreadStopInfo()
@ 0x7fb97902db18 lldb_private::process_gdb_remote::ProcessGDBRemote::DoConnectRemote()
@ 0x7fb97584965e lldb_private::Process::ConnectRemote()
@ 0x7fb975839fa6 lldb_private::Platform::DoConnectProcess()
@ 0x7fb97583a39e lldb_private::Platform::ConnectProcessSynchronous()
@ 0x7fb97545b28b CommandObjectProcessConnect::DoExecute()
@ 0x7fb9755a70c9 lldb_private::CommandObjectParsed::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb975460145 lldb_private::CommandObjectRegexCommand::DoExecute()
@ 0x7fb9755a72d2 lldb_private::CommandObjectRaw::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb997a5f22e lldb::SBCommandInterpreter::HandleCommand()
@ 0x7fb997a5ef9b lldb::SBCommandInterpreter::HandleCommand()

This change fixes the memory leaks by freeing memory after it is no
longer in use. Tested with "ninja check-lldb".

Differential revision: https://reviews.llvm.org/D116707
2022-01-10 14:33:09 -08:00
Jonas Devlieghere da4b7437f9 [lldb] Remove LLDB_RECORD_DUMMY_* macros 2022-01-10 12:05:54 -08:00
Jonas Devlieghere 69c55d6362 [lldb] Remove LLDB_RECORD_CHAR_PTR_* macros 2022-01-10 11:57:20 -08:00
Jonas Devlieghere 4609e30f50 [lldb] Remove lldb-instr 2022-01-10 11:48:16 -08:00
Stella Stamenova 9b5cf7267b [lldb] Disable several lldb tests that are flaky on Windows
This tests have recently become flaky (flakier?) causing occasional failures in the windows lldb buildbot
2022-01-10 10:21:12 -08:00
Pavel Labath 8ccfcab34f [lldb/platform-gdb] Clear cached protocol state upon disconnection
Previously we would persist the flags indicating whether the remote side
supports a particular feature across reconnects, which is obviously not
a good idea.

I implement the clearing by nuking (its the only way to be sure :) the
entire GDBRemoteCommunication object in the disconnect operation and
creating a new one upon connection. This allows us to maintain a nice
invariant that the GDBRemoteCommunication object (which is now a
pointer) exists only if it is connected. The downside to that is that a
lot of functions now needs to check the validity of the pointer instead
of blindly accessing the object.

The process communication does not suffer from the same issue because we
always destroy the entire Process object for a relaunch.

Differential Revision: https://reviews.llvm.org/D116539
2022-01-10 16:27:30 +01:00
Jonas Devlieghere d232abc33b [lldb] Remove LLDB_RECORD_RESULT macro 2022-01-09 22:54:17 -08:00
Dave Lee c4cdf86569 [lldb] Skip TestTargetXMLArch if no support for x86 target
If LLVM is configured without X86 as one of its TARGETS_TO_BUILD, then lldb
will crash when using X86 disassembler (which it does while running `image
show-unwind`).
2022-01-09 22:40:03 -08:00
Dave Lee ed3a4a4948 [lldb] Skip TestVSCode_coreFile if no x86 target support 2022-01-09 22:01:31 -08:00
Jonas Devlieghere d51402ac6b [lldb] Remove reproducer instrumentation
This patch removes most of the reproducer instrumentation. It keeps
around the LLDB_RECORD_* macros for logging. See [1] for more details.

[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html

Differential revision: https://reviews.llvm.org/D116847
2022-01-09 21:40:55 -08:00
Dave Lee 4a8549354c [lldb] Guard libstdc++ specific 'frame var' test
While working on D116788 (properly error out of `frame var`), this libstdc++
specific `frame var` invocation was found in the tests. This test is in the
generic directory, but has this one case that requires libstdc++. The fix here
is to put the one `expect()` inside of a condition that checks for libstdc++.

Differential Revision: https://reviews.llvm.org/D116901
2022-01-09 21:37:42 -08:00
Dave Lee aad27a8907 [lldb] Check for arm64 in TestDisassembleRawData
This test checks for `aarch64` but the lit config could also contain `arm64`.
This change adds `arm64` to make the test pass in all cases.

Differential Revision: https://reviews.llvm.org/D116912
2022-01-09 21:36:55 -08:00
Dave Lee 268a42d697 [lldb] Require x86 support for dwo-relative-path test 2022-01-09 21:35:32 -08:00
Dave Lee 08f70adedb Revert "[lldb] Set result error state in 'frame variable'"
This reverts commit 2bcff220bf.
2022-01-09 14:12:47 -08:00
Dave Lee 2bcff220bf [lldb] Set result error state in 'frame variable'
Ensure that errors in `frame variable` are reflected in result object.

The statistics for `frame variable` show invocations as being successful, even
when executing one of the error paths.

This change replaces `result.GetErrorStream()` with `result.AppendError()`,
which also sets the status to `eReturnStatusFailed`.

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

(cherry picked from commit 2c7d10c412)
2022-01-09 13:26:30 -08:00
Dave Lee a6f1d04665 [lldb][docs] Update references to SVN 2022-01-09 13:21:40 -08:00
Kazu Hirata 8afcfbfb8f Use true/false instead of 1/0 (NFC)
Identified by modernize-use-bool-literals.
2022-01-09 12:21:06 -08:00
Kazu Hirata 47b9aadb32 [lldb] Remove redundant member initialization (NFC) 2022-01-09 12:21:04 -08:00
Kazu Hirata b12fd13812 Fix bugprone argument comments.
Identified by bugprone-argument-comment.
2022-01-09 12:21:02 -08:00
Dave Lee 39ea676d9d [lldb] Compute fully qualified command names in FindCommandsForApropos
Fixes incomplete command names in `apropos` results.

The full command names given by `apropos` have come from command name string
literals given to `CommandObject` constructors. For most commands, this has
been accurate, but some commands have incorrect strings. This results in
`apropos` output that doesn't tell the user the full command name they might
want learn more about. These strings can be fixed.

There's a seperate issue that can't be fixed as easily: plugin commands. With
the way they're implemented, plugin commands have to exclude the root command
from their command name string. To illustrate, the `language objc` subcommand
has to set its command name string to "objc", which results in apropos printing
results as `objc ...` instead of `language objc ...`.

To fix both of these issues, this commit changes `FindCommandsForApropos` to
derive the fully qualified command name using the keys of subcommand maps.

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

(cherry picked from commit b3bfd595a5)
2022-01-09 12:11:32 -08:00
Dave Lee 9d9f3e0ec7 [lldb] Remove ProcessStructReader from NSStringSummaryProvider (NFC)
Simplify getting the length of `NSPathStore2` strings.

`NSStringSummaryProvider` uses a single field from `NSPathStore2` instances,
its first ivar: `_lengthAndRefCount`. This change uses
`GetSyntheticChildAtOffset` to replace the use of `ProcessStructReader`, and
removes the hard coded `CompilerType` definition of `NSPathStore2`.

Differential Revision: https://reviews.llvm.org/D116461
2022-01-09 12:09:02 -08:00
Kazu Hirata 51fd157635 Remove duplicate forward declarations (NFC) 2022-01-08 11:56:42 -08:00
Dave Lee 930f3c625e Revert "[lldb] Set result error state in 'frame variable'"
This reverts commit 2c7d10c412.
2022-01-08 09:35:13 -08:00
Dave Lee 2c7d10c412 [lldb] Set result error state in 'frame variable'
Ensure that errors in `frame variable` are reflected in result object.

The statistics for `frame variable` show invocations as being successful, even
when executing one of the error paths.

This change replaces `result.GetErrorStream()` with `result.AppendError()`,
which also sets the status to `eReturnStatusFailed`.

Differential Revision: https://reviews.llvm.org/D116788
2022-01-08 08:50:17 -08:00
Walter Erquinigo 69c8e64ba6 [formatters] Improve documentation
This adds some important remarks to the data formatter documentation.

Differential Revision: https://reviews.llvm.org/D115974
2022-01-07 16:27:03 -08:00
Jonas Devlieghere d13da5f0da [lldb] Remove lldbconfig module
The lldbconfig module was necessary to run the LLDB test suite against a
reproducer. Since this functionality has been removed, the module is no
longer necessary.
2022-01-07 15:58:43 -08:00
Jonas Devlieghere ab7618914d [lldb] Use lit_config.note to print module cache message 2022-01-07 13:35:18 -08:00
Shafik Yaghmour 4f6d3a376c [LLDB] Fix setting of success in Socket::Close()
Both close and closesocket should return 0 on success so using !! looks incorrect. I replaced this will a more readable == 0 check.

Differential Revision: https://reviews.llvm.org/D116768
2022-01-07 12:42:58 -08:00
Ben Jackson 7244e9c2f5 [LLDB] libcxx summary formatters for std::string_view
When printing a std::string_view, print the referenced string as the
summary. Support string_view, u32string_view, u16string_view and
wstring_view, as we do for std::string and friends.

This is based on the existing fomratter for std::string, and just
extracts the data and length members, pushing them through the existing
string formatter.

In testing this, a "FIXME" was corrected for printing of non-ASCII empty
values. Previously, the "u", 'U" etc. prefixes were not printed for
basic_string<> types that were not char. This is trivial to resolve by
printing the prefix before the "".

Differential revision: https://reviews.llvm.org/D112222
2022-01-07 11:41:16 -08:00
Qiu Chaofan c2cc70e4f5 [NFC] Fix endif comments to match with include guard 2022-01-07 15:52:59 +08:00
Dave Lee bd23dffc2c Revert "[lldb] Compute fully qualified command names in FindCommandsForApropos"
This reverts commit b3bfd595a5.
2022-01-06 20:15:19 -08:00
Dave Lee b3bfd595a5 [lldb] Compute fully qualified command names in FindCommandsForApropos
Fixes incomplete command names in `apropos` results.

The full command names given by `apropos` have come from command name string
literals given to `CommandObject` constructors. For most commands, this has
been accurate, but some commands have incorrect strings. This results in
`apropos` output that doesn't tell the user the full command name they might
want learn more about. These strings can be fixed.

There's a seperate issue that can't be fixed as easily: plugin commands. With
the way they're implemented, plugin commands have to exclude the root command
from their command name string. To illustrate, the `language objc` subcommand
has to set its command name string to "objc", which results in apropos printing
results as `objc ...` instead of `language objc ...`.

To fix both of these issues, this commit changes `FindCommandsForApropos` to
derive the fully qualified command name using the keys of subcommand maps.

Differential Revision: https://reviews.llvm.org/D116491
2022-01-06 19:26:57 -08:00
Michał Górny 9b1d27b2fa [lldb] [Process/FreeBSDKernel] Support finding all processes
Include the complete list of threads of all running processes
in the FreeBSDKernel plugin.  This makes it possible to inspect
the states (including partial register dumps from PCB) of all kernel
and userspace threads at the time of crash, or at the time of reading
/dev/mem first.

Differential Revision: https://reviews.llvm.org/D116255
2022-01-06 21:53:28 +01:00
Pavel Labath 31c7165a2b [lldb] Remove summary for signed char *
It conflicts with the summary for BOOL * (aka signed char *). This
partially reverts D112709.
2022-01-06 19:52:24 +01:00
Chuanqi Xu bbce75e352 Update Bug report URL to Github Issues
Although we moved to Github Issues. The bug report message refers to
Bugzilla still. This patch tries to update these URLs.

Reviewed By: MaskRay, Quuxplusone, jhenderson, libunwind, libc++

Differential Revision: https://reviews.llvm.org/D116351
2022-01-06 17:33:25 +08:00
Martin Storsjö 1919720fdd [lldb] [debugserver] Simplify handling of arch specific files
There are no duplicates among the include files, and all the
source files are wrapped in architecture ifdefs, so there's no harm
in including all of them, always.

This fixes builds if TARGET_TRIPLE is set to something else than the
build architecture.

This also allows building for multiple architectures at once by
setting CMAKE_OSX_ARCHITECTURES.

Differential Revision: https://reviews.llvm.org/D116625
2022-01-06 10:23:04 +02:00
Dave Lee 3a1a0d4957 [lldb] Add StringList::AppendString(const Twine&) (NFC)
Add a convenience for appending constructed string values.

Differential Revision: https://reviews.llvm.org/D116682
2022-01-05 18:49:15 -08:00
Dave Lee ef6817f932 [lldb] Break out long help for 'frame var'
The current help for `frame variable` is somewhat long. Its length, combined
with the few aliases (`var`, `v`, and `vo`) can make the output of `apropos`
redundant and noisy.

This separates out the details into a separate long help.

Differential Revision: https://reviews.llvm.org/D116708
2022-01-05 18:47:52 -08:00
Jonas Devlieghere 46a28a954e [lldb] Create a property to store the REPL language
Until the introduction of the C++ REPL, there was always a single REPL
language. Several places relied on this assumption through
repl_languages.GetSingularLanguage. Now that this is no longer the case,
we need a way to specify a selected/preferred REPL language. This patch
does that with the help of a debugger property, taking inspiration from
how we store the scripting language.

Differential revision: https://reviews.llvm.org/D116697
2022-01-05 15:03:46 -08:00
Nico Weber 085f078307 Revert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""
This reverts commit 859ebca744.
The change contained many unrelated changes and e.g. restored
unit test failes for the old lld port.
2022-01-05 13:10:25 -05:00
David Salinas 859ebca744 Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."
This reverts commit 640beb38e7.

That commit caused performance degradtion in Quicksilver test QS:sGPU and a functional test failure in (rocPRIM rocprim.device_segmented_radix_sort).
Reverting until we have a better solution to s_cselect_b64 codegen cleanup

Change-Id: Ibf8e397df94001f248fba609f072088a46abae08

Reviewed By: kzhuravl

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

Change-Id: Id169459ce4dfffa857d5645a0af50b0063ce1105
2022-01-05 17:57:32 +00:00
Pavel Labath df4ad3625f [lldb/linux] Fix a race in handling of simultaneous thread exits
D116372, while fixing one kind of a race, ended up creating a new one.
The new issue could occur when one inferior thread exits while another
thread initiates termination of the entire process (exit_group(2)).

With some bad luck, we could start processing the exit notification
(PTRACE_EVENT_EXIT) only to have the become unresponsive (ESRCH) in the
middle of the MonitorCallback function. This function would then delete
the thread from our list even though it wasn't completely dead (it stays
zombified until we read the WIFEXITED event). The linux kernel will not
deliver the exited event for the entire process until we process
individual thread exits.

In a pre-D116372 world, this wouldn't be a problem because we would read
this event (even though we would not know what to do with it) with
waitpid(-1). Now, when we issue invididual waitpids, this event will
never be picked up, and we end up hanging.

The fix for this is actually quite simple -- don't delete the thread in
this situation. The thread will be deleted when the WIFEXITED event
comes.

This situation was kind of already tested by
TestCreateDuringInstructionStep (which is how I found this problem), but
it was mostly accidental, so I am also creating a dedicated test which
reproduces this situation.
2022-01-05 13:21:35 +01:00
Zequan Wu d5b6e30ed3 [LLDB][Clang] add AccessSpecDecl for methods and fields in RecordType
This allows access type be printed when running `lldb-test -dump-ast` and
`lldb-test -dump-clang-ast`.

Differential Revision: https://reviews.llvm.org/D115062
2022-01-04 13:50:24 -08:00
Pavel Labath 0a07c9662e [lldb/python] Fix dangling Event and CommandReturnObject references
Unlike the rest of our SB objects, SBEvent and SBCommandReturnObject
have the ability to hold non-owning pointers to their non-SB
counterparts. This makes it hard to ensure the SB objects do not become
dangling once their backing object goes away.

While we could make these two objects behave like others, that would
require plubming even more shared pointers through our internal code
(Event objects are mostly prepared for it, CommandReturnObject are not).
Doing so seems unnecessarily disruptive, given that (unlike for some of
the other objects) I don't see any good reason why would someone want to
hold onto these objects after the function terminates.

For that reason, this patch implements a different approach -- the SB
objects will still hold non-owning pointers, but they will be reset to
the empty/default state as soon as the function terminates. This python
code will not crash if the user decides to store these objects -- but
the objects themselves will be useless/empty.

Differential Revision: https://reviews.llvm.org/D116162
2022-01-04 14:49:00 +01:00
Dave Lee 67c937f846 [lldb] Use std::move in StringList (NFC) 2022-01-03 15:36:19 -08:00