GDB (xrefs)

/tmp/gdb-8.1/gdb/microblaze-linux-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for Xilinx MicroBlaze.
2
3 Copyright (C) 2009-2018 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
40 static int
41 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
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
64 static void
65 microblaze_linux_sigtramp_cache (struct frame_info *next_frame,
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 struct gdbarch *gdbarch = get_frame_arch (next_frame);
74 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
75
76 base = frame_unwind_register_unsigned (next_frame, MICROBLAZE_SP_REGNUM);
77 if (bias > 0 && get_frame_address_in_block (next_frame) != func)
78 /* See below, some signal trampolines increment the stack as their
79 first instruction, need to compensate for that. */
80 base -= bias;
81
82 /* Find the address of the register buffer. */
83 gpregs = base + offset;
84
85 /* Registers saved on stack. */
86 for (regnum = 0; regnum < MICROBLAZE_BTR_REGNUM; regnum++)
87 trad_frame_set_reg_addr (this_cache, regnum,
88 gpregs + regnum * MICROBLAZE_REGISTER_SIZE);
89 trad_frame_set_id (this_cache, frame_id_build (base, func));
90 }
91
92
93 static void
94 microblaze_linux_sighandler_cache_init (const struct tramp_frame *self,
95 struct frame_info *next_frame,
96 struct trad_frame_cache *this_cache,
97 CORE_ADDR func)
98 {
99 microblaze_linux_sigtramp_cache (next_frame, this_cache, func,
100 0 /* Offset to ucontext_t. */
101 + 24 /* Offset to .reg. */,
102 0);
103 }
104
105 static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
106 {
107 SIGTRAMP_FRAME,
108 4,
109 {
110 { 0x31800077, -1 }, /* addik R12,R0,119. */
111 { 0xb9cc0008, -1 }, /* brki R14,8. */
112 { TRAMP_SENTINEL_INSN },
113 },
114 microblaze_linux_sighandler_cache_init
115 };
116
117
118 static void
119 microblaze_linux_init_abi (struct gdbarch_info info,
120 struct gdbarch *gdbarch)
121 {
122 linux_init_abi (info, gdbarch);
123
124 set_gdbarch_memory_remove_breakpoint (gdbarch,
125 microblaze_linux_memory_remove_breakpoint);
126
127 /* Shared library handling. */
128 set_solib_svr4_fetch_link_map_offsets (gdbarch,
129 svr4_ilp32_fetch_link_map_offsets);
130
131 /* Trampolines. */
132 tramp_frame_prepend_unwinder (gdbarch,
133 &microblaze_linux_sighandler_tramp_frame);
134 }
135
136 void
137 _initialize_microblaze_linux_tdep (void)
138 {
139 gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
140 microblaze_linux_init_abi);
141 }
gdbarch
Definition: gdbarch.c:127
bp_target_info::reqstd_address
CORE_ADDR reqstd_address
Definition: breakpoint.h:251
trad_frame_set_reg_addr
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition: trad-frame.c:126
frame_id_build
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
get_frame_address_in_block
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
Definition: frame.c:2407
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
microblaze_linux_sigtramp_cache
static void microblaze_linux_sigtramp_cache(struct frame_info *next_frame, struct trad_frame_cache *this_cache, CORE_ADDR func, LONGEST offset, int bias)
Definition: microblaze-linux-tdep.c:65
TRAMP_SENTINEL_INSN
#define TRAMP_SENTINEL_INSN
Definition: tramp-frame.h:44
func
void(* func)(char *)
Definition: remote-fileio.c:1104
trad_frame_set_id
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition: trad-frame.c:171
GDB_OSABI_LINUX
Definition: defs.h:517
frame_unwind_register_unsigned
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1279
microblaze_linux_init_abi
static void microblaze_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: microblaze-linux-tdep.c:119
microblaze_linux_sighandler_cache_init
static void microblaze_linux_sighandler_cache_init(const struct tramp_frame *self, struct frame_info *next_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
Definition: microblaze-linux-tdep.c:94
gdbarch_tdep
Definition: aarch64-tdep.h:55
linux_init_abi
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: linux-tdep.c:2492
SIGTRAMP_FRAME
Definition: frame.h:255
frame_info
Definition: frame.c:85
svr4_ilp32_fetch_link_map_offsets
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3183
defs.h
gdbarch_tdep
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
objfiles.h
bp_target_info
Definition: breakpoint.h:238
symtab.h
extract_bp_kind::bp
trad-frame.h
MICROBLAZE_REGISTER_SIZE
#define MICROBLAZE_REGISTER_SIZE
Definition: microblaze-tdep.h:116
microblaze_linux_sighandler_tramp_frame
static struct tramp_frame microblaze_linux_sighandler_tramp_frame
Definition: microblaze-linux-tdep.c:105
solib-svr4.h
osabi.h
trad_frame_cache
Definition: trad-frame.c:27
regcache.h
frame.h
BREAKPOINT_MAX
#define BREAKPOINT_MAX
Definition: breakpoint.h:62
bp_target_info::shadow_contents
gdb_byte shadow_contents[BREAKPOINT_MAX]
Definition: breakpoint.h:261
target_write_raw_memory
int target_write_raw_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
Definition: target.c:1469
inferior.h
set_solib_svr4_fetch_link_map_offsets
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3137
frame-unwind.h
microblaze_linux_memory_remove_breakpoint
static int microblaze_linux_memory_remove_breakpoint(struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: microblaze-linux-tdep.c:41
MICROBLAZE_BTR_REGNUM
Definition: microblaze-tdep.h:69
regnum
int regnum
Definition: aarch64-tdep.c:77
gdbarch_register_osabi
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:143
tramp-frame.h
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
_initialize_microblaze_linux_tdep
void _initialize_microblaze_linux_tdep(void)
Definition: microblaze-linux-tdep.c:137
gdbcore.h
target_read_memory
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1370
gdbarch_breakpoint_from_pc
const gdb_byte * gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
Definition: gdbarch.c:2844
offset
int offset
Definition: agent.c:65
tramp_frame_prepend_unwinder
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
Definition: tramp-frame.c:146
linux-tdep.h
target.h
value.h
set_gdbarch_memory_remove_breakpoint
void set_gdbarch_memory_remove_breakpoint(struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype memory_remove_breakpoint)
Definition: gdbarch.c:2963
gdbarch_info
Definition: gdbarch.h:1626
regset.h
tramp_frame
Definition: tramp-frame.h:46
MICROBLAZE_SP_REGNUM
Definition: microblaze-tdep.h:33
microblaze-tdep.h
gdbcmd.h
get_frame_arch
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2691
LONGEST
long long LONGEST
Definition: common-types.h:52
symfile.h