diff options
author | Andrew Pinski <apinski@marvell.com> | 2021-10-21 16:57:36 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2021-10-21 19:02:01 +0000 |
commit | f81ce492b2a5b8ffc83b3e8d03c2acfa45ce50ce (patch) | |
tree | 1f014933ff73455788dd0420837d0b414fa6fa7b | |
parent | 21a27fb021ad935b25da9f8f97ed4f7d70499c41 (diff) | |
download | gdb-f81ce492b2a5b8ffc83b3e8d03c2acfa45ce50ce.zip gdb-f81ce492b2a5b8ffc83b3e8d03c2acfa45ce50ce.tar.gz gdb-f81ce492b2a5b8ffc83b3e8d03c2acfa45ce50ce.tar.bz2 |
Refactor code slightly in nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity)
Since the two locations which check the debug arch are the same code currently, it is
a good idea to factor it out to a new function and just use that function from
aarch64_linux_get_debug_reg_capacity. This is also the first step to support
ARMv8.4 debug arch.
-rw-r--r-- | gdb/nat/aarch64-linux-hw-point.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c index af2cc42..5540a01 100644 --- a/gdb/nat/aarch64-linux-hw-point.c +++ b/gdb/nat/aarch64-linux-hw-point.c @@ -769,6 +769,22 @@ aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, state->dr_ctrl_wp[i], state->dr_ref_count_wp[i]); } +/* Return true if debug arch level is compatible for hw watchpoints + and breakpoints. */ + +static bool +compatible_debug_arch (unsigned int debug_arch) +{ + if (debug_arch == AARCH64_DEBUG_ARCH_V8) + return true; + if (debug_arch == AARCH64_DEBUG_ARCH_V8_1) + return true; + if (debug_arch == AARCH64_DEBUG_ARCH_V8_2) + return true; + + return false; +} + /* Get the hardware debug register capacity information from the process represented by TID. */ @@ -783,9 +799,7 @@ aarch64_linux_get_debug_reg_capacity (int tid) /* Get hardware watchpoint register info. */ if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0 - && (AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8 - || AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8_1 - || AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8_2)) + && compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) { aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM) @@ -805,9 +819,7 @@ aarch64_linux_get_debug_reg_capacity (int tid) /* Get hardware breakpoint register info. */ if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0 - && (AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8 - || AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8_1 - || AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8_2)) + && compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) { aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM) |