llvm-project/lldb
Pavel Labath 1408684957 [lldb] Introduce PlatformQemuUser
This adds a new platform class, whose job is to enable running
(debugging) executables under qemu.

(For general information about qemu, I recommend reading the RFC thread
on lldb-dev
<https://lists.llvm.org/pipermail/lldb-dev/2021-October/017106.html>.)

This initial patch implements the necessary boilerplate as well as the
minimal amount of functionality needed to actually be able to do
something useful (which, in this case means debugging a fully statically
linked executable).

The knobs necessary to emulate dynamically linked programs, as well as
to control other aspects of qemu operation (the emulated cpu, for
instance) will be added in subsequent patches. Same goes for the ability
to automatically bind to the executables of the emulated architecture.

Currently only two settings are available:
- architecture: the architecture that we should emulate
- emulator-path: the path to the emulator

Even though this patch is relatively small, it doesn't lack subtleties
that are worth calling out explicitly:
- named sockets: qemu supports tcp and unix socket connections, both of
  them in the "forward connect" mode (qemu listening, lldb connecting).
  Forward TCP connections are impossible to realise in a race-free way.
  This is the reason why I chose unix sockets as they have larger, more
  structured names, which can guarantee that there are no collisions
  between concurrent connection attempts.
- the above means that this code will not work on windows. I don't think
  that's an issue since user mode qemu does not support windows anyway.
- Right now, I am leaving the code enabled for windows, but maybe it
  would be better to disable it (otoh, disabling it means windows
  developers can't check they don't break it)
- qemu-user also does not support macOS, so one could contemplate
  disabling it there too. However, macOS does support named sockets, so
  one can even run the (mock) qemu tests there, and I think it'd be a
  shame to lose that.

Differential Revision: https://reviews.llvm.org/D114509
2021-11-30 14:16:08 +01:00
..
bindings [lldb] Remove 'extern "C"' from the lldb-swig-python interface 2021-11-30 11:06:09 +01:00
cmake Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM" 2021-11-02 19:11:44 +01:00
docs [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
examples [formatters] List and forward_list capping_size determination and application 2021-11-23 14:18:51 -08:00
include/lldb [lldb] Inline Platform::LoadCachedExecutable into its (single) caller 2021-11-30 14:15:49 +01:00
packages/Python [lldb] Introduce PlatformQemuUser 2021-11-30 14:16:08 +01:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb] Introduce PlatformQemuUser 2021-11-30 14:16:08 +01:00
test [lldb] Introduce PlatformQemuUser 2021-11-30 14:16:08 +01:00
third_party/Python/module [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
tools [lldb/gdb-remote] Ignore spurious ACK packets 2021-11-25 12:34:08 +01:00
unittests [lldb] Remove 'extern "C"' from the lldb-swig-python interface 2021-11-30 11:06:09 +01:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
.gitignore
CMakeLists.txt [lldb] remove usage of distutils, fix python path on debian/ubuntu 2021-11-17 13:14:30 -08:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py