From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8946 invoked by alias); 3 Aug 2007 12:12:17 -0000 Received: (qmail 8795 invoked by uid 22791); 3 Aug 2007 12:12:14 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 03 Aug 2007 12:12:08 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.8/8.13.8) with ESMTP id l73CC6A3254142 for ; Fri, 3 Aug 2007 12:12:06 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.4) with ESMTP id l73CC5QA2273306 for ; Fri, 3 Aug 2007 14:12:05 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l73CC2Jo020595 for ; Fri, 3 Aug 2007 14:12:02 +0200 Received: from bbkeks.boeblingen.de.ibm.com (dyn-9-152-248-39.boeblingen.de.ibm.com [9.152.248.39]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l73CC1At020571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Aug 2007 14:12:02 +0200 Message-ID: <46B31B38.50400@de.ibm.com> Date: Fri, 03 Aug 2007 12:12:00 -0000 From: Markus Deuling User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: GDB Patches , Ulrich Weigand Subject: [rfc] [12/12] Get rid of current_gdbarch in remote.c Content-Type: multipart/mixed; boundary="------------040708080305000405070205" 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-08/txt/msg00042.txt.bz2 This is a multi-part message in MIME format. --------------040708080305000405070205 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 448 Hi, this patch gets rid of some of the current_gdbarch's in remote.c Is this ok to commit? ChangeLog: * remote.c (init_remote_state, fetch_register_using_p) (process_g_packet, remote_fetch_registers, remote_prepare_to_store) (store_register_using_P, store_registers_using_G) (remote_store_registers): Use FRAME or REGCACHE to recognize current architecture. -- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com --------------040708080305000405070205 Content-Type: text/plain; name="diff-remote" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff-remote" Content-length: 5826 diff -urpN src/gdb/remote.c dev/gdb/remote.c --- src/gdb/remote.c 2007-07-04 06:01:37.000000000 +0200 +++ dev/gdb/remote.c 2007-08-02 09:36:14.000000000 +0200 @@ -336,13 +336,13 @@ init_remote_state (struct gdbarch *gdbar /* Use the architecture to build a regnum<->pnum table, which will be 1:1 unless a feature set specifies otherwise. */ rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch, - gdbarch_num_regs (current_gdbarch), + gdbarch_num_regs (gdbarch), struct packet_reg); - for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++) + for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++) { struct packet_reg *r = &rsa->regs[regnum]; - if (register_size (current_gdbarch, regnum) == 0) + if (register_size (gdbarch, regnum) == 0) /* Do not try to fetch zero-sized (placeholder) registers. */ r->pnum = -1; else @@ -355,10 +355,10 @@ init_remote_state (struct gdbarch *gdbar with a remote protocol number, in order of ascending protocol number. */ - remote_regs = alloca (gdbarch_num_regs (current_gdbarch) - * sizeof (struct packet_reg *)); + remote_regs = alloca (gdbarch_num_regs (gdbarch) + * sizeof (struct packet_reg *)); for (num_remote_regs = 0, regnum = 0; - regnum < gdbarch_num_regs (current_gdbarch); + regnum < gdbarch_num_regs (gdbarch); regnum++) if (rsa->regs[regnum].pnum != -1) remote_regs[num_remote_regs++] = &rsa->regs[regnum]; @@ -370,7 +370,7 @@ init_remote_state (struct gdbarch *gdbar { remote_regs[regnum]->in_g_packet = 1; remote_regs[regnum]->offset = offset; - offset += register_size (current_gdbarch, remote_regs[regnum]->regnum); + offset += register_size (gdbarch, remote_regs[regnum]->regnum); } /* Record the maximum possible size of the g packet - it may turn out @@ -3641,7 +3641,7 @@ fetch_register_using_p (struct regcache return 0; case PACKET_ERROR: error (_("Could not fetch register \"%s\""), - gdbarch_register_name (current_gdbarch, reg->regnum)); + gdbarch_register_name (get_regcache_arch (regcache), reg->regnum)); } /* If this register is unfetchable, tell the regcache. */ @@ -3705,6 +3705,7 @@ send_g_packet (void) static void process_g_packet (struct regcache *regcache) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); int i, buf_len; @@ -3731,7 +3732,7 @@ process_g_packet (struct regcache *regca { rsa->sizeof_g_packet = buf_len / 2; - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (gdbarch); i++) { if (rsa->regs[i].pnum == -1) continue; @@ -3769,7 +3770,7 @@ process_g_packet (struct regcache *regca { int i; - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (gdbarch); i++) { struct packet_reg *r = &rsa->regs[i]; if (r->in_g_packet) @@ -3836,7 +3837,7 @@ remote_fetch_registers (struct regcache fetch_registers_using_g (regcache); - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (!rsa->regs[i].in_g_packet) if (!fetch_register_using_p (regcache, &rsa->regs[i])) { @@ -3862,7 +3863,7 @@ remote_prepare_to_store (struct regcache case PACKET_DISABLE: case PACKET_SUPPORT_UNKNOWN: /* Make sure all the necessary registers are cached. */ - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (rsa->regs[i].in_g_packet) regcache_raw_read (regcache, rsa->regs[i].regnum, buf); break; @@ -3877,6 +3878,7 @@ remote_prepare_to_store (struct regcache static int store_register_using_P (const struct regcache *regcache, struct packet_reg *reg) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); /* Try storing a single register. */ @@ -3893,7 +3895,7 @@ store_register_using_P (const struct reg xsnprintf (buf, get_remote_packet_size (), "P%s=", phex_nz (reg->pnum, 0)); p = buf + strlen (buf); regcache_raw_collect (regcache, reg->regnum, regp); - bin2hex (regp, p, register_size (current_gdbarch, reg->regnum)); + bin2hex (regp, p, register_size (gdbarch, reg->regnum)); remote_send (&rs->buf, &rs->buf_size); switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_P])) @@ -3902,7 +3904,7 @@ store_register_using_P (const struct reg return 1; case PACKET_ERROR: error (_("Could not write register \"%s\""), - gdbarch_register_name (current_gdbarch, reg->regnum)); + gdbarch_register_name (gdbarch, reg->regnum)); case PACKET_UNKNOWN: return 0; default: @@ -3927,7 +3929,7 @@ store_registers_using_G (const struct re int i; regs = alloca (rsa->sizeof_g_packet); memset (regs, 0, rsa->sizeof_g_packet); - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) { struct packet_reg *r = &rsa->regs[i]; if (r->in_g_packet) @@ -3982,7 +3984,7 @@ remote_store_registers (struct regcache store_registers_using_G (regcache); - for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (!rsa->regs[i].in_g_packet) if (!store_register_using_P (regcache, &rsa->regs[i])) /* See above for why we do not issue an error here. */ --------------040708080305000405070205--