Hi. I'll take some tips about how I debug gnumach using GDB and Qemu, for
my SMP development.

I usually execute remote debugging using Qemu with GDB. In my Qemu script,
I added -s option to enable te debugging mode, and -S to pause the machine
before startup.
My script is here
https://gist.github.com/AlmuHS/73bae6dadf19b0482a34eaab567bfdfa

With this, the machine starts without boot the system. After this, I start
the debugging with
`gdb -ex 'target remote :1234' ./gnumach

where gnumach is the PATH to gnumach binary file.

I set the breakpoints where I want to stop, and then I type `run` to skip
the pause and startup the machine.
If you runs gdb from the same directory where you store the gnumach
sources, you can access to the functions by its name.

Other interesting tip is to disable kvm in Qemu script before debugging. If
KVM is enabled, you must set the breakpoints using hardware breaks; with
the physical or virtual address, depending of the booting stage.
And, once set the hardware break, you must remove It before continue
(typing next or `step into` doesn't works over a hardware breakpoint).
You can get these address with objdump, and debug adding and remove
hardware breakpoints, but it's a very lazy job; and makes even more
difficult the debugging.

Disabling kvm in Qemu script, the machine is emulated by software, and you
can debug It as a common application.

I don't debug at this way some months ago, so I can have some mistakes in
the commands.
But these are some useful tips about how to debug it.

El vie, 25 dic 2020 a las 19:41, Joan Lledó (<jlle...@mailfence.com>)
escribió:

> Hi Hurd,
>
> recently I tried to implement ranges on memory object proxies[1]. I
> never worked on gnumach before, so as expected it failed. That's ok, but
> now I'd like to debug gnumach in order to find the issue.
>
> The docs[2] say I can either use the built-in debugger or gdb over qemu.
> I tried kdb, but I don't know how to find the address of a local
> variable inside a function. I also tried the gdb approach, but I can't
> boot the kernel b/c I don't know how to load the modules from the qemu
> command-line ("panic: No bootstrap code loaded with the kernel!")
>
> - How do you guys debug gnumach? gdb or kdb?
>
> - If gdb, what command do you use?
>
> - If kdb, how do you read the value for a local variable?
>
>
> ---
> [1]
>
> http://git.savannah.gnu.org/cgit/hurd/gnumach.git/log/?h=jlledom-mem-obj-proxy
> [2]
> https://www.gnu.org/software/hurd/microkernel/mach/gnumach/debugging.html
>
>

Reply via email to