Automatic date update in version.in
[binutils-gdb.git] / gdb / sparc-netbsd-nat.c
blob82592ccc3cfa123264137fabc99bee82ef915f06
1 /* Native-dependent code for NetBSD/sparc.
3 Copyright (C) 2002-2024 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 3 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, see <http://www.gnu.org/licenses/>. */
20 #include "regcache.h"
21 #include "target.h"
23 #include "sparc-tdep.h"
24 #include "sparc-nat.h"
26 /* Support for debugging kernel virtual memory images. */
28 #include <sys/types.h>
29 #include <machine/pcb.h>
31 #include "bsd-kvm.h"
33 static int
34 sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
36 /* The following is true for NetBSD 1.6.2:
38 The pcb contains %sp, %pc, %psr and %wim. From this information
39 we reconstruct the register state as it would look when we just
40 returned from cpu_switch(). */
42 /* The stack pointer shouldn't be zero. */
43 if (pcb->pcb_sp == 0)
44 return 0;
46 regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp);
47 regcache->raw_supply (SPARC_O7_REGNUM, &pcb->pcb_pc);
48 regcache->raw_supply (SPARC32_PSR_REGNUM, &pcb->pcb_psr);
49 regcache->raw_supply (SPARC32_WIM_REGNUM, &pcb->pcb_wim);
50 regcache->raw_supply (SPARC32_PC_REGNUM, &pcb->pcb_pc);
52 sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
54 return 1;
57 static sparc_target<inf_ptrace_target> the_sparc_nbsd_nat_target;
59 void _initialize_sparcnbsd_nat ();
60 void
61 _initialize_sparcnbsd_nat ()
63 sparc_gregmap = &sparc32nbsd_gregmap;
64 sparc_fpregmap = &sparc32_bsd_fpregmap;
66 add_inf_child_target (&sparc_nbsd_nat_target);
68 /* Support debugging kernel virtual memory images. */
69 bsd_kvm_add_target (sparc32nbsd_supply_pcb);