1

In GDB you could continue/step/etc. the debugging process in the background by attaching an & after the command (ex: continue&), allowing you access to the CLI while the process/thread runs. I have found this to be invaluable when debugging multi-process/multi-thread applications when I want to keep the "non-interesting" threads/processes running while I stepped through a single thread.

I was wondering is there anything equivalent in LLDB? Specifically, I would like to specify which execution model I want to use in a script.

An example of something I would like to do in an LLDB script:

# this is just background setup for attaching to multiple processes
# I've figured out how to do this in LLDB
attach 1
add-inferior
inferior 2
attach 2
# this is the step I don't know how to get to work consistently
continue&
inferior 1
# ... do debugging work on inferior 1, possibly switching to inferior 2 as needed

Things I've tried:

In LLDB, the closest thing I've found in the documentation are two "options" --no-stdin, or settings set target.process.disable-stdio true (I don't need stdin for my applications, though stdout would be nice). However, when I tried looking for either of these options in LLDB 6.0, they don't exist anymore, or at least not by these names.

Another thing I have found (couldn't find any documentation on this) is if I attached LLDB to an existing process ID, then when I issued process continue from the CLI it would always execute in the background. However, if I run an LLDB commands script or have LLDB run the process locally then it always executes "in the foreground" and I lose control of the CLI unless I interrupt the running command. It's important to me that I be able to do something like continue& in a script since I will have quite a few processes and manually switching to/continuing each target is very time consuming.

1 Answer 1

3

Looks like --no-stdin was changed to the (arguably more accurate) --no-stdio option to process launch without changing the overview doc. Do help process launch to see all the options, including that one. The equivalent setting is target.disable-stdio.

Note also, lldb's help was enhanced so that aliases that end with -- - i.e. that explicitly turn off adding options to the command - don't list the options for the underlying command. run is an alias for process launch --, so if you do help run you won't see any options.

You can also use the --tty option to redirect the output to another terminal window.

As far as script commands go. The way this works is that lldb can run the processes in either synchronous or asynchronous mode. In synchronous mode, all the commands (and SB API calls) in the debugger that continue a process block till the process stops again. In async mode, control returns immediately, and then somebody needs to watch the lldb event stream for process events to figure out when the process has stopped again. For commands, lldb will do that for you. For Python scripts, you have to do that by hand.

If you are using the command line, we figure out which to do for command-line commands based on whether we are also trying to field stdio from the process.

For scripts written with the SB API's, either when used as lldb command-line commands or as stand-alone scripts, lldb runs the debugger in synchronous mode by default. That saves you the trouble of having to wait for events to know when the process has stopped. And since there isn't currently a way to "suspend" a command mid-stream and go back to the command line (till when?), running in async mode is not generally very useful. But it is useful in the case where you want to issue a "continue" as the last act of a python command, and want that to happen asynchronously. Then you can do:

old_async = debugger.GetAsync()    
debugger.SetAsync(True)
process.Continue()
debugger.SetAsync(old_async)

Then the Python based command will exit when the process successfully continues rather than waiting for it to stop again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.