]>
| Commit | Line | Data |
|---|---|---|
| 1ed586ce MK |
1 | /* Native-dependent code for OpenBSD/sparc64. |
| 2 | ||
| d01e8234 | 3 | Copyright (C) 2003-2025 Free Software Foundation, Inc. |
| 1ed586ce 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 | |
| 9 | the Free Software Foundation; either version 3 of the License, or | |
| 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 | |
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
| 19 | ||
| 1ed586ce MK |
20 | #include "gdbcore.h" |
| 21 | #include "regcache.h" | |
| 22 | #include "target.h" | |
| 23 | ||
| 24 | #include "sparc64-tdep.h" | |
| 25 | #include "sparc-nat.h" | |
| 26 | #include "obsd-nat.h" | |
| 27 | ||
| 28 | /* Determine whether `gregset_t' contains register REGNUM. */ | |
| 29 | ||
| 30 | static int | |
| 31 | sparc64obsd_gregset_supplies_p (struct gdbarch *gdbarch, int regnum) | |
| 32 | { | |
| 33 | /* Integer registers. */ | |
| 34 | if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM) | |
| 35 | || (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM) | |
| 36 | || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM) | |
| 37 | || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM)) | |
| 38 | return 1; | |
| 39 | ||
| 40 | /* Control registers. */ | |
| 41 | if (regnum == SPARC64_PC_REGNUM | |
| 42 | || regnum == SPARC64_NPC_REGNUM | |
| 43 | || regnum == SPARC64_STATE_REGNUM | |
| 44 | || regnum == SPARC64_Y_REGNUM) | |
| 45 | return 1; | |
| 46 | ||
| 47 | return 0; | |
| 48 | } | |
| 49 | ||
| 50 | /* Determine whether `fpregset_t' contains register REGNUM. */ | |
| 51 | ||
| 52 | static int | |
| 53 | sparc64obsd_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum) | |
| 54 | { | |
| 55 | /* Floating-point registers. */ | |
| 56 | if ((regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM) | |
| 57 | || (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM)) | |
| 58 | return 1; | |
| 59 | ||
| 60 | /* Control registers. */ | |
| 61 | if (regnum == SPARC64_FSR_REGNUM) | |
| 62 | return 1; | |
| 63 | ||
| 64 | return 0; | |
| 65 | } | |
| 66 | \f | |
| 67 | ||
| 68 | /* Support for debugging kernel virtual memory images. */ | |
| 69 | ||
| 70 | #include <sys/types.h> | |
| 71 | #include <machine/pcb.h> | |
| 72 | ||
| 73 | #include "bsd-kvm.h" | |
| 74 | ||
| 75 | static int | |
| 76 | sparc64obsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) | |
| 77 | { | |
| 78 | u_int64_t state; | |
| 79 | int regnum; | |
| 80 | ||
| 81 | /* The following is true for OpenBSD 3.0: | |
| 82 | ||
| 83 | The pcb contains %sp and %pc, %pstate and %cwp. From this | |
| 84 | information we reconstruct the register state as it would look | |
| 85 | when we just returned from cpu_switch(). */ | |
| 86 | ||
| 87 | /* The stack pointer shouldn't be zero. */ | |
| 88 | if (pcb->pcb_sp == 0) | |
| 89 | return 0; | |
| 90 | ||
| 91 | /* If the program counter is zero, this is probably a core dump, and | |
| 92 | we can get %pc from the stack. */ | |
| 93 | if (pcb->pcb_pc == 0) | |
| a5cbe675 | 94 | read_memory(pcb->pcb_sp + BIAS - 176 + (11 * 8), |
| 1ed586ce MK |
95 | (gdb_byte *)&pcb->pcb_pc, sizeof pcb->pcb_pc); |
| 96 | ||
| 73e1c03f SM |
97 | regcache->raw_supply (SPARC_SP_REGNUM, &pcb->pcb_sp); |
| 98 | regcache->raw_supply (SPARC64_PC_REGNUM, &pcb->pcb_pc); | |
| 1ed586ce MK |
99 | |
| 100 | state = pcb->pcb_pstate << 8 | pcb->pcb_cwp; | |
| 73e1c03f | 101 | regcache->raw_supply (SPARC64_STATE_REGNUM, &state); |
| 1ed586ce MK |
102 | |
| 103 | sparc_supply_rwindow (regcache, pcb->pcb_sp, -1); | |
| 104 | ||
| 105 | return 1; | |
| 106 | } | |
| 107 | ||
| f6ac5f3d PA |
108 | /* Add some extra features to the generic SPARC target. */ |
| 109 | static sparc_target<obsd_nat_target> the_sparc64_obsd_nat_target; | |
| 110 | ||
| 5fe70629 | 111 | INIT_GDB_FILE (sparc64obsd_nat) |
| 1ed586ce MK |
112 | { |
| 113 | sparc_supply_gregset = sparc64_supply_gregset; | |
| 114 | sparc_collect_gregset = sparc64_collect_gregset; | |
| 115 | sparc_supply_fpregset = sparc64_supply_fpregset; | |
| 116 | sparc_collect_fpregset = sparc64_collect_fpregset; | |
| 117 | sparc_gregset_supplies_p = sparc64obsd_gregset_supplies_p; | |
| 118 | sparc_fpregset_supplies_p = sparc64obsd_fpregset_supplies_p; | |
| 119 | ||
| b4fd25c9 AA |
120 | sparc_gregmap = &sparc64nbsd_gregmap; |
| 121 | sparc_fpregmap = &sparc64_bsd_fpregmap; | |
| 1ed586ce MK |
122 | |
| 123 | /* Add some extra features to the generic SPARC target. */ | |
| d9f719f1 | 124 | add_inf_child_target (&the_sparc64_obsd_nat_target); |
| 1ed586ce MK |
125 | |
| 126 | /* Support debugging kernel virtual memory images. */ | |
| 127 | bsd_kvm_add_target (sparc64obsd_supply_pcb); | |
| 128 | } |