[gdb/testsuite] Use unique portnum in parallel testing
[binutils-gdb.git] / gdb / microblaze-linux-tdep.c
blob49cdfc6013423ecbf1914462e6ffe838bbb1db68
1 /* Target-dependent code for Xilinx MicroBlaze.
3 Copyright (C) 2009-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 "frame.h"
21 #include "inferior.h"
22 #include "symtab.h"
23 #include "target.h"
24 #include "gdbcore.h"
25 #include "cli/cli-cmds.h"
26 #include "symfile.h"
27 #include "objfiles.h"
28 #include "regcache.h"
29 #include "value.h"
30 #include "osabi.h"
31 #include "regset.h"
32 #include "solib-svr4.h"
33 #include "microblaze-tdep.h"
34 #include "trad-frame.h"
35 #include "frame-unwind.h"
36 #include "tramp-frame.h"
37 #include "linux-tdep.h"
39 static int
40 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
41 struct bp_target_info *bp_tgt)
43 CORE_ADDR addr = bp_tgt->reqstd_address;
44 const gdb_byte *bp;
45 int val;
46 int bplen;
47 gdb_byte old_contents[BREAKPOINT_MAX];
49 /* Determine appropriate breakpoint contents and size for this address. */
50 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
52 val = target_read_memory (addr, old_contents, bplen);
54 /* If our breakpoint is no longer at the address, this means that the
55 program modified the code on us, so it is wrong to put back the
56 old value. */
57 if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
58 val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
60 return val;
63 static void
64 microblaze_linux_sigtramp_cache (const frame_info_ptr &next_frame,
65 struct trad_frame_cache *this_cache,
66 CORE_ADDR func, LONGEST offset,
67 int bias)
69 CORE_ADDR base;
70 CORE_ADDR gpregs;
71 int regnum;
73 base = frame_unwind_register_unsigned (next_frame, MICROBLAZE_SP_REGNUM);
74 if (bias > 0 && get_frame_address_in_block (next_frame) != func)
75 /* See below, some signal trampolines increment the stack as their
76 first instruction, need to compensate for that. */
77 base -= bias;
79 /* Find the address of the register buffer. */
80 gpregs = base + offset;
82 /* Registers saved on stack. */
83 for (regnum = 0; regnum < MICROBLAZE_BTR_REGNUM; regnum++)
84 trad_frame_set_reg_addr (this_cache, regnum,
85 gpregs + regnum * MICROBLAZE_REGISTER_SIZE);
86 trad_frame_set_id (this_cache, frame_id_build (base, func));
90 static void
91 microblaze_linux_sighandler_cache_init (const struct tramp_frame *self,
92 const frame_info_ptr &next_frame,
93 struct trad_frame_cache *this_cache,
94 CORE_ADDR func)
96 microblaze_linux_sigtramp_cache (next_frame, this_cache, func,
97 0 /* Offset to ucontext_t. */
98 + 24 /* Offset to .reg. */,
99 0);
102 static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
104 SIGTRAMP_FRAME,
107 { 0x31800077, ULONGEST_MAX }, /* addik R12,R0,119. */
108 { 0xb9cc0008, ULONGEST_MAX }, /* brki R14,8. */
109 { TRAMP_SENTINEL_INSN },
111 microblaze_linux_sighandler_cache_init
115 static void
116 microblaze_linux_init_abi (struct gdbarch_info info,
117 struct gdbarch *gdbarch)
119 linux_init_abi (info, gdbarch, 0);
121 set_gdbarch_memory_remove_breakpoint (gdbarch,
122 microblaze_linux_memory_remove_breakpoint);
124 /* Shared library handling. */
125 set_solib_svr4_fetch_link_map_offsets (gdbarch,
126 linux_ilp32_fetch_link_map_offsets);
128 /* Trampolines. */
129 tramp_frame_prepend_unwinder (gdbarch,
130 &microblaze_linux_sighandler_tramp_frame);
133 void _initialize_microblaze_linux_tdep ();
134 void
135 _initialize_microblaze_linux_tdep ()
137 gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
138 microblaze_linux_init_abi);