Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Brian Ford <ford@vss.fsi.com>, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp)
Date: Mon, 05 Apr 2004 18:18:00 -0000	[thread overview]
Message-ID: <vt2brm647f3.fsf@zenia.home> (raw)
In-Reply-To: <6654-Sat03Apr2004110513+0300-eliz@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 938 bytes --]


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.


[-- Attachment #2: test program to get a variable in %ebp --]
[-- Type: text/plain, Size: 609 bytes --]

#include <stdio.h>
#include <stdlib.h>

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])));
}

  reply	other threads:[~2004-04-05 18:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-01  0:11 Brian Ford
2004-04-01 17:22 ` Jim Blandy
2004-04-01 18:00   ` Brian Ford
2004-04-01 21:29     ` Jim Blandy
2004-04-01 22:54       ` Brian Ford
2004-04-02  7:45         ` Eli Zaretskii
     [not found]           ` <Pine dot GSO dot 4 dot 58 dot 0404021000390 dot 21204 at thing1-200>
     [not found]             ` <2719-Fri02Apr2004213907+0300-eliz at gnu dot org>
     [not found]               ` <Pine dot GSO dot 4 dot 58 dot 0404021648050 dot 21204 at thing1-200>
2004-04-02 17:31           ` Brian Ford
2004-04-02 19:42             ` Eli Zaretskii
2004-04-02 23:15               ` Brian Ford
2004-04-03  9:08                 ` Eli Zaretskii
2004-04-05 18:18                   ` Jim Blandy [this message]
2004-04-05 21:57                     ` Brian Ford
2004-04-18 16:33                       ` Eli Zaretskii
2004-04-05 18:21                   ` Jim Blandy
2004-04-05 22:46                   ` Brian Ford
2004-04-18 17:00                     ` Eli Zaretskii
2004-04-05 22:46                 ` Jim Blandy
2004-04-05 23:19                   ` Brian Ford
2004-04-05 23:38                     ` Jim Blandy
2004-04-06 14:53                       ` Brian Ford
2004-04-15  9:38                         ` Eli Zaretskii
2004-04-06 23:24                     ` Mark Kettenis
2004-04-07 16:25                       ` Brian Ford
2004-04-07 18:02                         ` Jim Blandy
2004-04-07 20:06                       ` [PATCH] Rename i386_xxx_reg_to_regnum Brian Ford
2004-04-07 20:48                         ` Jim Blandy
2004-04-07 21:06                           ` Brian Ford
2004-04-07 21:41                             ` Jim Blandy
2004-04-09 12:37                               ` Mark Kettenis
2004-04-09 17:49                                 ` Brian Ford
2004-04-06 23:23                   ` [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp) Mark Kettenis
2004-04-07 16:46                     ` Jim Blandy
2004-04-18 16:48                   ` Eli Zaretskii
2004-04-19  2:06                     ` ix86 PE/COFF DWARF register numbering (was Re: [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp)) Brian Ford
2004-04-19  5:59                       ` Eli Zaretskii
2004-04-19 16:34                         ` ix86 PE/COFF DWARF register numbering Brian Ford
2004-04-19 12:42                     ` [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp) Jim Blandy
2004-04-19  7:02                       ` Eli Zaretskii
2004-04-02 19:33           ` Eli Zaretskii
2004-04-02 22:47             ` Brian Ford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2brm647f3.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=eliz@gnu.org \
    --cc=ford@vss.fsi.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox