Threading model for Python API

Hi there!

I was wondering what the threading model is for the Python API (when
running inside of LLDB, in implementing a command)?

For example: If I create a Python thread in my command, how do I
access the LLDB API? Is there an equivalent of gdb's post_event
function to run it on the main thread? Or is the API threadsafe?

I tried to look for documentation on this but was unsuccessful.

Thanks!
Christian

The API is thread safe, but you can run into interesting issues if you don't thread things right. You don't want one thread stepping and another thread resuming. It will work, but you probably will have a tough time figuring out why certain functions return certain values. Also, you don't want one thread resuming a process while another things the process is stopped and tries to get and display local variables.

So yes the API is thread safe, but be careful with how you use things.

Greg

OK thanks! (If I try to get, for example, the local variables while
the process is running, will that fail or "succeed" in a weird way?)

Christian

OK thanks! (If I try to get, for example, the local variables while
the process is running, will that fail or "succeed" in a weird way?)

You will get an empty list. But if you get the list of variables on thread 1, then thread 2 continues, and back on thread 1 you ask each value in the lldb::SBValueList for their values, you will get fail values or no values when you ask. Mainly common sense kind of stuff, but just something to be aware of.