gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / m68k-bsd-tdep.c
CommitLineData
8f2d3ea0
MK
1/* Target-dependent code for Motorola 68000 BSD's.
2
b811d2c2 3 Copyright (C) 2004-2020 Free Software Foundation, Inc.
8f2d3ea0
MK
4
5 This file is part of GDB.
6
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
8f2d3ea0
MK
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8f2d3ea0
MK
19
20#include "defs.h"
21#include "arch-utils.h"
059cb7d2 22#include "frame.h"
8f2d3ea0
MK
23#include "osabi.h"
24#include "regcache.h"
25#include "regset.h"
059cb7d2
MK
26#include "trad-frame.h"
27#include "tramp-frame.h"
ec20a626 28#include "gdbtypes.h"
8f2d3ea0 29
8f2d3ea0
MK
30#include "m68k-tdep.h"
31#include "solib-svr4.h"
32
33/* Core file support. */
34
35/* Sizeof `struct reg' in <machine/reg.h>. */
36#define M68KBSD_SIZEOF_GREGS (18 * 4)
37
38/* Sizeof `struct fpreg' in <machine/reg.h. */
39#define M68KBSD_SIZEOF_FPREGS (((8 * 3) + 3) * 4)
40
41int
6ba38425 42m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum)
8f2d3ea0 43{
6ba38425 44 int fp_len = TYPE_LENGTH (gdbarch_register_type (gdbarch, regnum));
8ed86d01 45
8f2d3ea0 46 if (regnum >= M68K_FPC_REGNUM)
8ed86d01 47 return 8 * fp_len + (regnum - M68K_FPC_REGNUM) * 4;
8f2d3ea0 48
8ed86d01 49 return (regnum - M68K_FP0_REGNUM) * fp_len;
8f2d3ea0
MK
50}
51
52/* Supply register REGNUM from the buffer specified by FPREGS and LEN
53 in the floating-point register set REGSET to register cache
54 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
55
56static void
57m68kbsd_supply_fpregset (const struct regset *regset,
58 struct regcache *regcache,
59 int regnum, const void *fpregs, size_t len)
60{
ac7936df 61 struct gdbarch *gdbarch = regcache->arch ();
9a3c8263 62 const gdb_byte *regs = (const gdb_byte *) fpregs;
8f2d3ea0
MK
63 int i;
64
65 gdb_assert (len >= M68KBSD_SIZEOF_FPREGS);
66
67 for (i = M68K_FP0_REGNUM; i <= M68K_PC_REGNUM; i++)
68 {
69 if (regnum == i || regnum == -1)
73e1c03f 70 regcache->raw_supply (i, regs + m68kbsd_fpreg_offset (gdbarch, i));
8f2d3ea0
MK
71 }
72}
73
74/* Supply register REGNUM from the buffer specified by GREGS and LEN
75 in the general-purpose register set REGSET to register cache
76 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
77
78static void
79m68kbsd_supply_gregset (const struct regset *regset,
80 struct regcache *regcache,
81 int regnum, const void *gregs, size_t len)
82{
9a3c8263 83 const gdb_byte *regs = (const gdb_byte *) gregs;
8f2d3ea0
MK
84 int i;
85
86 gdb_assert (len >= M68KBSD_SIZEOF_GREGS);
87
88 for (i = M68K_D0_REGNUM; i <= M68K_PC_REGNUM; i++)
89 {
90 if (regnum == i || regnum == -1)
73e1c03f 91 regcache->raw_supply (i, regs + i * 4);
8f2d3ea0
MK
92 }
93
94 if (len >= M68KBSD_SIZEOF_GREGS + M68KBSD_SIZEOF_FPREGS)
95 {
96 regs += M68KBSD_SIZEOF_GREGS;
97 len -= M68KBSD_SIZEOF_GREGS;
98 m68kbsd_supply_fpregset (regset, regcache, regnum, regs, len);
99 }
100}
101
102/* Motorola 68000 register sets. */
103
3ca7dae4 104static const struct regset m68kbsd_gregset =
8f2d3ea0
MK
105{
106 NULL,
f962539a
AA
107 m68kbsd_supply_gregset,
108 NULL,
109 REGSET_VARIABLE_SIZE
8f2d3ea0
MK
110};
111
3ca7dae4 112static const struct regset m68kbsd_fpregset =
8f2d3ea0
MK
113{
114 NULL,
115 m68kbsd_supply_fpregset
116};
117
022c98ab 118/* Iterate over core file register note sections. */
8f2d3ea0 119
022c98ab
AA
120static void
121m68kbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
122 iterate_over_regset_sections_cb *cb,
123 void *cb_data,
124 const struct regcache *regcache)
8f2d3ea0 125{
a616bb94
AH
126 cb (".reg", M68KBSD_SIZEOF_GREGS, M68KBSD_SIZEOF_GREGS, &m68kbsd_gregset,
127 NULL, cb_data);
128 cb (".reg2", M68KBSD_SIZEOF_FPREGS, M68KBSD_SIZEOF_FPREGS, &m68kbsd_fpregset,
129 NULL, cb_data);
8f2d3ea0 130}
059cb7d2
MK
131\f
132
8f2d3ea0
MK
133static void
134m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
135{
136 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
137
138 tdep->jb_pc = 5;
139 tdep->jb_elt_size = 4;
140
9418f048
UW
141 set_gdbarch_decr_pc_after_break (gdbarch, 2);
142
022c98ab
AA
143 set_gdbarch_iterate_over_regset_sections
144 (gdbarch, m68kbsd_iterate_over_regset_sections);
8f2d3ea0 145
5ab5aa0f
MK
146 /* NetBSD ELF uses the SVR4 ABI. */
147 m68k_svr4_init_abi (info, gdbarch);
8f2d3ea0
MK
148 tdep->struct_return = pcc_struct_return;
149
150 /* NetBSD ELF uses SVR4-style shared libraries. */
8f2d3ea0
MK
151 set_solib_svr4_fetch_link_map_offsets
152 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
153}
8f2d3ea0 154
6c265988 155void _initialize_m68kbsd_tdep ();
8f2d3ea0 156void
6c265988 157_initialize_m68kbsd_tdep ()
8f2d3ea0 158{
1736a7bd
PA
159 gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_NETBSD,
160 m68kbsd_init_abi);
8f2d3ea0 161}
This page took 2.35981 seconds and 4 git commands to generate.