testsuite, threads: fix LD_LIBRARY_PATH in 'tls-sepdebug.exp'
[binutils-gdb.git] / gdb / arm-fbsd-nat.c
blobcbe9867f49d2a2f13859b3aa3580cfb1bc1920ff
1 /* Native-dependent code for FreeBSD/arm.
3 Copyright (C) 2017-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 "inferior.h"
21 #include "target.h"
23 #include "elf/common.h"
25 #include <sys/types.h>
26 #include <sys/ptrace.h>
27 #include <machine/reg.h>
29 #include "fbsd-nat.h"
30 #include "arm-tdep.h"
31 #include "arm-fbsd-tdep.h"
32 #include "inf-ptrace.h"
34 struct arm_fbsd_nat_target : public fbsd_nat_target
36 void fetch_registers (struct regcache *, int) override;
37 void store_registers (struct regcache *, int) override;
38 const struct target_desc *read_description () override;
41 static arm_fbsd_nat_target the_arm_fbsd_nat_target;
43 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
44 for all registers. */
46 void
47 arm_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
49 fetch_register_set<struct reg> (regcache, regnum, PT_GETREGS,
50 &arm_fbsd_gregset);
51 #ifdef PT_GETVFPREGS
52 fetch_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
53 &arm_fbsd_vfpregset);
54 #endif
55 #ifdef PT_GETREGSET
56 gdbarch *gdbarch = regcache->arch ();
57 arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
59 if (tdep->tls_regnum > 0)
60 fetch_regset<uint32_t> (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tls_regset,
61 tdep->tls_regnum);
62 #endif
65 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
66 this for all registers. */
68 void
69 arm_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
71 store_register_set<struct reg> (regcache, regnum, PT_GETREGS, PT_SETREGS,
72 &arm_fbsd_gregset);
73 #ifdef PT_GETVFPREGS
74 store_register_set<struct vfpreg> (regcache, regnum, PT_GETVFPREGS,
75 PT_SETVFPREGS, &arm_fbsd_vfpregset);
76 #endif
77 #ifdef PT_GETREGSET
78 gdbarch *gdbarch = regcache->arch ();
79 arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
81 if (tdep->tls_regnum > 0)
82 store_regset<uint32_t> (regcache, regnum, NT_ARM_TLS, &arm_fbsd_tls_regset,
83 tdep->tls_regnum);
84 #endif
87 /* Implement the to_read_description method. */
89 const struct target_desc *
90 arm_fbsd_nat_target::read_description ()
92 const struct target_desc *desc;
93 bool tls = false;
95 if (inferior_ptid == null_ptid)
96 return this->beneath ()->read_description ();
98 #ifdef PT_GETREGSET
99 tls = have_regset (inferior_ptid, NT_ARM_TLS) != 0;
100 #endif
101 desc = arm_fbsd_read_description_auxv (tls);
102 if (desc == NULL)
103 desc = this->beneath ()->read_description ();
104 return desc;
107 void _initialize_arm_fbsd_nat ();
108 void
109 _initialize_arm_fbsd_nat ()
111 add_inf_child_target (&the_arm_fbsd_nat_target);