Commit Graph

25531 Commits

Author SHA1 Message Date
Matheus Izvekov 5508595217
[lldb] fix test expectation broken by clang fix at D110216
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D113722
2021-11-12 01:47:29 +01:00
Alex Langford ac33e65d21 [lldb][NFC] Delete commented out code in AddressRange 2021-11-11 15:42:27 -08:00
Quinn Pham 04cbfa950e [lldb][NFC] Inclusive Language: rename master plan to controlling plan
[NFC] As part of using inclusive language within the llvm project, this patch
renames master plan to controlling plan in lldb.

Reviewed By: jingham

Differential Revision: https://reviews.llvm.org/D113019
2021-11-11 15:04:44 -06:00
Raphael Isemann b72727a75a [lldb][NFC] Remove commented out code in SymbolFileDWARF 2021-11-11 12:45:38 +01:00
Raphael Isemann 2a0e77362e [lldb][NFC] Remove no longer valid comment for TypeSystem::SetSymbolFile 2021-11-11 12:39:54 +01:00
David Spickett 9db2541d4c [lldb][AArch64] Add UnwindPlan for Linux sigreturn
This adds a specific unwind plan for AArch64 Linux sigreturn frames.
Previously we assumed that the fp would be valid here but it is not.

https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S

On Ubuntu Bionic it happened to point to an old frame info which meant
you got what looked like a correct backtrace. On Focal, the info is
completely invalid. (probably due to some code shuffling in libc)

This adds an UnwindPlan that knows that the sp in a sigreturn frame
points to an rt_sigframe from which we can offset to get saved
sp and pc values to backtrace correctly.

Based on LibUnwind's change: https://reviews.llvm.org/D90898

A new test is added that sets all compares the frames from the initial
signal catch to the handler break. Ensuring that the stack/frame pointer,
function name and register values match.
(this test is AArch64 Linux specific because it's the only one
with a specific unwind plan for this situation)

Fixes https://bugs.llvm.org/show_bug.cgi?id=52165

Reviewed By: omjavaid, labath

Differential Revision: https://reviews.llvm.org/D112069
2021-11-11 11:32:06 +00:00
Luís Ferreira 96a7359908 [lldb] Add support for demangling D symbols
This is part of https://github.com/dlang/projects/issues/81 .

This patch enables support for D programming language demangler by using a
pretty printed stacktrace with demangled D symbols, when present.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>

Reviewed By: JDevlieghere, teemperor

Differential Revision: https://reviews.llvm.org/D110578
2021-11-11 11:11:21 +01:00
Med Ismail Bennani 676576b6f0 [lldb/Plugins] Refactor ScriptedThread register context creation
This patch changes the ScriptedThread class to create the register
context when Process::RefreshStateAfterStop is called rather than
doing it in the thread constructor.

