diff options
author | Daniel Jacobowitz <drow@false.org> | 2007-10-01 00:22:50 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2007-10-01 00:22:50 +0000 |
commit | 9f0bdab8028f185719d163f3bfeafd1406ba5a58 (patch) | |
tree | a4c91496632a8629237eb3766c4fe11e1c5bd8e0 /gdb/amd64-linux-nat.c | |
parent | d983da9c3dfa91e6840fee2a7479d98ee4759f13 (diff) | |
download | gdb-9f0bdab8028f185719d163f3bfeafd1406ba5a58.zip gdb-9f0bdab8028f185719d163f3bfeafd1406ba5a58.tar.gz gdb-9f0bdab8028f185719d163f3bfeafd1406ba5a58.tar.bz2 |
* linux-nat.c (linux_nat_new_thread): New variable.
(linux_child_follow_fork): Set inferior_ptid to include LWP ID. Use
linux_nat_switch_fork.
(lwp_list): Make public.
(add_lwp): Call linux_nat_new_thread.
(lin_lwp_attach_lwp, linux_nat_attach): Call add_lwp after stopping
the new thread.
(resume_callback): Clear lp->siginfo. Remove unused variable.
(linux_nat_resume): Assert that the LWP list is already initialized.
Clear lp->siginfo.
(save_siginfo): New.
(stop_wait_callback, linux_nat_wait): Call it.
(linux_nat_set_new_thread, linux_nat_get_siginfo): New.
* linux-nat.h (struct lwp_info): Add siginfo.
(lwp_list, linux_nat_set_new_thread, linux_nat_get_siginfo): Declare.
(ALL_LWPS): Define.
* amd64-linux-nat.c (amd64_linux_dr): New.
(amd64_linux_dr_get): Take a PTID argument. Correct typo.
(amd64_linux_dr_set): Take a PTID argument.
(amd64_linux_dr_set_control, amd64_linux_dr_set_addr): Use ALL_LWPS.
(amd64_linux_dr_reset_addr): Use amd64_linux_dr_set_addr.
(amd64_linux_dr_get_status): Pass inferior_ptid to amd64_linux_dr_get.
(amd64_linux_new_thread): New.
(_initialize_amd64_linux_nat): Call linux_nat_set_new_thread.
* i386-linux-nat.c (i386_linux_dr): New.
(i386_linux_dr_get, i386_linux_dr_set): Take a PTID argument.
(i386_linux_dr_set_control, i386_linux_dr_set_addr): Use ALL_LWPS.
(i386_linux_dr_reset_addr): Use i386_linux_dr_set_addr.
(i386_linux_dr_get_status): Pass inferior_ptid to i386_linux_dr_get.
(i386_linux_new_thread): New.
(i386_linux_resume): Remove unnecessary PID check.
(_initialize_i386_linux_nat): Call linux_nat_set_new_thread.
* ia64-linux-nat.c (enable_watchpoints_in_psr): Take PTID argument.
(fetch_debug_register, fetch_debug_register_pair): Delete.
(debug_registers): New.
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint): Use
ALL_LWPS and debug_registers.
(ia64_linux_new_thread): New.
(ia64_linux_stopped_data_address): Use linux_nat_get_siginfo.
(_initialize_ia64_linux_nat): Call linux_nat_set_new_thread.
* ppc-linux-nat.c (last_stopped_data_address): Delete.
(saved_dabr_value): New.
(ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint): Use
ALL_LWPS.
(ppc_linux_new_thread): New.
(ppc_linux_stopped_data_address): Use linux_nat_get_siginfo.
(ppc_linux_stopped_by_watchpoint): Call ppc_linux_stopped_data_address.
(_initialize_ppc_linux_nat): Call linux_nat_set_new_thread.
* s390-nat.c (s390_stopped_by_watchpoint): Clear the watchpoint status
after reading it.
(s390_fix_watch_points): Take a PTID argument.
(s390_insert_watchpoint, s390_remove_watchpoint): Use ALL_LWPS.
(_initialize_s390_nat): Call linux_nat_set_new_thread.
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r-- | gdb/amd64-linux-nat.c | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 9e9e30f..e7643ac 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -233,25 +233,27 @@ amd64_linux_store_inferior_registers (struct regcache *regcache, int regnum) } } +/* Support for debug registers. */ + +static unsigned long amd64_linux_dr[DR_CONTROL + 1]; static unsigned long -amd64_linux_dr_get (int regnum) +amd64_linux_dr_get (ptid_t ptid, int regnum) { int tid; unsigned long value; - /* FIXME: kettenis/2001-01-29: It's not clear what we should do with - multi-threaded processes here. For now, pretend there is just - one thread. */ - tid = PIDGET (inferior_ptid); + tid = TIDGET (ptid); + if (tid == 0) + tid = PIDGET (ptid); /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the ptrace call fails breaks debugging remote targets. The correct way to fix this is to add the hardware breakpoint and watchpoint - stuff to the target vectore. For now, just return zero if the + stuff to the target vector. For now, just return zero if the ptrace call fails. */ errno = 0; - value = ptrace (PT_READ_U, tid, + value = ptrace (PTRACE_PEEKUSER, tid, offsetof (struct user, u_debugreg[regnum]), 0); if (errno != 0) #if 0 @@ -264,17 +266,17 @@ amd64_linux_dr_get (int regnum) } static void -amd64_linux_dr_set (int regnum, unsigned long value) +amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) { int tid; - /* FIXME: kettenis/2001-01-29: It's not clear what we should do with - multi-threaded processes here. For now, pretend there is just - one thread. */ - tid = PIDGET (inferior_ptid); + tid = TIDGET (ptid); + if (tid == 0) + tid = PIDGET (ptid); errno = 0; - ptrace (PT_WRITE_U, tid, offsetof (struct user, u_debugreg[regnum]), value); + ptrace (PTRACE_POKEUSER, tid, + offsetof (struct user, u_debugreg[regnum]), value); if (errno != 0) perror_with_name (_("Couldn't write debug register")); } @@ -282,29 +284,48 @@ amd64_linux_dr_set (int regnum, unsigned long value) void amd64_linux_dr_set_control (unsigned long control) { - amd64_linux_dr_set (DR_CONTROL, control); + struct lwp_info *lp; + ptid_t ptid; + + amd64_linux_dr[DR_CONTROL] = control; + ALL_LWPS (lp, ptid) + amd64_linux_dr_set (ptid, DR_CONTROL, control); } void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr) { + struct lwp_info *lp; + ptid_t ptid; + gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); - amd64_linux_dr_set (DR_FIRSTADDR + regnum, addr); + amd64_linux_dr[DR_FIRSTADDR + regnum] = addr; + ALL_LWPS (lp, ptid) + amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr); } void amd64_linux_dr_reset_addr (int regnum) { - gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR); - - amd64_linux_dr_set (DR_FIRSTADDR + regnum, 0L); + amd64_linux_dr_set_addr (regnum, 0); } unsigned long amd64_linux_dr_get_status (void) { - return amd64_linux_dr_get (DR_STATUS); + return amd64_linux_dr_get (inferior_ptid, DR_STATUS); +} + +static void +amd64_linux_new_thread (ptid_t ptid) +{ + int i; + + for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) + amd64_linux_dr_set (ptid, i, amd64_linux_dr[i]); + + amd64_linux_dr_set (ptid, DR_CONTROL, amd64_linux_dr[DR_CONTROL]); } @@ -408,4 +429,5 @@ _initialize_amd64_linux_nat (void) /* Register the target. */ linux_nat_add_target (t); + linux_nat_set_new_thread (t, amd64_linux_new_thread); } |