From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19831 invoked by alias); 17 Dec 2002 23:16:14 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19776 invoked from network); 17 Dec 2002 23:16:08 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 17 Dec 2002 23:16:08 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id gBHMnxg05274 for ; Tue, 17 Dec 2002 17:49:59 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gBHNG7232541; Tue, 17 Dec 2002 18:16:08 -0500 Received: from localhost.localdomain (vpn50-3.rdu.redhat.com [172.16.50.3]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gBHNG7L28552; Tue, 17 Dec 2002 18:16:07 -0500 Received: (from kev@localhost) by localhost.localdomain (8.11.6/8.11.6) id gBHNG1m18296; Tue, 17 Dec 2002 16:16:01 -0700 Date: Tue, 17 Dec 2002 15:28:00 -0000 From: Kevin Buettner Message-Id: <1021217231601.ZM18295@localhost.localdomain> In-Reply-To: cgd@broadcom.com "gdb tx39-elf configuration doesn't compile, multi-arch lossage?" (Dec 17, 10:52am) References: To: cgd@broadcom.com Subject: Re: gdb tx39-elf configuration doesn't compile, multi-arch lossage? Cc: gdb-patches@sources.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-12/txt/msg00528.txt.bz2 On Dec 17, 10:52am, cgd@broadcom.com wrote: > multi-arch lossage? Yes. (My fault, sorry.) I've just committed the patch below. Please let me know if you have any problems with it. Kevin 2002-12-17 Kevin Buettner * dve3900-rom.c (r3900_regnames): Don't use NUM_REGS to determine size. (fetch_bitmapped_register, store_bitmapped_register): Add bounds checks for r3900_regnames[]. Index: dve3900-rom.c =================================================================== RCS file: /cvs/src/src/gdb/dve3900-rom.c,v retrieving revision 1.8 diff -u -p -r1.8 dve3900-rom.c --- dve3900-rom.c 4 May 2001 04:15:24 -0000 1.8 +++ dve3900-rom.c 17 Dec 2002 23:07:55 -0000 @@ -113,7 +113,7 @@ static int ethernet = 0; different names than GDB does, and don't support all the registers either. */ -static char *r3900_regnames[NUM_REGS] = +static char *r3900_regnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -456,8 +456,15 @@ fetch_bitmapped_register (int regno, str { unsigned long val; unsigned char regbuf[MAX_REGISTER_RAW_SIZE]; + char *regname = NULL; - monitor_printf ("x%s\r", r3900_regnames[regno]); + if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0])) + internal_error (__FILE__, __LINE__, + "fetch_bitmapped_register: regno out of bounds"); + else + regname = r3900_regnames[regno]; + + monitor_printf ("x%s\r", regname); val = fetch_fields (bf); monitor_printf (".\r"); monitor_expect_prompt (NULL, 0); @@ -501,9 +508,16 @@ static void store_bitmapped_register (int regno, struct bit_field *bf) { unsigned long oldval, newval; + char *regname = NULL; + + if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0])) + internal_error (__FILE__, __LINE__, + "fetch_bitmapped_register: regno out of bounds"); + else + regname = r3900_regnames[regno]; /* Fetch the current value of the register. */ - monitor_printf ("x%s\r", r3900_regnames[regno]); + monitor_printf ("x%s\r", regname); oldval = fetch_fields (bf); newval = read_register (regno);