The following patch gets threaded watchpoint support working for the x86. On x86 linux, the dr_status register is thread-specific. This means that the current method which uses the PID to call PTRACE is wrong. I have changed this to use the current lwp for the inferior_ptid. Corresponding to this, the i386_stopped_data_address function switches the inferior_ptid to the trap_ptid. Thus, we can see if we really stopped for a watchpoint or hardware breakpoint. Because the thread-db.c code changes the trap_ptid into a high-level ptid (pid + tid), I had to add a new target vector interface which gives back the lwp for a given ptid. This is used by the low level dr get routine. With this change plus a change to breakpoint.c, threaded watchpoints work on the x86. Part 2 will be the breakpoint.c change which is not x86-specific. Part 3 will be a test case when I figure out how to code it properly. If you want to test it with the two patches applied, just debug gdb.threads/schedlock and issue: b main run watch args[0] watch args[1] continue continue continue etc... Ok? -- Jeff J. 2004-06-11 Jeff Johnston * i386-linux-nat.c (i386_linux_dr_get): Use target_get_lwp function to get lwp of current ptid to use in the PTRACE call. * i386-nat.c: Add comments regarding the DR status register. (i386_stopped_data_address): Switch to the trap_ptid before getting the dr_status register. (i386_stopped_by_hwbp): Ditto. * lin-lwp.c (child_wait): Set the trap_ptid when appropriate. * target.h (struct target ops): Add new function to_get_lwp. (target_get_lwp): New macro. * target.c (INHERIT): Inherit to_get_lwp. (update_current_target): Default to_get_lwp to ptid_get_lwp. (init_dummy_target): Ditto. * thread-db.c (thread_db_get_lwp): New function. (thread_db_init): Expose thread_db_get_lwp in target vector.