From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6370 invoked by alias); 14 Sep 2007 09:40:32 -0000 Received: (qmail 6345 invoked by uid 22791); 14 Sep 2007 09:40:28 -0000 X-Spam-Check-By: sourceware.org Received: from inet-tsb5.toshiba.co.jp (HELO inet-tsb5.toshiba.co.jp) (202.33.96.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Sep 2007 09:40:19 +0000 Received: from arc1.toshiba.co.jp ([133.199.194.235]) by inet-tsb5.toshiba.co.jp with ESMTP id l8E9eBMQ022982; Fri, 14 Sep 2007 18:40:11 +0900 (JST) Received: (from root@localhost) by arc1.toshiba.co.jp id l8E9eBhU029639; Fri, 14 Sep 2007 18:40:11 +0900 (JST) Received: from ovp1.toshiba.co.jp [133.199.192.124] by arc1.toshiba.co.jp with ESMTP id UAA29634; Fri, 14 Sep 2007 18:40:11 +0900 Received: from mx.toshiba.co.jp (localhost [127.0.0.1]) by ovp1.toshiba.co.jp with ESMTP id l8E9eA8N003217; Fri, 14 Sep 2007 18:40:10 +0900 (JST) Received: from mx.tjsys.co.jp by toshiba.co.jp id l8E9e8eJ018232; Fri, 14 Sep 2007 18:40:08 +0900 (JST) Received: from voltage-out.tjsys.co.jp (voltage-out.tjsys.co.jp [157.79.3.51]) by mx.tjsys.co.jp (8.12.11/8.12.11) with ESMTP id l8E9e8VC022035; Fri, 14 Sep 2007 18:40:08 +0900 (JST) Received: from is-com10 ([157.79.3.71]) by voltage-out.tjsys.co.jp (8.13.1/8.13.1) with SMTP id l8E9e3tU025944; Fri, 14 Sep 2007 18:40:03 +0900 Received: from localhost ([157.79.51.49]) by ims.tjsys.co.jp (iPlanet Messaging Server 5.2 HotFix 2.10 (built Dec 26 2005)) with ESMTP id <0JOC00LPJQUODS@ims.tjsys.co.jp>; Fri, 14 Sep 2007 18:40:01 +0900 (JST) Date: Fri, 14 Sep 2007 09:40:00 -0000 From: Emi SUZUKI Subject: Re: [RFC] checking the Z-packet support on gdbserver In-reply-to: To: jimb@codesourcery.com Cc: gdb-patches@sourceware.org Message-id: <20070914.183913.226021396.emi-suzuki@tjsys.co.jp> MIME-version: 1.0 X-Mailer: Mew version 5.2.51 on Emacs 22.1 / Mule 5.0 (SAKAKI) Content-type: Multipart/Mixed; boundary="--Next_Part(Fri_Sep_14_18_39_13_2007_055)--" Content-transfer-encoding: 7bit References: <20070913.210822.19763360.emi-suzuki@tjsys.co.jp> X-WAuditID: 0709141840010000013066 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00175.txt.bz2 ----Next_Part(Fri_Sep_14_18_39_13_2007_055)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 1650 Hello Jim, Thank you for your comment. From: Jim Blandy Subject: Re: [RFC] checking the Z-packet support on gdbserver Date: Thu, 13 Sep 2007 10:05:50 -0700 > Emi SUZUKI writes: > > Would anyone give me any comments how it should be treated as a whole? > > Defines another packet for it? Applies as proposed and notes "it > > might not work with older versions of gdbserver" ? > > I wonder, would it make sense to have GDB assume that hardware > watchpoints are *not* available on remote targets, and then have > gdbserver send a 'qSupported' packet stubfeature that tells GDB that > hardware watchpoints are okay? Well, I understood casually that the answer of 'qSupported' packet would tell the support for the other 'q' packets from the current implementaion... According to the description in the info, definitely it would make sense. How about the attached? Meanwhile, I've found the definition below in gdb/config/nm-i386.h. #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) 1 TARGET_CAN_USE_HARDWARE_WATCHPOINT is used in watch_command_1 for checking if the support of hardware watchpoints are available on the target. If it is not defined, the target vector function 'to_can_use_hw_breakpoint' would be called. So, the above implies that GDB built for the x86 native target is not supposed to debug the remote target. But it should be, to debug a target running on a remote machine which is the same architecture to the local host, shouldn't it? (Although it would not be much necessary in practice...) Best regards, -- Emi SUZUKI / emi-suzuki at tjsys.co.jp ----Next_Part(Fri_Sep_14_18_39_13_2007_055)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zpacket-redefined.diff" Content-length: 8675 Index: gdb/gdbserver/server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.56 diff -u -r1.56 server.c --- gdb/gdbserver/server.c 23 Aug 2007 18:08:48 -0000 1.56 +++ gdb/gdbserver/server.c 14 Sep 2007 09:30:25 -0000 @@ -540,8 +540,21 @@ strcat (own_buf, ";qXfer:spu:read+;qXfer:spu:write+"); if (get_features_xml ("target.xml") != NULL) - strcat (own_buf, ";qXfer:features:read+"); + strcat (own_buf, ";qXfer:features:read+"); + char type; + char buf[8]; + /* Watchpoints support: the watchpoint type codes are + described in target.h. */ + for (type = 2; type < 5; type++) + { + if (the_target->watchpoint_support != NULL + && the_target->watchpoint_support (type)) + { + sprintf (buf, ";Z%d+", type); + strcat (own_buf, buf); + } + } return; } Index: gdb/gdbserver/linux-low.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.h,v retrieving revision 1.18 diff -u -r1.18 linux-low.h --- gdb/gdbserver/linux-low.h 23 Aug 2007 18:08:48 -0000 1.18 +++ gdb/gdbserver/linux-low.h 14 Sep 2007 09:30:19 -0000 @@ -63,6 +63,7 @@ /* Watchpoint related functions. See target.h for comments. */ int (*insert_watchpoint) (char type, CORE_ADDR addr, int len); int (*remove_watchpoint) (char type, CORE_ADDR addr, int len); + int (*watchpoint_support) (char type); int (*stopped_by_watchpoint) (void); CORE_ADDR (*stopped_data_address) (void); Index: gdb/gdbserver/linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.61 diff -u -r1.61 linux-low.c --- gdb/gdbserver/linux-low.c 4 Sep 2007 21:30:23 -0000 1.61 +++ gdb/gdbserver/linux-low.c 14 Sep 2007 09:30:19 -0000 @@ -1635,6 +1635,16 @@ } static int +linux_watchpoint_support (char type) +{ + if (the_low_target.watchpoint_support != NULL) + return the_low_target.watchpoint_support (type); + else + /* Unsupported. */ + return 0; +} + +static int linux_stopped_by_watchpoint (void) { if (the_low_target.stopped_by_watchpoint != NULL) @@ -1721,6 +1731,7 @@ linux_read_auxv, linux_insert_watchpoint, linux_remove_watchpoint, + linux_watchpoint_support, linux_stopped_by_watchpoint, linux_stopped_data_address, #if defined(__UCLIBC__) && defined(HAS_NOMMU) Index: gdb/gdbserver/target.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/target.h,v retrieving revision 1.25 diff -u -r1.25 target.h --- gdb/gdbserver/target.h 23 Aug 2007 18:08:48 -0000 1.25 +++ gdb/gdbserver/target.h 14 Sep 2007 09:30:29 -0000 @@ -155,6 +155,11 @@ int (*insert_watchpoint) (char type, CORE_ADDR addr, int len); int (*remove_watchpoint) (char type, CORE_ADDR addr, int len); + + /* Check if hardware watchpoints are supported. + Returns 0 on unsupported, else on supported. + The type is coded as mentioned above. */ + int (*watchpoint_support) (char type); /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */ Index: gdb/gdbserver/linux-x86-64-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-64-low.c,v retrieving revision 1.16 diff -u -r1.16 linux-x86-64-low.c --- gdb/gdbserver/linux-x86-64-low.c 23 Aug 2007 18:08:48 -0000 1.16 +++ gdb/gdbserver/linux-x86-64-low.c 14 Sep 2007 09:30:21 -0000 @@ -174,6 +174,7 @@ NULL, NULL, NULL, + NULL, 0, "i386:x86-64", }; Index: gdb/gdbserver/win32-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.15 diff -u -r1.15 win32-low.c --- gdb/gdbserver/win32-low.c 3 Sep 2007 22:17:27 -0000 1.15 +++ gdb/gdbserver/win32-low.c 14 Sep 2007 09:30:34 -0000 @@ -1522,6 +1522,7 @@ NULL, NULL, NULL, + NULL, win32_arch_string }; Index: gdb/gdbserver/linux-i386-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-i386-low.c,v retrieving revision 1.13 diff -u -r1.13 linux-i386-low.c --- gdb/gdbserver/linux-i386-low.c 23 Aug 2007 18:08:48 -0000 1.13 +++ gdb/gdbserver/linux-i386-low.c 14 Sep 2007 09:30:10 -0000 @@ -200,6 +200,7 @@ NULL, NULL, NULL, + NULL, 0, "i386" }; Index: gdb/gdbserver/linux-crisv32-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-crisv32-low.c,v retrieving revision 1.5 diff -u -r1.5 linux-crisv32-low.c --- gdb/gdbserver/linux-crisv32-low.c 23 Aug 2007 18:08:48 -0000 1.5 +++ gdb/gdbserver/linux-crisv32-low.c 14 Sep 2007 09:30:10 -0000 @@ -307,6 +307,21 @@ } static int +cris_watchpoint_support (char type) +{ + /* Breakpoint/watchpoint types is described in the comment for + cris_insert_watchpoint. */ + + if (type < '2' || type > '4') + { + /* Unsupported. */ + return 0; + } + /* Supported. */ + return 1; +} + +static int cris_stopped_by_watchpoint (void) { unsigned long exs; @@ -373,6 +388,7 @@ cris_breakpoint_at, cris_insert_watchpoint, cris_remove_watchpoint, + cris_watchpoint_support, cris_stopped_by_watchpoint, cris_stopped_data_address, }; Index: gdb/gdbserver/linux-ppc64-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-ppc64-low.c,v retrieving revision 1.8 diff -u -r1.8 linux-ppc64-low.c --- gdb/gdbserver/linux-ppc64-low.c 23 Aug 2007 18:08:48 -0000 1.8 +++ gdb/gdbserver/linux-ppc64-low.c 14 Sep 2007 09:30:21 -0000 @@ -130,5 +130,6 @@ NULL, NULL, NULL, + NULL, 1 }; Index: gdb/gdbserver/spu-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/spu-low.c,v retrieving revision 1.12 diff -u -r1.12 spu-low.c --- gdb/gdbserver/spu-low.c 23 Aug 2007 18:08:48 -0000 1.12 +++ gdb/gdbserver/spu-low.c 14 Sep 2007 09:30:27 -0000 @@ -596,6 +596,7 @@ NULL, NULL, NULL, + NULL, spu_arch_string, spu_proc_xfer_spu, }; Index: gdb/gdbserver/linux-cris-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-cris-low.c,v retrieving revision 1.5 diff -u -r1.5 linux-cris-low.c --- gdb/gdbserver/linux-cris-low.c 23 Aug 2007 18:08:48 -0000 1.5 +++ gdb/gdbserver/linux-cris-low.c 14 Sep 2007 09:30:07 -0000 @@ -116,8 +116,4 @@ cris_reinsert_addr, 0, cris_breakpoint_at, - 0, - 0, - 0, - 0, }; Index: gdb/remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.266 diff -u -r1.266 remote.c --- gdb/remote.c 23 Aug 2007 18:08:36 -0000 1.266 +++ gdb/remote.c 14 Sep 2007 09:30:06 -0000 @@ -2395,6 +2395,11 @@ PACKET_qXfer_spu_write }, { "QPassSignals", PACKET_DISABLE, remote_supported_packet, PACKET_QPassSignals }, + { "Z0", PACKET_DISABLE, remote_supported_packet, PACKET_Z0 }, + { "Z1", PACKET_DISABLE, remote_supported_packet, PACKET_Z1 }, + { "Z2", PACKET_DISABLE, remote_supported_packet, PACKET_Z2 }, + { "Z3", PACKET_DISABLE, remote_supported_packet, PACKET_Z3 }, + { "Z4", PACKET_DISABLE, remote_supported_packet, PACKET_Z4 }, }; static void @@ -5374,6 +5379,39 @@ _("remote_remove_watchpoint: reached end of function")); } +static int +hardware_resouce_to_Z_packet (int type) +{ + switch (type) + { + case bp_hardware_breakpoint: + return Z_PACKET_HARDWARE_BP; + break; + case bp_hardware_watchpoint: + return Z_PACKET_WRITE_WP; + break; + case bp_read_watchpoint: + return Z_PACKET_READ_WP; + break; + case bp_access_watchpoint: + return Z_PACKET_ACCESS_WP; + break; + default: + internal_error (__FILE__, __LINE__, + _("hardware_resouce_to_Z_packet: bad watchpoint type %d"), type); + } +} + +static int +remote_check_Zpacket_support (int type) +{ + enum Z_packet_type packet = hardware_resouce_to_Z_packet (type); + + if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE) + return 0; + + return 1; +} int remote_hw_watchpoint_limit = -1; int remote_hw_breakpoint_limit = -1; @@ -5381,6 +5419,9 @@ static int remote_check_watch_resources (int type, int cnt, int ot) { + if (! remote_check_Zpacket_support (type)) + return 0; + if (type == bp_hardware_breakpoint) { if (remote_hw_breakpoint_limit == 0) ----Next_Part(Fri_Sep_14_18_39_13_2007_055)----