From patchwork Wed Apr 23 17:46:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 652 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 541AF361046 for ; Wed, 23 Apr 2014 10:46:59 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 1318E4CA402A; Wed, 23 Apr 2014 10:46:59 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.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-mx22.g.dreamhost.com (Postfix) with ESMTPS id D98EA4CBB991 for ; Wed, 23 Apr 2014 10:46:58 -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; q=dns; s= default; b=Uu0gJcoUusHtt4u0fsZKJE4dAnFOz9FaLVCb3H17i/cQrcVrI5Qwg rb1d4mPAslyU0WluP9j1B2mT99xJJbQzz1YctOL0T7MCT6UH/5jS8yHmHMLvSbnj 8i8fXN3Hwki0xJVWNSReHz4CrjzFvcsddV4QloDCnDmbnCnkdZLdpo= 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; s=default; bh=qmqnC1ZMx3Ypr2llJ6QfuhQSxiA=; b=t1uaVthx0AMm1lGJGfI1SB3tyovw ABBCXDZxEwskTWZ5NGvGJlbavN9SrAogKrUeYbbbeR4aehCIosQezQimF7EWyrOc ufpgCENfYOsnvyWmaznUN8DYfrY/rfgdh/FhNZ6sRJAQh5ufjYvjUOH0y+MO/Tem IvQ+q8M92Ysgjo4= Received: (qmail 2649 invoked by alias); 23 Apr 2014 17:46:57 -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 2639 invoked by uid 89); 23 Apr 2014 17:46:57 -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 17:46:56 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3NHks0D020606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Apr 2014 13:46:54 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3NHkrps016188 for ; Wed, 23 Apr 2014 13:46:54 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] gdbserver: decouple x86 watchpoint / hw breakpoint routines from Z packet numbers. Date: Wed, 23 Apr 2014 18:46:53 +0100 Message-Id: <1398275213-1550-1-git-send-email-palves@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in My main motivation here is moving in the direction of decoupling insert_point/remove_point from packet numbers, though this bit alone should make it a little bit easier to merge gdb/gdbserver/i386-low.c and gdb/i386-nat.c (which are largely the same). Tested on x86_64 Fedora 17, and cross built for i686-mingw32 too. gdb/gdbserver/ 2014-04-23 Pedro Alves * i386-low.c: Don't include break-common.h here. (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change prototype to take target_hw_bp_type as argument instead of a Z packet char. * i386-low.h: Include break-common.h here. (Z_packet_to_hw_type): Declare. (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change prototypes. * linux-x86-low.c (x86_insert_point): Convert the packet number to a target_hw_bp_type before calling i386_low_insert_watchpoint. (x86_remove_point): Convert the packet number to a target_hw_bp_type before calling i386_low_remove_watchpoint. * win32-i386-low.c (i386_insert_point): Convert the packet number to a target_hw_bp_type before calling i386_low_insert_watchpoint. (i386_remove_point): Convert the packet number to a target_hw_bp_type before calling i386_low_remove_watchpoint. --- gdb/gdbserver/ChangeLog | 19 +++++++++++++++++++ gdb/gdbserver/i386-low.c | 15 ++++++--------- gdb/gdbserver/i386-low.h | 15 +++++++++++---- gdb/gdbserver/linux-x86-low.c | 18 ++++++++++++++---- gdb/gdbserver/win32-i386-low.c | 16 ++++++++++++---- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index ad2b1ae..c419e43 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,24 @@ 2014-04-23 Pedro Alves + * i386-low.c: Don't include break-common.h here. + (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change + prototype to take target_hw_bp_type as argument instead of a Z + packet char. + * i386-low.h: Include break-common.h here. + (Z_packet_to_hw_type): Declare. + (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change + prototypes. + * linux-x86-low.c (x86_insert_point): Convert the packet number to + a target_hw_bp_type before calling i386_low_insert_watchpoint. + (x86_remove_point): Convert the packet number to a + target_hw_bp_type before calling i386_low_remove_watchpoint. + * win32-i386-low.c (i386_insert_point): Convert the packet number + to a target_hw_bp_type before calling i386_low_insert_watchpoint. + (i386_remove_point): Convert the packet number to a + target_hw_bp_type before calling i386_low_remove_watchpoint. + +2014-04-23 Pedro Alves + * utils.h (perror_with_name): Add ATTRIBUTE_NORETURN. 2014-04-10 Pedro Alves diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c index 33ef0a4..03eebd1 100644 --- a/gdb/gdbserver/i386-low.c +++ b/gdb/gdbserver/i386-low.c @@ -20,7 +20,6 @@ #include "server.h" #include "target.h" #include "i386-low.h" -#include "break-common.h" /* Support for 8-byte wide hw watchpoints. */ #ifndef TARGET_HAS_DR_LEN_8 @@ -408,9 +407,7 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n", #define Z_PACKET_READ_WP '3' #define Z_PACKET_ACCESS_WP '4' -/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type. */ - -static enum target_hw_bp_type +enum target_hw_bp_type Z_packet_to_hw_type (char type) { switch (type) @@ -457,10 +454,10 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *inf_state, int i386_low_insert_watchpoint (struct i386_debug_reg_state *state, - char type_from_packet, CORE_ADDR addr, int len) + enum target_hw_bp_type type, + CORE_ADDR addr, int len) { int retval; - enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet); /* Work on a local copy of the debug registers, and on success, commit the change back to the inferior. */ struct i386_debug_reg_state local_state = *state; @@ -493,14 +490,14 @@ i386_low_insert_watchpoint (struct i386_debug_reg_state *state, /* Remove a watchpoint that watched the memory region which starts at address ADDR, whose length is LEN bytes, and for accesses of the - type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */ + type TYPE. Return 0 on success, -1 on failure. */ int i386_low_remove_watchpoint (struct i386_debug_reg_state *state, - char type_from_packet, CORE_ADDR addr, int len) + enum target_hw_bp_type type, + CORE_ADDR addr, int len) { int retval; - enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet); /* Work on a local copy of the debug registers, and on success, commit the change back to the inferior. */ struct i386_debug_reg_state local_state = *state; diff --git a/gdb/gdbserver/i386-low.h b/gdb/gdbserver/i386-low.h index 1a4e3cc..d91c90a 100644 --- a/gdb/gdbserver/i386-low.h +++ b/gdb/gdbserver/i386-low.h @@ -29,6 +29,11 @@ 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 @@ -58,16 +63,18 @@ extern void i386_low_init_dregs (struct i386_debug_reg_state *state); /* Insert a watchpoint to watch a memory region which starts at address ADDR and whose length is LEN bytes. Watch memory accesses - of the type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */ + of the type TYPE. Return 0 on success, -1 on failure. */ extern int i386_low_insert_watchpoint (struct i386_debug_reg_state *state, - char type_from_packet, CORE_ADDR addr, + enum target_hw_bp_type type, + CORE_ADDR addr, int len); /* Remove a watchpoint that watched the memory region which starts at address ADDR, whose length is LEN bytes, and for accesses of the - type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */ + type TYPE. Return 0 on success, -1 on failure. */ extern int i386_low_remove_watchpoint (struct i386_debug_reg_state *state, - char type_from_packet, CORE_ADDR addr, + enum target_hw_bp_type type, + CORE_ADDR addr, int len); /* Return non-zero if we can watch a memory region that starts at diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 33b5f26..2f518b1 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -641,8 +641,13 @@ x86_insert_point (char type, CORE_ADDR addr, int len) case '2': /* write watchpoint */ case '3': /* read watchpoint */ case '4': /* access watchpoint */ - return i386_low_insert_watchpoint (&proc->private->arch_private->debug_reg_state, - type, addr, len); + { + enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + struct i386_debug_reg_state *state + = &proc->private->arch_private->debug_reg_state; + + return i386_low_insert_watchpoint (state, hw_type, addr, len); + } default: /* Unsupported. */ @@ -671,8 +676,13 @@ x86_remove_point (char type, CORE_ADDR addr, int len) case '2': /* write watchpoint */ case '3': /* read watchpoint */ case '4': /* access watchpoint */ - return i386_low_remove_watchpoint (&proc->private->arch_private->debug_reg_state, - type, addr, len); + { + enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + struct i386_debug_reg_state *state + = &proc->private->arch_private->debug_reg_state; + + return i386_low_remove_watchpoint (state, hw_type, addr, len); + } default: /* Unsupported. */ return 1; diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index 1cb0c5f..ce9b303 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -105,8 +105,12 @@ i386_insert_point (char type, CORE_ADDR addr, int len) case '2': case '3': case '4': - return i386_low_insert_watchpoint (&debug_reg_state, - type, addr, len); + { + enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + + return i386_low_insert_watchpoint (&debug_reg_state, + hw_type, addr, len); + } default: /* Unsupported. */ return 1; @@ -121,8 +125,12 @@ i386_remove_point (char type, CORE_ADDR addr, int len) case '2': case '3': case '4': - return i386_low_remove_watchpoint (&debug_reg_state, - type, addr, len); + { + enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type); + + return i386_low_remove_watchpoint (&debug_reg_state, + hw_type, addr, len); + } default: /* Unsupported. */ return 1;