Home | History | Annotate | Line # | Download | only in gdb
      1 /* Native-dependent code for AArch64.
      2 
      3    Copyright (C) 2011-2024 Free Software Foundation, Inc.
      4 
      5    This file is part of GDB.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19 
     20 #ifndef AARCH64_NAT_H
     21 #define AARCH64_NAT_H
     22 
     23 #include "breakpoint.h"
     24 #include "nat/aarch64-hw-point.h"
     25 #include "target.h"
     26 
     27 /* Hardware-assisted breakpoints and watchpoints.  */
     28 
     29 /* Initialize platform-independent state for hardware-assisted
     30    breakpoints and watchpoints.  */
     31 
     32 void aarch64_initialize_hw_point ();
     33 
     34 /* Return the debug register state for process PID.  If no existing
     35    state is found for this process, return nullptr.  */
     36 
     37 struct aarch64_debug_reg_state *aarch64_lookup_debug_reg_state (pid_t pid);
     38 
     39 /* Return the debug register state for process PID.  If no existing
     40    state is found for this process, create new state.  */
     41 
     42 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
     43 
     44 /* Remove any existing per-process debug state for process PID.  */
     45 
     46 void aarch64_remove_debug_reg_state (pid_t pid);
     47 
     48 /* Helper functions used by aarch64_nat_target below.  See their
     49    definitions.  */
     50 
     51 int aarch64_can_use_hw_breakpoint (enum bptype type, int cnt, int othertype);
     52 int aarch64_insert_watchpoint (CORE_ADDR addr, int len,
     53 			       enum target_hw_bp_type type,
     54 			       struct expression *cond);
     55 int aarch64_remove_watchpoint (CORE_ADDR addr, int len,
     56 			       enum target_hw_bp_type type,
     57 			       struct expression *cond);
     58 int aarch64_insert_hw_breakpoint (struct gdbarch *gdbarch,
     59 				  struct bp_target_info *bp_tgt);
     60 int aarch64_remove_hw_breakpoint (struct gdbarch *gdbarch,
     61 				  struct bp_target_info *bp_tgt);
     62 int aarch64_stopped_by_hw_breakpoint ();
     63 
     64 /* Convenience template mixin used to add aarch64 watchpoints support to a
     65    target.  */
     66 
     67 template <typename BaseTarget>
     68 struct aarch64_nat_target : public BaseTarget
     69 {
     70   /* Hook in common aarch64 hardware watchpoints/breakpoints support.  */
     71 
     72   int can_use_hw_breakpoint (enum bptype type, int cnt, int othertype) override
     73   { return aarch64_can_use_hw_breakpoint (type, cnt, othertype); }
     74 
     75   int region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) override
     76   { return aarch64_region_ok_for_watchpoint (addr, len); }
     77 
     78   int insert_watchpoint (CORE_ADDR addr, int len,
     79 			 enum target_hw_bp_type type,
     80 			 struct expression *cond) override
     81   { return aarch64_insert_watchpoint (addr, len, type, cond); }
     82 
     83   int remove_watchpoint (CORE_ADDR addr, int len,
     84 			 enum target_hw_bp_type type,
     85 			 struct expression *cond) override
     86   { return aarch64_remove_watchpoint (addr, len, type, cond); }
     87 
     88   int insert_hw_breakpoint (struct gdbarch *gdbarch,
     89 			    struct bp_target_info *bp_tgt) override
     90   { return aarch64_insert_hw_breakpoint (gdbarch, bp_tgt); }
     91 
     92   int remove_hw_breakpoint (struct gdbarch *gdbarch,
     93 			    struct bp_target_info *bp_tgt) override
     94   { return aarch64_remove_hw_breakpoint (gdbarch, bp_tgt); }
     95 
     96   bool watchpoint_addr_within_range (CORE_ADDR addr, CORE_ADDR start,
     97 				     int length) override
     98   { return start <= addr && start + length - 1 >= addr; }
     99 };
    100 
    101 #endif /* AARCH64_NAT_H */
    102