From patchwork Wed Apr 23 23:41:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 658 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 78C9A36022D for ; Wed, 23 Apr 2014 16:41:27 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 33649411A998D; Wed, 23 Apr 2014 16:41:27 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 13BA9411A9980 for ; Wed, 23 Apr 2014 16:41:27 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=cum9VeQfWKlmR6CygDl1R+qTD/5WbKu lh9GrqFoanNDhV9u6J0LpqqN4HbsxtlE6BGuKS7NR7nZPJkqKzhmREhsbL5SwqNd fzRCTUiWfRnie6QX2mzpshENFcVoZs4ydomt4qOYLOvy4jSukmvnGfhTHuAguivX PPbRqvL7BhxI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=ZibvcdzuHetySFMbVglPrK6KjGY=; b=Rh2xE 1uogHyQ7nusnfiPL8VjcZ9ALaBZdjNwi56OsEsGZjHEs2xczQzsn7mQYJh5xlWO0 MUl7LSUFgTSaAGkShPNbCwziBvoPX2b7FdBvWfwlAxB/tIfiUOTpefoezT4ThXbm nO0bBEGCIqf5QfHmTn7KEMFJClCvayGF85+WWw= Received: (qmail 2754 invoked by alias); 23 Apr 2014 23:41:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2658 invoked by uid 89); 23 Apr 2014 23:41:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Apr 2014 23:41:19 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3NNfHXM027922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Apr 2014 19:41:17 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3NNfFIZ002541 for ; Wed, 23 Apr 2014 19:41:17 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [GDBserver][Aarch64] Make watchpoint support use target_hw_bp_type. Date: Thu, 24 Apr 2014 00:41:13 +0100 Message-Id: <1398296475-27997-2-git-send-email-palves@redhat.com> In-Reply-To: <1398296475-27997-1-git-send-email-palves@redhat.com> References: <1398296475-27997-1-git-send-email-palves@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in This makes linux-aarch64-low.c use target_hw_bp_type, like gdb's aarch64-linux-nat.c. The original motivation is decoupling insert_point/remove_point from Z packet numbers, but I think making the files a little bit more similar is a good thing on its own right. Ideally we'd merge these files even... The aarch64_point_encode_ctrl_reg change is taken straight from GDB's copy. I confirmed with a cross compiler that this builds, but it's otherwise untested. gdb/gdbserver/ 2014-04-23 Pedro Alves * linux-aarch64-low.c: Include break-common.h. (enum target_point_type): Delete. (Z_packet_to_point_type): Rename to ... (Z_packet_to_target_hw_bp_type): ... this, and return a target_hw_bp_type instead. (aarch64_show_debug_reg_state): Take an enum target_hw_bp_type instead of an enum target_point_type. (aarch64_point_encode_ctrl_reg): Likewise. Compute type mask from breakpoint type. (aarch64_dr_state_insert_one_point) (aarch64_dr_state_remove_one_point, aarch64_handle_breakpoint) (aarch64_handle_aligned_watchpoint) (aarch64_handle_unaligned_watchpoint, aarch64_handle_watchpoint): Take an enum target_hw_bp_type instead of an enum target_point_type. (aarch64_supports_z_point_type): New function. (aarch64_insert_point, aarch64_remove_point): Use it. Adjust to use Z_packet_to_target_hw_bp_type. --- gdb/gdbserver/linux-aarch64-low.c | 100 +++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 627ade3..8b32d79 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -29,6 +29,7 @@ #include #include "gdb_proc_service.h" +#include "break-common.h" /* Defined in auto-generated files. */ void init_registers_aarch64 (void); @@ -208,36 +209,20 @@ struct arch_lwp_info static int aarch64_num_bp_regs; static int aarch64_num_wp_regs; -/* Hardware breakpoint/watchpoint types. - The values map to their encodings in the bit 4 and bit 3 of the - hardware breakpoint/watchpoint control registers. */ - -enum target_point_type -{ - hw_execute = 0, /* Execute HW breakpoint */ - hw_read = 1, /* Read HW watchpoint */ - hw_write = 2, /* Common HW watchpoint */ - hw_access = 3, /* Access HW watchpoint */ - point_type_unsupported -}; - #define Z_PACKET_SW_BP '0' #define Z_PACKET_HW_BP '1' #define Z_PACKET_WRITE_WP '2' #define Z_PACKET_READ_WP '3' #define Z_PACKET_ACCESS_WP '4' -/* Map the protocol breakpoint/watchpoint type TYPE to - enum target_point_type. */ +/* Map the protocol breakpoint/watchpoint type TYPE to enum + target_hw_bp_type. */ -static enum target_point_type -Z_packet_to_point_type (char type) +static enum target_hw_bp_type +Z_packet_to_target_hw_bp_type (char type) { switch (type) { - case Z_PACKET_SW_BP: - /* Leave the handling of the sw breakpoint with the gdb client. */ - return point_type_unsupported; case Z_PACKET_HW_BP: return hw_execute; case Z_PACKET_WRITE_WP: @@ -247,7 +232,7 @@ Z_packet_to_point_type (char type) case Z_PACKET_ACCESS_WP: return hw_access; default: - return point_type_unsupported; + fatal ("bad watchpoint type %c", type); } } @@ -358,7 +343,7 @@ aarch64_breakpoint_at (CORE_ADDR where) static void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, const char *func, CORE_ADDR addr, - int len, enum target_point_type type) + int len, enum target_hw_bp_type type) { int i; @@ -448,12 +433,31 @@ aarch64_watchpoint_length (unsigned int ctrl) breakpoint/watchpoint control register. */ static unsigned int -aarch64_point_encode_ctrl_reg (enum target_point_type type, int len) +aarch64_point_encode_ctrl_reg (enum target_hw_bp_type type, int len) { - unsigned int ctrl; + unsigned int ctrl, ttype; /* type */ - ctrl = type << 3; + switch (type) + { + case hw_write: + ttype = 2; + break; + case hw_read: + ttype = 1; + break; + case hw_access: + ttype = 3; + break; + case hw_execute: + ttype = 0; + break; + default: + perror_with_name (_("Unrecognized breakpoint/watchpoint type")); + } + + /* type */ + ctrl = ttype << 3; /* length bitmask */ ctrl |= ((1 << len) - 1) << 5; /* enabled at el0 */ @@ -749,7 +753,7 @@ aarch64_get_debug_reg_state () static int aarch64_dr_state_insert_one_point (struct aarch64_debug_reg_state *state, - enum target_point_type type, + enum target_hw_bp_type type, CORE_ADDR addr, int len) { int i, idx, num_regs, is_watchpoint; @@ -822,7 +826,7 @@ aarch64_dr_state_insert_one_point (struct aarch64_debug_reg_state *state, static int aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state, - enum target_point_type type, + enum target_hw_bp_type type, CORE_ADDR addr, int len) { int i, num_regs, is_watchpoint; @@ -876,7 +880,7 @@ aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state, } static int -aarch64_handle_breakpoint (enum target_point_type type, CORE_ADDR addr, +aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert) { struct aarch64_debug_reg_state *state; @@ -898,7 +902,7 @@ aarch64_handle_breakpoint (enum target_point_type type, CORE_ADDR addr, from that it is an aligned watchpoint to be handled. */ static int -aarch64_handle_aligned_watchpoint (enum target_point_type type, +aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert) { struct aarch64_debug_reg_state *state; @@ -919,7 +923,7 @@ aarch64_handle_aligned_watchpoint (enum target_point_type type, Return 0 if succeed. */ static int -aarch64_handle_unaligned_watchpoint (enum target_point_type type, +aarch64_handle_unaligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert) { struct aarch64_debug_reg_state *state @@ -956,7 +960,7 @@ aarch64_handle_unaligned_watchpoint (enum target_point_type type, } static int -aarch64_handle_watchpoint (enum target_point_type type, CORE_ADDR addr, +aarch64_handle_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr, int len, int is_insert) { if (aarch64_point_is_aligned (1 /* is_watchpoint */ , addr, len)) @@ -965,6 +969,22 @@ aarch64_handle_watchpoint (enum target_point_type type, CORE_ADDR addr, return aarch64_handle_unaligned_watchpoint (type, addr, len, is_insert); } +static int +aarch64_supports_z_point_type (char z_type) +{ + switch (z_type) + { + case Z_PACKET_HW_BP: + case Z_PACKET_WRITE_WP: + case Z_PACKET_READ_WP: + case Z_PACKET_ACCESS_WP: + return 1; + default: + /* Leave the handling of sw breakpoints with the gdb client. */ + return 0; + } +} + /* Insert a hardware breakpoint/watchpoint. It actually only records the info of the to-be-inserted bp/wp; the actual insertion will happen when threads are resumed. @@ -977,16 +997,17 @@ static int aarch64_insert_point (char type, CORE_ADDR addr, int len) { int ret; - enum target_point_type targ_type; + enum target_hw_bp_type targ_type; + + if (!aarch64_supports_z_point_type (type)) + return 1; if (debug_hw_points) fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n", (unsigned long) addr, len); /* Determine the type from the packet. */ - targ_type = Z_packet_to_point_type (type); - if (targ_type == point_type_unsupported) - return 1; + targ_type = Z_packet_to_target_hw_bp_type (type); if (targ_type != hw_execute) ret = @@ -1014,16 +1035,17 @@ static int aarch64_remove_point (char type, CORE_ADDR addr, int len) { int ret; - enum target_point_type targ_type; + enum target_hw_bp_type targ_type; + + if (!aarch64_supports_z_point_type (type)) + return 1; if (debug_hw_points) fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n", (unsigned long) addr, len); /* Determine the type from the packet. */ - targ_type = Z_packet_to_point_type (type); - if (targ_type == point_type_unsupported) - return 1; + targ_type = Z_packet_to_target_hw_bp_type (type); /* Set up state pointers. */ if (targ_type != hw_execute)