1 /* GNU/Linux/x86-64 specific low level interface, for the in-process
4 Copyright (C) 2010-2015 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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/>. */
22 #include "tracepoint.h"
24 /* Defined in auto-generated file amd64-linux.c. */
25 void init_registers_amd64_linux (void);
26 extern const struct target_desc
*tdesc_amd64_linux
;
28 /* fast tracepoints collect registers. */
31 #define FT_CR_EFLAGS 1
49 static const int x86_64_ft_collect_regmap
[] = {
50 FT_CR_RAX
* 8, FT_CR_RBX
* 8, FT_CR_RCX
* 8, FT_CR_RDX
* 8,
51 FT_CR_RSI
* 8, FT_CR_RDI
* 8, FT_CR_RBP
* 8, FT_CR_RSP
* 8,
52 FT_CR_R8
* 8, FT_CR_R9
* 8, FT_CR_R10
* 8, FT_CR_R11
* 8,
53 FT_CR_R12
* 8, FT_CR_R13
* 8, FT_CR_R14
* 8, FT_CR_R15
* 8,
54 FT_CR_RIP
* 8, FT_CR_EFLAGS
* 8
57 #define X86_64_NUM_FT_COLLECT_GREGS \
58 (sizeof (x86_64_ft_collect_regmap) / sizeof(x86_64_ft_collect_regmap[0]))
61 supply_fast_tracepoint_registers (struct regcache
*regcache
,
62 const unsigned char *buf
)
66 for (i
= 0; i
< X86_64_NUM_FT_COLLECT_GREGS
; i
++)
67 supply_register (regcache
, i
,
68 ((char *) buf
) + x86_64_ft_collect_regmap
[i
]);
71 IP_AGENT_EXPORT_FUNC ULONGEST
72 gdb_agent_get_raw_reg (const unsigned char *raw_regs
, int regnum
)
74 if (regnum
>= X86_64_NUM_FT_COLLECT_GREGS
)
77 return *(ULONGEST
*) (raw_regs
+ x86_64_ft_collect_regmap
[regnum
]);
82 #include <ust/processor.h>
84 /* "struct registers" is the UST object type holding the registers at
85 the time of the static tracepoint marker call. This doesn't
86 contain RIP, but we know what it must have been (the marker
89 #define ST_REGENTRY(REG) \
91 offsetof (struct registers, REG), \
92 sizeof (((struct registers *) NULL)->REG) \
99 } x86_64_st_collect_regmap
[] =
123 #define X86_64_NUM_ST_COLLECT_GREGS \
124 (sizeof (x86_64_st_collect_regmap) / sizeof (x86_64_st_collect_regmap[0]))
126 /* GDB's RIP register number. */
127 #define AMD64_RIP_REGNUM 16
130 supply_static_tracepoint_registers (struct regcache
*regcache
,
131 const unsigned char *buf
,
135 unsigned long newpc
= pc
;
137 supply_register (regcache
, AMD64_RIP_REGNUM
, &newpc
);
139 for (i
= 0; i
< X86_64_NUM_ST_COLLECT_GREGS
; i
++)
140 if (x86_64_st_collect_regmap
[i
].offset
!= -1)
142 switch (x86_64_st_collect_regmap
[i
].size
)
145 supply_register (regcache
, i
,
147 + x86_64_st_collect_regmap
[i
].offset
);
152 = * (short *) (((char *) buf
)
153 + x86_64_st_collect_regmap
[i
].offset
);
155 supply_register (regcache
, i
, ®
);
159 internal_error (__FILE__
, __LINE__
,
160 "unhandled register size: %d",
161 x86_64_st_collect_regmap
[i
].size
);
167 #endif /* HAVE_UST */
170 initialize_low_tracepoint (void)
172 init_registers_amd64_linux ();
173 ipa_tdesc
= tdesc_amd64_linux
;