GDB (xrefs)
Loading...
Searching...
No Matches
microblaze-linux-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for Xilinx MicroBlaze.
2
3 Copyright (C) 2009-2023 Free Software Foundation, Inc.
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
20#include "defs.h"
21#include "frame.h"
22#include "inferior.h"
23#include "symtab.h"
24#include "target.h"
25#include "gdbcore.h"
26#include "gdbcmd.h"
27#include "symfile.h"
28#include "objfiles.h"
29#include "regcache.h"
30#include "value.h"
31#include "osabi.h"
32#include "regset.h"
33#include "solib-svr4.h"
34#include "microblaze-tdep.h"
35#include "trad-frame.h"
36#include "frame-unwind.h"
37#include "tramp-frame.h"
38#include "linux-tdep.h"
39
40static int
42 struct bp_target_info *bp_tgt)
43{
44 CORE_ADDR addr = bp_tgt->reqstd_address;
45 const gdb_byte *bp;
46 int val;
47 int bplen;
48 gdb_byte old_contents[BREAKPOINT_MAX];
49
50 /* Determine appropriate breakpoint contents and size for this address. */
51 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
52
53 val = target_read_memory (addr, old_contents, bplen);
54
55 /* If our breakpoint is no longer at the address, this means that the
56 program modified the code on us, so it is wrong to put back the
57 old value. */
58 if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
59 val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
60
61 return val;
62}
63
64static void
66 struct trad_frame_cache *this_cache,
67 CORE_ADDR func, LONGEST offset,
68 int bias)
69{
70 CORE_ADDR base;
71 CORE_ADDR gpregs;
72 int regnum;
73
75 if (bias > 0 && get_frame_address_in_block (next_frame) != func)
76 /* See below, some signal trampolines increment the stack as their
77 first instruction, need to compensate for that. */
78 base -= bias;
79
80 /* Find the address of the register buffer. */
81 gpregs = base + offset;
82
83 /* Registers saved on stack. */
85 trad_frame_set_reg_addr (this_cache, regnum,
87 trad_frame_set_id (this_cache, frame_id_build (base, func));
88}
89
90
91static void
93 frame_info_ptr next_frame,
94 struct trad_frame_cache *this_cache,
95 CORE_ADDR func)
96{
97 microblaze_linux_sigtramp_cache (next_frame, this_cache, func,
98 0 /* Offset to ucontext_t. */
99 + 24 /* Offset to .reg. */,
100 0);
101}
102
104{
106 4,
107 {
108 { 0x31800077, ULONGEST_MAX }, /* addik R12,R0,119. */
109 { 0xb9cc0008, ULONGEST_MAX }, /* brki R14,8. */
111 },
113};
114
115
116static void
133
135void
int regnum
#define BREAKPOINT_MAX
Definition breakpoint.h:78
ULONGEST frame_unwind_register_unsigned(frame_info_ptr next_frame, int regnum)
Definition frame.c:1371
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
CORE_ADDR get_frame_address_in_block(frame_info_ptr this_frame)
Definition frame.c:2742
@ SIGTRAMP_FRAME
Definition frame.h:198
const gdb_byte * gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition gdbarch.c:2777
void set_gdbarch_memory_remove_breakpoint(struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint)
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)
static int microblaze_linux_memory_remove_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static void microblaze_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void microblaze_linux_sighandler_cache_init(const struct tramp_frame *self, frame_info_ptr next_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
void _initialize_microblaze_linux_tdep()
static void microblaze_linux_sigtramp_cache(frame_info_ptr next_frame, struct trad_frame_cache *this_cache, CORE_ADDR func, LONGEST offset, int bias)
static struct tramp_frame microblaze_linux_sighandler_tramp_frame
#define MICROBLAZE_REGISTER_SIZE
@ MICROBLAZE_BTR_REGNUM
@ MICROBLAZE_SP_REGNUM
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(* func)(remote_target *remote, char *)
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
gdb_byte shadow_contents[BREAKPOINT_MAX]
Definition breakpoint.h:279
CORE_ADDR reqstd_address
Definition breakpoint.h:269
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1785
int target_write_raw_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
Definition target.c:1878
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