Help needed: Multi-threaded debugging on OSX

Hello,
sorry to bother, I would like advise on os x debugging and since it is not documented very well I figured this would be the best place to ask.

I am developing a graphical debugger for OSX - currently it runs as a GDB frontend. This is very cumbersome and slow though.
I would like to either create my own mini debugger as a backend or possibly embed lldb.
My mini debugger works but I found out that it is not reliable when trying to debug a multi-threaded target when more than 1 thread hits a breakpoint. Trying to single step then sometimes works and sometimes causes the target to exit…
Could someone give me some pointers if I post my code here? (my code is quite small and not difficult to understand)
Also could tell me whether it is difficult to embed lldb as a backend into my Cocoa frontend? Where should I start?

Many thanks,
Kurt

Hello,
sorry to bother, I am looking for advise on OS X (Mach) debugging and since there are not many examples I figured this would be the best place to ask.

I am developing a graphical debugger for OSX - currently it runs as a GDB frontend. This is very cumbersome and slow though.
I would like to either create my own mini debugger as a backend or possibly embed lldb.
My mini debugger works but I found out that it is not reliable when trying to debug a multi-threaded target when more than 1 thread hits a breakpoint. Trying to single step then sometimes works and sometimes causes the target to exit…
Could someone give me some pointers or help me if I share my code with you? (my code is quite small and not difficult to understand)
Also could someone tell me whether it is difficult to embed lldb as a backend into my Cocoa frontend? Where should I start?

Many thanks,
Kurt

The ability to embed the LLDB framework within a variety of applications is one of the main design goals for lldb, so this should certainly work. You should look at the Driver.cpp code as a model for how to do this. That code doesn't do anything particularly magical, and does not have the problems you cite...

Are you using debugserver & the gdb-remote process plugin in your code, or the MacOSX Native plugin? The latter has bit-rotted since we've been focusing on the gdb-remote interface. We plan to revive that at some point, but right now using the gdb-remote plugin is the way to go on MacOS X.

Jim

As Jim sais,

LLDB is designed to be shared between many programs, so the best thing you can probably do is to adopt it in your program. Properly handing multi-threaded debugging is a tough issue that has taken a large portion of our development time and I wouldn't recommend trying to reproduce that logic.

To get started, you would build lldb locally on your machine and then link against the LLDB.framework that results from the build. As Jim also said, you can then look at Driver.cpp as a model of how you would interact with the debugger with an event loop.

Feel free to ask question if/when you have more.

Greg Clayton