From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29614 invoked by alias); 5 Apr 2004 18:18: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 29587 invoked from network); 5 Apr 2004 18:17:55 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 Apr 2004 18:17: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 i35IHt5D022367 for ; Mon, 5 Apr 2004 14:17: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 i35IHqj29097; Mon, 5 Apr 2004 14:17:53 -0400 To: Eli Zaretskii Cc: Brian Ford , 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> <6654-Sat03Apr2004110513+0300-eliz@gnu.org> From: Jim Blandy Date: Mon, 05 Apr 2004 18:18:00 -0000 In-Reply-To: <6654-Sat03Apr2004110513+0300-eliz@gnu.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2004-04/txt/msg00120.txt.bz2 --=-=-= Content-length: 938 Eli, here is a program you can use to see whether DJGPP's GCC and the current GDB disagree on how to number %ebp and %esp. One of the reasons people would tend not to notice if %ebp and %esp are misnumbered in STABS is that they almost never occur. Dwarf 2 emits explicit location expressions to specify the "frame base" for a function; these expressions usually refer to %esp or %ebp. In STABS, however, stack-based variables are simply marked as "LSYMS" or "PSYMS", whose locations are given as offsets relative to some implicit base that the debugger just has to know. So the only way to get those register numbers to appear at all is to get a variable allocated to them. You'll never get a variable allocated to %esp. And you'll never get a varable allocated to %ebp unless you compile with -fomit-frame-pointer. So, if I compile the attached program with GCC 3.3 passing -O -fomit-frame-pointer, 'n' gets allocated to %ebp. --=-=-= Content-Disposition: attachment; filename=frameless.c Content-Description: test program to get a variable in %ebp Content-length: 609 #include #include int foo (register int n) { register int i; register int a = n * 1; register int b = n * 2; register int c = n * 3; register int d = n * 4; register int e = n * 5; for (i = 0; i < n; i++) { if (i & 1) a = b + c; else a = c + e; if (i & 2) b = c + d; else b = d + a; if (i & 4) c = d + e; else c = e + b; if (i & 8) d = e + a; else d = a + c; if (i & 16) e = a + b; else e = b + d; } return a + b + c + d + e; } int main (int argc, char **argv) { if (argc == 2) printf ("%d\n", foo (atoi (argv[1]))); } --=-=-=--