OperatingSystem plugins

I would like to change the list of threads that lldb presents to the user for an internal application (not to be submitted upstream). It seems the right way to do this is to write an OperatingSystem plugin.

  1. Can I still make it so the user can see real threads as well as whatever other “threads” I make up?

  2. Is the purpose of the Python OperatingSystem plugin to allow the user to write plugins in Python? It doesn’t look like it’s to help debugging of Python programs.

2a. If that’s true, is there a reason the Go OperatingSystem plugin is written in C++ instead of Python? Is it just historical, or is there some advantage to writing it in C++?

  1. Does this work just as well when dealing with core files as when dealing with a running process?

I would like to change the list of threads that lldb presents to the user for an internal application (not to be submitted upstream). It seems the right way to do this is to write an OperatingSystem plugin.

1. Can I still make it so the user can see real threads as well as whatever other "threads" I make up?

Yes, you can present whatever thread objects you want in the public thread list.

2. Is the purpose of the Python OperatingSystem plugin to allow the user to write plugins in Python? It doesn't look like it's to help debugging of Python programs.

Exactly. That's the way the OS X Kernel team presents the "activations" in the OS X kernel.

If you can get your hands on the Mac OS KDK (you can get it here:

but you need an ADC account) the xnu.dSYM contains the (Python) implementation of the xnu Operating System plugin.

2a. If that's true, is there a reason the Go OperatingSystem plugin is written in C++ instead of Python? Is it just historical, or is there some advantage to writing it in C++?

I don't know why the Go OS plugin was written in C++. Most likely since the Go support was built into lldb anyway, that seemed natural? There is a "load plugin" command that you can use to load your plugin into lldb if you write it in C++. So you aren't limited in distribution choice by which language you choose. I don't think there's any advantage to using C++ over Python, except I guess if the computations you need to do to generate the threads are particularly compute intensive.

3. Does this work just as well when dealing with core files as when dealing with a running process?

Yes, core file analysis using threads provided by the xnu operating system plugin is pretty heavily used at Apple.

Jim