From patchwork Wed Apr 23 23:41:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 659 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 2F79F3606F8 for ; Wed, 23 Apr 2014 16:41:33 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id E685A411A998E; Wed, 23 Apr 2014 16:41:32 -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 C2F40411A9981 for ; Wed, 23 Apr 2014 16:41:32 -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=yySBFeWY0okZudI5oa/d6cRsDoZb8lJ u4dZ9kyfsvBqmaoA+5uhoPvLbmn1h5He5uODydcdxPZIQUK/53fCNbdWE+35nE+v WWUqq2LXhph5ans5iP69QOFZ8CWn875vTb7ZuM+7E1umz9E/Crv+iNi3Luv+ZMIp Pmz+/Hsp7i8s= 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=BdiREfe/3xIWiQCQBlzLzPLEszY=; b=f7xCK dcc/nNTBjHUI/ypwEfOIrxmVPWecY/nKx6XhJFJXWJiaLLLK8RGWYXUM8SL98SpK 4hRHVFDN3GidM88+/r99kNvMMUUvArdtzFJCXA0BGeDxM9DE+2HJz46ccycx1gq7 dNxnbKNDpVNvVf1eYdZ8HEUTlRGo/dKRfQMBYU= Received: (qmail 2976 invoked by alias); 23 Apr 2014 23:41:22 -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 2941 invoked by uid 89); 23 Apr 2014 23:41:22 -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 s3NNfIh6028044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Apr 2014 19:41:18 -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 s3NNfFIa002541 for ; Wed, 23 Apr 2014 19:41:18 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/3] [GDBserver] Move Z packet defines and type convertion routines to shared code. Date: Thu, 24 Apr 2014 00:41:14 +0100 Message-Id: <1398296475-27997-3-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 The Aarch64, MIPS and x86 Linux backends all have Z packet number defines and corresponding protocol number to internal type convertion routinea. Factor them all out to gdbserver's core code, so we only have one shared copy. Tested on x86_64 Fedora 17, and also cross built for aarch64-linux-gnu and mips-linux-gnu. gdb/gdbserver/ 2014-04-23 Pedro Alves * mem-break.h: Include break-common.h. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): New defines. (Z_packet_to_target_hw_bp_type): New declaration. * mem-break.c (Z_packet_to_target_hw_bp_type): New function. * i386-low.c (Z_PACKET_HW_BP, Z_PACKET_WRITE_WP, Z_PACKET_READ_WP) (Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_hw_type): Delete function. * i386-low.h: Don't include break-common.h here. (Z_packet_to_hw_type): Delete declaration. * linux-x86-low.c (x86_insert_point, x86_insert_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * win32-i386-low.c (i386_insert_point, i386_remove_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * linux-aarch64-low.c: Don't include break-common.h here. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_target_hw_bp_type): Delete function. * linux-mips-low.c (rsp_bp_type_to_target_hw_bp_type): Delete function. (mips_insert_point, mips_remove_point): Use Z_packet_to_target_hw_bp_type. --- gdb/gdbserver/i386-low.c | 23 ----------------------- gdb/gdbserver/i386-low.h | 6 ------ gdb/gdbserver/linux-aarch64-low.c | 28 ---------------------------- gdb/gdbserver/linux-mips-low.c | 22 ++-------------------- gdb/gdbserver/linux-x86-low.c | 4 ++-- gdb/gdbserver/mem-break.c | 18 ++++++++++++++++++ gdb/gdbserver/mem-break.h | 13 +++++++++++++ gdb/gdbserver/win32-i386-low.c | 4 ++-- 8 files changed, 37 insertions(+), 81 deletions(-) diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c index 03eebd1..de2d11a 100644 --- a/gdb/gdbserver/i386-low.c +++ b/gdb/gdbserver/i386-low.c @@ -402,29 +402,6 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n", return retval; } -#define Z_PACKET_HW_BP '1' -#define Z_PACKET_WRITE_WP '2' -#define Z_PACKET_READ_WP '3' -#define Z_PACKET_ACCESS_WP '4' - -enum target_hw_bp_type -Z_packet_to_hw_type (char type) -{ - switch (type) - { - case Z_PACKET_HW_BP: - return hw_execute; - case Z_PACKET_WRITE_WP: - return hw_write; - case Z_PACKET_READ_WP: - return hw_read; - case Z_PACKET_ACCESS_WP: - return hw_access; - default: - fatal ("Z_packet_to_hw_type: bad watchpoint type %c", type); - } -} - /* Update the inferior debug registers state, in INF_STATE, with the new debug registers state, in NEW_STATE. */ diff --git a/gdb/gdbserver/i386-low.h b/gdb/gdbserver/i386-low.h index d91c90a..8d8e73f 100644 --- a/gdb/gdbserver/i386-low.h +++ b/gdb/gdbserver/i386-low.h @@ -29,12 +29,6 @@ counts, and allow to watch regions up to 16 bytes long (32 bytes on 64 bit hosts). */ -#include "break-common.h" - -/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type. */ - -enum target_hw_bp_type Z_packet_to_hw_type (char type); - /* Debug registers' indices. */ #define DR_FIRSTADDR 0 #define DR_LASTADDR 3 diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 8b32d79..7e425c9 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -29,7 +29,6 @@ #include #include "gdb_proc_service.h" -#include "break-common.h" /* Defined in auto-generated files. */ void init_registers_aarch64 (void); @@ -209,33 +208,6 @@ struct arch_lwp_info static int aarch64_num_bp_regs; static int aarch64_num_wp_regs; -#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_hw_bp_type. */ - -static enum target_hw_bp_type -Z_packet_to_target_hw_bp_type (char type) -{ - switch (type) - { - case Z_PACKET_HW_BP: - return hw_execute; - case Z_PACKET_WRITE_WP: - return hw_write; - case Z_PACKET_READ_WP: - return hw_read; - case Z_PACKET_ACCESS_WP: - return hw_access; - default: - fatal ("bad watchpoint type %c", type); - } -} - static int aarch64_cannot_store_register (int regno) { diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index 5a24bfe..112448c 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -372,24 +372,6 @@ mips_linux_prepare_to_resume (struct lwp_info *lwp) } } -/* Translate breakpoint type TYPE in rsp to 'enum target_hw_bp_type'. */ - -static enum target_hw_bp_type -rsp_bp_type_to_target_hw_bp_type (char type) -{ - switch (type) - { - case '2': - return hw_write; - case '3': - return hw_read; - case '4': - return hw_access; - } - - gdb_assert_not_reached ("unhandled RSP breakpoint type"); -} - /* This is the implementation of linux_target_ops method insert_point. */ @@ -434,7 +416,7 @@ mips_insert_point (char type, CORE_ADDR addr, int len) mips_linux_watch_populate_regs (private->current_watches, ®s); /* Now try to add the new watch. */ - watch_type = rsp_bp_type_to_target_hw_bp_type (type); + watch_type = Z_packet_to_target_hw_bp_type (type); irw = mips_linux_watch_type_to_irw (watch_type); if (!mips_linux_watch_try_one_watch (®s, addr, len, irw)) return -1; @@ -490,7 +472,7 @@ mips_remove_point (char type, CORE_ADDR addr, int len) } /* Search for a known watch that matches. Then unlink and free it. */ - watch_type = rsp_bp_type_to_target_hw_bp_type (type); + watch_type = Z_packet_to_target_hw_bp_type (type); deleted_one = 0; pw = &private->current_watches; while ((w = *pw)) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 2f518b1..ab68572 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -642,7 +642,7 @@ x86_insert_point (char type, CORE_ADDR addr, int len) case '3': /* read watchpoint */ case '4': /* access watchpoint */ { - enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type); struct i386_debug_reg_state *state = &proc->private->arch_private->debug_reg_state; @@ -677,7 +677,7 @@ x86_remove_point (char type, CORE_ADDR addr, int len) case '3': /* read watchpoint */ case '4': /* access watchpoint */ { - enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type); struct i386_debug_reg_state *state = &proc->private->arch_private->debug_reg_state; diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c index 680e97f..b19cbc8 100644 --- a/gdb/gdbserver/mem-break.c +++ b/gdb/gdbserver/mem-break.c @@ -138,6 +138,24 @@ struct breakpoint int (*handler) (CORE_ADDR); }; +enum target_hw_bp_type +Z_packet_to_target_hw_bp_type (char type) +{ + switch (type) + { + case Z_PACKET_HW_BP: + return hw_execute; + case Z_PACKET_WRITE_WP: + return hw_write; + case Z_PACKET_READ_WP: + return hw_read; + case Z_PACKET_ACCESS_WP: + return hw_access; + default: + fatal ("bad watchpoint type %c", type); + } +} + int any_persistent_commands () { diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h index 74369a7..ffc1b80 100644 --- a/gdb/gdbserver/mem-break.h +++ b/gdb/gdbserver/mem-break.h @@ -21,10 +21,23 @@ #ifndef MEM_BREAK_H #define MEM_BREAK_H +#include "break-common.h" + /* Breakpoints are opaque. */ struct breakpoint; struct fast_tracepoint_jump; +#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_hw_bp_type. */ + +enum target_hw_bp_type Z_packet_to_target_hw_bp_type (char type); + /* Create a new GDB breakpoint at WHERE. Returns -1 if breakpoints are not supported on this target, 0 otherwise. */ diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index ce9b303..e70ca71 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -106,7 +106,7 @@ i386_insert_point (char type, CORE_ADDR addr, int len) case '3': case '4': { - enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type); return i386_low_insert_watchpoint (&debug_reg_state, hw_type, addr, len); @@ -126,7 +126,7 @@ i386_remove_point (char type, CORE_ADDR addr, int len) case '3': case '4': { - enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type); return i386_low_remove_watchpoint (&debug_reg_state, hw_type, addr, len);