From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28734 invoked by alias); 7 May 2008 10:12:21 -0000 Received: (qmail 28709 invoked by uid 22791); 7 May 2008 10:12:18 -0000 X-Spam-Check-By: sourceware.org Received: from nwd2mail10.analog.com (HELO nwd2mail10.analog.com) (137.71.25.55) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 07 May 2008 10:11:58 +0000 X-IronPort-AV: E=Sophos;i="4.27,447,1204520400"; d="diff'?scan'208";a="67868916" Received: from nwd2mhb1.analog.com ([137.71.5.12]) by nwd2mail10.analog.com with ESMTP; 07 May 2008 06:11:56 -0400 Received: from nwd2exm4.ad.analog.com (nwd2exm4.ad.analog.com [10.64.53.123]) by nwd2mhb1.analog.com (8.9.3 (PHNE_28810+JAGae91741)/8.9.3) with ESMTP id GAA02691 for ; Wed, 7 May 2008 06:11:56 -0400 (EDT) Received: from chinexm1.ad.analog.com ([10.99.27.42]) by nwd2exm4.ad.analog.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 7 May 2008 06:11:56 -0400 Received: from [192.168.0.4] ([10.99.22.103]) by chinexm1.ad.analog.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 7 May 2008 18:11:46 +0800 Message-ID: <4821809E.2010904@analog.com> Date: Wed, 07 May 2008 12:43:00 -0000 From: Jie Zhang User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Call get_remote_state after gdbarch_breakpoint_from_pc is called Content-Type: multipart/mixed; boundary="------------050204090702020007060204" 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: 2008-05/txt/msg00260.txt.bz2 This is a multi-part message in MIME format. --------------050204090702020007060204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 533 Hi, I'm working on Blackfin port of GDB. Since Blackfin requires that 16-bit breakpoint for 16-bit instruction and 32-bit breakpoint for 32-bit instruction, Blackfin port GDB tries to read memory, decode instruction, and find the instruction length in gdbarch_breakpoint_from_pc. Reading memory calls putpkt and getpkt when debugging remotely, which might change rs->buf. So we have to call get_remote_state after gdbarch_breakpoint_from_pc in remote_insert_breakpoint. Same for remote_insert_hw_breakpoint. Is it OK? Jie --------------050204090702020007060204 Content-Type: text/x-diff; name="gdb-remote-state.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-remote-state.diff" Content-length: 2186 * remote.c (remote_insert_breakpoint): Call get_remote_state after gdbarch_breakpoint_from_pc is called. (remote_insert_hw_breakpoint): Likewise. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.286 diff -u -p -r1.286 remote.c --- remote.c 21 Mar 2008 17:09:35 -0000 1.286 +++ remote.c 7 May 2008 09:24:01 -0000 @@ -5496,9 +5496,6 @@ extended_remote_async_create_inferior (c static int remote_insert_breakpoint (struct bp_target_info *bp_tgt) { - CORE_ADDR addr = bp_tgt->placed_address; - struct remote_state *rs = get_remote_state (); - /* Try the "Z" s/w breakpoint packet if it is not already disabled. If it succeeds, then set the support to PACKET_ENABLE. If it fails, and the user has explicitly requested the Z support then @@ -5506,13 +5503,19 @@ remote_insert_breakpoint (struct bp_targ if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) { - char *p = rs->buf; + CORE_ADDR addr; + struct remote_state *rs; + char *p; + + gdbarch_breakpoint_from_pc + (current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size); + + rs = get_remote_state (); + p = rs->buf; *(p++) = 'Z'; *(p++) = '0'; *(p++) = ','; - gdbarch_breakpoint_from_pc - (current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size); addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address); p += hexnumstr (p, addr); sprintf (p, ",%d", bp_tgt->placed_size); @@ -5698,8 +5701,8 @@ static int remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt) { CORE_ADDR addr; - struct remote_state *rs = get_remote_state (); - char *p = rs->buf; + struct remote_state *rs; + char *p; /* The length field should be set to the size of a breakpoint instruction, even though we aren't inserting one ourselves. */ @@ -5710,6 +5713,9 @@ remote_insert_hw_breakpoint (struct bp_t if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) return -1; + rs = get_remote_state (); + p = rs->buf; + *(p++) = 'Z'; *(p++) = '1'; *(p++) = ','; --------------050204090702020007060204--