[Lldb-commits] [PATCH] Refactor POSIXThread::GetRegisterContext and use i386 register context
Todd Fiala
tfiala at google.com
Thu Feb 13 16:10:28 PST 2014
More info:
I started suspecting that the PTRACE_USERDATA offset we were looking at was just wrong. I now have some data that would seem to suggest that hypothesis is correct.
I modified the linux process monitor register read/write operations to print off the PTRACE_PEEKUSER offsets being used. Here is the new lldb run with that information printed out in an [offset = ...] section for the debug breakpoint control registers.
tfiala at ub-x86-13:~/play/hello$ ~/lldb/work/build-debug/bin/lldb ./hello
Current executable set to './hello' (i386).
(lldb) log enable linux registers
(lldb) run
Process 11609 launching
operation ProcessMonitor::Execute() write reg dr6 [offset 0x02a8]: 0xffffffff
operation ProcessMonitor::Execute() write reg dr7 [offset 0x02ac]: 0xffffffff
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() read reg dr6 [offset 0x02a8]: 0x2ac
operation ProcessMonitor::Execute() write reg dr6 [offset 0x02a8]: 0xffffffff
operation ProcessMonitor::Execute() read reg dr7 [offset 0x02ac]: 0x2a8
operation ProcessMonitor::Execute() read reg dr2 [offset 0x0298]: 0x2a8
lldb: /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:526: void POSIXThread::WatchNotify(const ProcessMessage&): Assertion `wp_sp.get() && "No watchpoint found"' failed.
Aborted (core dumped)
Here is a little program I wrote that should be printing out the actual offsets that should be used, based on sys/user.h on a Ubuntu 13.10 x86 (32-bit) box:
#include <stdio.h>
#include <sys/user.h>
int main(int argc, char **argv)
{
const int debug_reg_count = 8;
for (int i = 0; i < debug_reg_count; ++i)
{
printf("DR%d: 0x%04lx\n", i, ((unsigned long) &((struct user *)0)->u_debugreg[i]));
}
return 0;
}
This prints out the following on that 32-bit box:
tfiala at ub-x86-13:~/play/debug_regs$ g++ -g -o print_regs print_regs.cpp
tfiala at ub-x86-13:~/play/debug_regs$ ./print_regs
DR0: 0x00fc
DR1: 0x0100
DR2: 0x0104
DR3: 0x0108
DR4: 0x010c
DR5: 0x0110
DR6: 0x0114
DR7: 0x0118
These appear to be significantly different. If this DR register calculation code is correct, then the x86 32-bit registers are way off on Linux 32-bit.
Investigating further now.
http://llvm-reviews.chandlerc.com/D2765
More information about the lldb-commits
mailing list