This is required to update the thread state for execution control.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-11 00:13:58 +01:00
Shafik Yaghmour 0d62e31c45 [LLDB][NFC] Fix test that broke due to libc++ std::vector changes
D112976 moved most of the guts of __vector_base into vector, this broke
some LLDB tests by changing the result types that LLDB sees. This updates
the test to reflect the new structure.
2021-11-10 12:29:08 -08:00
Jonas Devlieghere 18d883cc0a [debugserver] Remove varaible `ldb_set` which is set but not used.
Differential revision: https://reviews.llvm.org/D113598
2021-11-10 11:56:59 -08:00
Zequan Wu cc9ced0ed4 [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad.
Teach LLDB to understand INLINE and INLINE_ORIGIN records in breakpad.
They have the following formats:
```
INLINE inline_nest_level call_site_line call_site_file_num origin_num [address size]+
INLINE_ORIGIN origin_num name
```
`INLNIE_ORIGIN` is simply a string pool for INLINE so that we won't have
duplicated names for inlined functions and can show up anywhere in the symbol
file.
`INLINE` follows immediately after `FUNC` represents the ranges of momery
address that has functions inlined inside the function.

Differential Revision: https://reviews.llvm.org/D113330
2021-11-10 11:20:32 -08:00
Med Ismail Bennani 419b471196 [lldb/test] Skip TestScriptedProcess when using system's debugserver (NFC)
Because TestScriptedProcess.py creates a skinny corefile to provides data
to the ScriptedProcess and ScriptedThread, we need to make sure that the
debugserver used is not out of tree, to ensure feature availability
between debugserver and lldb.

This also removes the `SKIP_SCRIPTED_PROCESS_LAUNCH` env variable after
each test finish running.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-10 20:12:42 +01:00
Zequan Wu fbf665a008 [LLDB][Breakpad] Create a function for each compilation unit.
Since every FUNC record (in breakpad) is a compilation unit, creating the
function for the CU allows `ResolveSymbolContext` to resolve
`eSymbolContextFunction`.

Differential Revision: https://reviews.llvm.org/D113163
2021-11-10 10:51:16 -08:00
Jordan Rupprecht 360d901bf0 Revert "[lldb] Disable minimal import mode for RecordDecls that back FieldDecls"
This reverts commit 3bf96b0329.

It causes crashes as reported in PR52257 and a few other places. A reproducer is bundled with this commit to verify any fix forward. The original test is left in place, but marked XFAIL as it now produces the wrong result.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113449
2021-11-10 10:38:01 -08:00
Lawrence D'Anna bbef51eb43 [lldb] make it easier to find LLDB's python
It is surprisingly difficult to write a simple python script that
can reliably `import lldb` without failing, or crashing.   I'm
currently resorting to convolutions like this:

    def find_lldb(may_reexec=False):
		if prefix := os.environ.get('LLDB_PYTHON_PREFIX'):
			if os.path.realpath(prefix) != os.path.realpath(sys.prefix):
				raise Exception("cannot import lldb.\n"
					f"  sys.prefix should be: {prefix}\n"
					f"  but it is: {sys.prefix}")
		else:
			line1, line2 = subprocess.run(
				['lldb', '-x', '-b', '-o', 'script print(sys.prefix)'],
				encoding='utf8', stdout=subprocess.PIPE,
				check=True).stdout.strip().splitlines()
			assert line1.strip() == '(lldb) script print(sys.prefix)'
			prefix = line2.strip()
			os.environ['LLDB_PYTHON_PREFIX'] = prefix

		if sys.prefix != prefix:
			if not may_reexec:
				raise Exception(
					"cannot import lldb.\n" +
					f"  This python, at {sys.prefix}\n"
					f"  does not math LLDB's python at {prefix}")
			os.environ['LLDB_PYTHON_PREFIX'] = prefix
			python_exe = os.path.join(prefix, 'bin', 'python3')
			os.execl(python_exe, python_exe, *sys.argv)

		lldb_path = subprocess.run(['lldb', '-P'],
			check=True, stdout=subprocess.PIPE,
				encoding='utf8').stdout.strip()

		sys.path = [lldb_path] + sys.path

This patch aims to replace all that with:

  #!/usr/bin/env lldb-python
  import lldb
  ...

... by adding the following features:

* new command line option: --print-script-interpreter-info.  This
   prints language-specific information about the script interpreter
   in JSON format.

* new tool (unix only): lldb-python which finds python and exec's it.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D112973
2021-11-10 10:33:34 -08:00
Michał Górny d96656ca90 [lldb] [test] Fix new signal tests to use remote-linux plugin
Hopefully this will fix OSX and Windows buildbots
2021-11-10 18:08:05 +01:00
Med Ismail Bennani 976867b513 [lldb/test] Update TestScriptedProcess to use skinny corefiles
This patch changes the ScriptedProcess test to use a stack-only skinny
corefile as a backing store.

The corefile is saved as a temporary file at the beginning of the test,
and a second target is created for the ScriptedProcess. To do so, we use
the SBAPI from the ScriptedProcess' python script to interact with the
corefile process.

This patch also makes some small adjustments to the other ScriptedProcess
scripts to resolve some inconsistencies and removes the raw memory dump
that was previously checked in.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-10 17:43:29 +01:00
Med Ismail Bennani 738621d047 [lldb/bindings] Change ScriptedThread initializer parameters
This patch changes the `ScriptedThread` initializer in couple of ways:
- It replaces the `SBTarget` parameter by a `SBProcess` (pointing to the
  `ScriptedProcess` that "owns" the `ScriptedThread`).
- It adds a reference to the `ScriptedProcessInfo` Dictionary, to pass
  arbitrary user-input to the `ScriptedThread`.

This patch also fixes the SWIG bindings methods that call the
`ScriptedProcess` and `ScriptedThread` initializers by passing all the
arguments to the appropriate `PythonCallable` object.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-10 17:43:28 +01:00
Med Ismail Bennani ad0f7d3d4a
[lldb] Fix Scripted ProcessLaunchInfo Argument nullptr deref
This patch adds a new `StructuredData::Dictionary` constructor that
takes a `StructuredData::ObjectSP` as an argument. This is used to pass
the opaque_ptr from the `SBStructuredData` used to initialize a
ScriptedProecss, to the `ProcessLaunchInfo` class.

This also updates `SBLaunchInfo::SetScriptedProcessDictionary` to
reflect the formentionned changes which solves the nullptr deref.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-11-10 16:43:19 +00:00
Pavel Labath ff7ce0af04 [lldb] DeConstStringify the Property class
Most of the interfaces were converted already, this just converts the
internal implementation.
2021-11-10 15:07:30 +01:00
Michał Górny e7861449ea [lldb] [test] Skip new signal tests on Windows 2021-11-10 11:31:21 +01:00
Michał Górny 82ce912743 [lldb] [gdb-server] Fix fill_clamp to handle signed src types
Fix the fill_clamp() function to handle signed source types.  Make sure
that the source value is always non-negative, and cast it to unsigned
when verifying the upper bound.  This fixes compiler warnings about
comparing unsigned and signed types.

Differential Revision: https://reviews.llvm.org/D113519
2021-11-10 09:38:55 +01:00
Michał Górny 3f1372365a [lldb] Support gdbserver signals
GDB and LLDB use different signal models.  GDB uses a predefined set
of signal codes, and maps platform's signos to them.  On the other hand,
LLDB has historically simply passed native signos.

In order to improve compatibility between LLDB and gdbserver, the GDB
signal model should be used.  However, GDB does not provide a mapping
for all existing signals on Linux and unsupported signals are passed
as 'unknown'.  Limiting LLDB to this behavior could be considered
a regression.

To get the best of both worlds, use the LLDB signal model when talking
to lldb-server, and the GDB signal model otherwise.  For this purpose,
new versions of lldb-server indicate "native-signals+" via qSupported.
At the same time, we also detect older versions of lldb-server
via QThreadSuffixSupported for backwards compatibility.  If neither test
succeeds, we assume gdbserver or another implementation using GDB model.

Differential Revision: https://reviews.llvm.org/D108078
2021-11-10 09:38:55 +01:00
Danil Stefaniuc 577c1eecf8 [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
This diff adds a data formatter for libstdcpp's forward_list. Besides, it refactors the existing code by extracting the common functionality between libstdcpp forward_list and list formatters into the AbstractListSynthProvider class.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D113362
2021-11-09 21:33:08 -08:00
Pavel Labath adc7d63f46 [lldb] XFAIL TestPlatformKill on windows
-> PR52451
2021-11-09 19:50:14 +01:00
Adrian Prantl 68a4d179c2 Use yaml2obj instead of relying on invoking the Darwin system assembler. 2021-11-09 10:47:26 -08:00
Adrian Prantl 56f7da6e0d Add a requires line to test. 2021-11-09 10:16:03 -08:00
Adrian Prantl c9881c7d99 Support looking up absolute symbols
The Swift stdlib uses absolute symbols in the dylib to communicate
feature flags to the process. LLDB's expression evaluator needs to be
able to find them. This wires up absolute symbols so they show up in
the symtab lookup command, which is also all that's needed for them to
be visible to the expression evaluator JIT.

rdar://85093828

Differential Revision: https://reviews.llvm.org/D113445
2021-11-09 09:44:37 -08:00
Andy Yankovsky dc8f0035ca [lldb-vscode] Add presentation hints for scopes
Scopes can have an optional hint for how to present this scope in the UI:
https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope

The IDEs can use the hint to present the data accordingly. For example,
Visual Studio has a separate Registers window, which is populated with the
data from the scope with `presentationHint: "registers"`.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D113400
2021-11-09 17:50:46 +01:00
Pavel Labath a40929dcd2 [lldb] Fix cross-platform kills
This patch fixes an amusing bug where a Platform::Kill operation would
happily terminate a proces on a completely different platform, as long
as they have the same process ID. This was due to the fact that the
implementation was iterating through all known (debugged) processes in
order terminate them directly.

This patch just deletes that logic, and makes everything go through the
OS process termination APIs. While it would be possible to fix the logic
to check for a platform match, it seemed to me that the implementation
was being too smart for its own good -- accessing random Process
objects without knowing anything about their state is risky at best.
Going through the os ensures we avoid any races.

I also "upgrade" the termination signal to a SIGKILL to ensure the
process really dies after this operation.

Differential Revision: https://reviews.llvm.org/D113184
2021-11-09 15:31:07 +01:00
Jonas Devlieghere 0f2a7f2955 [debugserver] Put building for arm64e behind a CMake flag 2021-11-08 21:01:43 -08:00
Quinn Pham c3b15b71ce [NFC] Inclusive Language: change master to main for .chm files
[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113299
2021-11-08 08:23:04 -06:00
Jonas Devlieghere d09a21a0b3 [lldb] Remove failures case from TestTaggedPointerCmd
Somehow every pointer looks like it's tagged on GreenDragon. Removing
the check to unblock the bot until we can get to the bottom of this.
2021-11-07 10:40:43 -08:00
Jonas Devlieghere 1ab9a2906e [lldb] Fix C2360: initialization of 'identifier' is skipped by 'case' label
Make sure that every case has its own lexical block.
2021-11-05 23:09:35 -07:00
Jonas Devlieghere cd7a2bf94b [lldb] Don't set the OS for ARMGetSupportedArchitectureAtIndex
Don't set the OS when computing supported architectures in
PlatformDarwin::ARMGetSupportedArchitectureAtIndex.

Differential revision: https://reviews.llvm.org/D113159
2021-11-05 22:52:28 -07:00
Jonas Devlieghere ef2efd2553 [lldb] Remove 'result' variable which is set but not used (NFC) 2021-11-05 21:12:00 -07:00
Jonas Devlieghere 05fbe75890 [lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)
Remove the nested switches from the ARMGetSupportedArchitectureAtIndex
implementation.

Differential revision: https://reviews.llvm.org/D113155
2021-11-05 21:12:00 -07:00
Jonas Devlieghere 6d48e2505c [lldb] Use std::string instead of llvm::Twine in GDBRemoteCommunicationClient
From the documentation:

  A Twine is not intended for use directly and should not be stored, its
  implementation relies on the ability to store pointers to temporary
  stack objects which may be deallocated at the end of a statement.
  Twines should only be used accepted as const references in arguments,
  when an API wishes to accept possibly-concatenated strings.

rdar://84799118

Differential revision: https://reviews.llvm.org/D113314
2021-11-05 13:19:00 -07:00
Jonas Devlieghere 10eb32f45d [lldb] Improve 'lang objc tagged-pointer info' command
Don't try to get a class descriptor for a pointer that doesn't look like
a tagged pointer. Also print addresses as fixed-width hex and update the
test.
2021-11-05 13:19:00 -07:00
Martin Storsjö a2c9cf4c76 [lldb] Use is_style_posix() for path style checks
Since a8b54834a1, there are two
distinct Windows path styles, `windows_backslash` (with the old
`windows` being an alias for it) and `windows_slash`.
4e4883e1f3 added helpers for
inspecting path styles.

The newly added windows_slash path style doesn't end up used in
LLDB yet anyway, as LLDB is quite decoupled from most of
llvm::sys::path and uses its own FileSpec class. To take it in
use, it could be hooked up in `FileSpec::Style::GetNativeStyle`
(in lldb/source/Utility/FileSpec.cpp) just like in the `real_style`
function in llvm/lib/Support/Path.cpp in
df0ba47c36.

It is not currently clear whether there's a real need for using
the Windows path style with forward slashes in LLDB (if there's any
other applications interacting with it, expecting that style), and
what other changes in LLDB are needed for that to work, but this
at least makes some of the checks more ready for the new style,
simplifying code a bit.

Differential Revision: https://reviews.llvm.org/D113255
2021-11-05 21:50:45 +02:00
Quinn Pham c71fbdd87b [NFC] Inclusive language: Remove instances of master in URLs
[NFC] This patch fixes URLs containing "master". Old URLs were either broken or
redirecting to the new URL.

Reviewed By: #libc, ldionne, mehdi_amini

Differential Revision: https://reviews.llvm.org/D113186
2021-11-05 08:48:41 -05:00
Jonas Devlieghere 3120cadac7 [debugserver] Fix typo in DNBArchImplARM64
rdar://85020754
2021-11-04 09:43:50 -07:00
Raphael Isemann f6b7bcc64a [lldb][NFC] StringRef-ify name param in CreateClassTemplateDecl 2021-11-04 15:28:02 +01:00
Raphael Isemann 7323d07483 [lldb][NFC] Remove a bunch of unnecessary nullptr checks
Those nullptr checks are after we already accessed the pointer.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D113175
2021-11-04 15:21:03 +01:00
Raphael Isemann b738a69ab8 [lldb][NFC] StringRef-ify the name parameter in CreateEnumerationType
Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D113176
2021-11-04 14:49:16 +01:00
Muhammad Omair Javaid b595137fe1 [LLDB] Fix Cpsr size for WoA64 target
CPSR on Arm64 is 4 bytes in size but windows on Arm implementation is trying to read/write 8 bytes against a byte register causing LLDB unit tests failures.

Ref: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-arm64_nt_context

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D112471
2021-11-04 17:43:31 +05:00
Muhammad Omair Javaid cbd215dfe5 [LIT] Add win32 PLATFORM env var to test config
LIT skips various system environment variables while building test
config. It turns out that we require PLATFORM environment variable for
detection of x86 vs Arm windows platform.

This patch adds system environment variable PLATFORM into LIT test
config for detection of win32 Arm platform.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D113165
2021-11-04 17:42:43 +05:00
Lawrence D'Anna 531d877ee6 [lldb] Fix TestEchoCommands.test again
In 7f01f78593 [lldb] update TestEchoCommands -- I fixed this test,
but not on windows, becuase I used  some unix shell syntax that
doesn't work with cmd.exe.   Fixed it so it will work in both.
Test logic is the same.

This is a trivial fix, so bypassing review to get the build clean again
ASAP.
2021-11-04 01:24:25 -07:00
Muhammad Omair Javaid 553a872465 [LLDB] Adjust DumpDataExtractorTest.Formats for Windows
Floating point results mismtach between Visual stdio 2019 and previous
versions. This adjusts macro accordingly.
2021-11-04 08:48:26 +05:00
Jonas Devlieghere f9e6be5cc1 [lldb] Update tagged pointer command output and test.
- Use formatv to print the addresses.
 - Add check for 0x0 which is treated as an invalid address.
 - Use a an address that's less likely to be interpreted as a real
   tagged pointer.
2021-11-03 15:04:36 -07:00