2 * Copyright (c) 2004 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/types.h>
32 #include <sys/ptrace.h>
33 #include <machine/reg.h>
35 #ifdef HAVE_SYS_PROCFS_H
36 #include <sys/procfs.h>
39 #ifndef HAVE_GREGSET_T
40 typedef struct reg gregset_t;
43 #ifndef HAVE_FPREGSET_T
44 typedef struct fpreg fpregset_t;
49 #define FPREG_SUPPLIES(r) ((r) >= IA64_FR0_REGNUM && (r) <= IA64_FR127_REGNUM)
50 #define GREG_SUPPLIES(r) (!FPREG_SUPPLIES(r))
53 fetch_inferior_registers (int regno)
60 if (regno == -1 || GREG_SUPPLIES(regno))
62 if (ptrace (PT_GETREGS, PIDGET(inferior_ptid),
63 (PTRACE_ARG3_TYPE)®s.r, 0) == -1)
64 perror_with_name ("Couldn't get registers");
65 supply_gregset (®s.r);
68 if (regno == -1 || FPREG_SUPPLIES(regno))
70 if (ptrace (PT_GETFPREGS, PIDGET(inferior_ptid),
71 (PTRACE_ARG3_TYPE)®s.fpr, 0) == -1)
72 perror_with_name ("Couldn't get FP registers");
73 supply_fpregset (®s.fpr);
78 store_inferior_registers (int regno)
85 if (regno == -1 || GREG_SUPPLIES(regno))
87 if (ptrace (PT_GETREGS, PIDGET(inferior_ptid),
88 (PTRACE_ARG3_TYPE)®s.r, 0) == -1)
89 perror_with_name ("Couldn't get registers");
90 fill_gregset (®s.r, regno);
91 if (ptrace (PT_SETREGS, PIDGET(inferior_ptid),
92 (PTRACE_ARG3_TYPE)®s.r, 0) == -1)
93 perror_with_name ("Couldn't get registers");
98 if (regno == -1 || FPREG_SUPPLIES(regno))
100 if (ptrace (PT_GETFPREGS, PIDGET(inferior_ptid),
101 (PTRACE_ARG3_TYPE)®s.fpr, 0) == -1)
102 perror_with_name ("Couldn't get FP registers");
103 fill_fpregset (®s.fpr, regno);
104 if (ptrace (PT_SETFPREGS, PIDGET(inferior_ptid),
105 (PTRACE_ARG3_TYPE)®s.fpr, 0) == -1)
106 perror_with_name ("Couldn't get FP registers");
112 LONGEST ia64_fbsd_xfer_dirty (struct target_ops *ops, enum target_object obj,
113 const char *annex, void *rbuf, const void *wbuf,
114 ULONGEST ofs, LONGEST len)
119 if (ptrace (PT_GETKSTACK, PIDGET(inferior_ptid), (PTRACE_ARG3_TYPE)rbuf,
121 perror_with_name ("Couldn't read dirty register");
125 if (ptrace (PT_SETKSTACK, PIDGET(inferior_ptid), (PTRACE_ARG3_TYPE)wbuf,
127 perror_with_name ("Couldn't write dirty register");
135 _initialize_ia64_fbsd_nat (void)