[lldb-dev] -o "process launch" and stdio forwarding

Greg Clayton gclayton at apple.com
Tue Mar 10 10:55:37 PDT 2015

Ahhh, I see this now. The process should be pushing an input reader onto the stack, but it must not do that if we use "-o" for some reason. All commands from "-o" and "-O" as well as any implicit target create from specifying a target from the command line will be put into a pipe and then info a "FILE *" in:

        FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
        if (commands_file)

Then we run the command interpreter with this "commands_file" as the debugger input, then it exits and we enter again using:


This will exit when all items from the "commands_file" have been consumed. Then later we set the debugger's input file handle to stdin and run again:

    if (go_interactive)
        m_debugger.SetInputFileHandle (stdin, true);
        m_debugger.RunCommandInterpreter(handle_events, spawn_thread);

The one thing I do know about is that when m_debugger.RunCommandInterpreter exits, it always shuts down the event thread and then it restarts it when m_debugger.RunCommandInterpreter is run again. This might be responsible somehow. 

The process will push its input reader on top to the IOHandler stack so it can get user input and pass it to the function. This is done in:


Check to see how and if this is being called and also watch for calls to:


This shouldn't be too hard to track down.


> On Mar 10, 2015, at 10:44 AM, Pavel Labath <labath at google.com> wrote:
> The trick is that you need to start the process from the command line, via the -o "process launch" argument.
> pl
> On 10 March 2015 at 17:41, Greg Clayton <gclayton at apple.com> wrote:
> Works fine for me on Mac:
> % lldb a.out
> (lldb) target create "a.out"
> Current executable set to 'a.out' (x86_64).
> (lldb) process launch
> Process 22983 launched: '/private/tmp/a.out' (x86_64)
> carp
> Read: carp
> Process 22983 exited with status = 0 (0x00000000)
> (lldb)
> > On Mar 10, 2015, at 3:42 AM, Pavel Labath <labath at google.com> wrote:
> >
> > std::cout << "Read: " << s << std::endl;
> >
> > }
> >
> >

More information about the lldb-dev mailing list