1 /* Target-dependent code for NetBSD/Alpha.
2 Copyright 2002 Free Software Foundation, Inc.
3 Contributed by Wasabi Systems, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
27 #include "alpha-tdep.h"
28 #include "alphabsd-tdep.h"
29 #include "nbsd-tdep.h"
32 fetch_core_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
38 /* Table to map a gdb register number to a trapframe register index. */
39 static const int regmap
[] =
50 #define SIZEOF_TRAPFRAME (33 * 8)
52 /* We get everything from one section. */
57 fpregs
= core_reg_sect
+ SIZEOF_TRAPFRAME
;
59 if (core_reg_size
< (SIZEOF_TRAPFRAME
+ SIZEOF_STRUCT_FPREG
))
61 warning ("Wrong size register set in core file.");
65 /* Integer registers. */
66 for (regno
= 0; regno
< ALPHA_ZERO_REGNUM
; regno
++)
67 supply_register (regno
, regs
+ (regmap
[regno
] * 8));
68 supply_register (ALPHA_ZERO_REGNUM
, NULL
);
69 supply_register (FP_REGNUM
, NULL
);
70 supply_register (PC_REGNUM
, regs
+ (28 * 8));
72 /* Floating point registers. */
73 alphabsd_supply_fpreg (fpregs
, -1);
77 fetch_elfcore_registers (char *core_reg_sect
, unsigned core_reg_size
, int which
,
82 case 0: /* Integer registers. */
83 if (core_reg_size
!= SIZEOF_STRUCT_REG
)
84 warning ("Wrong size register set in core file.");
86 alphabsd_supply_reg (core_reg_sect
, -1);
89 case 2: /* Floating point registers. */
90 if (core_reg_size
!= SIZEOF_STRUCT_FPREG
)
91 warning ("Wrong size FP register set in core file.");
93 alphabsd_supply_fpreg (core_reg_sect
, -1);
97 /* Don't know what kind of register request this is; just ignore it. */
102 static struct core_fns alphanbsd_core_fns
=
104 bfd_target_unknown_flavour
, /* core_flavour */
105 default_check_format
, /* check_format */
106 default_core_sniffer
, /* core_sniffer */
107 fetch_core_registers
, /* core_read_registers */
111 static struct core_fns alphanbsd_elfcore_fns
=
113 bfd_target_elf_flavour
, /* core_flavour */
114 default_check_format
, /* check_format */
115 default_core_sniffer
, /* core_sniffer */
116 fetch_elfcore_registers
, /* core_read_registers */
120 /* Under NetBSD/alpha, signal handler invocations can be identified by the
121 designated code sequence that is used to return from a signal handler.
122 In particular, the return address of a signal handler points to the
123 following code sequence:
127 lda v0, 295(zero) # __sigreturn14
130 Each instruction has a unique encoding, so we simply attempt to match
131 the instruction the PC is pointing to with any of the above instructions.
132 If there is a hit, we know the offset to the start of the designated
133 sequence and can then check whether we really are executing in the
134 signal trampoline. If not, -1 is returned, otherwise the offset from the
135 start of the return sequence is returned. */
136 static const unsigned int sigtramp_retcode
[] =
138 0xa61e0000, /* ldq a0, 0(sp) */
139 0x23de0010, /* lda sp, 16(sp) */
140 0x201f0127, /* lda v0, 295(zero) */
141 0x00000083, /* call_pal callsys */
143 #define RETCODE_NWORDS \
144 (sizeof (sigtramp_retcode) / sizeof (sigtramp_retcode[0]))
147 alphanbsd_sigtramp_offset (CORE_ADDR pc
)
149 unsigned int ret
[4], w
;
153 if (read_memory_nobpt (pc
, (char *) &w
, 4) != 0)
156 for (i
= 0; i
< RETCODE_NWORDS
; i
++)
158 if (w
== sigtramp_retcode
[i
])
161 if (i
== RETCODE_NWORDS
)
167 if (read_memory_nobpt (pc
, (char *) ret
, sizeof (ret
)) != 0)
170 if (memcmp (ret
, sigtramp_retcode
, sizeof (sigtramp_retcode
)) == 0)
177 alphanbsd_pc_in_sigtramp (CORE_ADDR pc
, char *func_name
)
179 return (alphanbsd_sigtramp_offset (pc
) >= 0);
183 alphanbsd_init_abi (struct gdbarch_info info
,
184 struct gdbarch
*gdbarch
)
186 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
188 set_gdbarch_pc_in_sigtramp (gdbarch
, alphanbsd_pc_in_sigtramp
);
190 /* NetBSD/alpha does not provide single step support via ptrace(2); we
191 must use software single-stepping. */
192 set_gdbarch_software_single_step (gdbarch
, alpha_software_single_step
);
194 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
195 nbsd_lp64_solib_svr4_fetch_link_map_offsets
);
197 tdep
->dynamic_sigtramp_offset
= alphanbsd_sigtramp_offset
;
200 tdep
->jb_elt_size
= 8;
204 _initialize_alphanbsd_tdep (void)
206 alpha_gdbarch_register_os_abi (ALPHA_ABI_NETBSD
, alphanbsd_init_abi
);
208 add_core_fns (&alphanbsd_core_fns
);
209 add_core_fns (&alphanbsd_elfcore_fns
);