Commit Graph

13494 Commits

Author SHA1 Message Date
Martin Storsjö 0cd9e59829 [ProcessGDBRemote] Fix a typo in an ifdef from 58de2a3851 2020-06-24 23:49:33 +03:00
Davide Italiano 58de2a3851 [ProcessGDBRemote] Placate the Windows buildbot.
I'm probably going to rewrite this function anyway, but, in
the meanwhile.
2020-06-24 13:23:49 -07:00
Davide Italiano b4fdddf971 [Apple Silicon] Debugging of process under Rosetta is supported.
Remove this early exit. It's vestigial from the ppc -> Intel transition,
but it doesn't apply anymore.
2020-06-24 12:25:01 -07:00
Davide Italiano fd19ddb8f2 [Apple Silicon] Initial support for Rosetta
Translated processes talk with a different debugserver, shipped with
macOS 11. This patch detects whether a process is translated and
attaches to the correct debugserver implementation.
It's the first patch of a series. Tested on the lldb test suite.

Differential Revision:  https://reviews.llvm.org/D82491
2020-06-24 12:19:21 -07:00
Pavel Labath 16e17ca16a [lldb] Refactor Scalar::TruncOrExtendTo
The "type" argument to the function is mostly useless -- the only
interesting aspect of it is signedness. Pass signedness directly and
compute the value of bits and signedness fields -- that's exactly
what the single caller of this function does.
2020-06-24 15:58:33 +02:00
Jonas Devlieghere be494adb30 [lldb/Lua] Fix typo: s/stdout/stderr/
This wasn't caught by the existing test, but will be covered by the
extended test that's part of D82412.
2020-06-23 14:19:03 -07:00
Davide Italiano 63d597093c [ObjectFileMachO] Check for TARGET_EMBEDDED instead of listing architectures.
Now that Apple Silicon is a thing, we need to generalize the check.
2020-06-23 12:37:45 -07:00
Davide Italiano 3c79212319 [Host] Check for TARGET_OS_EMBEDDED instead of listing architectures.
With the advent of Apple Silicon, checking for the architectures
specifically is not correct anymore. This code is only supposed to
run on embedded devices (iPhones et similia), so mark it accordingly.
2020-06-23 12:27:21 -07:00
Jonas Devlieghere fa1b4a96a0 [lldb/Lua] Use the debugger's output and error file for Lua's I/O library.
Add support for changing the stdout and stderr file in Lua's I/O library
and hook it up with the debugger's output and error file respectively
for the interactive Lua interpreter.

https://reviews.llvm.org/D82273
2020-06-23 09:05:51 -07:00
Sander de Smalen 121e585ec8 [AArch64][SVE] ACLE: Add bfloat16 to struct load/stores.
This patch contains:
- Support in LLVM CodeGen for bfloat16 types for ld2/3/4 and st2/3/4.
- New bfloat16 ACLE builtins for svld(2|3|4)[_vnum] and svst(2|3|4)[_vnum]

Reviewers: stuij, efriedma, c-rhodes, fpetrogalli

Reviewed By: fpetrogalli

Tags: #clang, #lldb, #llvm

Differential Revision: https://reviews.llvm.org/D82187
2020-06-23 12:12:35 +01:00
Pavel Labath 5a4d78064e [lldb] Split ClangASTSource::CompleteType
Move the part of the code which is responsible for finding a complete
definition of the type into a separate function (FindCompleteType). This
is split off from D81561, as it's a generally useful cleanup.

