From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21557 invoked by alias); 23 Jun 2003 21:39:34 -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 11768 invoked from network); 23 Jun 2003 21:18:26 -0000 Received: from unknown (HELO mailhost.intrinsity.com) (208.246.32.130) by sources.redhat.com with SMTP; 23 Jun 2003 21:18:26 -0000 Received: from victoria.intrinsity.com (victoria.eng.intrinsity.com [192.168.1.29]) by mailhost.intrinsity.com (Postfix) with ESMTP id E65063F385; Mon, 23 Jun 2003 16:18:24 -0500 (CDT) Received: from beeville.vert.intrinsity.com (beeville.vert.intrinsity.com [192.168.3.48]) by victoria.intrinsity.com (Postfix) with ESMTP id A9EB74586D; Mon, 23 Jun 2003 16:18:24 -0500 (CDT) Received: by beeville.vert.intrinsity.com (Postfix, from userid 621) id AEF0E2F2F2C; Mon, 23 Jun 2003 21:18:23 +0000 (UTC) Subject: Re: [PATCH] Don't clobber info->mach in gdb_print_insn_mips To: ac131313@redhat.com (Andrew Cagney) Date: Mon, 23 Jun 2003 21:39:00 -0000 Cc: fnf@intrinsity.com (Fred Fish), gdb-patches@sources.redhat.com Reply-To: fnf@intrinsity.com (Fred Fish) In-Reply-To: <3EF763B4.9080708@redhat.com> from "Andrew Cagney" at Jun 23, 2003 04:31:48 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030623211823.AEF0E2F2F2C@beeville.vert.intrinsity.com> From: fnf@intrinsity.com (Fred Fish) X-SW-Source: 2003-06/txt/msg00740.txt.bz2 > > info->mach field being clobbered by gdb_print_insn_mips. The attached > > patch fixes it, though I'm not sure if this is the correct solution. > > What happens if info->mach is never set? gdb_disassemble_info should > have already set it correctly. Yes, gdb_disassemble_info sets it correctly, and then gdb_print_insn_mips clobbers it back to zero. Here is a typescript showing the order that various functions are called. Without my patch, gdb_disassemble_info sets it to a correct value, gdb_print_insn_mips clobbers it back to zero, and then eventually choose_arch_by_number gets called with mach==0 (my typescript shows 10611501, the expected value for my port, since I have my patch installed). Since choose_arch_by_number then returns zero, the code in set_default_mips_dis_options that sets mips_isa never gets executed: chosen_arch = choose_arch_by_number (info->mach); if (chosen_arch != NULL) { mips_processor = chosen_arch->processor; mips_isa = chosen_arch->isa; mips_cp0_names = chosen_arch->cp0_names; mips_cp0sel_names = chosen_arch->cp0sel_names; mips_cp0sel_names_len = chosen_arch->cp0sel_names_len; mips_hwr_names = chosen_arch->hwr_names; } and mips_isa remains set to ISA_MIPS3 from earlier in set_default_mips_dis_options: mips_isa = ISA_MIPS3; -Fred ============================================================================ fred:intrinsity [35] gdb -nw gdb GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... Setting up the environment for debugging gdb. Breakpoint 1 at 0x815f7ae: file /src/intrinsity/sdk/sdk/fsf/gdb/gdb/utils.c, line 800. Breakpoint 2 at 0x8096c2c: file /src/intrinsity/sdk/sdk/fsf/gdb/gdb/cli/cli-cmds.c, line 191. Breakpoint 3 at 0x82e8c52: file /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c, line 469. Breakpoint 4 at 0x82e8d11: file /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c, line 495. Breakpoint 5 at 0x82ea158: file /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c, line 1209. Breakpoint 6 at 0x81126cb: file /src/intrinsity/sdk/sdk/fsf/gdb/gdb/mips-tdep.c, line 5273. Breakpoint 7 at 0x80bb7de: file /src/intrinsity/sdk/sdk/fsf/gdb/gdb/disasm.c, line 318. (top-gdb) run j Starting program: /links2/build/intrinsity/sdk/T-mipsisa32-intrinsity-elf/fsf/gdb/gdb/gdb j GNU gdb 2003-06-22-cvs Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=mipsisa32-intrinsity-elf"... Setting up the environment for debugging gdb. .gdbinit:5: Error in sourced command file: Function "internal_error" not defined. (gdb) x/i main Breakpoint 7, gdb_disassemble_info (gdbarch=0x859c090, file=0x859a170) at /src/intrinsity/sdk/sdk/fsf/gdb/gdb/disasm.c:318 318 (fprintf_ftype) fprintf_filtered); (top-gdb) c Continuing. Breakpoint 6, gdb_print_insn_mips (memaddr=18446744071562199548, info=0xbfffd2a0) at /src/intrinsity/sdk/sdk/fsf/gdb/gdb/mips-tdep.c:5273 5273 memaddr = ADDR_BITS_REMOVE (memaddr); (top-gdb) c Continuing. Breakpoint 5, _print_insn_mips (memaddr=18446744071562199548, info=0xbfffd2a0, endianness=BFD_ENDIAN_BIG) at /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c:1209 1209 set_default_mips_dis_options (info); (top-gdb) c Continuing. Breakpoint 4, set_default_mips_dis_options (info=0xbfffd2a0) at /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c:495 495 mips_isa = ISA_MIPS3; (top-gdb) c Continuing. Breakpoint 3, choose_arch_by_number (mach=10611501) at /src/intrinsity/sdk/sdk/fsf/gdb/opcodes/mips-dis.c:469 469 if (hint_bfd_mach == mach (top-gdb) c Continuing. 0x800201fc
: addiu sp,sp,-256 (gdb)