On 13.12.2016 04:12, Valery Ushakov wrote:
> On Tue, Dec 13, 2016 at 02:04:36 +0100, Kamil Rytarowski wrote:
>
>> The design is as follows:
>>
>> 1. Accessors through:
>> - PT_WRITE_WATCHPOINT - write new watchpoint's state (set, unset, ...),
>> - PT_READ_WATCHPOINT - read watchpoints's state,
>> - PT_COUNT_WATCHPOINT - receive the number of available watchpoints.
>
> Gdb supports hardware assisted watchpoints. That implies that other
> OSes have existing designs for them. Have you studied those existing
> designs? Why do you think they are not suitable to be copied?
>
They are based on the concept of exporting debug registers to tracee's
context (machine context/userdata/etc). FreeBSD exposes MD-specific
DBREGS to be set/get by a user, similar with Linux and with MacOSX.
GDB supports hardware and software assisted watchpoints. Software ones
are stepping the code and checking each instruction, hardware ones make
use of the registers.
I propose to export an interface that is not limited to one type of
hardware assisted action, while it can be fully used for hardware
watchpoints (if CPU supports it). This interface will abstract
underlying hardware specific capabilities with a MI ptrace(2) calls (but
MD-specific ptrace_watchpoint structure).
These interfaces are already platform specific and aren't shared between
OSes.
Some time ago I checked and IIRC the only two users of these interfaces
were GDB and LLDB, I implied from this that there is no danger from
heavy patching 3rd party software.