[gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change
[external/binutils.git] / gdb / gdbserver / linux-aarch64-low.c
1 /* GNU/Linux/AArch64 specific low level interface, for the remote server for
2    GDB.
3
4    Copyright (C) 2009-2015 Free Software Foundation, Inc.
5    Contributed by ARM Ltd.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
22 #include "server.h"
23 #include "linux-low.h"
24 #include "nat/aarch64-linux-hw-point.h"
25 #include "linux-aarch32-low.h"
26 #include "elf/common.h"
27
28 #include <signal.h>
29 #include <sys/user.h>
30 #include "nat/gdb_ptrace.h"
31 #include <asm/ptrace.h>
32 #include <sys/uio.h>
33
34 #include "gdb_proc_service.h"
35
36 /* Defined in auto-generated files.  */
37 void init_registers_aarch64 (void);
38 extern const struct target_desc *tdesc_aarch64;
39
40 #ifdef HAVE_SYS_REG_H
41 #include <sys/reg.h>
42 #endif
43
44 #define AARCH64_X_REGS_NUM 31
45 #define AARCH64_V_REGS_NUM 32
46 #define AARCH64_X0_REGNO    0
47 #define AARCH64_SP_REGNO   31
48 #define AARCH64_PC_REGNO   32
49 #define AARCH64_CPSR_REGNO 33
50 #define AARCH64_V0_REGNO   34
51 #define AARCH64_FPSR_REGNO (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM)
52 #define AARCH64_FPCR_REGNO (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 1)
53
54 #define AARCH64_NUM_REGS (AARCH64_V0_REGNO + AARCH64_V_REGS_NUM + 2)
55
56 /* Per-process arch-specific data we want to keep.  */
57
58 struct arch_process_info
59 {
60   /* Hardware breakpoint/watchpoint data.
61      The reason for them to be per-process rather than per-thread is
62      due to the lack of information in the gdbserver environment;
63      gdbserver is not told that whether a requested hardware
64      breakpoint/watchpoint is thread specific or not, so it has to set
65      each hw bp/wp for every thread in the current process.  The
66      higher level bp/wp management in gdb will resume a thread if a hw
67      bp/wp trap is not expected for it.  Since the hw bp/wp setting is
68      same for each thread, it is reasonable for the data to live here.
69      */
70   struct aarch64_debug_reg_state debug_reg_state;
71 };
72
73 /* Return true if the size of register 0 is 8 byte.  */
74
75 static int
76 is_64bit_tdesc (void)
77 {
78   struct regcache *regcache = get_thread_regcache (current_thread, 0);
79
80   return register_size (regcache->tdesc, 0) == 8;
81 }
82
83 /* Implementation of linux_target_ops method "cannot_store_register".  */
84
85 static int
86 aarch64_cannot_store_register (int regno)
87 {
88   return regno >= AARCH64_NUM_REGS;
89 }
90
91 /* Implementation of linux_target_ops method "cannot_fetch_register".  */
92
93 static int
94 aarch64_cannot_fetch_register (int regno)
95 {
96   return regno >= AARCH64_NUM_REGS;
97 }
98
99 static void
100 aarch64_fill_gregset (struct regcache *regcache, void *buf)
101 {
102   struct user_pt_regs *regset = buf;
103   int i;
104
105   for (i = 0; i < AARCH64_X_REGS_NUM; i++)
106     collect_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
107   collect_register (regcache, AARCH64_SP_REGNO, &regset->sp);
108   collect_register (regcache, AARCH64_PC_REGNO, &regset->pc);
109   collect_register (regcache, AARCH64_CPSR_REGNO, &regset->pstate);
110 }
111
112 static void
113 aarch64_store_gregset (struct regcache *regcache, const void *buf)
114 {
115   const struct user_pt_regs *regset = buf;
116   int i;
117
118   for (i = 0; i < AARCH64_X_REGS_NUM; i++)
119     supply_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
120   supply_register (regcache, AARCH64_SP_REGNO, &regset->sp);
121   supply_register (regcache, AARCH64_PC_REGNO, &regset->pc);
122   supply_register (regcache, AARCH64_CPSR_REGNO, &regset->pstate);
123 }
124
125 static void
126 aarch64_fill_fpregset (struct regcache *regcache, void *buf)
127 {
128   struct user_fpsimd_state *regset = buf;
129   int i;
130
131   for (i = 0; i < AARCH64_V_REGS_NUM; i++)
132     collect_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
133   collect_register (regcache, AARCH64_FPSR_REGNO, &regset->fpsr);
134   collect_register (regcache, AARCH64_FPCR_REGNO, &regset->fpcr);
135 }
136
137 static void
138 aarch64_store_fpregset (struct regcache *regcache, const void *buf)
139 {
140   const struct user_fpsimd_state *regset = buf;
141   int i;
142
143   for (i = 0; i < AARCH64_V_REGS_NUM; i++)
144     supply_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
145   supply_register (regcache, AARCH64_FPSR_REGNO, &regset->fpsr);
146   supply_register (regcache, AARCH64_FPCR_REGNO, &regset->fpcr);
147 }
148
149 /* Enable miscellaneous debugging output.  The name is historical - it
150    was originally used to debug LinuxThreads support.  */
151 extern int debug_threads;
152
153 /* Implementation of linux_target_ops method "get_pc".  */
154
155 static CORE_ADDR
156 aarch64_get_pc (struct regcache *regcache)
157 {
158   if (register_size (regcache->tdesc, 0) == 8)
159     {
160       unsigned long pc;
161
162       collect_register_by_name (regcache, "pc", &pc);
163       if (debug_threads)
164         debug_printf ("stop pc is %08lx\n", pc);
165       return pc;
166     }
167   else
168     {
169       unsigned int pc;
170
171       collect_register_by_name (regcache, "pc", &pc);
172       if (debug_threads)
173         debug_printf ("stop pc is %04x\n", pc);
174       return pc;
175     }
176 }
177
178 /* Implementation of linux_target_ops method "set_pc".  */
179
180 static void
181 aarch64_set_pc (struct regcache *regcache, CORE_ADDR pc)
182 {
183   if (register_size (regcache->tdesc, 0) == 8)
184     {
185       unsigned long newpc = pc;
186       supply_register_by_name (regcache, "pc", &newpc);
187     }
188   else
189     {
190       unsigned int newpc = pc;
191       supply_register_by_name (regcache, "pc", &newpc);
192     }
193 }
194
195 #define aarch64_breakpoint_len 4
196
197 /* AArch64 BRK software debug mode instruction.
198    This instruction needs to match gdb/aarch64-tdep.c
199    (aarch64_default_breakpoint).  */
200 static const gdb_byte aarch64_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};
201
202 /* Implementation of linux_target_ops method "breakpoint_at".  */
203
204 static int
205 aarch64_breakpoint_at (CORE_ADDR where)
206 {
207   gdb_byte insn[aarch64_breakpoint_len];
208
209   (*the_target->read_memory) (where, (unsigned char *) &insn,
210                               aarch64_breakpoint_len);
211   if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
212     return 1;
213
214   return 0;
215 }
216
217 static void
218 aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
219 {
220   int i;
221
222   for (i = 0; i < AARCH64_HBP_MAX_NUM; ++i)
223     {
224       state->dr_addr_bp[i] = 0;
225       state->dr_ctrl_bp[i] = 0;
226       state->dr_ref_count_bp[i] = 0;
227     }
228
229   for (i = 0; i < AARCH64_HWP_MAX_NUM; ++i)
230     {
231       state->dr_addr_wp[i] = 0;
232       state->dr_ctrl_wp[i] = 0;
233       state->dr_ref_count_wp[i] = 0;
234     }
235 }
236
237 struct aarch64_dr_update_callback_param
238 {
239   int is_watchpoint;
240   unsigned int idx;
241 };
242
243 /* Callback for iterate_over_lwps.  Records the
244    information about the change of one hardware breakpoint/watchpoint
245    setting for the thread LWP.
246    The information is passed in via PTR.
247    N.B.  The actual updating of hardware debug registers is not
248    carried out until the moment the thread is resumed.  */
249
250 static int
251 debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
252 {
253   struct aarch64_dr_update_callback_param *param_p
254     = (struct aarch64_dr_update_callback_param *) ptr;
255   int pid = pid_of (lwp->thread);
256   int idx = param_p->idx;
257   int is_watchpoint = param_p->is_watchpoint;
258   struct arch_lwp_info *info = lwp->arch_private;
259   dr_changed_t *dr_changed_ptr;
260   dr_changed_t dr_changed;
261
262   if (show_debug_regs)
263     {
264       fprintf (stderr, "debug_reg_change_callback: \n\tOn entry:\n");
265       fprintf (stderr, "\tpid%d, dr_changed_bp=0x%llx, "
266                "dr_changed_wp=0x%llx\n",
267                pid, info->dr_changed_bp,
268                info->dr_changed_wp);
269     }
270
271   dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
272     : &info->dr_changed_bp;
273   dr_changed = *dr_changed_ptr;
274
275       gdb_assert (idx >= 0
276                   && (idx <= (is_watchpoint ? aarch64_num_wp_regs
277                               : aarch64_num_bp_regs)));
278
279       /* The following assertion is not right, as there can be changes
280          that have not been made to the hardware debug registers
281          before new changes overwrite the old ones.  This can happen,
282          for instance, when the breakpoint/watchpoint hit one of the
283          threads and the user enters continue; then what happens is:
284          1) all breakpoints/watchpoints are removed for all threads;
285          2) a single step is carried out for the thread that was hit;
286          3) all of the points are inserted again for all threads;
287          4) all threads are resumed.
288          The 2nd step will only affect the one thread in which the
289          bp/wp was hit, which means only that one thread is resumed;
290          remember that the actual updating only happen in
291          aarch64_linux_prepare_to_resume, so other threads remain
292          stopped during the removal and insertion of bp/wp.  Therefore
293          for those threads, the change of insertion of the bp/wp
294          overwrites that of the earlier removals.  (The situation may
295          be different when bp/wp is steppable, or in the non-stop
296          mode.)  */
297       /* gdb_assert (DR_N_HAS_CHANGED (dr_changed, idx) == 0);  */
298
299       /* The actual update is done later just before resuming the lwp,
300          we just mark that one register pair needs updating.  */
301       DR_MARK_N_CHANGED (dr_changed, idx);
302       *dr_changed_ptr = dr_changed;
303
304       /* If the lwp isn't stopped, force it to momentarily pause, so
305          we can update its debug registers.  */
306       if (!lwp->stopped)
307         linux_stop_lwp (lwp);
308
309   if (show_debug_regs)
310     {
311       fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%llx, "
312                "dr_changed_wp=0x%llx\n",
313                pid, info->dr_changed_bp,
314                info->dr_changed_wp);
315     }
316
317   return 0;
318 }
319
320 /* Notify each thread that their IDXth breakpoint/watchpoint register
321    pair needs to be updated.  The message will be recorded in each
322    thread's arch-specific data area, the actual updating will be done
323    when the thread is resumed.  */
324
325 void
326 aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
327                                  int is_watchpoint, unsigned int idx)
328 {
329   struct aarch64_dr_update_callback_param param;
330   ptid_t pid_ptid = pid_to_ptid (pid_of (current_thread));
331
332   param.is_watchpoint = is_watchpoint;
333   param.idx = idx;
334
335   iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
336 }
337
338
339 /* Return the pointer to the debug register state structure in the
340    current process' arch-specific data area.  */
341
342 static struct aarch64_debug_reg_state *
343 aarch64_get_debug_reg_state ()
344 {
345   struct process_info *proc;
346
347   proc = current_process ();
348   return &proc->priv->arch_private->debug_reg_state;
349 }
350
351 /* Implementation of linux_target_ops method "supports_z_point_type".  */
352
353 static int
354 aarch64_supports_z_point_type (char z_type)
355 {
356   switch (z_type)
357     {
358     case Z_PACKET_SW_BP:
359       {
360         if (!extended_protocol && is_64bit_tdesc ())
361           {
362             /* Only enable Z0 packet in non-multi-arch debugging.  If
363                extended protocol is used, don't enable Z0 packet because
364                GDBserver may attach to 32-bit process.  */
365             return 1;
366           }
367         else
368           {
369             /* Disable Z0 packet so that GDBserver doesn't have to handle
370                different breakpoint instructions (aarch64, arm, thumb etc)
371                in multi-arch debugging.  */
372             return 0;
373           }
374       }
375     case Z_PACKET_HW_BP:
376     case Z_PACKET_WRITE_WP:
377     case Z_PACKET_READ_WP:
378     case Z_PACKET_ACCESS_WP:
379       return 1;
380     default:
381       return 0;
382     }
383 }
384
385 /* Implementation of linux_target_ops method "insert_point".
386
387    It actually only records the info of the to-be-inserted bp/wp;
388    the actual insertion will happen when threads are resumed.  */
389
390 static int
391 aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
392                       int len, struct raw_breakpoint *bp)
393 {
394   int ret;
395   enum target_hw_bp_type targ_type;
396   struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
397
398   if (show_debug_regs)
399     fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n",
400              (unsigned long) addr, len);
401
402   /* Determine the type from the raw breakpoint type.  */
403   targ_type = raw_bkpt_type_to_target_hw_bp_type (type);
404
405   if (targ_type != hw_execute)
406     ret =
407       aarch64_handle_watchpoint (targ_type, addr, len, 1 /* is_insert */,
408                                  state);
409   else
410     ret =
411       aarch64_handle_breakpoint (targ_type, addr, len, 1 /* is_insert */,
412                                  state);
413
414   if (show_debug_regs)
415     aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
416                                   "insert_point", addr, len, targ_type);
417
418   return ret;
419 }
420
421 /* Implementation of linux_target_ops method "remove_point".
422
423    It actually only records the info of the to-be-removed bp/wp,
424    the actual removal will be done when threads are resumed.  */
425
426 static int
427 aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
428                       int len, struct raw_breakpoint *bp)
429 {
430   int ret;
431   enum target_hw_bp_type targ_type;
432   struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
433
434   if (show_debug_regs)
435     fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n",
436              (unsigned long) addr, len);
437
438   /* Determine the type from the raw breakpoint type.  */
439   targ_type = raw_bkpt_type_to_target_hw_bp_type (type);
440
441   /* Set up state pointers.  */
442   if (targ_type != hw_execute)
443     ret =
444       aarch64_handle_watchpoint (targ_type, addr, len, 0 /* is_insert */,
445                                  state);
446   else
447     ret =
448       aarch64_handle_breakpoint (targ_type, addr, len, 0 /* is_insert */,
449                                  state);
450
451   if (show_debug_regs)
452     aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
453                                   "remove_point", addr, len, targ_type);
454
455   return ret;
456 }
457
458 /* Implementation of linux_target_ops method "stopped_data_address".  */
459
460 static CORE_ADDR
461 aarch64_stopped_data_address (void)
462 {
463   siginfo_t siginfo;
464   int pid, i;
465   struct aarch64_debug_reg_state *state;
466
467   pid = lwpid_of (current_thread);
468
469   /* Get the siginfo.  */
470   if (ptrace (PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0)
471     return (CORE_ADDR) 0;
472
473   /* Need to be a hardware breakpoint/watchpoint trap.  */
474   if (siginfo.si_signo != SIGTRAP
475       || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
476     return (CORE_ADDR) 0;
477
478   /* Check if the address matches any watched address.  */
479   state = aarch64_get_debug_reg_state ();
480   for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
481     {
482       const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
483       const CORE_ADDR addr_trap = (CORE_ADDR) siginfo.si_addr;
484       const CORE_ADDR addr_watch = state->dr_addr_wp[i];
485       if (state->dr_ref_count_wp[i]
486           && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
487           && addr_trap >= addr_watch
488           && addr_trap < addr_watch + len)
489         return addr_trap;
490     }
491
492   return (CORE_ADDR) 0;
493 }
494
495 /* Implementation of linux_target_ops method "stopped_by_watchpoint".  */
496
497 static int
498 aarch64_stopped_by_watchpoint (void)
499 {
500   if (aarch64_stopped_data_address () != 0)
501     return 1;
502   else
503     return 0;
504 }
505
506 /* Fetch the thread-local storage pointer for libthread_db.  */
507
508 ps_err_e
509 ps_get_thread_area (const struct ps_prochandle *ph,
510                     lwpid_t lwpid, int idx, void **base)
511 {
512   struct iovec iovec;
513   uint64_t reg;
514
515   iovec.iov_base = &reg;
516   iovec.iov_len = sizeof (reg);
517
518   if (ptrace (PTRACE_GETREGSET, lwpid, NT_ARM_TLS, &iovec) != 0)
519     return PS_ERR;
520
521   /* IDX is the bias from the thread pointer to the beginning of the
522      thread descriptor.  It has to be subtracted due to implementation
523      quirks in libthread_db.  */
524   *base = (void *) (reg - idx);
525
526   return PS_OK;
527 }
528
529 /* Implementation of linux_target_ops method "linux_new_process".  */
530
531 static struct arch_process_info *
532 aarch64_linux_new_process (void)
533 {
534   struct arch_process_info *info = xcalloc (1, sizeof (*info));
535
536   aarch64_init_debug_reg_state (&info->debug_reg_state);
537
538   return info;
539 }
540
541 /* Implementation of linux_target_ops method "linux_new_thread".  */
542
543 static void
544 aarch64_linux_new_thread (struct lwp_info *lwp)
545 {
546   struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
547
548   /* Mark that all the hardware breakpoint/watchpoint register pairs
549      for this thread need to be initialized (with data from
550      aarch_process_info.debug_reg_state).  */
551   DR_MARK_ALL_CHANGED (info->dr_changed_bp, aarch64_num_bp_regs);
552   DR_MARK_ALL_CHANGED (info->dr_changed_wp, aarch64_num_wp_regs);
553
554   lwp->arch_private = info;
555 }
556
557 /* Implementation of linux_target_ops method "linux_new_fork".  */
558
559 static void
560 aarch64_linux_new_fork (struct process_info *parent,
561                         struct process_info *child)
562 {
563   /* These are allocated by linux_add_process.  */
564   gdb_assert (parent->priv != NULL
565               && parent->priv->arch_private != NULL);
566   gdb_assert (child->priv != NULL
567               && child->priv->arch_private != NULL);
568
569   /* Linux kernel before 2.6.33 commit
570      72f674d203cd230426437cdcf7dd6f681dad8b0d
571      will inherit hardware debug registers from parent
572      on fork/vfork/clone.  Newer Linux kernels create such tasks with
573      zeroed debug registers.
574
575      GDB core assumes the child inherits the watchpoints/hw
576      breakpoints of the parent, and will remove them all from the
577      forked off process.  Copy the debug registers mirrors into the
578      new process so that all breakpoints and watchpoints can be
579      removed together.  The debug registers mirror will become zeroed
580      in the end before detaching the forked off process, thus making
581      this compatible with older Linux kernels too.  */
582
583   *child->priv->arch_private = *parent->priv->arch_private;
584 }
585
586 /* Implementation of linux_target_ops method "linux_prepare_to_resume".
587
588    If the debug regs have changed, update the thread's copies.  */
589
590 static void
591 aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
592 {
593   struct thread_info *thread = get_lwp_thread (lwp);
594   ptid_t ptid = ptid_of (thread);
595   struct arch_lwp_info *info = lwp->arch_private;
596
597   if (DR_HAS_CHANGED (info->dr_changed_bp)
598       || DR_HAS_CHANGED (info->dr_changed_wp))
599     {
600       int tid = ptid_get_lwp (ptid);
601       struct process_info *proc = find_process_pid (ptid_get_pid (ptid));
602       struct aarch64_debug_reg_state *state
603         = &proc->priv->arch_private->debug_reg_state;
604
605       if (show_debug_regs)
606         fprintf (stderr, "prepare_to_resume thread %ld\n", lwpid_of (thread));
607
608       /* Watchpoints.  */
609       if (DR_HAS_CHANGED (info->dr_changed_wp))
610         {
611           aarch64_linux_set_debug_regs (state, tid, 1);
612           DR_CLEAR_CHANGED (info->dr_changed_wp);
613         }
614
615       /* Breakpoints.  */
616       if (DR_HAS_CHANGED (info->dr_changed_bp))
617         {
618           aarch64_linux_set_debug_regs (state, tid, 0);
619           DR_CLEAR_CHANGED (info->dr_changed_bp);
620         }
621     }
622 }
623
624 /* Return the right target description according to the ELF file of
625    current thread.  */
626
627 static const struct target_desc *
628 aarch64_linux_read_description (void)
629 {
630   unsigned int machine;
631   int is_elf64;
632   int tid;
633
634   tid = lwpid_of (current_thread);
635
636   is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine);
637
638   if (is_elf64)
639     return tdesc_aarch64;
640   else
641     return tdesc_arm_with_neon;
642 }
643
644 /* Implementation of linux_target_ops method "arch_setup".  */
645
646 static void
647 aarch64_arch_setup (void)
648 {
649   current_process ()->tdesc = aarch64_linux_read_description ();
650
651   aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread));
652 }
653
654 static struct regset_info aarch64_regsets[] =
655 {
656   { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
657     sizeof (struct user_pt_regs), GENERAL_REGS,
658     aarch64_fill_gregset, aarch64_store_gregset },
659   { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET,
660     sizeof (struct user_fpsimd_state), FP_REGS,
661     aarch64_fill_fpregset, aarch64_store_fpregset
662   },
663   { 0, 0, 0, -1, -1, NULL, NULL }
664 };
665
666 static struct regsets_info aarch64_regsets_info =
667   {
668     aarch64_regsets, /* regsets */
669     0, /* num_regsets */
670     NULL, /* disabled_regsets */
671   };
672
673 static struct regs_info regs_info_aarch64 =
674   {
675     NULL, /* regset_bitmap */
676     NULL, /* usrregs */
677     &aarch64_regsets_info,
678   };
679
680 /* Implementation of linux_target_ops method "regs_info".  */
681
682 static const struct regs_info *
683 aarch64_regs_info (void)
684 {
685   if (is_64bit_tdesc ())
686     return &regs_info_aarch64;
687   else
688     return &regs_info_aarch32;
689 }
690
691 /* Implementation of linux_target_ops method "supports_tracepoints".  */
692
693 static int
694 aarch64_supports_tracepoints (void)
695 {
696   if (current_thread == NULL)
697     return 1;
698   else
699     {
700       /* We don't support tracepoints on aarch32 now.  */
701       return is_64bit_tdesc ();
702     }
703 }
704
705 /* Implementation of linux_target_ops method "supports_range_stepping".  */
706
707 static int
708 aarch64_supports_range_stepping (void)
709 {
710   return 1;
711 }
712
713 struct linux_target_ops the_low_target =
714 {
715   aarch64_arch_setup,
716   aarch64_regs_info,
717   aarch64_cannot_fetch_register,
718   aarch64_cannot_store_register,
719   NULL, /* fetch_register */
720   aarch64_get_pc,
721   aarch64_set_pc,
722   (const unsigned char *) &aarch64_breakpoint,
723   aarch64_breakpoint_len,
724   NULL, /* breakpoint_reinsert_addr */
725   0,    /* decr_pc_after_break */
726   aarch64_breakpoint_at,
727   aarch64_supports_z_point_type,
728   aarch64_insert_point,
729   aarch64_remove_point,
730   aarch64_stopped_by_watchpoint,
731   aarch64_stopped_data_address,
732   NULL, /* collect_ptrace_register */
733   NULL, /* supply_ptrace_register */
734   NULL, /* siginfo_fixup */
735   aarch64_linux_new_process,
736   aarch64_linux_new_thread,
737   aarch64_linux_new_fork,
738   aarch64_linux_prepare_to_resume,
739   NULL, /* process_qsupported */
740   aarch64_supports_tracepoints,
741   NULL, /* get_thread_area */
742   NULL, /* install_fast_tracepoint_jump_pad */
743   NULL, /* emit_ops */
744   NULL, /* get_min_fast_tracepoint_insn_len */
745   aarch64_supports_range_stepping,
746 };
747
748 void
749 initialize_low_arch (void)
750 {
751   init_registers_aarch64 ();
752
753   initialize_low_arch_aarch32 ();
754
755   initialize_regsets_info (&aarch64_regsets_info);
756 }