Il 21/03/23 10:11, Sergey Bugaev ha scritto:
Can you attach with gdb at this point? IIRC you can also dynamically
enable/disable the gdb server through the qemu monitor, or stop and see
the registers from there.
Sure:
(gdb) target rem :1234
Remote debugging using :1234
warning: Remote gdbserver does not support determining executable automatically.
RHEL <=6.8 and <=7.2 versions of gdbserver do not support such
automatic executable detection.
The following versions of gdbserver support it:
- Upstream version of gdbserver (unsupported) 7.10 or later
- Red Hat Developer Toolset (DTS) version of gdbserver from DTS 4.0 or
later (only on x86_64)
- RHEL-7.3 versions of gdbserver (on any architecture)
0xffffffff8100c065 in machine_idle (cpu=cpu@entry=0) at
../i386/i386at/model_dep.c:227
227 asm volatile ("hlt" : : : "memory");
(gdb) bt
#0 0xffffffff8100c065 in machine_idle (cpu=cpu@entry=0) at
../i386/i386at/model_dep.c:227
#1 0xffffffff81019737 in idle_thread_continue () at ../kern/sched_prim.c:1658
#2 0xffffffff81038b8c in Thread_continue () at ../x86_64/cswitch.S:104
#3 0xffffffffbf11ca88 in ?? ()
#4 0xffffffff81018db0 in ?? () at ../kern/sched_prim.c:924
#5 0xffffffffbf117fb8 in ?? ()
#6 0x0000000000000000 in ?? ()
(gdb) info thread
Id Target Id Frame
* 1 Thread 1.1 (CPU#0 [halted ]) 0xffffffff8100c065 in machine_idle
(cpu=cpu@entry=0) at ../i386/i386at/model_dep.c:227
(gdb)
Great! if you still have issues with the long mode, you could try to
hack gnumach to wait at some point (e.g. user_bootstrap() or
setup_main()), attach with gdb and then continue. Either with some delay
or polling a flag that you flip from gdb once attached. In this way you
should be able to set a breakpoint in userspace.
I've no idea how to use kdb anyway, and why it is even needed when GDB
remote exists. (Maybe it's helpful for running on physical hardware?)
It's definitely useful on real hw, and it also allows you to list
threads, tasks and many other gnumach-specific stuff. When using gdb you
could add some commands using the gdb-python interface to do similar
stuff, but it's probably not very useful in this case.
By the way, It seems kdb still needs some work for x86_64, I tried using
it to stop execution and resume (as in prompt-task-resume with kdb
enabled) and resuming seems to fail.
Luca