Reimplement ravenscar registers using tables
[binutils-gdb.git] / gdb / ravenscar-thread.h
1 /* Ada Ravenscar thread support.
2
3 Copyright (C) 2004-2022 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 #ifndef RAVENSCAR_THREAD_H
21 #define RAVENSCAR_THREAD_H
22
23 /* Architecture-specific hooks. */
24
25 struct ravenscar_arch_ops
26 {
27 ravenscar_arch_ops (gdb::array_view<const int> offsets_,
28 int first_stack = -1,
29 int last_stack = -1)
30 : offsets (offsets_),
31 first_stack_register (first_stack),
32 last_stack_register (last_stack)
33 {
34 /* These must either both be -1 or both be valid. */
35 gdb_assert ((first_stack_register == -1) == (last_stack_register == -1));
36 /* They must also be ordered. */
37 gdb_assert (last_stack_register >= first_stack_register);
38 }
39
40 void fetch_registers (struct regcache *, int) const;
41 void store_registers (struct regcache *, int) const;
42
43 private:
44
45 /* An array where the indices are register numbers and the contents
46 are offsets. The offsets are either in the thread descriptor or
47 the stack, depending on the other fields. An offset of -1 means
48 that the corresponding register is not stored. */
49 const gdb::array_view<const int> offsets;
50
51 /* If these are -1, then all registers for this architecture are
52 stored in the thread descriptor. Otherwise, these mark a range
53 of registers that are stored on the stack. */
54 const int first_stack_register;
55 const int last_stack_register;
56
57 /* Helper function to supply one register. */
58 void supply_one_register (struct regcache *regcache, int regnum,
59 CORE_ADDR descriptor,
60 CORE_ADDR stack_base) const;
61 /* Helper function to store one register. */
62 void store_one_register (struct regcache *regcache, int regnum,
63 CORE_ADDR descriptor,
64 CORE_ADDR stack_base) const;
65 /* Helper function to find stack address where registers are stored.
66 This must be called with the stack pointer already supplied in
67 the register cache. */
68 CORE_ADDR get_stack_base (struct regcache *) const;
69 };
70
71 #endif /* !defined (RAVENSCAR_THREAD_H) */