public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mohamed Bouhaouel <mohamed.bouhaouel@intel.com>
To: gdb-patches@sourceware.org
Cc: blarsen@redhat.com, mohamed.bouhaouel@intel.com
Subject: [PATCH v2 2/3] gdb, breakpoint: add a breakpoint type converter
Date: Tue, 14 Nov 2023 10:20:28 +0100	[thread overview]
Message-ID: <20231114092029.31205-3-mohamed.bouhaouel@intel.com> (raw)
In-Reply-To: <20231114092029.31205-1-mohamed.bouhaouel@intel.com>

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(+)

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) */
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  parent reply	other threads:[~2023-11-14  9:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  9:20 [PATCH v2 0/3] Check for zpoint support when handling watchpoints Mohamed Bouhaouel
2023-11-14  9:20 ` [PATCH v2 1/3] gdb, gdbserver, zpoint: report z_point support Mohamed Bouhaouel
2023-11-14 12:50   ` Eli Zaretskii
2023-11-14  9:20 ` Mohamed Bouhaouel [this message]
2023-11-14  9:20 ` [PATCH v2 3/3] gdb, zpoint: check for target hardware breakpoint support Mohamed Bouhaouel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231114092029.31205-3-mohamed.bouhaouel@intel.com \
    --to=mohamed.bouhaouel@intel.com \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).