diff options
author | 2012-04-11 08:44:20 +0000 | |
---|---|---|
committer | 2012-04-11 08:44:20 +0000 | |
commit | c9d97425b53eb2c95333e2ccd62cc009fe5c85e4 (patch) | |
tree | 5aca8594836f193ae5528e28e793c73880f33f94 | |
parent | delete excessive evtimer_pending; ok claudio (diff) | |
download | wireguard-openbsd-c9d97425b53eb2c95333e2ccd62cc009fe5c85e4.tar.xz wireguard-openbsd-c9d97425b53eb2c95333e2ccd62cc009fe5c85e4.zip |
Minimal threads support for i386.
-rw-r--r-- | gnu/usr.bin/binutils/gdb/config/i386/obsd.mh | 2 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/i386bsd-nat.c | 46 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/gdb/i386obsd-nat.c | 10 |
3 files changed, 35 insertions, 23 deletions
diff --git a/gnu/usr.bin/binutils/gdb/config/i386/obsd.mh b/gnu/usr.bin/binutils/gdb/config/i386/obsd.mh index 3bdd4c12a9b..244ae704e4f 100644 --- a/gnu/usr.bin/binutils/gdb/config/i386/obsd.mh +++ b/gnu/usr.bin/binutils/gdb/config/i386/obsd.mh @@ -1,5 +1,5 @@ # Host: OpenBSD/i386 ELF -NATDEPFILES= fork-child.o inf-ptrace.o \ +NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o \ i386bsd-nat.o i386obsd-nat.o bsd-kvm.o NAT_FILE= nm-obsd.h diff --git a/gnu/usr.bin/binutils/gdb/i386bsd-nat.c b/gnu/usr.bin/binutils/gdb/i386bsd-nat.c index 349112a4ad0..75251c8fd83 100644 --- a/gnu/usr.bin/binutils/gdb/i386bsd-nat.c +++ b/gnu/usr.bin/binutils/gdb/i386bsd-nat.c @@ -133,12 +133,19 @@ i386bsd_collect_gregset (const struct regcache *regcache, static void i386bsd_fetch_inferior_registers (int regnum) { + int pid; + + /* Cater for systems like OpenBSD, that implement threads as + separate processes. */ + pid = ptid_get_lwp (inferior_ptid); + if (pid == 0) + pid = ptid_get_pid (inferior_ptid); + if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; - if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name ("Couldn't get registers"); i386bsd_supply_gregset (current_regcache, ®s); @@ -153,23 +160,20 @@ i386bsd_fetch_inferior_registers (int regnum) char xmmregs[512]; if (have_ptrace_xmmregs != 0 - && ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) + && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; i387_supply_fxsave (current_regcache, -1, xmmregs); } else { - if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); i387_supply_fsave (current_regcache, -1, &fpregs); } #else - if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); i387_supply_fsave (current_regcache, -1, &fpregs); @@ -183,18 +187,24 @@ i386bsd_fetch_inferior_registers (int regnum) static void i386bsd_store_inferior_registers (int regnum) { + int pid; + + /* Cater for systems like OpenBSD, that implement threads as + separate processes. */ + pid = ptid_get_lwp (inferior_ptid); + if (pid == 0) + pid = ptid_get_pid (inferior_ptid); + if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { struct reg regs; - if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name ("Couldn't get registers"); i386bsd_collect_gregset (current_regcache, ®s, regnum); - if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name ("Couldn't write registers"); if (regnum != -1) @@ -208,29 +218,25 @@ i386bsd_store_inferior_registers (int regnum) char xmmregs[512]; if (have_ptrace_xmmregs != 0 - && ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) + && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; i387_collect_fxsave (current_regcache, regnum, xmmregs); - if (ptrace (PT_SETXMMREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) xmmregs, 0) == -1) + if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == -1) perror_with_name ("Couldn't write XMM registers"); } else { have_ptrace_xmmregs = 0; #endif - if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); i387_collect_fsave (current_regcache, regnum, &fpregs); - if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name ("Couldn't write floating point status"); #ifdef HAVE_PT_GETXMMREGS } diff --git a/gnu/usr.bin/binutils/gdb/i386obsd-nat.c b/gnu/usr.bin/binutils/gdb/i386obsd-nat.c index 892b17b71eb..5637c423df7 100644 --- a/gnu/usr.bin/binutils/gdb/i386obsd-nat.c +++ b/gnu/usr.bin/binutils/gdb/i386obsd-nat.c @@ -25,6 +25,7 @@ #include "target.h" #include "i386-tdep.h" +#include "obsd-nat.h" #include "i386bsd-nat.h" #include <sys/param.h> @@ -97,6 +98,8 @@ void _initialize_i386obsd_nat (void); void _initialize_i386obsd_nat (void) { + struct target_ops *t; + /* OpenBSD provides a vm.psstrings sysctl that we can use to locate the sigtramp. That way we can still recognize a sigtramp if its location is changed in a new kernel. This is especially @@ -123,8 +126,11 @@ _initialize_i386obsd_nat (void) } #endif - /* We've got nothing to add to the common *BSD/i386 target. */ - add_target (i386bsd_target ()); + /* Add some extra features to the common *BSD/i386 target. */ + t = i386bsd_target (); + t->to_pid_to_str = obsd_pid_to_str; + t->to_find_new_threads = obsd_find_new_threads; + add_target (t); /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (i386obsd_supply_pcb); |