Linux kernel hardware break points

2019-04-13 08:33发布

问题:

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)?

回答1:

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.