[all-commits] [llvm/llvm-project] 5c4cb3: [lldb/qemu] Add support for pty redirection

Pavel Labath via All-commits all-commits at lists.llvm.org
Mon Dec 6 06:06:36 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c4cb323e86aaf816c0dd45191dad08e5d4691cf
      https://github.com/llvm/llvm-project/commit/5c4cb323e86aaf816c0dd45191dad08e5d4691cf
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2021-12-06 (Mon, 06 Dec 2021)

  Changed paths:
    M lldb/source/Host/common/ProcessLaunchInfo.cpp
    M lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
    M lldb/source/Target/Target.cpp
    M lldb/test/API/qemu/TestQemuLaunch.py
    M lldb/test/API/qemu/qemu.py

  Log Message:
  -----------
  [lldb/qemu] Add support for pty redirection

Lldb uses a pty to read/write to the standard input and output of the
debugged process. For host processes this would be automatically set up
by Target::FinalizeFileActions. The Qemu platform is in a unique
position of not really being a host platform, but not being remote
either. It reports IsHost() = false, but it is sufficiently host-like
that we can use the usual pty mechanism.

This patch adds the necessary glue code to enable pty redirection. It
includes a small refactor of Target::FinalizeFileActions and
ProcessLaunchInfo::SetUpPtyRedirection to reduce the amount of
boilerplate that would need to be copied.

I will note that qemu is not able to separate output from the emulated
program from the output of the emulator itself, so the two will arrive
intertwined. Normally this should not be a problem since qemu should not
produce any output during regular operation, but some output can slip
through in case of errors. This situation should be pretty obvious (to a
human), and it is the best we can do anyway.

For testing purposes, and inspired by lldb-server tests, I have extended
the mock emulator with the ability "program" the behavior of the
"emulated" program via command-line arguments.

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




More information about the All-commits mailing list