1 /* Target-dependent code for Xilinx MicroBlaze.
3 Copyright 2009-2012 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/>. */
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"
41 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
42 struct bp_target_info *bp_tgt)
44 CORE_ADDR addr = bp_tgt->placed_address;
48 gdb_byte old_contents[BREAKPOINT_MAX];
50 /* Determine appropriate breakpoint contents and size for this address. */
51 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
53 error (_("Software breakpoints not implemented for this target."));
55 val = target_read_memory (addr, old_contents, bplen);
57 /* If our breakpoint is no longer at the address, this means that the
58 program modified the code on us, so it is wrong to put back the
60 if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
61 val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
67 microblaze_linux_sigtramp_cache (struct frame_info *next_frame,
68 struct trad_frame_cache *this_cache,
69 CORE_ADDR func, LONGEST offset,
75 struct gdbarch *gdbarch = get_frame_arch (next_frame);
76 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
78 base = frame_unwind_register_unsigned (next_frame, MICROBLAZE_SP_REGNUM);
79 if (bias > 0 && get_frame_address_in_block (next_frame) != func)
80 /* See below, some signal trampolines increment the stack as their
81 first instruction, need to compensate for that. */
84 /* Find the address of the register buffer. */
85 gpregs = base + offset;
87 /* Registers saved on stack. */
88 for (regnum = 0; regnum < MICROBLAZE_BTR_REGNUM; regnum++)
89 trad_frame_set_reg_addr (this_cache, regnum,
90 gpregs + regnum * MICROBLAZE_REGISTER_SIZE);
91 trad_frame_set_id (this_cache, frame_id_build (base, func));
96 microblaze_linux_sighandler_cache_init (const struct tramp_frame *self,
97 struct frame_info *next_frame,
98 struct trad_frame_cache *this_cache,
101 microblaze_linux_sigtramp_cache (next_frame, this_cache, func,
102 0 /* Offset to ucontext_t. */
103 + 24 /* Offset to .reg. */,
107 static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
112 { 0x31800077, -1 }, /* addik R12,R0,119. */
113 { 0xb9cc0008, -1 }, /* brki R14,8. */
114 { TRAMP_SENTINEL_INSN },
116 microblaze_linux_sighandler_cache_init
121 microblaze_linux_init_abi (struct gdbarch_info info,
122 struct gdbarch *gdbarch)
124 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
126 linux_init_abi (info, gdbarch);
128 set_gdbarch_memory_remove_breakpoint (gdbarch,
129 microblaze_linux_memory_remove_breakpoint);
131 /* Shared library handling. */
132 set_solib_svr4_fetch_link_map_offsets (gdbarch,
133 svr4_ilp32_fetch_link_map_offsets);
136 tramp_frame_prepend_unwinder (gdbarch,
137 µblaze_linux_sighandler_tramp_frame);
141 _initialize_microblaze_linux_tdep (void)
143 gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
144 microblaze_linux_init_abi);