From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3427 invoked by alias); 5 Apr 2004 22:46:03 -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 3352 invoked from network); 5 Apr 2004 22:45:55 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 Apr 2004 22:45:55 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i35Mjt5D026167 for ; Mon, 5 Apr 2004 18:45:55 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i35Mjqj06099; Mon, 5 Apr 2004 18:45:53 -0400 To: Brian Ford Cc: Eli Zaretskii , gdb-patches@sources.redhat.com Subject: Re: [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp) References: <8011-Fri02Apr2004094123+0300-eliz@gnu.org> <2719-Fri02Apr2004213907+0300-eliz@gnu.org> From: Jim Blandy Date: Mon, 05 Apr 2004 22:46:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-04/txt/msg00129.txt.bz2 I'm getting a bit lost, so let me try to sum up the discussion, for my own sake. There are two distinct questions at hand: - Should GDB's i386_stab_reg_to_regnum be changed? - What register numbering should Cygwin Dwarf 2 use? For the first question: I think your original patch is correct. The big question is, "Why wasn't it noticed before?" but there's an answer to that which seems pretty solid to me: - GCC's dbx_register_map and GDB's i386_stab_reg_to_regnum simply aren't used on many modern systems. Every ELF target that I see in GCC (except for i[34567]86-*-nto-qnx*) uses gcc/config/i386/i386.c's svr4_dbx_register_map. That agrees with i386-tdep.c's i386_dwarf_reg_to_regnum. In GDB, we have: void i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { /* We typically use stabs-in-ELF with the DWARF register numbering. */ set_gdbarch_stab_reg_to_regnum (gdbarch, i386_dwarf_reg_to_regnum); } and i386_elf_init_abi is called by: - i386fbsd-tdep.c (i386fbsd_init_abi) - i386gnu-tdep.c (i386gnu_init_abi) - i386-linux-tdep.c (i386_linux_init_abi) - i386nbsd-tdep.c (i386nbsdelf_init_abi) - i386-nto-tdep.c (i386nto_init_abi) - i386obsd-tdep.c (i386obsd_elf_init_abi) - i386-tdep.c (i386_svr4_init_abi) So just about every ELF target uses gdb/i386.c's i386_dwarf_reg_to_regnum for both STABS and Dwarf 2. So they never see the broken numbering. - The remain non-ELF tagrets are mostly non-Dwarf 2, and thus mostly STABS. And my message to Eli Zaretskii explains why %ebp / %esp discrepancies won't often show up in STABS. The bit-twiddling is correct, but I'd rather see something more direct, like: Index: gdb/i386-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.182 diff -c -c -F'^(' -r1.182 i386-tdep.c *** gdb/i386-tdep.c 1 Apr 2004 18:14:03 -0000 1.182 --- gdb/i386-tdep.c 5 Apr 2004 22:15:01 -0000 *************** *** 211,218 **** /* This implements what GCC calls the "default" register map. */ if (reg >= 0 && reg <= 7) { ! /* General-purpose registers. */ ! return reg; } else if (reg >= 12 && reg <= 19) { --- 211,223 ---- /* This implements what GCC calls the "default" register map. */ if (reg >= 0 && reg <= 7) { ! /* General-purpose registers. The debug info calls %ebp ! register 4, and %esp register 5. */ ! if (reg == 4) ! return 5; ! else if (reg == 5) ! return 4; ! else return reg; } else if (reg >= 12 && reg <= 19) { For the second question, about what register numbering to use in Cygwin Dwarf 2: We agree that there are no toolchains, other than the one we're putting together right now, that uses Dwarf 2 in PE, right? So we could choose any numbering we please without introducing incompatibilities with any existing toolchain. I'm not talking about what would be most consistent yet; I'm just observing that we wouldn't misread any prior existing compiler's output, or misdirect any prior existing debugger. So what would b the most consistent numbering to use? It's been said that "Dwarf 2 uses svr4_dbx_register_map." This is true, but it's incomplete. The big picture, I think, is this: - GCC doesn't switch register numberings depending on the debug format in use (except on rs6000). For a given GCC, -gstabs+ and -gdwarf-2 use the same numberings. - Dwarf 2 is mostly widely used on ELF systems, which almost all use svr4_dbx_register_map --- for both STABS and Dwarf 2. The statement "Dwarf 2 uses svr4_dbx_register_map" suggests that there would be targets that use svr4_dbx_register_map with Dwarf 2, but a different map for other debug formats. But that's the exception (the rs6000), not the rule. In fact, it looks to me as if DJGPP uses dbx_register_map for both STABS and Dwarf 2. (Eli, is this right?) It's true that the comments for svr4_dbx_register_map in gcc/config/i386/i386.c say: /* Define the register numbers to be used in Dwarf debugging information. but this comment doesn't match the code it accompanies: every i386 GCC configuration uses either dbx_register_map or svr4_dbx_register_map for both debug formats.