[all-commits] [llvm/llvm-project] c22329: [lldb] Add a C language REPL to test LLDB's REPL i...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Sep 23 10:40:09 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c22329972f02f9d51e2f9ea54d9075a4a808ffde
      https://github.com/llvm/llvm-project/commit/c22329972f02f9d51e2f9ea54d9075a4a808ffde
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    M lldb/source/Commands/Options.td
    M lldb/source/Plugins/CMakeLists.txt
    A lldb/source/Plugins/REPL/CMakeLists.txt
    A lldb/source/Plugins/REPL/Clang/CMakeLists.txt
    A lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
    A lldb/source/Plugins/REPL/Clang/ClangREPL.h
    A lldb/test/API/repl/clang/Makefile
    A lldb/test/API/repl/clang/TestClangREPL.py
    A lldb/test/API/repl/clang/main.c

  Log Message:
  -----------
  [lldb] Add a C language REPL to test LLDB's REPL infrastructure

LLDB has a bunch of code that implements REPL support, but all that code is
unreachable as no language in master currently has an implemented REPL backend.
The only REPL that exists is in the downstream Swift fork. All patches for this
generic REPL code therefore also only have tests downstream which is clearly not
a good situation.

This patch implements a basic C language REPL on top of LLDB's REPL framework.
Beside implementing the REPL interface and hooking it up into the plugin
manager, the only other small part of this patch is making the `--language` flag
of the expression command compatible with the `--repl` flag. The `--repl` flag
uses the value of `--language` to see which REPL should be started, but right
now the `--language` flag is only available in OptionGroups 1 and 2, but not in
OptionGroup 3 where the `--repl` flag is declared.

The REPL currently can currently only start if a running target exists. I'll add
the 'create and run a dummy executable' logic from Swift (which is requires when
doing `lldb --repl`) when I have time to translate all this logic to something
that will work with Clang.

I should point out that the REPL currently uses the C expression parser's
approach to persistent variables where only result variables and the ones
starting with a '$' are transferred between expressions. I'll fix that in a
follow up patch. Also the REPL currently doesn't work in a non-interactive
terminal. This seems to be fixed in the Swift fork, so I assume one of our many
REPL downstream changes addresses the issue.

Reviewed By: JDevlieghere

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




More information about the All-commits mailing list