Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show all x86 control registers when debugging the Linux kernel in GDB through QEMU?

I am curious why gdb does not show control registers for x86. I have been using gdb with qemu to debug some kernel stuff. I get register values using info registers and info all-registers.

However, I cant get cr3 and cr2.(In general CRs). Is there any way to get them. If not then why are not they provided.

like image 829
agent.smith Avatar asked Jun 11 '14 18:06

agent.smith


People also ask

How do I run gdb on QEMU?

In order to use gdb, launch QEMU with the -s and -S options. The -s option will make QEMU listen for an incoming connection from gdb on TCP port 1234, and -S will make QEMU not start the guest until you tell it to from gdb.

How do I enable QEMU debugging?

Setup a debugger connection to a Windows Image on QEMUDownload and install QEMU on Windows. Configure a target QEMU Virtual Windows Image to launch with the required network and BIOS/UEFI settings for debugging. Start the QEMU environment, using the configured launch script. Start the gdbserver on QEMU.

How do I use KGDB?

Two machines are required for using KGDB. One of the machines runs a kernel to be debugged called "TEST MACHINE". The other machine runs gdb "DEVELOPMENT MACHINE". A serial line is required between the development and the test machine.


1 Answers

If you are using qemu, you can get all registers states (even control ones) by issuing theses two commands in the shell you start qemu:

  • ctrl-a c (to switch to qemu command interface)
  • info registers (to get registers states)
like image 110
Mahouk Avatar answered Sep 18 '22 23:09

Mahouk