1 /* Target-dependent code for NetBSD/amd64.
3 Copyright 2003, 2004 Free Software Foundation, 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. */
23 #include "arch-utils.h"
29 #include "gdb_assert.h"
31 #include "amd64-tdep.h"
32 #include "nbsd-tdep.h"
33 #include "solib-svr4.h"
35 /* Support for signal handlers. */
37 /* Return whether the frame preceding NEXT_FRAME corresponds to a
38 NetBSD sigtramp routine. */
41 amd64nbsd_sigtramp_p (struct frame_info
*next_frame
)
43 CORE_ADDR pc
= frame_pc_unwind (next_frame
);
46 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
47 return nbsd_pc_in_sigtramp (pc
, name
);
50 /* Assuming NEXT_FRAME is for a frame following a BSD sigtramp
51 routine, return the address of the associated sigcontext structure. */
54 amd64nbsd_sigcontext_addr (struct frame_info
*next_frame
)
58 /* The stack pointer points at `struct sigcontext' upon entry of a
60 sp
= frame_unwind_register_unsigned (next_frame
, AMD64_RSP_REGNUM
);
64 /* NetBSD 2.0 or later. */
66 /* Mapping between the general-purpose registers in `struct reg'
67 format and GDB's register cache layout. */
69 /* From <machine/reg.h>. */
70 int amd64nbsd_r_reg_offset
[] =
87 11 * 8, /* ... %r15 */
99 amd64nbsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
101 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
105 /* Initialize general-purpose register set details first. */
106 tdep
->gregset_reg_offset
= amd64nbsd_r_reg_offset
;
107 tdep
->gregset_num_regs
= ARRAY_SIZE (amd64nbsd_r_reg_offset
);
108 tdep
->sizeof_gregset
= 26 * 8;
110 amd64_init_abi (info
, gdbarch
);
112 tdep
->jb_pc_offset
= 7 * 8;
114 /* NetBSD has its own convention for signal trampolines. */
115 tdep
->sigtramp_p
= amd64nbsd_sigtramp_p
;
116 tdep
->sigcontext_addr
= amd64nbsd_sigcontext_addr
;
118 /* Initialize the array with register offsets in `struct
119 sigcontext'. This `struct sigcontext' has an sc_mcontext member
120 at offset 32, and in <machine/reg.h> we have an explicit comment
121 saying that `struct reg' is the same as mcontext.__gregs. */
122 tdep
->sc_num_regs
= ARRAY_SIZE (amd64nbsd_r_reg_offset
);
123 tdep
->sc_reg_offset
= XCALLOC (tdep
->sc_num_regs
, int);
124 for (i
= 0; i
< tdep
->sc_num_regs
; i
++)
126 if (amd64nbsd_r_reg_offset
[i
] < 0)
127 tdep
->sc_reg_offset
[i
] = -1;
129 tdep
->sc_reg_offset
[i
] = 32 + amd64nbsd_r_reg_offset
[i
];
132 /* NetBSD uses SVR4-style shared libraries. */
133 set_solib_svr4_fetch_link_map_offsets
134 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
138 /* Provide a prototype to silence -Wmissing-prototypes. */
139 void _initialize_amd64nbsd_tdep (void);
142 _initialize_amd64nbsd_ndep (void)
144 /* The NetBSD/amd64 native dependent code makes this assumption. */
145 gdb_assert (ARRAY_SIZE (amd64nbsd_r_reg_offset
) == AMD64_NUM_GREGS
);
147 gdbarch_register_osabi (bfd_arch_i386
, bfd_mach_x86_64
,
148 GDB_OSABI_NETBSD_ELF
, amd64nbsd_init_abi
);