Add support for fast tracepoints
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-aarch64-ipa.c
CommitLineData
bb903df0
PL
1/* GNU/Linux/AArch64 specific low level interface, for the in-process
2 agent library for GDB.
3
4 Copyright (C) 2015 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#include "server.h"
22#include "tracepoint.h"
23
24/* Defined in auto-generated file aarch64.c. */
25void init_registers_aarch64 (void);
26extern const struct target_desc *tdesc_aarch64;
27
28/* Each register saved by the jump pad is in a 16 byte cell. */
29#define FT_CR_SIZE 16
30
31#define FT_CR_FPCR 0
32#define FT_CR_FPSR 1
33#define FT_CR_CPSR 2
34#define FT_CR_PC 3
35#define FT_CR_SP 4
36#define FT_CR_X0 5
37#define FT_CR_GPR(n) (FT_CR_X0 + (n))
38#define FT_CR_FPR(n) (FT_CR_GPR (31) + (n))
39
40/* Mapping between registers collected by the jump pad and GDB's register
41 array layout used by regcache.
42
43 See linux-aarch64-low.c (aarch64_install_fast_tracepoint_jump_pad) for
44 more details. */
45
46static const int aarch64_ft_collect_regmap[] = {
47 FT_CR_GPR (0),
48 FT_CR_GPR (1),
49 FT_CR_GPR (2),
50 FT_CR_GPR (3),
51 FT_CR_GPR (4),
52 FT_CR_GPR (5),
53 FT_CR_GPR (6),
54 FT_CR_GPR (7),
55 FT_CR_GPR (8),
56 FT_CR_GPR (9),
57 FT_CR_GPR (10),
58 FT_CR_GPR (11),
59 FT_CR_GPR (12),
60 FT_CR_GPR (13),
61 FT_CR_GPR (14),
62 FT_CR_GPR (15),
63 FT_CR_GPR (16),
64 FT_CR_GPR (17),
65 FT_CR_GPR (18),
66 FT_CR_GPR (19),
67 FT_CR_GPR (20),
68 FT_CR_GPR (21),
69 FT_CR_GPR (22),
70 FT_CR_GPR (23),
71 FT_CR_GPR (24),
72 FT_CR_GPR (25),
73 FT_CR_GPR (26),
74 FT_CR_GPR (27),
75 FT_CR_GPR (28),
76 /* FP */
77 FT_CR_GPR (29),
78 /* LR */
79 FT_CR_GPR (30),
80 FT_CR_SP,
81 FT_CR_PC,
82 FT_CR_CPSR,
83 FT_CR_FPR (0),
84 FT_CR_FPR (1),
85 FT_CR_FPR (2),
86 FT_CR_FPR (3),
87 FT_CR_FPR (4),
88 FT_CR_FPR (5),
89 FT_CR_FPR (6),
90 FT_CR_FPR (7),
91 FT_CR_FPR (8),
92 FT_CR_FPR (9),
93 FT_CR_FPR (10),
94 FT_CR_FPR (11),
95 FT_CR_FPR (12),
96 FT_CR_FPR (13),
97 FT_CR_FPR (14),
98 FT_CR_FPR (15),
99 FT_CR_FPR (16),
100 FT_CR_FPR (17),
101 FT_CR_FPR (18),
102 FT_CR_FPR (19),
103 FT_CR_FPR (20),
104 FT_CR_FPR (21),
105 FT_CR_FPR (22),
106 FT_CR_FPR (23),
107 FT_CR_FPR (24),
108 FT_CR_FPR (25),
109 FT_CR_FPR (26),
110 FT_CR_FPR (27),
111 FT_CR_FPR (28),
112 FT_CR_FPR (29),
113 FT_CR_FPR (30),
114 FT_CR_FPR (31),
115 FT_CR_FPSR,
116 FT_CR_FPCR
117};
118
119#define AARCH64_NUM_FT_COLLECT_GREGS \
120 (sizeof (aarch64_ft_collect_regmap) / sizeof(aarch64_ft_collect_regmap[0]))
121
122/* Fill in REGCACHE with registers saved by the jump pad in BUF. */
123
124void
125supply_fast_tracepoint_registers (struct regcache *regcache,
126 const unsigned char *buf)
127{
128 int i;
129
130 for (i = 0; i < AARCH64_NUM_FT_COLLECT_GREGS; i++)
131 supply_register (regcache, i,
132 ((char *) buf)
133 + (aarch64_ft_collect_regmap[i] * FT_CR_SIZE));
134}
135
136IP_AGENT_EXPORT_FUNC ULONGEST
137gdb_agent_get_raw_reg (const unsigned char *raw_regs, int regnum)
138{
139 if (regnum >= AARCH64_NUM_FT_COLLECT_GREGS)
140 return 0;
141
142 return *(ULONGEST *) (raw_regs
143 + aarch64_ft_collect_regmap[regnum] * FT_CR_SIZE);
144}
145
146void
147initialize_low_tracepoint (void)
148{
149 init_registers_aarch64 ();
150 ipa_tdesc = tdesc_aarch64;
151}
This page took 0.048787 seconds and 4 git commands to generate.