[PATCH] Remove unnecessary writing to dr6/dr7 on linux


My first two weeks of playing with lldb on 32-bit linux has been
blighted by the Watchpoint notify failed assertion bug:

  $ lldb hello
Current executable set to 'hello' (i386).
(lldb) run
Process 421 launching
lldb: /home/mg11/src/heracles2/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:514: void POSIXThread::WatchNotify(const ProcessMessage&): Assertion `wp_sp.get() && "No watchpoint found"' failed.
Aborted (core dumped)

After firstly discovering that the x86_64 register map was being used for
32-bit linux, I eventually have discovered that this bug occurs due to
unnecessary writes to dr6 and dr7, in IsWatchpointHit and
IsWatchpointVacant from RegisterContextPOSIXProcessMonitor_x86.cpp. (I also
found that the RegisterValue::GetAsXXX functions, in general, return fail_value
when queried for a smaller integral type than that used in the constructor. But
that's another story...). Those writes result in dr6 subsequently reading back
as 0x118, which results in breakpoint detection but with no data in wp_sp, and
hence the assertion failure.

So is there a good reason these writes? I've read the relevant section of the
intel manual and I can't find any justification.

Removing the writes, removes the assertion failure. Please could somebody
consider this applying patch, which removes them - or justify the existence of
the writes?

Index: source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp

RegisterContextPOSIXProcessMonitor_x86.cpp.diff (1.49 KB)