codelldb icon indicating copy to clipboard operation
codelldb copied to clipboard

Freeze/Thaw threads in multi-thread cpp debugging

Open XimingCheng opened this issue 4 months ago • 4 comments

In Visual Studio cpp debugger, freeze and thaw threads are important for debugging complex multi-thread programs. In lldb, there are lldb.SBThread.Suspend() and lldb.SBThread.Resume(), which may deal the same way as Visual Studio.

XimingCheng avatar Sep 03 '25 16:09 XimingCheng

LLDB may support suspending a thread, but VSCode doesn't, as far as I know. Nor can I see any requests for this in the DAP spec.

vadimcn avatar Nov 23 '25 20:11 vadimcn

You can pause/resume individual threads in DAP with PauseRequest/ContinueRequest passing threadId: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Pause / https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Continue. is this talking about something else?

puremourning avatar Nov 23 '25 23:11 puremourning

That's for thread-centric debugging, which LLDB currently doesn't support.
It sounds similar, but there is a difference - for example, when VSCode asks to resume a thread, it expects that only this thread is resumed, but in LLDB there's no API to do that. One could try to emulate this behavior by remembering which threads are supposed to be stopped and keeping them suspended via SBThread.Suspend(). But this is more complicated than just implementing dedicated "freeze/unfreeze thread" requests and is a potential bug farm.

vadimcn avatar Nov 24 '25 03:11 vadimcn

Right, makes sense, ta.

puremourning avatar Nov 24 '25 21:11 puremourning