[v2,2/3] gdb, breakpoint: add a breakpoint type converter

Message ID 20231114092029.31205-3-mohamed.bouhaouel@intel.com
State New
Headers
Series Check for zpoint support when handling watchpoints |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed

Commit Message

Bouhaouel, Mohamed Nov. 14, 2023, 9:20 a.m. UTC
  Add a new function 'bptype_to_target_hw_bp_type' to perform
the translation from 'bptype' to 'target_hw_bp_type'.

Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
---
 gdb/breakpoint.c | 20 ++++++++++++++++++++
 gdb/breakpoint.h |  3 +++
 2 files changed, 23 insertions(+)
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fe09dbcbeee..13eaff79789 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9827,6 +9827,26 @@  watchpoint::~watchpoint ()
   bpt->related_breakpoint = this->related_breakpoint;
 }
 
+/* See breakpoint.h.  */
+
+target_hw_bp_type
+bptype_to_target_hw_bp_type (bptype type)
+{
+  switch (type)
+    {
+    case bp_hardware_watchpoint:
+      return hw_write;
+    case bp_read_watchpoint:
+      return hw_read;
+    case bp_access_watchpoint:
+      return hw_access;
+    case bp_hardware_breakpoint:
+      return hw_execute;
+    default:
+      error (_ ("Bad breakpoint type: bptype %d."), type);
+    }
+}
+
 /*  Return non-zero if EXP is verified as constant.  Returned zero
     means EXP is variable.  Also the constant detection may fail for
     some constant expressions and in such case still falsely return
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index e75efc90495..cc9a1ebc184 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -2029,4 +2029,7 @@  extern void enable_disable_bp_location (bp_location *loc, bool enable);
 
 extern void notify_breakpoint_modified (breakpoint *b);
 
+/* Translate BPTYPE to TARGET_HW_BP_TYPE.  */
+
+extern target_hw_bp_type bptype_to_target_hw_bp_type (bptype type);
 #endif /* !defined (BREAKPOINT_H) */