No functional change.
2020-06-23 11:47:52 +02:00
Jonas Devlieghere 1728dec255 [lldb/Lua] Recognize "quit" as a way to exit the script interpreter.
Add a way to quit the interactive script interpreter from a shell tests.
Currently, the only way (that I know) to exit the interactive Lua
interpreter is to send a EOF with CTRL-D. I noticed that the embedded
Python script interpreter accepts quit (while the regular python
interpreter doesn't). I've added a special case to the Lua interpreter
to do the same.

Differential revision: https://reviews.llvm.org/D82272
2020-06-22 09:27:12 -07:00
Jonas Devlieghere 6e3faaeb44 [lldb/Lua] Remove redundant variable (NFC) 2020-06-20 23:28:22 -07:00
Jonas Devlieghere e13fca4fac [lldb] Remove unused <iostream> includes (NFC) 2020-06-20 22:38:45 -07:00
Eric Christopher efb328f674 As part of using inclusive language with the llvm project,
migrate away from the use of blacklist and whitelist.
2020-06-19 14:48:48 -07:00
Jonas Devlieghere 827c012297 [lldb] Replace calls to new with std::make_shared<> (NFC) 2020-06-19 11:20:15 -07:00
Raphael Isemann f5eaa2afe2 [lldb] Replace std::isprint/isspace with llvm's locale-independent version
Summary:
LLVM is using its own isPrint/isSpace implementation that doesn't change depending on the current locale. LLDB should do the same
to prevent that internal logic changes depending on the set locale.

Reviewers: JDevlieghere, labath, mib, totally_not_teemperor

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D82175
2020-06-19 19:17:56 +02:00
Raphael Isemann 8340fbb9c7 [lldb] Reactivate Objective-C++ plugin
Summary:
Since commit 7b3ef05a37 the Objective-C++ plugin is dead code.
That commit added Objective-C++ to the list of languages for which `Language::LanguageIsCPlusPlus`
returns true. As the C++ language plugin also uses that method to figure out if it is responsible for a
given language, the C++ plugin since then also became the plugin that we found when looking for
a language plugin for Objective-C++. The only real fallout from that is that the source highlighting
for Objective-C++ files never worked as we always found the C++ plugin which refuses to highlight
files with Objective-C++ extensions.

This patch just adds a special exception for Objective-C++ to the list of languages that are governed
by the C++ plugin. Also adds a test that makes sure that we find the right plugin for all C language
types and that the highlighting for `.mm` (Objective-C++) and `.m` (Objective-C) files works.

I didn't revert 7b3ef05a37 as it does make sense to return
true for Objective-C++ from `Language::LanguageIsCPlusPlus` (e.g., we currently check if we care about
ODR violations by doing `if (Language::LanguageIsCPlusPlus(...))` and this should also work for
Objective-C++).

Fixes rdar://64420183

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: mgorny, abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D82109
2020-06-19 19:16:46 +02:00
Raphael Isemann be18df3d23 [lldb] Fix that SIGWINCH crashes IOHandlerEditline when we are not using the editline backend
Summary:
TerminalSizeChanged is called from our SIGWINCH signal handler but the
IOHandlerEditline currently doesn't check if we are actually using the real
editline backend. If we're not using the real editline backend, `m_editline_up`
won't be set and `IOHandlerEditline::TerminalSizeChanged` will access
the empty unique_ptr. In a real use case we don't use the editline backend
when we for example read input from a file. We also create some temporary
IOHandlerEditline's during LLDB startup it seems that are also treated
as non-interactive (apparently to read startup commands).

This patch just adds a nullptr check for`m_editline_up` as we do in the rest of
IOHandlerEditline.

Fixes rdar://problem/63921950

Reviewers: labath, friss

Reviewed By: friss

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D81729
2020-06-19 19:14:16 +02:00
Adrian Prantl 7e825abd57 Repair support for launching ios/tv/watch simulator binaries through platform
and delete a bunch (but not all) redundant code. If you compare the remaining implementations of Platform*Simulator.cpp, there is still an obvious leftover cleanup task.

Specifically, this patch

- removes SDK initialization from dotest (there is equivalent but more
  complete code in Makefile.rules)

- make Platform*Simulator inherit the generic implementation of
  PlatformAppleSimulator (more can be done here)

- simplify the platform logic in Makefile.rules

- replace the custom SDK finding logic in Platform*Simulator with XcodeSDK

- adds a test for each supported simulator

Differential Revision: https://reviews.llvm.org/D81980
2020-06-19 09:42:44 -07:00
Raphael Isemann 1e8e1ec00c [lldb][NFC] Remove unused DEPTH_INCREMENT in CompilerType.cpp 2020-06-19 16:35:03 +02:00
Derek Schuff c1709e5d90 Set appropriate host defines for building under emscripten
Emscripten has emulations for several headers found on Linux,
including spwan.h and endian.h

Differential Revision: https://reviews.llvm.org/D82121
2020-06-18 17:00:53 -07:00
Eric Christopher 50939c0a67 Add SveBFloat16 to type switch. 2020-06-18 12:39:03 -07:00
Muhammad Omair Javaid 6c45532908 Remove code duplication from RegisterContextPOSIX_*
Summary:
This patch aims to remove multiple copies of GetByteOrder() and ConvertRegisterKindToRegisterNumber used in various versions of RegisterContextPOSIX_*.

Both register implementations are move to RegisterContext class which is parent of RegisterContextPOSIX_* classes.

Built and tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabihf targets.

Reviewers: labath

Reviewed By: labath

Subscribers: wuzish, nemanjai, kristof.beyls, kbarton, atanasyan, lldb-commits

Differential Revision: https://reviews.llvm.org/D80104
2020-06-18 01:02:46 +05:00
Jonas Devlieghere 4dd3dfe8e3 [lldb/Python] Fix the infinitely looping Python prompt bug
Executing commands below will get you bombarded by a wall of Python
command prompts (>>> ).

$ echo 'foo' | ./bin/lldb -o script
$ cat /tmp/script
script
print("foo")
$ lldb --source /tmp/script

The issue is that our custom input reader doesn't handle EOF. According
to the Python documentation, file.readline always includes a trailing
newline character unless the file ends with an incomplete line. An empty
string signals EOF. This patch raises an EOFError when that happens.

[1] https://docs.python.org/2/library/stdtypes.html#file.readline

Differential revision: https://reviews.llvm.org/D81898
2020-06-16 11:05:19 -07:00
Jonas Devlieghere 388afd8406 [lldb] Remove redundant access specifiers (NFC) 2020-06-15 21:34:13 -07:00
Jonas Devlieghere 5ddd4fc5a6 [lldb/Lua] Fix override/virtual in ScriptInterpreterLua (NFC) 2020-06-15 21:15:35 -07:00
Jonas Devlieghere 93571c3c3b [lldb/Python] Various cleanups in ScriptInterpreterPython (NFC) 2020-06-15 21:07:43 -07:00
Jonas Devlieghere 64ec505dd4 [lldb] Rename Master/Slave to Primary/Secondary (NFC) 2020-06-15 15:38:28 -07:00
Jonas Devlieghere d74323606d [lldb] Remove indentation before help output.
This patch remove the indentation before the command help output.
Supposedly it was meant to be aligned with the different subcommands.

Differential revision: https://reviews.llvm.org/D81783
2020-06-15 09:27:17 -07:00
Kirill Bobyrev 2d8f8c4de3
[lldb] Handle all Clang::Type::Builtin enums
Cleanup after https://reviews.llvm.org/D81459
2020-06-15 10:18:59 +02:00
Jonas Devlieghere ff058e7331 [lldb] Remove unnecessary c_str() in OutputFormattedHelpText calls (NFC) 2020-06-12 21:13:21 -07:00
Jonas Devlieghere 58e34ede5b [lldb] Small improvements in ValueObjectPrinter::PrintDecl (NFC)
Remove unused argument, simply code and reformat.
2020-06-12 21:05:05 -07:00
Jonas Devlieghere da601ea731 [lldb/Test] Assert that no targets or modules remain after a test completes.
The reproducer intentionally leak every object allocated during replay,
which means that modules never get orphaned. If this were to happen for
another reason, we might not be testing what we think we are. Assert
that there are no targets left at the end of a test and that the global
module cache is empty in the non-reproducer scenario.

Differential revision: https://reviews.llvm.org/D81612
2020-06-12 15:17:44 -07:00
Jonas Devlieghere 2b34632a57 [lldb/SymbolFile] Don't parse the whole line table for the support files
Prior to my patch of using the LLVM line table parsing code,
SymbolFileDWARF::ParseSupportFiles would only parse the line table
prologues to get the file list for any files that could be in the line
table.

With the old behavior, if we found the file that someone is setting the
breakpoint in in the support files list, we would get a valid index. If
we didn't, we would not look any further. So someone sets a breakpoint
one "MyFile.cpp:12" and if we find "MyFile.cpp" in the support file list
for the compile unit, then and only then would we get the entire line
table for that compile unit.

With the current behavior, no matter what, we always fully parse the
line table for all compile units any time any file and line breakpoint
is set. This creates a serious problem when debugging a large DWARF in
.o file project.

This patch re-instates the old behavior. Unfortunately it means we might
end up parsing to prologue twice, but I don't think that outweighs the
cost of trying to cache/reuse it.

Differential revision: https://reviews.llvm.org/D81589
2020-06-12 09:39:17 -07:00
Raphael Isemann 91728b9172 [lldb] Don't print IRForTarget errors directly to the console
Summary:

When we get an error back from IRForTarget we directly print that error to the
debugger output stream instead of putting it in the result object. The result
object only gets a vague "The expression could not be prepared to run in the
target" error message that doesn't actually tell the user what went wrong.

This patch just puts the IRForTarget errors into the status object that is
returned to the caller instead of directly printing it to the debugger. Also
updates one test that now can actually check for the error message it is
supposed to check for (instead of the default error which is all we had before).

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D81654
2020-06-12 10:27:25 +02:00
Ilya Bukonkin 3b43f00629 [lldb] Check if thread was suspended during previous stop added.
Encountered the following situation: Let we started thread T1 and it hit
breakpoint on B1 location. We suspended T1 and continued the process.
Then we started thread T2 which hit for example the same location B1.
This time in a breakpoint callback we decided not to stop returning
false.

Expected result: process continues (as if T2 did not hit breakpoint) its
workflow with T1 still suspended. Actual result: process do stops (as if
T2 callback returned true).

Solution: We need invalidate StopInfo for threads that was previously
suspended just because something that is already inactive can not be the
reason of stop. Thread::GetPrivateStopInfo() may be appropriate place to
do it, because it gets called (through Thread::GetStopInfo()) every time
before process reports stop and user gets chance to change
m_resume_state again i.e if we see m_resume_state == eStateSuspended
it definitely means it was set during previous stop and it also means
this thread can not be stopped again (cos' it was frozen during
previous stop).

Differential revision: https://reviews.llvm.org/D80112
2020-06-11 15:02:46 -07:00
Reid Kleckner 1c03389c29 Re-land "Migrate the rest of COFFObjectFile to Error"
This reverts commit 101fbc0138.

Remove leftover debugging attribute.

Update LLDB as well, which was missed before.
2020-06-11 14:46:16 -07:00
Pavel Labath e966a5deaa [lldb] Remove Scalar operator= overloads
The are not needed as Scalar is implicitly constructible from all of
these types (so the compiler will use a combination of a constructor +
move assignment instead), and they make it very easy for implementations
of assignment and construction operations to diverge.
2020-06-11 13:55:02 +02:00
Raphael Isemann dc0f098048 [lldb] Fix a crash in PlatformAppleSimulator::GetCoreSimulatorPath when Xcode developer directory can't be found
Summary:

`PlatformAppleSimulator::GetCoreSimulatorPath` currently checks if
`m_core_simulator_framework_path` wasn't set yet and then tries to calculate its
actual value. However, if `GetXcodeDeveloperDirectory` returns an invalid
FileSpec, `m_core_simulator_framework_path` is never assigned a value which
causes that the `return m_core_simulator_framework_path.getValue();` at the end
of the function will trigger an assert.

This patch just assigns an invalid FileSpec to `m_core_simulator_framework_path`
which seems what the calling code in `PlatformAppleSimulator::LoadCoreSimulator`
expects as an error value.

I assume this can be reproduces on machines that don't have an Xcode
installation, but this patch is mostly based on this backtrace I received from
someone else that tried to run the test suite:

```
Assertion failed: (hasVal), function getValue, file llvm/include/llvm/ADT/Optional.h, line 73.
[...]
3   libsystem_c.dylib             	0x00007fff682a1ac6 __assert_rtn + 314
4   liblldb.11.0.0git.dylib       	0x000000010b835931 PlatformAppleSimulator::GetCoreSimulatorPath() (.cold.1) + 33
5   liblldb.11.0.0git.dylib       	0x0000000107e92f11 PlatformAppleSimulator::GetCoreSimulatorPath() + 369
6   liblldb.11.0.0git.dylib       	0x0000000107e9383e void std::__1::__call_once_proxy<std::__1::tuple<PlatformAppleSimulator::LoadCoreSimulator()::$_1&&> >(void*) + 30
7   libc++.1.dylib                	0x00007fff654d5bea std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) + 139
8   liblldb.11.0.0git.dylib       	0x0000000107e92019 PlatformAppleSimulator::LaunchProcess(lldb_private::ProcessLaunchInfo&) + 89
9   liblldb.11.0.0git.dylib       	0x0000000107e92be5 PlatformAppleSimulator::DebugProcess(lldb_private::ProcessLaunchInfo&, lldb_private::Debugger&, lldb_private::Target*, lldb_private::Status&) + 101
10  liblldb.11.0.0git.dylib       	0x0000000107cb044d lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::Stream*) + 669
11  liblldb.11.0.0git.dylib       	0x000000010792c9c5 lldb::SBTarget::Launch(lldb::SBLaunchInfo&, lldb::SBError&) + 1109
12  liblldb.11.0.0git.dylib       	0x0000000107a92acd _wrap_SBTarget_Launch(_object*, _object*) + 477
13  org.python.python             	0x000000010681076f PyCFunction_Call + 321
14  org.python.python             	0x000000010689ee12 _PyEval_EvalFrameDefault + 7738
```

Reviewers: JDevlieghere, jasonmolenda

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D80997
2020-06-11 09:48:39 +02:00
Jonas Devlieghere 6b2e676555 [Debugger] Use FileSystem instead of calling openFileForWrite directly.
This replaces the (only) call to llvm::sys::fs::openFileForWrite with
FileSystem::Open. This guarantees that we include log files in the
reproducers.

Differential revision: https://reviews.llvm.org/D81499
2020-06-10 18:13:32 -07:00
Raphael Isemann bb9d93f4d5 [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with calls to LLVM's LEB128 implementation
Reviewers: labath, JDevlieghere

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D81453
2020-06-10 16:35:09 +02:00
Pavel Labath 040eca7717 [lldb/Utility] Remove m_ieee_quad from Scalar
This field is unused (the only way to change its value is via a
constructor which is never called), and as far as I can tell it has been
unused since it was introduced in D12100. It also has some soundness
issues -- e.g.  operator= does not reinitialize it, but uses the old
value from the overwritten object.

It sounds like this class should be able to support different floating
point semantics, but if that is needed, it would be better to start
afresh -- probably by passing in an APFloat::fltSemantics object instead
of a bool flag.
2020-06-10 15:15:01 +02:00
Raphael Isemann 834708a6a0 [lldb][NFC] Rename ClangExpressionDeclMap::AddThisType and clarify documentation 2020-06-10 12:26:47 +02:00
Jonas Devlieghere 6c5c4a2a50 [lldb/Reproducers] Also collect ::open and ::fopen
Report files opened trough ::open and ::fopen to the FileCollector.
2020-06-09 11:59:02 -07:00
Jonas Devlieghere de019b88dd [lldb/Interpreter] Support color in CommandReturnObject
Color the error: and warning: part of the CommandReturnObject output,
similar to how an error is printed from the driver when colors are
enabled.

Differential revision: https://reviews.llvm.org/D81058
2020-06-09 10:45:45 -07:00
Jan Kratochvil 4515d35f5c [lldb] Fix DW_TAG_GNU_call_site-DW_AT_low_pc as produced by GCC
D80519 <https://reviews.llvm.org/D80519>
added support for `DW_TAG_GNU_call_site` but
Bug 45886 <https://bugs.llvm.org/show_bug.cgi?id=45886>
found one case did not work.

There is:

  0x000000b1:     DW_TAG_GNU_call_site
                    DW_AT_low_pc  (0x000000000040111e)
                    DW_AT_abstract_origin (0x000000cc "a")
  ...
  0x000000cc:   DW_TAG_subprogram
                  DW_AT_name      ("a")
                  DW_AT_prototyped        (true)
                  DW_AT_low_pc    (0x0000000000401109)
                  ^^^^^^^^^^^^ - here it did overwrite the 'low_pc' variable containing value 0x40111e we wanted
                  DW_AT_high_pc   (0x0000000000401114)
                  DW_AT_frame_base        (DW_OP_call_frame_cfa)
                  DW_AT_GNU_all_call_sites        (true)

DW_TAG_GNU_call_site attributes order as produced by GCC:
0x000000b1:     DW_TAG_GNU_call_site
                  DW_AT_low_pc  (0x000000000040111e)
                  DW_AT_abstract_origin (0x000000cc "a")

clang produces the attributes in opposite order:
0x00000064:     DW_TAG_GNU_call_site
                  DW_AT_abstract_origin (0x0000002a "a")
                  DW_AT_low_pc  (0x0000000000401146)

Differential Revision: https://reviews.llvm.org/D81334
2020-06-09 13:41:41 +02:00
Jan Kratochvil fd31e60b8d [nfc] [lldb] Reduce GetAttributes's depth parameter usage
Clean the code up a bit for D81334.

Differential Revision: https://reviews.llvm.org/D81423
2020-06-09 13:41:06 +02:00
Pavel Labath 17798c60bc [lldb] Fix -Wmissing-field-initializers in StackFrameList
The code is correct without these default values, but it is freaking the
compiler out.
2020-06-09 11:58:08 +02:00
Pavel Labath 731fee8b42 [lldb] Fail evaluation of DWARF expressions with unknown opcodes
Previously, we were simply ignoring them and continuing the evaluation.
This behavior does not seem useful, because the resulting value will
most likely be completely bogus.
2020-06-08 15:52:28 +02:00