I want to build a simple linux kernel debugger for the x86 architecture. I first want it to set break points. I was wondering if there is a kernel api for configuring the debugger registers and if so any good documentation? If there is no kernel api for debugger registers is there any documentation on how to properly configure the registers manually(using the assembly "MOV" instruction)?
Asked
Active
Viewed 4,043 times
2
-
1Why can't you use `kgdb` ??? – Basile Starynkevitch May 03 '13 at 16:36
1 Answers
4
It depends on which kernel versions you would like to handle.
There is an API for setting hardware breakpoints in the kernel at least since 2.6.33, although it might have changed a bit around versions 3.0-3.2.
Take a look at register_wide_hw_breakpoint() function in kernel/events/hw_breakpoint.c
and the ones near it.
The documentation seems to be quite scarce but there is an example of how to use that API in the kernel, it may help.
A more complex example using that API can be found in RaceHound project.

Eugene
- 5,977
- 2
- 29
- 46
-
Thanks for this, @Eugene; for cross-reference: I posted an example on http://stackoverflow.com/questions/19725900/watch-a-variable-memory-address-change-in-linux-kernel-and-print-stack-trace/19755213#19755213 ... Cheers! – sdaau Nov 03 '13 at 16:39