From patchwork Tue Mar 28 11:54:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bouhaouel, Mohamed" X-Patchwork-Id: 67008 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF51838582BD for ; Tue, 28 Mar 2023 11:55:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF51838582BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680004541; bh=53TmgT10EiQjqW6fz74a32PR1lVWhOeYS4wMzwkBPXA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=uQxe6LJi8RN0W08BYsV/Bn+3a1cOUyOEejnAlMj/C+na2iGmPPpgLv5swE0HsVp5w op0yJ0vTa/eys09Uf3IBud3fw0doDsIsaa9sOEYQyob0BTMc4IkAzTbmbsfqujivfL z26BJYGBeRpJsYIT/9uHSY1mfO7dr7T5DQlaH4Yo= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id D322E3858C53 for ; Tue, 28 Mar 2023 11:55:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D322E3858C53 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="320944369" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="320944369" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 04:55:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="753116301" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="753116301" Received: from mbouhaou-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.40.224]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 04:55:16 -0700 To: gdb-patches@sourceware.org Subject: [PATCH 2/3] gdb, breakpoint: add a breakpoint type converter Date: Tue, 28 Mar 2023 13:54:48 +0200 Message-Id: <20230328115449.6526-3-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230328115449.6526-1-mohamed.bouhaouel@intel.com> References: <20230328115449.6526-1-mohamed.bouhaouel@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mohamed Bouhaouel via Gdb-patches From: "Bouhaouel, Mohamed" Reply-To: Mohamed Bouhaouel Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add a new function 'bptype_to_target_hw_bp_type' to perform the translation from 'bptype' to 'target_hw_bp_type'. Signed-off-by: Mohamed Bouhaouel --- gdb/breakpoint.c | 20 ++++++++++++++++++++ gdb/breakpoint.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 7228acfd8fe..e71cf7639d9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9581,6 +9581,26 @@ break_range_command (const char *arg, int from_tty) install_breakpoint (false, std::move (br), true); } +/* 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 7c5cf3f2bef..12fa5c96e08 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1946,4 +1946,7 @@ extern void describe_other_breakpoints (struct gdbarch *, extern void enable_disable_bp_location (bp_location *loc, bool enable); +/* Translate BPTYPE to TARGET_HW_BP_TYPE. */ + +extern target_hw_bp_type bptype_to_target_hw_bp_type (bptype type); #endif /* !defined (BREAKPOINT_H) */