Hi Samuel,
On 05/05/2026 20:15, Samuel Thibault wrote:
Michael Kelly, le mar. 05 mai 2026 20:11:29 +0100, a ecrit:
I have done that on occasion but I'm rather thinking of the case where a
gnumach thread is stuck awaiting an event which never happens. How can you
switch context to that thread and view its stack and so on?
Ah, yes, in that case you can implement a libthread_db library that you
give to gdb so it knows how to switch between threads in gnumach.
Can you please elaborate on your vision for a libthread_db assisting
with gnumach stack traces? I'm sorry but I'm not seeing how it fits.
I can see how thread_db operates for debugging a local user process and
indeed a remote user process with gdbserver if, for example, you had a
highly customised threads implementation. I cannot see how it might work
debugging an emulated kernel though. gdb will always use the gdbremote
protocol for this case and surely the detail of the gnumach threads has
to be supplied by the remote to the local gdb ? Does that not mean that
the customisation has to run either within the emulator (ie.
qemu-system) or on the target (guest) ?
I haven't seen documentation for any support in Qemu's gdbstub for
customisation for a specific inferior and I can't see how that would
work anyway. The emulator itself has no specific knowledge of the target
and analysis of the target's memory content seems unlikely if even
possible. Am I making any sense or I am so far wide of the mark as to be
describing nonsense?
I can see how an alternative solution could be implemented by writing a
complete gdbstub in gnumach. That would be something similar in concept
to the Linux KGDB, I suppose. The Linux implementation is around 1000
lines of code or more. I'd think that some of the existing debugger code
could be shared with a gnumach equivalent to KGDB but even so it's still
quite a task itself. It's probably less of a task than implementing the
Dwarf parsing and analysis stuff. If this could be implemented it has
the minor advantage of being usable on real hardware with a serial port.
I'm going around in circles here, getting nowhere, so I'd be very
grateful for a steer.
All the best,
Mike.