Commit Graph

25569 Commits

Author SHA1 Message Date
Adrian Prantl 08c0a45ab8 Unbreak test after D111899 2021-11-18 08:51:50 -08:00
Pavel Labath 4c56f734b3 [lldb] (Partially) enable formatting of utf strings before the program is started
The StringPrinter class was using a Process instance to read memory.
This automatically prevented it from working before starting the
program.

This patch changes the class to use the Target object for reading
memory, as targets are always available. This required moving
ReadStringFromMemory from Process to Target.

This is sufficient to make frame/target variable work, but further
changes are necessary for the expression evaluator. Preliminary analysis
indicates the failures are due to the expression result ValueObjects
failing to provide an address, presumably because we're operating on
file addresses before starting. I haven't looked into what would it take
to make that work.

Differential Revision: https://reviews.llvm.org/D113098
2021-11-18 14:45:17 +01:00
Pavel Labath 3a56f5622f [lldb] Convert internal platform usages GetSupportedArchitectures 2021-11-18 13:31:09 +01:00
Greg Clayton a68ccda203 Revert "[NFC] Refactor symbol table parsing."
This reverts commit 951b107eed.

Buildbots were failing, there is a deadlock in /Users/gclayton/Documents/src/llvm/clean/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s when ELF files try to relocate things.
2021-11-17 18:07:28 -08:00
Jim Ingham 92eaad2dd7 Revert "Revert "Make it possible for lldb to launch a remote binary with no local file.""
This reverts commit dd5505a8f2.

I picked the wrong class for the test, should have been GDBRemoteTestBase.
2021-11-17 17:59:47 -08:00
Greg Clayton 951b107eed [NFC] Refactor symbol table parsing.
Symbol table parsing has evolved over the years and many plug-ins contained duplicate code in the ObjectFile::GetSymtab() that used to be pure virtual. With this change, the "Symbtab *ObjectFile::GetSymtab()" is no longer virtual and will end up calling a new "void ObjectFile::ParseSymtab(Symtab &symtab)" pure virtual function to actually do the parsing. This helps centralize the code for parsing the symbol table and allows the ObjectFile base class to do all of the common work, like taking the necessary locks and creating the symbol table object itself. Plug-ins now just need to parse when they are asked to parse as the ParseSymtab function will only get called once.

Differential Revision: https://reviews.llvm.org/D113965
2021-11-17 15:14:01 -08:00
Lawrence D'Anna 63270710f1 [lldb] remove usage of distutils, fix python path on debian/ubuntu
distutils is deprecated and will be removed, so we shouldn't be
using it.

We were using it to compute LLDB_PYTHON_RELATIVE_PATH.

