Run REPL whilst program is running

Is this possible? I want to run my executable whilst having a REPL opened, ideally being able to patch methods or simply just access variables.

If not, are there creative solutions around this? Such as RPC.

Here's my attempt. Effectively I have two threads a main thread (receives input from the user) and a repl thread (to set a breakpoint with LLDB):

Compile & run the swift program (defined below)

swiftc multi_thread.swift

Debug with LLDB

$ lldb -p 32661
> break multi_thread.swift:8
> c

in the program - start the "repl thread" by entering input and then in LLDB's prompt:

continue the main thread:

<breakpoint will be hit - pausing the program>
> thread continue 1

Finally, try to open a REPL in LLDB:

> repl

With this I receive: error: Process is running. Use 'process interrupt' to pause execution.

Is this due to the implementation of the REPL?

The swift program

# multi_thread.swift

import Foundation

func foobar() {
    print("foobar - to patch")

func repl_thread() {
    while true {

func main_thread() {
    let pid = getpid()
    print("Running process with pid:", pid)

    // start repl_thread in another thread
    let repl = Thread {
    print("Waiting for input to start repl thread")
    let input = readLine()
    if input == nil {

    while true {
        let line = readLine()
        if line == nil {
        else if line == "c" {
        } else {