| 1 | /* Target-dependent code for GNU/Linux AArch64. |
| 2 | |
| 3 | Copyright (C) 2009-2015 Free Software Foundation, Inc. |
| 4 | Contributed by ARM Ltd. |
| 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 "defs.h" |
| 22 | |
| 23 | #include "gdbarch.h" |
| 24 | #include "glibc-tdep.h" |
| 25 | #include "linux-tdep.h" |
| 26 | #include "aarch64-tdep.h" |
| 27 | #include "aarch64-linux-tdep.h" |
| 28 | #include "osabi.h" |
| 29 | #include "solib-svr4.h" |
| 30 | #include "symtab.h" |
| 31 | #include "tramp-frame.h" |
| 32 | #include "trad-frame.h" |
| 33 | |
| 34 | #include "inferior.h" |
| 35 | #include "regcache.h" |
| 36 | #include "regset.h" |
| 37 | |
| 38 | #include "cli/cli-utils.h" |
| 39 | #include "stap-probe.h" |
| 40 | #include "parser-defs.h" |
| 41 | #include "user-regs.h" |
| 42 | #include "xml-syscall.h" |
| 43 | #include <ctype.h> |
| 44 | |
| 45 | #include "record-full.h" |
| 46 | #include "linux-record.h" |
| 47 | |
| 48 | /* Signal frame handling. |
| 49 | |
| 50 | +------------+ ^ |
| 51 | | saved lr | | |
| 52 | +->| saved fp |--+ |
| 53 | | | | |
| 54 | | | | |
| 55 | | +------------+ |
| 56 | | | saved lr | |
| 57 | +--| saved fp | |
| 58 | ^ | | |
| 59 | | | | |
| 60 | | +------------+ |
| 61 | ^ | | |
| 62 | | | signal | |
| 63 | | | | SIGTRAMP_FRAME (struct rt_sigframe) |
| 64 | | | saved regs | |
| 65 | +--| saved sp |--> interrupted_sp |
| 66 | | | saved pc |--> interrupted_pc |
| 67 | | | | |
| 68 | | +------------+ |
| 69 | | | saved lr |--> default_restorer (movz x8, NR_sys_rt_sigreturn; svc 0) |
| 70 | +--| saved fp |<- FP |
| 71 | | | NORMAL_FRAME |
| 72 | | |<- SP |
| 73 | +------------+ |
| 74 | |
| 75 | On signal delivery, the kernel will create a signal handler stack |
| 76 | frame and setup the return address in LR to point at restorer stub. |
| 77 | The signal stack frame is defined by: |
| 78 | |
| 79 | struct rt_sigframe |
| 80 | { |
| 81 | siginfo_t info; |
| 82 | struct ucontext uc; |
| 83 | }; |
| 84 | |
| 85 | typedef struct |
| 86 | { |
| 87 | ... 128 bytes |
| 88 | } siginfo_t; |
| 89 | |
| 90 | The ucontext has the following form: |
| 91 | struct ucontext |
| 92 | { |
| 93 | unsigned long uc_flags; |
| 94 | struct ucontext *uc_link; |
| 95 | stack_t uc_stack; |
| 96 | sigset_t uc_sigmask; |
| 97 | struct sigcontext uc_mcontext; |
| 98 | }; |
| 99 | |
| 100 | typedef struct sigaltstack |
| 101 | { |
| 102 | void *ss_sp; |
| 103 | int ss_flags; |
| 104 | size_t ss_size; |
| 105 | } stack_t; |
| 106 | |
| 107 | struct sigcontext |
| 108 | { |
| 109 | unsigned long fault_address; |
| 110 | unsigned long regs[31]; |
| 111 | unsigned long sp; / * 31 * / |
| 112 | unsigned long pc; / * 32 * / |
| 113 | unsigned long pstate; / * 33 * / |
| 114 | __u8 __reserved[4096] |
| 115 | }; |
| 116 | |
| 117 | The restorer stub will always have the form: |
| 118 | |
| 119 | d28015a8 movz x8, #0xad |
| 120 | d4000001 svc #0x0 |
| 121 | |
| 122 | This is a system call sys_rt_sigreturn. |
| 123 | |
| 124 | We detect signal frames by snooping the return code for the restorer |
| 125 | instruction sequence. |
| 126 | |
| 127 | The handler then needs to recover the saved register set from |
| 128 | ucontext.uc_mcontext. */ |
| 129 | |
| 130 | /* These magic numbers need to reflect the layout of the kernel |
| 131 | defined struct rt_sigframe and ucontext. */ |
| 132 | #define AARCH64_SIGCONTEXT_REG_SIZE 8 |
| 133 | #define AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET 128 |
| 134 | #define AARCH64_UCONTEXT_SIGCONTEXT_OFFSET 176 |
| 135 | #define AARCH64_SIGCONTEXT_XO_OFFSET 8 |
| 136 | |
| 137 | /* Implement the "init" method of struct tramp_frame. */ |
| 138 | |
| 139 | static void |
| 140 | aarch64_linux_sigframe_init (const struct tramp_frame *self, |
| 141 | struct frame_info *this_frame, |
| 142 | struct trad_frame_cache *this_cache, |
| 143 | CORE_ADDR func) |
| 144 | { |
| 145 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
| 146 | CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); |
| 147 | CORE_ADDR sigcontext_addr = |
| 148 | sp |
| 149 | + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET |
| 150 | + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET; |
| 151 | int i; |
| 152 | |
| 153 | for (i = 0; i < 31; i++) |
| 154 | { |
| 155 | trad_frame_set_reg_addr (this_cache, |
| 156 | AARCH64_X0_REGNUM + i, |
| 157 | sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET |
| 158 | + i * AARCH64_SIGCONTEXT_REG_SIZE); |
| 159 | } |
| 160 | trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, |
| 161 | sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET |
| 162 | + 31 * AARCH64_SIGCONTEXT_REG_SIZE); |
| 163 | trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, |
| 164 | sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET |
| 165 | + 32 * AARCH64_SIGCONTEXT_REG_SIZE); |
| 166 | |
| 167 | trad_frame_set_id (this_cache, frame_id_build (sp, func)); |
| 168 | } |
| 169 | |
| 170 | static const struct tramp_frame aarch64_linux_rt_sigframe = |
| 171 | { |
| 172 | SIGTRAMP_FRAME, |
| 173 | 4, |
| 174 | { |
| 175 | /* movz x8, 0x8b (S=1,o=10,h=0,i=0x8b,r=8) |
| 176 | Soo1 0010 1hhi iiii iiii iiii iiir rrrr */ |
| 177 | {0xd2801168, -1}, |
| 178 | |
| 179 | /* svc 0x0 (o=0, l=1) |
| 180 | 1101 0100 oooi iiii iiii iiii iii0 00ll */ |
| 181 | {0xd4000001, -1}, |
| 182 | {TRAMP_SENTINEL_INSN, -1} |
| 183 | }, |
| 184 | aarch64_linux_sigframe_init |
| 185 | }; |
| 186 | |
| 187 | /* Register maps. */ |
| 188 | |
| 189 | static const struct regcache_map_entry aarch64_linux_gregmap[] = |
| 190 | { |
| 191 | { 31, AARCH64_X0_REGNUM, 8 }, /* x0 ... x30 */ |
| 192 | { 1, AARCH64_SP_REGNUM, 8 }, |
| 193 | { 1, AARCH64_PC_REGNUM, 8 }, |
| 194 | { 1, AARCH64_CPSR_REGNUM, 8 }, |
| 195 | { 0 } |
| 196 | }; |
| 197 | |
| 198 | static const struct regcache_map_entry aarch64_linux_fpregmap[] = |
| 199 | { |
| 200 | { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */ |
| 201 | { 1, AARCH64_FPSR_REGNUM, 4 }, |
| 202 | { 1, AARCH64_FPCR_REGNUM, 4 }, |
| 203 | { 0 } |
| 204 | }; |
| 205 | |
| 206 | /* Register set definitions. */ |
| 207 | |
| 208 | const struct regset aarch64_linux_gregset = |
| 209 | { |
| 210 | aarch64_linux_gregmap, |
| 211 | regcache_supply_regset, regcache_collect_regset |
| 212 | }; |
| 213 | |
| 214 | const struct regset aarch64_linux_fpregset = |
| 215 | { |
| 216 | aarch64_linux_fpregmap, |
| 217 | regcache_supply_regset, regcache_collect_regset |
| 218 | }; |
| 219 | |
| 220 | /* Implement the "regset_from_core_section" gdbarch method. */ |
| 221 | |
| 222 | static void |
| 223 | aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, |
| 224 | iterate_over_regset_sections_cb *cb, |
| 225 | void *cb_data, |
| 226 | const struct regcache *regcache) |
| 227 | { |
| 228 | cb (".reg", AARCH64_LINUX_SIZEOF_GREGSET, &aarch64_linux_gregset, |
| 229 | NULL, cb_data); |
| 230 | cb (".reg2", AARCH64_LINUX_SIZEOF_FPREGSET, &aarch64_linux_fpregset, |
| 231 | NULL, cb_data); |
| 232 | } |
| 233 | |
| 234 | /* Implementation of `gdbarch_stap_is_single_operand', as defined in |
| 235 | gdbarch.h. */ |
| 236 | |
| 237 | static int |
| 238 | aarch64_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) |
| 239 | { |
| 240 | return (*s == '#' || isdigit (*s) /* Literal number. */ |
| 241 | || *s == '[' /* Register indirection. */ |
| 242 | || isalpha (*s)); /* Register value. */ |
| 243 | } |
| 244 | |
| 245 | /* This routine is used to parse a special token in AArch64's assembly. |
| 246 | |
| 247 | The special tokens parsed by it are: |
| 248 | |
| 249 | - Register displacement (e.g, [fp, #-8]) |
| 250 | |
| 251 | It returns one if the special token has been parsed successfully, |
| 252 | or zero if the current token is not considered special. */ |
| 253 | |
| 254 | static int |
| 255 | aarch64_stap_parse_special_token (struct gdbarch *gdbarch, |
| 256 | struct stap_parse_info *p) |
| 257 | { |
| 258 | if (*p->arg == '[') |
| 259 | { |
| 260 | /* Temporary holder for lookahead. */ |
| 261 | const char *tmp = p->arg; |
| 262 | char *endp; |
| 263 | /* Used to save the register name. */ |
| 264 | const char *start; |
| 265 | char *regname; |
| 266 | int len; |
| 267 | int got_minus = 0; |
| 268 | long displacement; |
| 269 | struct stoken str; |
| 270 | |
| 271 | ++tmp; |
| 272 | start = tmp; |
| 273 | |
| 274 | /* Register name. */ |
| 275 | while (isalnum (*tmp)) |
| 276 | ++tmp; |
| 277 | |
| 278 | if (*tmp != ',') |
| 279 | return 0; |
| 280 | |
| 281 | len = tmp - start; |
| 282 | regname = alloca (len + 2); |
| 283 | |
| 284 | strncpy (regname, start, len); |
| 285 | regname[len] = '\0'; |
| 286 | |
| 287 | if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) |
| 288 | error (_("Invalid register name `%s' on expression `%s'."), |
| 289 | regname, p->saved_arg); |
| 290 | |
| 291 | ++tmp; |
| 292 | tmp = skip_spaces_const (tmp); |
| 293 | /* Now we expect a number. It can begin with '#' or simply |
| 294 | a digit. */ |
| 295 | if (*tmp == '#') |
| 296 | ++tmp; |
| 297 | |
| 298 | if (*tmp == '-') |
| 299 | { |
| 300 | ++tmp; |
| 301 | got_minus = 1; |
| 302 | } |
| 303 | else if (*tmp == '+') |
| 304 | ++tmp; |
| 305 | |
| 306 | if (!isdigit (*tmp)) |
| 307 | return 0; |
| 308 | |
| 309 | displacement = strtol (tmp, &endp, 10); |
| 310 | tmp = endp; |
| 311 | |
| 312 | /* Skipping last `]'. */ |
| 313 | if (*tmp++ != ']') |
| 314 | return 0; |
| 315 | |
| 316 | /* The displacement. */ |
| 317 | write_exp_elt_opcode (&p->pstate, OP_LONG); |
| 318 | write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long); |
| 319 | write_exp_elt_longcst (&p->pstate, displacement); |
| 320 | write_exp_elt_opcode (&p->pstate, OP_LONG); |
| 321 | if (got_minus) |
| 322 | write_exp_elt_opcode (&p->pstate, UNOP_NEG); |
| 323 | |
| 324 | /* The register name. */ |
| 325 | write_exp_elt_opcode (&p->pstate, OP_REGISTER); |
| 326 | str.ptr = regname; |
| 327 | str.length = len; |
| 328 | write_exp_string (&p->pstate, str); |
| 329 | write_exp_elt_opcode (&p->pstate, OP_REGISTER); |
| 330 | |
| 331 | write_exp_elt_opcode (&p->pstate, BINOP_ADD); |
| 332 | |
| 333 | /* Casting to the expected type. */ |
| 334 | write_exp_elt_opcode (&p->pstate, UNOP_CAST); |
| 335 | write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type)); |
| 336 | write_exp_elt_opcode (&p->pstate, UNOP_CAST); |
| 337 | |
| 338 | write_exp_elt_opcode (&p->pstate, UNOP_IND); |
| 339 | |
| 340 | p->arg = tmp; |
| 341 | } |
| 342 | else |
| 343 | return 0; |
| 344 | |
| 345 | return 1; |
| 346 | } |
| 347 | |
| 348 | /* Implement the "get_syscall_number" gdbarch method. */ |
| 349 | |
| 350 | static LONGEST |
| 351 | aarch64_linux_get_syscall_number (struct gdbarch *gdbarch, |
| 352 | ptid_t ptid) |
| 353 | { |
| 354 | struct regcache *regs = get_thread_regcache (ptid); |
| 355 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
| 356 | |
| 357 | /* The content of register x8. */ |
| 358 | gdb_byte buf[X_REGISTER_SIZE]; |
| 359 | /* The result. */ |
| 360 | LONGEST ret; |
| 361 | |
| 362 | /* Getting the system call number from the register x8. */ |
| 363 | regcache_cooked_read (regs, AARCH64_DWARF_X0 + 8, buf); |
| 364 | |
| 365 | ret = extract_signed_integer (buf, X_REGISTER_SIZE, byte_order); |
| 366 | |
| 367 | return ret; |
| 368 | } |
| 369 | |
| 370 | /* AArch64 process record-replay constructs: syscall, signal etc. */ |
| 371 | |
| 372 | struct linux_record_tdep aarch64_linux_record_tdep; |
| 373 | |
| 374 | /* Enum that defines the AArch64 linux specific syscall identifiers used for |
| 375 | process record/replay. */ |
| 376 | |
| 377 | enum aarch64_syscall { |
| 378 | aarch64_sys_io_setup = 0, |
| 379 | aarch64_sys_io_destroy = 1, |
| 380 | aarch64_sys_io_submit = 2, |
| 381 | aarch64_sys_io_cancel = 3, |
| 382 | aarch64_sys_io_getevents = 4, |
| 383 | aarch64_sys_setxattr = 5, |
| 384 | aarch64_sys_lsetxattr = 6, |
| 385 | aarch64_sys_fsetxattr = 7, |
| 386 | aarch64_sys_getxattr = 8, |
| 387 | aarch64_sys_lgetxattr = 9, |
| 388 | aarch64_sys_fgetxattr = 10, |
| 389 | aarch64_sys_listxattr = 11, |
| 390 | aarch64_sys_llistxattr = 12, |
| 391 | aarch64_sys_flistxattr = 13, |
| 392 | aarch64_sys_removexattr = 14, |
| 393 | aarch64_sys_lremovexattr = 15, |
| 394 | aarch64_sys_fremovexattr = 16, |
| 395 | aarch64_sys_getcwd = 17, |
| 396 | aarch64_sys_lookup_dcookie = 18, |
| 397 | aarch64_sys_eventfd2 = 19, |
| 398 | aarch64_sys_epoll_create1 = 20, |
| 399 | aarch64_sys_epoll_ctl = 21, |
| 400 | aarch64_sys_epoll_pwait = 22, |
| 401 | aarch64_sys_dup = 23, |
| 402 | aarch64_sys_dup3 = 24, |
| 403 | aarch64_sys_fcntl = 25, |
| 404 | aarch64_sys_inotify_init1 = 26, |
| 405 | aarch64_sys_inotify_add_watch = 27, |
| 406 | aarch64_sys_inotify_rm_watch = 28, |
| 407 | aarch64_sys_ioctl = 29, |
| 408 | aarch64_sys_ioprio_set = 30, |
| 409 | aarch64_sys_ioprio_get = 31, |
| 410 | aarch64_sys_flock = 32, |
| 411 | aarch64_sys_mknod = 33, |
| 412 | aarch64_sys_mkdir = 34, |
| 413 | aarch64_sys_unlink = 35, |
| 414 | aarch64_sys_symlink = 36, |
| 415 | aarch64_sys_link = 37, |
| 416 | aarch64_sys_rename = 38, |
| 417 | aarch64_sys_umount2 = 39, |
| 418 | aarch64_sys_mount = 40, |
| 419 | aarch64_sys_pivot_root = 41, |
| 420 | aarch64_sys_nfsservctl = 42, |
| 421 | aarch64_sys_statfs = 43, |
| 422 | aarch64_sys_fstatfs = 44, |
| 423 | aarch64_sys_truncate = 45, |
| 424 | aarch64_sys_ftruncate = 46, |
| 425 | aarch64_sys_fallocate = 47, |
| 426 | aarch64_sys_faccess = 48, |
| 427 | aarch64_sys_chdir = 49, |
| 428 | aarch64_sys_fchdir = 50, |
| 429 | aarch64_sys_chroot = 51, |
| 430 | aarch64_sys_fchmod = 52, |
| 431 | aarch64_sys_fchmodat = 53, |
| 432 | aarch64_sys_fchownat = 54, |
| 433 | aarch64_sys_fchown = 55, |
| 434 | aarch64_sys_open = 56, |
| 435 | aarch64_sys_close = 57, |
| 436 | aarch64_sys_vhangup = 58, |
| 437 | aarch64_sys_pipe2 = 59, |
| 438 | aarch64_sys_quotactl = 60, |
| 439 | aarch64_sys_getdents64 = 61, |
| 440 | aarch64_sys_lseek = 62, |
| 441 | aarch64_sys_read = 63, |
| 442 | aarch64_sys_write = 64, |
| 443 | aarch64_sys_readv = 65, |
| 444 | aarch64_sys_writev = 66, |
| 445 | aarch64_sys_pread64 = 67, |
| 446 | aarch64_sys_pwrite64 = 68, |
| 447 | aarch64_sys_preadv = 69, |
| 448 | aarch64_sys_pwritev = 70, |
| 449 | aarch64_sys_sendfile = 71, |
| 450 | aarch64_sys_pselect6 = 72, |
| 451 | aarch64_sys_ppoll = 73, |
| 452 | aarch64_sys_signalfd4 = 74, |
| 453 | aarch64_sys_vmsplice = 75, |
| 454 | aarch64_sys_splice = 76, |
| 455 | aarch64_sys_tee = 77, |
| 456 | aarch64_sys_readlink = 78, |
| 457 | aarch64_sys_fstatat = 79, |
| 458 | aarch64_sys_fstat = 80, |
| 459 | aarch64_sys_sync = 81, |
| 460 | aarch64_sys_fsync = 82, |
| 461 | aarch64_sys_fdatasync = 83, |
| 462 | aarch64_sys_sync_file_range2 = 84, |
| 463 | aarch64_sys_sync_file_range = 84, |
| 464 | aarch64_sys_timerfd_create = 85, |
| 465 | aarch64_sys_timerfd_settime = 86, |
| 466 | aarch64_sys_timerfd_gettime = 87, |
| 467 | aarch64_sys_utimensat = 88, |
| 468 | aarch64_sys_acct = 89, |
| 469 | aarch64_sys_capget = 90, |
| 470 | aarch64_sys_capset = 91, |
| 471 | aarch64_sys_personality = 92, |
| 472 | aarch64_sys_exit = 93, |
| 473 | aarch64_sys_exit_group = 94, |
| 474 | aarch64_sys_waitid = 95, |
| 475 | aarch64_sys_set_tid_address = 96, |
| 476 | aarch64_sys_unshare = 97, |
| 477 | aarch64_sys_futex = 98, |
| 478 | aarch64_sys_set_robust_list = 99, |
| 479 | aarch64_sys_get_robust_list = 100, |
| 480 | aarch64_sys_nanosleep = 101, |
| 481 | aarch64_sys_getitimer = 102, |
| 482 | aarch64_sys_setitimer = 103, |
| 483 | aarch64_sys_kexec_load = 104, |
| 484 | aarch64_sys_init_module = 105, |
| 485 | aarch64_sys_delete_module = 106, |
| 486 | aarch64_sys_timer_create = 107, |
| 487 | aarch64_sys_timer_gettime = 108, |
| 488 | aarch64_sys_timer_getoverrun = 109, |
| 489 | aarch64_sys_timer_settime = 110, |
| 490 | aarch64_sys_timer_delete = 111, |
| 491 | aarch64_sys_clock_settime = 112, |
| 492 | aarch64_sys_clock_gettime = 113, |
| 493 | aarch64_sys_clock_getres = 114, |
| 494 | aarch64_sys_clock_nanosleep = 115, |
| 495 | aarch64_sys_syslog = 116, |
| 496 | aarch64_sys_ptrace = 117, |
| 497 | aarch64_sys_sched_setparam = 118, |
| 498 | aarch64_sys_sched_setscheduler = 119, |
| 499 | aarch64_sys_sched_getscheduler = 120, |
| 500 | aarch64_sys_sched_getparam = 121, |
| 501 | aarch64_sys_sched_setaffinity = 122, |
| 502 | aarch64_sys_sched_getaffinity = 123, |
| 503 | aarch64_sys_sched_yield = 124, |
| 504 | aarch64_sys_sched_get_priority_max = 125, |
| 505 | aarch64_sys_sched_get_priority_min = 126, |
| 506 | aarch64_sys_sched_rr_get_interval = 127, |
| 507 | aarch64_sys_kill = 129, |
| 508 | aarch64_sys_tkill = 130, |
| 509 | aarch64_sys_tgkill = 131, |
| 510 | aarch64_sys_sigaltstack = 132, |
| 511 | aarch64_sys_rt_sigsuspend = 133, |
| 512 | aarch64_sys_rt_sigaction = 134, |
| 513 | aarch64_sys_rt_sigprocmask = 135, |
| 514 | aarch64_sys_rt_sigpending = 136, |
| 515 | aarch64_sys_rt_sigtimedwait = 137, |
| 516 | aarch64_sys_rt_sigqueueinfo = 138, |
| 517 | aarch64_sys_rt_sigreturn = 139, |
| 518 | aarch64_sys_setpriority = 140, |
| 519 | aarch64_sys_getpriority = 141, |
| 520 | aarch64_sys_reboot = 142, |
| 521 | aarch64_sys_setregid = 143, |
| 522 | aarch64_sys_setgid = 144, |
| 523 | aarch64_sys_setreuid = 145, |
| 524 | aarch64_sys_setuid = 146, |
| 525 | aarch64_sys_setresuid = 147, |
| 526 | aarch64_sys_getresuid = 148, |
| 527 | aarch64_sys_setresgid = 149, |
| 528 | aarch64_sys_getresgid = 150, |
| 529 | aarch64_sys_setfsuid = 151, |
| 530 | aarch64_sys_setfsgid = 152, |
| 531 | aarch64_sys_times = 153, |
| 532 | aarch64_sys_setpgid = 154, |
| 533 | aarch64_sys_getpgid = 155, |
| 534 | aarch64_sys_getsid = 156, |
| 535 | aarch64_sys_setsid = 157, |
| 536 | aarch64_sys_getgroups = 158, |
| 537 | aarch64_sys_setgroups = 159, |
| 538 | aarch64_sys_uname = 160, |
| 539 | aarch64_sys_sethostname = 161, |
| 540 | aarch64_sys_setdomainname = 162, |
| 541 | aarch64_sys_getrlimit = 163, |
| 542 | aarch64_sys_setrlimit = 164, |
| 543 | aarch64_sys_getrusage = 165, |
| 544 | aarch64_sys_umask = 166, |
| 545 | aarch64_sys_prctl = 167, |
| 546 | aarch64_sys_getcpu = 168, |
| 547 | aarch64_sys_gettimeofday = 169, |
| 548 | aarch64_sys_settimeofday = 170, |
| 549 | aarch64_sys_adjtimex = 171, |
| 550 | aarch64_sys_getpid = 172, |
| 551 | aarch64_sys_getppid = 173, |
| 552 | aarch64_sys_getuid = 174, |
| 553 | aarch64_sys_geteuid = 175, |
| 554 | aarch64_sys_getgid = 176, |
| 555 | aarch64_sys_getegid = 177, |
| 556 | aarch64_sys_gettid = 178, |
| 557 | aarch64_sys_sysinfo = 179, |
| 558 | aarch64_sys_mq_open = 180, |
| 559 | aarch64_sys_mq_unlink = 181, |
| 560 | aarch64_sys_mq_timedsend = 182, |
| 561 | aarch64_sys_mq_timedreceive = 183, |
| 562 | aarch64_sys_mq_notify = 184, |
| 563 | aarch64_sys_mq_getsetattr = 185, |
| 564 | aarch64_sys_msgget = 186, |
| 565 | aarch64_sys_msgctl = 187, |
| 566 | aarch64_sys_msgrcv = 188, |
| 567 | aarch64_sys_msgsnd = 189, |
| 568 | aarch64_sys_semget = 190, |
| 569 | aarch64_sys_semctl = 191, |
| 570 | aarch64_sys_semtimedop = 192, |
| 571 | aarch64_sys_semop = 193, |
| 572 | aarch64_sys_shmget = 194, |
| 573 | aarch64_sys_shmctl = 195, |
| 574 | aarch64_sys_shmat = 196, |
| 575 | aarch64_sys_shmdt = 197, |
| 576 | aarch64_sys_socket = 198, |
| 577 | aarch64_sys_socketpair = 199, |
| 578 | aarch64_sys_bind = 200, |
| 579 | aarch64_sys_listen = 201, |
| 580 | aarch64_sys_accept = 202, |
| 581 | aarch64_sys_connect = 203, |
| 582 | aarch64_sys_getsockname = 204, |
| 583 | aarch64_sys_getpeername = 205, |
| 584 | aarch64_sys_sendto = 206, |
| 585 | aarch64_sys_recvfrom = 207, |
| 586 | aarch64_sys_setsockopt = 208, |
| 587 | aarch64_sys_getsockopt = 209, |
| 588 | aarch64_sys_shutdown = 210, |
| 589 | aarch64_sys_sendmsg = 211, |
| 590 | aarch64_sys_recvmsg = 212, |
| 591 | aarch64_sys_readahead = 213, |
| 592 | aarch64_sys_brk = 214, |
| 593 | aarch64_sys_munmap = 215, |
| 594 | aarch64_sys_mremap = 216, |
| 595 | aarch64_sys_add_key = 217, |
| 596 | aarch64_sys_request_key = 218, |
| 597 | aarch64_sys_keyctl = 219, |
| 598 | aarch64_sys_clone = 220, |
| 599 | aarch64_sys_execve = 221, |
| 600 | aarch64_sys_mmap = 222, |
| 601 | aarch64_sys_fadvise64 = 223, |
| 602 | aarch64_sys_swapon = 224, |
| 603 | aarch64_sys_swapoff = 225, |
| 604 | aarch64_sys_mprotect = 226, |
| 605 | aarch64_sys_msync = 227, |
| 606 | aarch64_sys_mlock = 228, |
| 607 | aarch64_sys_munlock = 229, |
| 608 | aarch64_sys_mlockall = 230, |
| 609 | aarch64_sys_munlockall = 231, |
| 610 | aarch64_sys_mincore = 232, |
| 611 | aarch64_sys_madvise = 233, |
| 612 | aarch64_sys_remap_file_pages = 234, |
| 613 | aarch64_sys_mbind = 235, |
| 614 | aarch64_sys_get_mempolicy = 236, |
| 615 | aarch64_sys_set_mempolicy = 237, |
| 616 | aarch64_sys_migrate_pages = 238, |
| 617 | aarch64_sys_move_pages = 239, |
| 618 | aarch64_sys_rt_tgsigqueueinfo = 240, |
| 619 | aarch64_sys_perf_event_open = 241, |
| 620 | aarch64_sys_accept4 = 242, |
| 621 | aarch64_sys_recvmmsg = 243, |
| 622 | aarch64_sys_wait4 = 260, |
| 623 | aarch64_sys_prlimit64 = 261, |
| 624 | aarch64_sys_fanotify_init = 262, |
| 625 | aarch64_sys_fanotify_mark = 263, |
| 626 | aarch64_sys_name_to_handle_at = 264, |
| 627 | aarch64_sys_open_by_handle_at = 265, |
| 628 | aarch64_sys_clock_adjtime = 266, |
| 629 | aarch64_sys_syncfs = 267, |
| 630 | aarch64_sys_setns = 268, |
| 631 | aarch64_sys_sendmmsg = 269, |
| 632 | aarch64_sys_process_vm_readv = 270, |
| 633 | aarch64_sys_process_vm_writev = 271, |
| 634 | aarch64_sys_kcmp = 272, |
| 635 | aarch64_sys_finit_module = 273, |
| 636 | aarch64_sys_sched_setattr = 274, |
| 637 | aarch64_sys_sched_getattr = 275, |
| 638 | }; |
| 639 | |
| 640 | /* aarch64_canonicalize_syscall maps syscall ids from the native AArch64 |
| 641 | linux set of syscall ids into a canonical set of syscall ids used by |
| 642 | process record. */ |
| 643 | |
| 644 | static enum gdb_syscall |
| 645 | aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number) |
| 646 | { |
| 647 | #define SYSCALL_MAP(SYSCALL) case aarch64_sys_##SYSCALL: \ |
| 648 | return gdb_sys_##SYSCALL |
| 649 | |
| 650 | switch (syscall_number) |
| 651 | { |
| 652 | SYSCALL_MAP (io_setup); |
| 653 | SYSCALL_MAP (io_destroy); |
| 654 | SYSCALL_MAP (io_submit); |
| 655 | SYSCALL_MAP (io_cancel); |
| 656 | SYSCALL_MAP (io_getevents); |
| 657 | |
| 658 | SYSCALL_MAP (setxattr); |
| 659 | SYSCALL_MAP (lsetxattr); |
| 660 | SYSCALL_MAP (fsetxattr); |
| 661 | SYSCALL_MAP (getxattr); |
| 662 | SYSCALL_MAP (lgetxattr); |
| 663 | SYSCALL_MAP (fgetxattr); |
| 664 | SYSCALL_MAP (listxattr); |
| 665 | SYSCALL_MAP (llistxattr); |
| 666 | SYSCALL_MAP (flistxattr); |
| 667 | SYSCALL_MAP (removexattr); |
| 668 | SYSCALL_MAP (lremovexattr); |
| 669 | SYSCALL_MAP (fremovexattr); |
| 670 | SYSCALL_MAP (getcwd); |
| 671 | SYSCALL_MAP (lookup_dcookie); |
| 672 | |
| 673 | case aarch64_sys_epoll_create1: |
| 674 | return gdb_sys_epoll_create; |
| 675 | |
| 676 | SYSCALL_MAP (epoll_ctl); |
| 677 | SYSCALL_MAP (epoll_pwait); |
| 678 | SYSCALL_MAP (dup); |
| 679 | SYSCALL_MAP (fcntl); |
| 680 | SYSCALL_MAP (inotify_add_watch); |
| 681 | SYSCALL_MAP (inotify_rm_watch); |
| 682 | SYSCALL_MAP (ioctl); |
| 683 | SYSCALL_MAP (ioprio_set); |
| 684 | SYSCALL_MAP (ioprio_get); |
| 685 | SYSCALL_MAP (flock); |
| 686 | SYSCALL_MAP (mount); |
| 687 | SYSCALL_MAP (nfsservctl); |
| 688 | SYSCALL_MAP (statfs); |
| 689 | SYSCALL_MAP (truncate); |
| 690 | SYSCALL_MAP (ftruncate); |
| 691 | SYSCALL_MAP (fchdir); |
| 692 | SYSCALL_MAP (chroot); |
| 693 | SYSCALL_MAP (fchmod); |
| 694 | SYSCALL_MAP (fchmodat); |
| 695 | SYSCALL_MAP (fchownat); |
| 696 | SYSCALL_MAP (fchown); |
| 697 | SYSCALL_MAP (close); |
| 698 | SYSCALL_MAP (vhangup); |
| 699 | SYSCALL_MAP (quotactl); |
| 700 | SYSCALL_MAP (getdents64); |
| 701 | SYSCALL_MAP (lseek); |
| 702 | SYSCALL_MAP (read); |
| 703 | SYSCALL_MAP (write); |
| 704 | SYSCALL_MAP (readv); |
| 705 | SYSCALL_MAP (writev); |
| 706 | SYSCALL_MAP (pread64); |
| 707 | SYSCALL_MAP (pwrite64); |
| 708 | SYSCALL_MAP (sendfile); |
| 709 | SYSCALL_MAP (pselect6); |
| 710 | SYSCALL_MAP (ppoll); |
| 711 | SYSCALL_MAP (vmsplice); |
| 712 | SYSCALL_MAP (splice); |
| 713 | SYSCALL_MAP (tee); |
| 714 | SYSCALL_MAP (fstat); |
| 715 | SYSCALL_MAP (sync); |
| 716 | SYSCALL_MAP (fsync); |
| 717 | SYSCALL_MAP (fdatasync); |
| 718 | SYSCALL_MAP (sync_file_range); |
| 719 | SYSCALL_MAP (acct); |
| 720 | SYSCALL_MAP (capget); |
| 721 | SYSCALL_MAP (capset); |
| 722 | SYSCALL_MAP (personality); |
| 723 | SYSCALL_MAP (exit); |
| 724 | SYSCALL_MAP (exit_group); |
| 725 | SYSCALL_MAP (waitid); |
| 726 | SYSCALL_MAP (set_tid_address); |
| 727 | SYSCALL_MAP (unshare); |
| 728 | SYSCALL_MAP (futex); |
| 729 | SYSCALL_MAP (set_robust_list); |
| 730 | SYSCALL_MAP (get_robust_list); |
| 731 | SYSCALL_MAP (nanosleep); |
| 732 | |
| 733 | SYSCALL_MAP (getitimer); |
| 734 | SYSCALL_MAP (setitimer); |
| 735 | SYSCALL_MAP (kexec_load); |
| 736 | SYSCALL_MAP (init_module); |
| 737 | SYSCALL_MAP (delete_module); |
| 738 | SYSCALL_MAP (timer_create); |
| 739 | SYSCALL_MAP (timer_settime); |
| 740 | SYSCALL_MAP (timer_gettime); |
| 741 | SYSCALL_MAP (timer_getoverrun); |
| 742 | SYSCALL_MAP (timer_delete); |
| 743 | SYSCALL_MAP (clock_settime); |
| 744 | SYSCALL_MAP (clock_gettime); |
| 745 | SYSCALL_MAP (clock_getres); |
| 746 | SYSCALL_MAP (clock_nanosleep); |
| 747 | SYSCALL_MAP (syslog); |
| 748 | SYSCALL_MAP (ptrace); |
| 749 | SYSCALL_MAP (sched_setparam); |
| 750 | SYSCALL_MAP (sched_setscheduler); |
| 751 | SYSCALL_MAP (sched_getscheduler); |
| 752 | SYSCALL_MAP (sched_getparam); |
| 753 | SYSCALL_MAP (sched_setaffinity); |
| 754 | SYSCALL_MAP (sched_getaffinity); |
| 755 | SYSCALL_MAP (sched_yield); |
| 756 | SYSCALL_MAP (sched_get_priority_max); |
| 757 | SYSCALL_MAP (sched_get_priority_min); |
| 758 | SYSCALL_MAP (sched_rr_get_interval); |
| 759 | SYSCALL_MAP (kill); |
| 760 | SYSCALL_MAP (tkill); |
| 761 | SYSCALL_MAP (tgkill); |
| 762 | SYSCALL_MAP (sigaltstack); |
| 763 | SYSCALL_MAP (rt_sigsuspend); |
| 764 | SYSCALL_MAP (rt_sigaction); |
| 765 | SYSCALL_MAP (rt_sigprocmask); |
| 766 | SYSCALL_MAP (rt_sigpending); |
| 767 | SYSCALL_MAP (rt_sigtimedwait); |
| 768 | SYSCALL_MAP (rt_sigqueueinfo); |
| 769 | SYSCALL_MAP (rt_sigreturn); |
| 770 | SYSCALL_MAP (setpriority); |
| 771 | SYSCALL_MAP (getpriority); |
| 772 | SYSCALL_MAP (reboot); |
| 773 | SYSCALL_MAP (setregid); |
| 774 | SYSCALL_MAP (setgid); |
| 775 | SYSCALL_MAP (setreuid); |
| 776 | SYSCALL_MAP (setuid); |
| 777 | SYSCALL_MAP (setresuid); |
| 778 | SYSCALL_MAP (getresuid); |
| 779 | SYSCALL_MAP (setresgid); |
| 780 | SYSCALL_MAP (getresgid); |
| 781 | SYSCALL_MAP (setfsuid); |
| 782 | SYSCALL_MAP (setfsgid); |
| 783 | SYSCALL_MAP (times); |
| 784 | SYSCALL_MAP (setpgid); |
| 785 | SYSCALL_MAP (getpgid); |
| 786 | SYSCALL_MAP (getsid); |
| 787 | SYSCALL_MAP (setsid); |
| 788 | SYSCALL_MAP (getgroups); |
| 789 | SYSCALL_MAP (setgroups); |
| 790 | SYSCALL_MAP (uname); |
| 791 | SYSCALL_MAP (sethostname); |
| 792 | SYSCALL_MAP (setdomainname); |
| 793 | SYSCALL_MAP (getrlimit); |
| 794 | SYSCALL_MAP (setrlimit); |
| 795 | SYSCALL_MAP (getrusage); |
| 796 | SYSCALL_MAP (umask); |
| 797 | SYSCALL_MAP (prctl); |
| 798 | SYSCALL_MAP (gettimeofday); |
| 799 | SYSCALL_MAP (settimeofday); |
| 800 | SYSCALL_MAP (adjtimex); |
| 801 | SYSCALL_MAP (getpid); |
| 802 | SYSCALL_MAP (getppid); |
| 803 | SYSCALL_MAP (getuid); |
| 804 | SYSCALL_MAP (geteuid); |
| 805 | SYSCALL_MAP (getgid); |
| 806 | SYSCALL_MAP (getegid); |
| 807 | SYSCALL_MAP (gettid); |
| 808 | SYSCALL_MAP (sysinfo); |
| 809 | SYSCALL_MAP (mq_open); |
| 810 | SYSCALL_MAP (mq_unlink); |
| 811 | SYSCALL_MAP (mq_timedsend); |
| 812 | SYSCALL_MAP (mq_timedreceive); |
| 813 | SYSCALL_MAP (mq_notify); |
| 814 | SYSCALL_MAP (mq_getsetattr); |
| 815 | SYSCALL_MAP (msgget); |
| 816 | SYSCALL_MAP (msgctl); |
| 817 | SYSCALL_MAP (msgrcv); |
| 818 | SYSCALL_MAP (msgsnd); |
| 819 | SYSCALL_MAP (semget); |
| 820 | SYSCALL_MAP (semctl); |
| 821 | SYSCALL_MAP (semtimedop); |
| 822 | SYSCALL_MAP (semop); |
| 823 | SYSCALL_MAP (shmget); |
| 824 | SYSCALL_MAP (shmctl); |
| 825 | SYSCALL_MAP (shmat); |
| 826 | SYSCALL_MAP (shmdt); |
| 827 | SYSCALL_MAP (socket); |
| 828 | SYSCALL_MAP (socketpair); |
| 829 | SYSCALL_MAP (bind); |
| 830 | SYSCALL_MAP (listen); |
| 831 | SYSCALL_MAP (accept); |
| 832 | SYSCALL_MAP (connect); |
| 833 | SYSCALL_MAP (getsockname); |
| 834 | SYSCALL_MAP (getpeername); |
| 835 | SYSCALL_MAP (sendto); |
| 836 | SYSCALL_MAP (recvfrom); |
| 837 | SYSCALL_MAP (setsockopt); |
| 838 | SYSCALL_MAP (getsockopt); |
| 839 | SYSCALL_MAP (shutdown); |
| 840 | SYSCALL_MAP (sendmsg); |
| 841 | SYSCALL_MAP (recvmsg); |
| 842 | SYSCALL_MAP (readahead); |
| 843 | SYSCALL_MAP (brk); |
| 844 | SYSCALL_MAP (munmap); |
| 845 | SYSCALL_MAP (mremap); |
| 846 | SYSCALL_MAP (add_key); |
| 847 | SYSCALL_MAP (request_key); |
| 848 | SYSCALL_MAP (keyctl); |
| 849 | SYSCALL_MAP (clone); |
| 850 | SYSCALL_MAP (execve); |
| 851 | |
| 852 | case aarch64_sys_mmap: |
| 853 | return gdb_sys_mmap2; |
| 854 | |
| 855 | SYSCALL_MAP (fadvise64); |
| 856 | SYSCALL_MAP (swapon); |
| 857 | SYSCALL_MAP (swapoff); |
| 858 | SYSCALL_MAP (mprotect); |
| 859 | SYSCALL_MAP (msync); |
| 860 | SYSCALL_MAP (mlock); |
| 861 | SYSCALL_MAP (munlock); |
| 862 | SYSCALL_MAP (mlockall); |
| 863 | SYSCALL_MAP (munlockall); |
| 864 | SYSCALL_MAP (mincore); |
| 865 | SYSCALL_MAP (madvise); |
| 866 | SYSCALL_MAP (remap_file_pages); |
| 867 | SYSCALL_MAP (mbind); |
| 868 | SYSCALL_MAP (get_mempolicy); |
| 869 | SYSCALL_MAP (set_mempolicy); |
| 870 | SYSCALL_MAP (migrate_pages); |
| 871 | SYSCALL_MAP (move_pages); |
| 872 | |
| 873 | default: |
| 874 | return -1; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | /* Record all registers but PC register for process-record. */ |
| 879 | |
| 880 | static int |
| 881 | aarch64_all_but_pc_registers_record (struct regcache *regcache) |
| 882 | { |
| 883 | int i; |
| 884 | |
| 885 | for (i = AARCH64_X0_REGNUM; i < AARCH64_PC_REGNUM; i++) |
| 886 | if (record_full_arch_list_add_reg (regcache, i)) |
| 887 | return -1; |
| 888 | |
| 889 | if (record_full_arch_list_add_reg (regcache, AARCH64_CPSR_REGNUM)) |
| 890 | return -1; |
| 891 | |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | /* Handler for aarch64 system call instruction recording. */ |
| 896 | |
| 897 | static int |
| 898 | aarch64_linux_syscall_record (struct regcache *regcache, |
| 899 | unsigned long svc_number) |
| 900 | { |
| 901 | int ret = 0; |
| 902 | enum gdb_syscall syscall_gdb; |
| 903 | |
| 904 | syscall_gdb = aarch64_canonicalize_syscall (svc_number); |
| 905 | |
| 906 | if (syscall_gdb < 0) |
| 907 | { |
| 908 | printf_unfiltered (_("Process record and replay target doesn't " |
| 909 | "support syscall number %s\n"), |
| 910 | plongest (svc_number)); |
| 911 | return -1; |
| 912 | } |
| 913 | |
| 914 | if (syscall_gdb == gdb_sys_sigreturn |
| 915 | || syscall_gdb == gdb_sys_rt_sigreturn) |
| 916 | { |
| 917 | if (aarch64_all_but_pc_registers_record (regcache)) |
| 918 | return -1; |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | ret = record_linux_system_call (syscall_gdb, regcache, |
| 923 | &aarch64_linux_record_tdep); |
| 924 | if (ret != 0) |
| 925 | return ret; |
| 926 | |
| 927 | /* Record the return value of the system call. */ |
| 928 | if (record_full_arch_list_add_reg (regcache, AARCH64_X0_REGNUM)) |
| 929 | return -1; |
| 930 | /* Record LR. */ |
| 931 | if (record_full_arch_list_add_reg (regcache, AARCH64_LR_REGNUM)) |
| 932 | return -1; |
| 933 | /* Record CPSR. */ |
| 934 | if (record_full_arch_list_add_reg (regcache, AARCH64_CPSR_REGNUM)) |
| 935 | return -1; |
| 936 | |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | static void |
| 941 | aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
| 942 | { |
| 943 | static const char *const stap_integer_prefixes[] = { "#", "", NULL }; |
| 944 | static const char *const stap_register_prefixes[] = { "", NULL }; |
| 945 | static const char *const stap_register_indirection_prefixes[] = { "[", |
| 946 | NULL }; |
| 947 | static const char *const stap_register_indirection_suffixes[] = { "]", |
| 948 | NULL }; |
| 949 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
| 950 | |
| 951 | tdep->lowest_pc = 0x8000; |
| 952 | |
| 953 | linux_init_abi (info, gdbarch); |
| 954 | |
| 955 | set_solib_svr4_fetch_link_map_offsets (gdbarch, |
| 956 | svr4_lp64_fetch_link_map_offsets); |
| 957 | |
| 958 | /* Enable TLS support. */ |
| 959 | set_gdbarch_fetch_tls_load_module_address (gdbarch, |
| 960 | svr4_fetch_objfile_link_map); |
| 961 | |
| 962 | /* Shared library handling. */ |
| 963 | set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); |
| 964 | set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); |
| 965 | |
| 966 | tramp_frame_prepend_unwinder (gdbarch, &aarch64_linux_rt_sigframe); |
| 967 | |
| 968 | /* Enable longjmp. */ |
| 969 | tdep->jb_pc = 11; |
| 970 | |
| 971 | set_gdbarch_iterate_over_regset_sections |
| 972 | (gdbarch, aarch64_linux_iterate_over_regset_sections); |
| 973 | |
| 974 | /* SystemTap related. */ |
| 975 | set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes); |
| 976 | set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes); |
| 977 | set_gdbarch_stap_register_indirection_prefixes (gdbarch, |
| 978 | stap_register_indirection_prefixes); |
| 979 | set_gdbarch_stap_register_indirection_suffixes (gdbarch, |
| 980 | stap_register_indirection_suffixes); |
| 981 | set_gdbarch_stap_is_single_operand (gdbarch, aarch64_stap_is_single_operand); |
| 982 | set_gdbarch_stap_parse_special_token (gdbarch, |
| 983 | aarch64_stap_parse_special_token); |
| 984 | |
| 985 | /* Reversible debugging, process record. */ |
| 986 | set_gdbarch_process_record (gdbarch, aarch64_process_record); |
| 987 | /* Syscall record. */ |
| 988 | tdep->aarch64_syscall_record = aarch64_linux_syscall_record; |
| 989 | |
| 990 | /* Initialize the aarch64_linux_record_tdep. */ |
| 991 | /* These values are the size of the type that will be used in a system |
| 992 | call. They are obtained from Linux Kernel source. */ |
| 993 | aarch64_linux_record_tdep.size_pointer |
| 994 | = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; |
| 995 | aarch64_linux_record_tdep.size__old_kernel_stat = 32; |
| 996 | aarch64_linux_record_tdep.size_tms = 32; |
| 997 | aarch64_linux_record_tdep.size_loff_t = 8; |
| 998 | aarch64_linux_record_tdep.size_flock = 32; |
| 999 | aarch64_linux_record_tdep.size_oldold_utsname = 45; |
| 1000 | aarch64_linux_record_tdep.size_ustat = 32; |
| 1001 | aarch64_linux_record_tdep.size_old_sigaction = 152; |
| 1002 | aarch64_linux_record_tdep.size_old_sigset_t = 128; |
| 1003 | aarch64_linux_record_tdep.size_rlimit = 16; |
| 1004 | aarch64_linux_record_tdep.size_rusage = 144; |
| 1005 | aarch64_linux_record_tdep.size_timeval = 16; |
| 1006 | aarch64_linux_record_tdep.size_timezone = 8; |
| 1007 | aarch64_linux_record_tdep.size_old_gid_t = 2; |
| 1008 | aarch64_linux_record_tdep.size_old_uid_t = 2; |
| 1009 | aarch64_linux_record_tdep.size_fd_set = 128; |
| 1010 | aarch64_linux_record_tdep.size_dirent = 280; |
| 1011 | aarch64_linux_record_tdep.size_dirent64 = 280; |
| 1012 | aarch64_linux_record_tdep.size_statfs = 120; |
| 1013 | aarch64_linux_record_tdep.size_statfs64 = 120; |
| 1014 | aarch64_linux_record_tdep.size_sockaddr = 16; |
| 1015 | aarch64_linux_record_tdep.size_int |
| 1016 | = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT; |
| 1017 | aarch64_linux_record_tdep.size_long |
| 1018 | = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; |
| 1019 | aarch64_linux_record_tdep.size_ulong |
| 1020 | = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; |
| 1021 | aarch64_linux_record_tdep.size_msghdr = 56; |
| 1022 | aarch64_linux_record_tdep.size_itimerval = 32; |
| 1023 | aarch64_linux_record_tdep.size_stat = 144; |
| 1024 | aarch64_linux_record_tdep.size_old_utsname = 325; |
| 1025 | aarch64_linux_record_tdep.size_sysinfo = 112; |
| 1026 | aarch64_linux_record_tdep.size_msqid_ds = 120; |
| 1027 | aarch64_linux_record_tdep.size_shmid_ds = 112; |
| 1028 | aarch64_linux_record_tdep.size_new_utsname = 390; |
| 1029 | aarch64_linux_record_tdep.size_timex = 208; |
| 1030 | aarch64_linux_record_tdep.size_mem_dqinfo = 24; |
| 1031 | aarch64_linux_record_tdep.size_if_dqblk = 72; |
| 1032 | aarch64_linux_record_tdep.size_fs_quota_stat = 80; |
| 1033 | aarch64_linux_record_tdep.size_timespec = 16; |
| 1034 | aarch64_linux_record_tdep.size_pollfd = 8; |
| 1035 | aarch64_linux_record_tdep.size_NFS_FHSIZE = 32; |
| 1036 | aarch64_linux_record_tdep.size_knfsd_fh = 132; |
| 1037 | aarch64_linux_record_tdep.size_TASK_COMM_LEN = 16; |
| 1038 | aarch64_linux_record_tdep.size_sigaction = 152; |
| 1039 | aarch64_linux_record_tdep.size_sigset_t = 128; |
| 1040 | aarch64_linux_record_tdep.size_siginfo_t = 128; |
| 1041 | aarch64_linux_record_tdep.size_cap_user_data_t = 8; |
| 1042 | aarch64_linux_record_tdep.size_stack_t = 24; |
| 1043 | aarch64_linux_record_tdep.size_off_t = 8; |
| 1044 | aarch64_linux_record_tdep.size_stat64 = 144; |
| 1045 | aarch64_linux_record_tdep.size_gid_t = 4; |
| 1046 | aarch64_linux_record_tdep.size_uid_t = 4; |
| 1047 | aarch64_linux_record_tdep.size_PAGE_SIZE = 4096; |
| 1048 | aarch64_linux_record_tdep.size_flock64 = 32; |
| 1049 | aarch64_linux_record_tdep.size_user_desc = 16; |
| 1050 | aarch64_linux_record_tdep.size_io_event = 32; |
| 1051 | aarch64_linux_record_tdep.size_iocb = 64; |
| 1052 | aarch64_linux_record_tdep.size_epoll_event = 12; |
| 1053 | aarch64_linux_record_tdep.size_itimerspec = 32; |
| 1054 | aarch64_linux_record_tdep.size_mq_attr = 64; |
| 1055 | aarch64_linux_record_tdep.size_siginfo = 128; |
| 1056 | aarch64_linux_record_tdep.size_termios = 60; |
| 1057 | aarch64_linux_record_tdep.size_termios2 = 44; |
| 1058 | aarch64_linux_record_tdep.size_pid_t = 4; |
| 1059 | aarch64_linux_record_tdep.size_winsize = 8; |
| 1060 | aarch64_linux_record_tdep.size_serial_struct = 72; |
| 1061 | aarch64_linux_record_tdep.size_serial_icounter_struct = 80; |
| 1062 | aarch64_linux_record_tdep.size_hayes_esp_config = 12; |
| 1063 | aarch64_linux_record_tdep.size_size_t = 8; |
| 1064 | aarch64_linux_record_tdep.size_iovec = 16; |
| 1065 | |
| 1066 | /* These values are the second argument of system call "sys_ioctl". |
| 1067 | They are obtained from Linux Kernel source. */ |
| 1068 | aarch64_linux_record_tdep.ioctl_TCGETS = 0x5401; |
| 1069 | aarch64_linux_record_tdep.ioctl_TCSETS = 0x5402; |
| 1070 | aarch64_linux_record_tdep.ioctl_TCSETSW = 0x5403; |
| 1071 | aarch64_linux_record_tdep.ioctl_TCSETSF = 0x5404; |
| 1072 | aarch64_linux_record_tdep.ioctl_TCGETA = 0x5405; |
| 1073 | aarch64_linux_record_tdep.ioctl_TCSETA = 0x5406; |
| 1074 | aarch64_linux_record_tdep.ioctl_TCSETAW = 0x5407; |
| 1075 | aarch64_linux_record_tdep.ioctl_TCSETAF = 0x5408; |
| 1076 | aarch64_linux_record_tdep.ioctl_TCSBRK = 0x5409; |
| 1077 | aarch64_linux_record_tdep.ioctl_TCXONC = 0x540a; |
| 1078 | aarch64_linux_record_tdep.ioctl_TCFLSH = 0x540b; |
| 1079 | aarch64_linux_record_tdep.ioctl_TIOCEXCL = 0x540c; |
| 1080 | aarch64_linux_record_tdep.ioctl_TIOCNXCL = 0x540d; |
| 1081 | aarch64_linux_record_tdep.ioctl_TIOCSCTTY = 0x540e; |
| 1082 | aarch64_linux_record_tdep.ioctl_TIOCGPGRP = 0x540f; |
| 1083 | aarch64_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410; |
| 1084 | aarch64_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411; |
| 1085 | aarch64_linux_record_tdep.ioctl_TIOCSTI = 0x5412; |
| 1086 | aarch64_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413; |
| 1087 | aarch64_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414; |
| 1088 | aarch64_linux_record_tdep.ioctl_TIOCMGET = 0x5415; |
| 1089 | aarch64_linux_record_tdep.ioctl_TIOCMBIS = 0x5416; |
| 1090 | aarch64_linux_record_tdep.ioctl_TIOCMBIC = 0x5417; |
| 1091 | aarch64_linux_record_tdep.ioctl_TIOCMSET = 0x5418; |
| 1092 | aarch64_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419; |
| 1093 | aarch64_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541a; |
| 1094 | aarch64_linux_record_tdep.ioctl_FIONREAD = 0x541b; |
| 1095 | aarch64_linux_record_tdep.ioctl_TIOCINQ = 0x541b; |
| 1096 | aarch64_linux_record_tdep.ioctl_TIOCLINUX = 0x541c; |
| 1097 | aarch64_linux_record_tdep.ioctl_TIOCCONS = 0x541d; |
| 1098 | aarch64_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541e; |
| 1099 | aarch64_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541f; |
| 1100 | aarch64_linux_record_tdep.ioctl_TIOCPKT = 0x5420; |
| 1101 | aarch64_linux_record_tdep.ioctl_FIONBIO = 0x5421; |
| 1102 | aarch64_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422; |
| 1103 | aarch64_linux_record_tdep.ioctl_TIOCSETD = 0x5423; |
| 1104 | aarch64_linux_record_tdep.ioctl_TIOCGETD = 0x5424; |
| 1105 | aarch64_linux_record_tdep.ioctl_TCSBRKP = 0x5425; |
| 1106 | aarch64_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426; |
| 1107 | aarch64_linux_record_tdep.ioctl_TIOCSBRK = 0x5427; |
| 1108 | aarch64_linux_record_tdep.ioctl_TIOCCBRK = 0x5428; |
| 1109 | aarch64_linux_record_tdep.ioctl_TIOCGSID = 0x5429; |
| 1110 | aarch64_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a; |
| 1111 | aarch64_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b; |
| 1112 | aarch64_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c; |
| 1113 | aarch64_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d; |
| 1114 | aarch64_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430; |
| 1115 | aarch64_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431; |
| 1116 | aarch64_linux_record_tdep.ioctl_FIONCLEX = 0x5450; |
| 1117 | aarch64_linux_record_tdep.ioctl_FIOCLEX = 0x5451; |
| 1118 | aarch64_linux_record_tdep.ioctl_FIOASYNC = 0x5452; |
| 1119 | aarch64_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453; |
| 1120 | aarch64_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454; |
| 1121 | aarch64_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455; |
| 1122 | aarch64_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456; |
| 1123 | aarch64_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457; |
| 1124 | aarch64_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458; |
| 1125 | aarch64_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459; |
| 1126 | aarch64_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545a; |
| 1127 | aarch64_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545b; |
| 1128 | aarch64_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545c; |
| 1129 | aarch64_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545d; |
| 1130 | aarch64_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545e; |
| 1131 | aarch64_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545f; |
| 1132 | aarch64_linux_record_tdep.ioctl_FIOQSIZE = 0x5460; |
| 1133 | |
| 1134 | /* These values are the second argument of system call "sys_fcntl" |
| 1135 | and "sys_fcntl64". They are obtained from Linux Kernel source. */ |
| 1136 | aarch64_linux_record_tdep.fcntl_F_GETLK = 5; |
| 1137 | aarch64_linux_record_tdep.fcntl_F_GETLK64 = 12; |
| 1138 | aarch64_linux_record_tdep.fcntl_F_SETLK64 = 13; |
| 1139 | aarch64_linux_record_tdep.fcntl_F_SETLKW64 = 14; |
| 1140 | |
| 1141 | /* The AArch64 syscall calling convention: reg x0-x6 for arguments, |
| 1142 | reg x8 for syscall number and return value in reg x0. */ |
| 1143 | aarch64_linux_record_tdep.arg1 = AARCH64_X0_REGNUM + 0; |
| 1144 | aarch64_linux_record_tdep.arg2 = AARCH64_X0_REGNUM + 1; |
| 1145 | aarch64_linux_record_tdep.arg3 = AARCH64_X0_REGNUM + 2; |
| 1146 | aarch64_linux_record_tdep.arg4 = AARCH64_X0_REGNUM + 3; |
| 1147 | aarch64_linux_record_tdep.arg5 = AARCH64_X0_REGNUM + 4; |
| 1148 | aarch64_linux_record_tdep.arg6 = AARCH64_X0_REGNUM + 5; |
| 1149 | aarch64_linux_record_tdep.arg7 = AARCH64_X0_REGNUM + 6; |
| 1150 | |
| 1151 | /* `catch syscall' */ |
| 1152 | set_xml_syscall_file_name (gdbarch, "syscalls/aarch64-linux.xml"); |
| 1153 | set_gdbarch_get_syscall_number (gdbarch, aarch64_linux_get_syscall_number); |
| 1154 | } |
| 1155 | |
| 1156 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
| 1157 | extern initialize_file_ftype _initialize_aarch64_linux_tdep; |
| 1158 | |
| 1159 | void |
| 1160 | _initialize_aarch64_linux_tdep (void) |
| 1161 | { |
| 1162 | gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX, |
| 1163 | aarch64_linux_init_abi); |
| 1164 | } |