Discussing a similar issue
[at python.org](https://bugs.python.org/issue41282), Filipe Laíns said:

    If you are relying on the value of distutils.sysconfig.get_python_lib()
    as you shown in your system, you probably don't want to. That
    directory (dist-packages) should be for Debian provided packages
    only, so moving to sysconfig.get_path() would be a good thing,
    as it has the correct value for user installed packages on your
    system.

So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.

On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.

On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.

This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D114106
2021-11-17 13:14:30 -08:00
Pavel Labath 1b468f1c1b [lldb] Port PlatformWindows, PlatformOpenBSD and PlatformRemoteGDBServer to GetSupportedArchitectures 2021-11-17 20:09:31 +01:00
Lawrence D'Anna f07ddbc620 [lldb] build failure for LLDB_PYTHON_EXE_RELATIVE_PATH on greendragon
see: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38387/console

```
Could not find a relative path to sys.executable under sys.prefix
tried: /usr/local/opt/python/bin/python3.7
tried: /usr/local/opt/python/bin/../Frameworks/Python.framework/Versions/3.7/bin/python3.7
sys.prefix: /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7
```

It was unable to find LLDB_PYTHON_EXE_RELATIVE_PATH because it was not resolving
the real path of sys.prefix.

caused by: https://reviews.llvm.org/D113650
2021-11-17 09:26:24 -08:00
SYNOPSYS\georgiev 9574da8f51 [lldb/test] TestRegisterVariables test fix 2021-11-17 10:58:48 +00:00
SYNOPSYS\georgiev 9f0b5f9a39 [lldb/test] Added lldbutil function to test a breakpoint
Testing the breakpoint itself rather than the lldb string.

Differential Revision: https://reviews.llvm.org/D111899
2021-11-17 08:37:30 +00:00
Jim Ingham dd5505a8f2 Revert "Make it possible for lldb to launch a remote binary with no local file."
The reworking of the gdb client tests into the PlatformClientTestBase broke
the test for this.  I did the mutatis mutandis for the move, but the test
still fails.  Reverting till I have time to figure out why.

This reverts commit b715b79d54.
2021-11-16 16:46:21 -08:00
Jim Ingham b715b79d54 Make it possible for lldb to launch a remote binary with no local file.
We don't actually need a local copy of the main executable to debug
a remote process.  So instead of treating "no local module" as an error,
see if the LaunchInfo has an executable it wants lldb to use, and if so
use it.  Then report whatever error the remote server returns.

Differential Revision: https://reviews.llvm.org/D113521
2021-11-16 16:06:07 -08:00
Lawrence D'Anna ae389b2450 [lldb] use EXT_SUFFIX for python extension
LLDB doesn't use only the python stable ABI, which means loading
it into an incompatible python can cause the process to crash.
_lldb.so should be named with the full EXT_SUFFIX from sysconfig
-- such as _lldb.cpython-39-darwin.so -- so this doesn't happen.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D112972
2021-11-16 14:32:26 -08:00
Lawrence D'Anna 4c2cf3a314 [lldb] fix -print-script-interpreter-info on windows
Apparently "{sys.prefix}/bin/python3" isn't where you find the
python interpreter on windows, so the test I wrote for
-print-script-interpreter-info is failing.

We can't rely on sys.executable at runtime, because that will point
to lldb.exe not python.exe.

We can't just record sys.executable from build time, because python
could have been moved to a different location.

But it should be OK to apply relative path from sys.prefix to sys.executable
from build-time to the sys.prefix at runtime.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D113650
2021-11-16 13:50:20 -08:00
River Riddle 4c484f11d3 [llvm] Add a SFINAE template parameter to DenseMapInfo
This allows for using SFINAE partial specialization for DenseMapInfo.
In MLIR, this is particularly useful as it will allow for defining partial
specializations that support all Attribute, Op, and Type classes without
needing to specialize DenseMapInfo for each individual class.

Differential Revision: https://reviews.llvm.org/D113641
2021-11-16 18:54:14 +00:00
Adrian Prantl db5b960e2d fix decorator 2021-11-16 09:17:47 -08:00
Adrian Prantl 948b36d258 Skip tests on older versions of clang 2021-11-16 09:09:56 -08:00
Adrian Prantl 6424dc21bf Increase gdbremote timeout.
I'm still seeing random timeouts on green dragon.
2021-11-16 09:09:55 -08:00
Adrian Prantl 6e78cfb28a typo 2021-11-16 09:09:55 -08:00
Pavel Labath 098c01c132 [lldb] Refactor Platform::ResolveExecutable
Module resolution is probably the most complex piece of lldb [citation
needed], with numerous levels of abstraction, each one implementing
various retry and fallback strategies.

It is also a very repetitive, with only small differences between
"host", "remote-and-connected" and "remote-but-not-(yet)-connected"
scenarios.

The goal of this patch (first in series) is to reduce the number of
abstractions, and deduplicate the code.

One of the reasons for this complexity is the tension between the desire
to offload the process of module resolution to the remote platform
instance (that's how most other platform methods work), and the desire
to keep it local to the outer platform class (its easier to subclass the
outer class, and it generally makes more sense).

This patch resolves that conflict in favour of doing everything in the
outer class. The gdb-remote (our only remote platform) implementation of
ResolveExecutable was not doing anything gdb-specific, and was rather
similar to the other implementations of that method (any divergence is
most likely the result of fixes not being applied everywhere rather than
intentional).

It does this by excising the remote platform out of the resolution
codepath. The gdb-remote implementation of ResolveExecutable is moved to
Platform::ResolveRemoteExecutable, and the (only) call site is
redirected to that. On its own, this does not achieve (much), but it
creates new opportunities for layer peeling and code sharing, since all
of the code now lives closer together.

Differential Revision: https://reviews.llvm.org/D113487
2021-11-16 12:52:51 +01:00
Pavel Labath 669e57ebd1 [lldb] Simplify specifying of platform supported architectures
The GetSupportedArchitectureAtIndex pattern forces the use of
complicated patterns in both the implementations of the function and in
the various callers.

This patch creates a new method (GetSupportedArchitectures), which
returns a list (vector) of architectures. The
GetSupportedArchitectureAtIndex is kept in order to enable incremental
rollout. Base Platform class contains implementations of both of these
methods, using the other method as the source of truth. Platforms
without infinite stacks should implement at least one of them.

This patch also ports Linux, FreeBSD and NetBSD platforms to the new
API. A new helper function (CreateArchList) is added to simplify the
common task of creating a list of ArchSpecs with the same OS but
different architectures.

Differential Revision: https://reviews.llvm.org/D113608
2021-11-16 11:43:48 +01:00
Pavel Labath 33c0f93f6c [lldb/test] Move gdb client utils into the packages tree
This infrastructure has proven proven its worth, so give it a more
prominent place.

My immediate motivation for this is the desire to reuse this
infrastructure for qemu platform testing, but I believe this move makes
sense independently of that. Moving this code to the packages tree will
allow as to add more structure to the gdb client tests -- currently they
are all crammed into the same test folder as that was the only way they
could access this code.

I'm splitting the code into two parts while moving it. The first once
contains just the generic gdb protocol wrappers, while the other one
contains the unit test glue. The reason for that is that for qemu
testing, I need to run the gdb code in a separate process, so I will
only be using the first part there.

Differential Revision: https://reviews.llvm.org/D113893
2021-11-16 11:35:56 +01:00
Greg Clayton dbd36e1e9f Add the stop count to "statistics dump" in each target's dictionary.
It is great to know how many times the target has stopped over its lifetime as each time the target stops, and possibly resumes without the user seeing it for things like shared library loading and signals that are not notified and auto continued, to help explain why a debug session might be slow. This is now included as "stopCount" inside each target JSON.

Differential Revision: https://reviews.llvm.org/D113810
2021-11-15 18:59:09 -08:00
Zequan Wu b6d3535230 [LLDB][NativePDB] Fix local-variables.cpp failure on windows bots 2021-11-15 16:14:55 -08:00
Matheus Izvekov c9e46219f3
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110216
2021-11-15 23:07:45 +01:00
Zequan Wu f17404a733 [LLDB][NativePDB] Fix image lookup by address
`image lookup -a ` doesn't work because the compilands list is always empty.
Create CU at given index if doesn't exit.

Differential Revision: https://reviews.llvm.org/D113821
2021-11-15 12:30:23 -08:00
Andy Yankovsky 95102b7dc3 [lldb] Unwrap the type when dereferencing the value
The value type can be a typedef of a reference (e.g. `typedef int& myint`).
In this case `GetQualType(type)` will return `clang::Typedef`, which cannot
be casted to `clang::ReferenceType`.

Fix a regression introduced in https://reviews.llvm.org/D103532.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113673
2021-11-15 14:48:19 +01:00
Pavel Labath 5e20cd6568 [lldb/test] Fix std-module vector tests to work with both kinds of vector layouts
D112976 changed the layout and 0d62e31c45 andjusted the test
expectations to match.

This patch changes the tests to expect both versions, so that one can
run the test suite against older libc++ versions as well.
2021-11-15 11:12:05 +01:00
Shao-Ce SUN 0c660256eb [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
Matheus Izvekov 6438a52df1
Revert "[clang] retain type sugar in auto / template argument deduction"
This reverts commit 4d8fff477e.
2021-11-15 00:29:05 +01:00
Raphael Isemann c3a3e65ecc Revert "[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT"
This reverts commit cef1e07cc6.

It broke the windows bot.
2021-11-13 18:18:24 +01:00
Matheus Izvekov 4d8fff477e
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110216
2021-11-13 03:35:22 +01:00
Lawrence D'Anna 19cd6f31d8 [lldb] temporarily disable TestPaths.test_interpreter_info on windows
I'm disabling this test until the fix is reviewed
(here https://reviews.llvm.org/D113650/)
2021-11-12 15:41:39 -08:00
Quinn Pham 84c5702b76 [lldb][NFC] Inclusive language: rename m_master in ASTImporterDelegate
[NFC] As part of using inclusive language within the llvm project, this patch
replaces `m_master` in `ASTImporterDelegate` with `m_main`.

Reviewed By: teemperor, clayborg

Differential Revision: https://reviews.llvm.org/D113720
2021-11-12 12:04:14 -06:00
Quinn Pham 52a3ed5b93 [lldb][NFC] Inclusive language: replace master/slave names for ptys
[NFC] This patch replaces master and slave with primary and secondary
respectively when referring to pseudoterminals/file descriptors.

Reviewed By: clayborg, teemperor

Differential Revision: https://reviews.llvm.org/D113687
2021-11-12 10:54:18 -06:00
Raphael Isemann cef1e07cc6 [lldb] Fix that the embedded Python REPL crashes if it receives SIGINT
When LLDB receives a SIGINT while running the embedded Python REPL it currently
just crashes in `ScriptInterpreterPythonImpl::Interrupt` with an error such as
the one below:

```

Fatal Python error: PyThreadState_Get: the function must be called with the GIL
held, but the GIL is released (the current Python thread state is NULL)

```

The faulty code that causes this error is this part of `ScriptInterpreterPythonImpl::Interrupt`:
```
    PyThreadState *state = PyThreadState_GET();
    if (!state)
      state = GetThreadState();
    if (state) {
      long tid = state->thread_id;
      PyThreadState_Swap(state);
      int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
```

The obvious fix I tried is to just acquire the GIL before this code is running
which fixes the crash but the `KeyboardInterrupt` we want to raise immediately
is actually just queued and would only be raised once the next line of input has
been parsed (which e.g. won't interrupt Python code that is currently waiting on
a timer or IO from what I can see). Also none of the functions we call here is
marked as safe to be called from a signal handler from what I can see, so we
might still end up crashing here with some bad timing.

Python 3.2 introduced `PyErr_SetInterrupt` to solve this and the function takes
care of all the details and avoids doing anything that isn't safe to do inside a
signal handler. The only thing we need to do is to manually setup our own fake
SIGINT handler that behaves the same way as the standalone Python REPL signal
handler (which raises a KeyboardInterrupt).

From what I understand the old code used to work with Python 2 so I kept the old
code around until we officially drop support for Python 2.

There is a small gap here with Python 3.0->3.1 where we might still be crashing,
but those versions have reached their EOL more than a decade ago so I think we
don't need to bother about them.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D104886
2021-11-12 14:19:15 +01:00
Adrian Kuegel c30c37c00a Revert "[lldb] fix test expectation broken by clang fix at D110216"
This reverts commit 5508595217.
The patch it depends on is reverted.
2021-11-12 13:21:30 +01:00
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