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. */
25 #include "solib-svr4.h"
27 #include "alpha-tdep.h"
29 /* Fetch (and possibly build) an appropriate link_map_offsets
30 structure for NetBSD/alpha targets using the struct offsets
31 defined in <link.h> (but without actual reference to that file).
33 This makes it possible to access NetBSD/alpha shared libraries
34 from a GDB that was not built on a NetBSD/alpha host (for cross
37 static struct link_map_offsets
*
38 alphanbsd_solib_svr4_fetch_link_map_offsets (void)
40 static struct link_map_offsets lmo
;
41 static struct link_map_offsets
*lmp
= NULL
;
47 lmo
.r_debug_size
= 32;
52 lmo
.link_map_size
= 40;
54 lmo
.l_addr_offset
= 0;
57 lmo
.l_name_offset
= 8;
60 lmo
.l_next_offset
= 24;
63 lmo
.l_prev_offset
= 32;
70 /* Under NetBSD/alpha, signal handler invocations can be identified by the
71 designated code sequence that is used to return from a signal handler.
72 In particular, the return address of a signal handler points to the
73 following code sequence:
77 lda v0, 295(zero) # __sigreturn14
80 Each instruction has a unique encoding, so we simply attempt to match
81 the instruction the PC is pointing to with any of the above instructions.
82 If there is a hit, we know the offset to the start of the designated
83 sequence and can then check whether we really are executing in the
84 signal trampoline. If not, -1 is returned, otherwise the offset from the
85 start of the return sequence is returned. */
86 static const unsigned int sigtramp_retcode
[] =
88 0xa61e0000, /* ldq a0, 0(sp) */
89 0x23de0010, /* lda sp, 16(sp) */
90 0x201f0127, /* lda v0, 295(zero) */
91 0x00000083, /* call_pal callsys */
93 #define RETCODE_NWORDS \
94 (sizeof (sigtramp_retcode) / sizeof (sigtramp_retcode[0]))
97 alphanbsd_sigtramp_offset (CORE_ADDR pc
)
99 unsigned int ret
[4], w
;
103 if (read_memory_nobpt (pc
, (char *) &w
, 4) != 0)
106 for (i
= 0; i
< RETCODE_NWORDS
; i
++)
108 if (w
== sigtramp_retcode
[i
])
111 if (i
== RETCODE_NWORDS
)
117 if (read_memory_nobpt (pc
, (char *) ret
, sizeof (ret
)) != 0)
120 if (memcmp (ret
, sigtramp_retcode
, sizeof (sigtramp_retcode
)) == 0)
127 alphanbsd_pc_in_sigtramp (CORE_ADDR pc
, char *func_name
)
129 return (alphanbsd_sigtramp_offset (pc
) >= 0);
133 alphanbsd_init_abi (struct gdbarch_info info
,
134 struct gdbarch
*gdbarch
)
136 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
138 set_gdbarch_pc_in_sigtramp (gdbarch
, alphanbsd_pc_in_sigtramp
);
140 /* NetBSD/alpha does not provide single step support via ptrace(2); we
141 must use software single-stepping. */
142 set_gdbarch_software_single_step (gdbarch
, alpha_software_single_step
);
144 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
145 alphanbsd_solib_svr4_fetch_link_map_offsets
);
147 tdep
->dynamic_sigtramp_offset
= alphanbsd_sigtramp_offset
;
151 _initialize_alphanbsd_tdep (void)
153 alpha_gdbarch_register_os_abi (ALPHA_ABI_NETBSD
, alphanbsd_init_abi
);