xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/amd64-ravenscar-thread.c (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1*6881a400Schristos /* Ravenscar x86-64 target support.
2*6881a400Schristos 
3*6881a400Schristos    Copyright (C) 2020-2023 Free Software Foundation, Inc.
4*6881a400Schristos 
5*6881a400Schristos    This file is part of GDB.
6*6881a400Schristos 
7*6881a400Schristos    This program is free software; you can redistribute it and/or modify
8*6881a400Schristos    it under the terms of the GNU General Public License as published by
9*6881a400Schristos    the Free Software Foundation; either version 3 of the License, or
10*6881a400Schristos    (at your option) any later version.
11*6881a400Schristos 
12*6881a400Schristos    This program is distributed in the hope that it will be useful,
13*6881a400Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*6881a400Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*6881a400Schristos    GNU General Public License for more details.
16*6881a400Schristos 
17*6881a400Schristos    You should have received a copy of the GNU General Public License
18*6881a400Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19*6881a400Schristos 
20*6881a400Schristos #include "defs.h"
21*6881a400Schristos #include "gdbarch.h"
22*6881a400Schristos #include "gdbcore.h"
23*6881a400Schristos #include "regcache.h"
24*6881a400Schristos #include "amd64-tdep.h"
25*6881a400Schristos #include "inferior.h"
26*6881a400Schristos #include "ravenscar-thread.h"
27*6881a400Schristos #include "amd64-ravenscar-thread.h"
28*6881a400Schristos 
29*6881a400Schristos /* x86-64 Ravenscar stores registers as:
30*6881a400Schristos 
31*6881a400Schristos    type Context_Buffer is record
32*6881a400Schristos       RIP    : System.Address;
33*6881a400Schristos       RFLAGS : EFLAGS;
34*6881a400Schristos       RSP    : System.Address;
35*6881a400Schristos 
36*6881a400Schristos       RBX    : System.Address;
37*6881a400Schristos       RBP    : System.Address;
38*6881a400Schristos       R12    : System.Address;
39*6881a400Schristos       R13    : System.Address;
40*6881a400Schristos       R14    : System.Address;
41*6881a400Schristos       R15    : System.Address;
42*6881a400Schristos    end record;
43*6881a400Schristos */
44*6881a400Schristos static const int register_layout[] =
45*6881a400Schristos {
46*6881a400Schristos   /* RAX */ -1,
47*6881a400Schristos   /* RBX */ 3 * 8,
48*6881a400Schristos   /* RCX */ -1,
49*6881a400Schristos   /* RDX */ -1,
50*6881a400Schristos   /* RSI */ -1,
51*6881a400Schristos   /* RDI */ -1,
52*6881a400Schristos   /* RBP */ 4 * 8,
53*6881a400Schristos   /* RSP */ 2 * 8,
54*6881a400Schristos   /* R8 */ -1,
55*6881a400Schristos   /* R9 */ -1,
56*6881a400Schristos   /* R10 */ -1,
57*6881a400Schristos   /* R11 */ -1,
58*6881a400Schristos   /* R12 */ 5 * 8,
59*6881a400Schristos   /* R13 */ 6 * 8,
60*6881a400Schristos   /* R14 */ 7 * 8,
61*6881a400Schristos   /* R15 */ 8 * 8,
62*6881a400Schristos   /* RIP */ 0 * 8,
63*6881a400Schristos   /* EFLAGS */ 1 * 8,
64*6881a400Schristos };
65*6881a400Schristos 
66*6881a400Schristos /* The ravenscar_arch_ops vector for AMD64 targets.  */
67*6881a400Schristos 
68*6881a400Schristos static struct ravenscar_arch_ops amd64_ravenscar_ops (register_layout);
69*6881a400Schristos 
70*6881a400Schristos /* Register amd64_ravenscar_ops in GDBARCH.  */
71*6881a400Schristos 
72*6881a400Schristos void
73*6881a400Schristos register_amd64_ravenscar_ops (struct gdbarch *gdbarch)
74*6881a400Schristos {
75*6881a400Schristos   set_gdbarch_ravenscar_ops (gdbarch, &amd64_ravenscar_ops);
76*6881a400Schristos }
77