GDB (xrefs)
Loading...
Searching...
No Matches
or1k-linux-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for GNU/Linux on OpenRISC processors.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include "defs.h"
20#include "or1k-tdep.h"
21#include "osabi.h"
22#include "glibc-tdep.h"
23#include "linux-tdep.h"
24#include "solib-svr4.h"
25#include "regset.h"
26#include "tramp-frame.h"
27#include "trad-frame.h"
28#include "gdbarch.h"
29
30#include "features/or1k-linux.c"
31
32/* Define the general register mapping. The kernel and GDB put registers
33 r1 to r31 in the same place. The NPC register is stored at index 32 in
34 linux and 33 in GDB, in GDB 32 is for PPC which is not populated from linux.
35 Register r0 is always 0 and can be ignored. */
36
38{
39 { 32, OR1K_ZERO_REGNUM, 4 }, /* r0 to r31 */
40 { 1, OR1K_NPC_REGNUM, 4 },
41 { 0 }
42};
43
44/* Define the general register regset. */
45
50
51/* Define hook for core file support. */
52
53static void
56 void *cb_data,
57 const struct regcache *regcache)
58{
59 cb (".reg", (33 * 4), (33 * 4), &or1k_linux_gregset, NULL, cb_data);
60}
61
62/* Signal trampoline support. */
63
64static void or1k_linux_sigframe_init (const struct tramp_frame *self,
65 frame_info_ptr this_frame,
66 struct trad_frame_cache *this_cache,
67 CORE_ADDR func);
68
69#define OR1K_RT_SIGRETURN 139
70
71#define OR1K_INST_L_ORI_R11_R0_IMM 0xa9600000
72#define OR1K_INST_L_SYS_1 0x20000001
73#define OR1K_INST_L_NOP 0x15000000
74
75static const struct tramp_frame or1k_linux_sigframe = {
77 4,
78 {
80 { OR1K_INST_L_SYS_1, ULONGEST_MAX },
81 { OR1K_INST_L_NOP, ULONGEST_MAX },
83 },
85 NULL
86};
87
88/* Runtime signal frames look like this:
89 struct rt_sigframe {
90 struct siginfo info;
91 struct ucontext uc;
92 unsigned char retcode[16];
93 };
94
95 struct ucontext {
96 unsigned long uc_flags; - 4
97 struct ucontext *uc_link; - 4
98 stack_t uc_stack; - 4 * 3
99 struct sigcontext uc_mcontext;
100 sigset_t uc_sigmask;
101 };
102
103 struct sigcontext {
104 struct user_regs_struct regs;
105 unsigned long oldmask;
106 };
107
108 struct user_regs_struct {
109 unsigned long gpr[32];
110 unsigned long pc;
111 unsigned long sr;
112 }; */
113
114#define SIGFRAME_SIGINFO_SIZE 128
115#define UCONTEXT_MCONTEXT_OFFSET 20
116
117static void
119 frame_info_ptr this_frame,
120 struct trad_frame_cache *this_cache,
121 CORE_ADDR func)
122{
123 CORE_ADDR frame_sp = get_frame_sp (this_frame);
124 CORE_ADDR mcontext_base;
125 CORE_ADDR regs_base;
126
127 mcontext_base = frame_sp + SIGFRAME_SIGINFO_SIZE + UCONTEXT_MCONTEXT_OFFSET;
128
129 /* Handle the general registers 0-31 followed by the PC. */
130 regs_base = mcontext_base;
131 for (int i = 0; i < 32; i++)
133 regs_base + (i * 4));
134 trad_frame_set_reg_addr (this_cache, OR1K_NPC_REGNUM, regs_base + (32 * 4));
135 trad_frame_set_reg_addr (this_cache, OR1K_SR_REGNUM, regs_base + (33 * 4));
136
137 /* Choice of the bottom of the sigframe is somewhat arbitrary. */
138 trad_frame_set_id (this_cache, frame_id_build (frame_sp, func));
139}
140
141/* Initialize OpenRISC Linux ABI info. */
142
143static void
168
169/* Initialize OpenRISC Linux target support. */
170
172void
174{
175 gdbarch_register_osabi (bfd_arch_or1k, 0, GDB_OSABI_LINUX,
177
178 /* Initialize the standard target descriptions. */
180}
CORE_ADDR get_frame_sp(frame_info_ptr this_frame)
Definition frame.c:3115
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
@ SIGTRAMP_FRAME
Definition frame.h:198
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step)
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code)
void set_gdbarch_fetch_tls_load_module_address(struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address)
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype *skip_solib_resolver)
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections)
void iterate_over_regset_sections_cb(const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data)
Definition gdbarch.h:104
CORE_ADDR glibc_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition glibc-tdep.c:38
link_map_offsets * linux_ilp32_fetch_link_map_offsets()
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch, int num_disp_step_buffers)
CORE_ADDR find_solib_trampoline_target(frame_info_ptr frame, CORE_ADDR pc)
Definition minsyms.c:1554
void _initialize_or1k_linux_tdep()
#define SIGFRAME_SIGINFO_SIZE
static void or1k_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
#define OR1K_RT_SIGRETURN
static const struct regcache_map_entry or1k_linux_gregmap[]
static const struct regset or1k_linux_gregset
static void or1k_linux_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
#define OR1K_INST_L_NOP
static void or1k_linux_sigframe_init(const struct tramp_frame *self, frame_info_ptr this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
#define OR1K_INST_L_SYS_1
static const struct tramp_frame or1k_linux_sigframe
#define UCONTEXT_MCONTEXT_OFFSET
#define OR1K_INST_L_ORI_R11_R0_IMM
static void initialize_tdesc_or1k_linux(void)
Definition or1k-linux.c:10
std::vector< CORE_ADDR > or1k_software_single_step(struct regcache *regcache)
Definition or1k-tdep.c:408
#define OR1K_NPC_REGNUM
Definition or1k-tdep.h:42
#define OR1K_SR_REGNUM
Definition or1k-tdep.h:43
#define OR1K_ZERO_REGNUM
Definition or1k-tdep.h:33
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition osabi.c:146
@ GDB_OSABI_LINUX
Definition osabi.h:32
void regcache_collect_regset(const struct regset *regset, const struct regcache *regcache, int regnum, void *buf, size_t size)
Definition regcache.c:1273
void regcache_supply_regset(const struct regset *regset, struct regcache *regcache, int regnum, const void *buf, size_t size)
Definition regcache.c:1251
void(* func)(remote_target *remote, char *)
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
CORE_ADDR svr4_fetch_objfile_link_map(struct objfile *objfile)
Definition regcache.h:111
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition trad-frame.c:110
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition trad-frame.c:220
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
#define TRAMP_SENTINEL_INSN
Definition tramp-frame.h:44