Samsung / netcoredbg

NetCoreDbg is a managed code debugger with MI interface for CoreCLR.
MIT License
743 stars 98 forks source link

How to change current thread? #150

Open qgindi opened 7 months ago

qgindi commented 7 months ago

Using MI protocol, it seems there is no way to change current thread (m_debugger.SetLastStoppedThreadId?). The debugger does not implement -thread-select command or --thread argument. It seems it is possible only if using the VSCode protocol.

For example, when the user clicks the Pause button, the current thread is the last stopped thread, or a random thread if never stopped (often not even the main thread). Then the user may want to step-debug another thread.

viewizard commented 7 months ago

Now --thread argument supported for stack-list-frames, stack-list-variables, var-create and step commands (exec-step, exec-next and exec-finish). What command, that you need don't support --thread argument?

qgindi commented 7 months ago

Now I see, --thread is supported, although undocumented. exec-interrupt should support it too. Then I would use -exec-interrupt --thread mainThread if never was stopped.

qgindi commented 7 months ago

The problem is that -exec-interrupt sets random current thread if never stopped. And difficult to find a workaround. Would be easier if there was -thread-select.

viewizard commented 7 months ago

Please note, GDB/MI protocol is not human oriented, IDE/plugins provide proper formed commands with --thread if need. I am just worry, why you need this command.

qgindi commented 7 months ago

I'm adding your debugger to my C# script IDE project. Like in VS, VSCode, Rider. Almost everything works well, just several non-fatal problems.

viewizard commented 7 months ago

I added this to "feature requests" list (as I see we planned same for CLI too), but at this moment we all involved in porting to riscv64 (.NET runtime/debugger), not sure this will be done in near future.