Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@cygnus.com>
To: "Ben Combee" <bcombee@metrowerks.com>
Cc: <egcs@egcs.cygnus.com>, <gdb@sourceware.cygnus.com>
Subject: Re: IA32: printing FP register variables
Date: Fri, 09 Jul 1999 10:53:00 -0000	[thread overview]
Message-ID: <np3dyxu2ua.fsf@zwingli.cygnus.com> (raw)
In-Reply-To: <000d01bec9c2$06f4fdb0$3404010a@metrowerks.com>

> I have a similar problem as you have, Jim.  I'm working on the CodeWarrior
> x86/Linux port, and I have no way to represent that a value has been
> allocated to a MMX register.  While CW will also allocate local variables to
> floating point stack locations, we don't emit any useful debugging info for
> those variables.

I don't have an MMX manual handy, but it seems like a much easier case
than the FPU, since the registers don't shift around every time you do
an operation.

> As long as the relative position of items on the stack didn't change
> (this var is always 2 from the top), this should be OK.

Well, the reason this problem seems hard to me is exactly because the
position of items relative to the top of the stack *will* change,
whenever you execute instructions like FILD, FDIVP, etc.  If they were
a constant distance, then we could simply assign register numbers to
ST(0) -- ST(7) in the usual way, and everything would work.
From jimb@cygnus.com Fri Jul 09 11:14:00 1999
From: Jim Blandy <jimb@cygnus.com>
To: law@cygnus.com
Cc: egcs@egcs.cygnus.com, gdb@sourceware.cygnus.com
Subject: Re: IA32: printing FP register variables
Date: Fri, 09 Jul 1999 11:14:00 -0000
Message-id: <np1zehu1vd.fsf@zwingli.cygnus.com>
References: <4264.931496789@upchuck.cygnus.com>
X-SW-Source: 1999-q3/msg00027.html
Content-length: 1208

STABS's live range splitting notation can certainly do the job
correctly, but I wonder whether it can do it efficiently.  For every
instruction that changes TOP, you have to start a new range for every
variable.  So the size of debug info is O(number of insns * average
number of live variables).

Without knowing too much about how the FPU register allocation works,
I'd guess that GCC could simply emit a stab after each instruction
which changes the depth, whose value is the code address and whose
`desc' is the distance from TOP to the base used for register
numbering.

That is, if we've got an N_RSYM saying that foo lives in ST(2), and
we've just seen an N_FPSTACK stab with a value of 3, then we'll look
for foo in ST(5).  Or change the sign of things as appropriate.

This means the size of the debug info is O(number of insns).  On the
other hand, it's more work to implement in GDB.

In either case, GCC needs to be fixed to propagate the register
numbers through the stackifier.  At that point, if it is
straightforward to get GCC to emit LRS info, we could give that a try
(no work for me, assuming GDB's LRS code works!).  If that's too big,
then maybe we could try implementing a depth stab.
From amylaar@cygnus.co.uk Fri Jul 09 11:22:00 1999
From: Joern Rennecke <amylaar@cygnus.co.uk>
To: jimb@cygnus.com (Jim Blandy)
Cc: law@cygnus.com, egcs@egcs.cygnus.com, gdb@sourceware.cygnus.com
Subject: Re: IA32: printing FP register variables
Date: Fri, 09 Jul 1999 11:22:00 -0000
Message-id: <199907091822.TAA31184@phal.cygnus.co.uk>
References: <np1zehu1vd.fsf@zwingli.cygnus.com>
X-SW-Source: 1999-q3/msg00028.html
Content-length: 494

> STABS's live range splitting notation can certainly do the job
> correctly, but I wonder whether it can do it efficiently.  For every
> instruction that changes TOP, you have to start a new range for every
> variable.  So the size of debug info is O(number of insns * average
> number of live variables).

You only have to care about variables that are live in the register stack
before or after the operation.  So you can use an upper bound of 8.
Hence the deubg info is O(number of insns).
From bcombee@metrowerks.com Fri Jul 09 12:33:00 1999
From: "Ben Combee" <bcombee@metrowerks.com>
To: "Jim Blandy" <jimb@cygnus.com>
Cc: <egcs@egcs.cygnus.com>, <gdb@sourceware.cygnus.com>
Subject: Re: IA32: printing FP register variables
Date: Fri, 09 Jul 1999 12:33:00 -0000
Message-id: <014f01beca41$c42b4e50$3404010a@metrowerks.com>
References: <199907090356.WAA01337@zwingli.cygnus.com> <000d01bec9c2$06f4fdb0$3404010a@metrowerks.com> <np3dyxu2ua.fsf@zwingli.cygnus.com>
X-SW-Source: 1999-q3/msg00029.html
Content-length: 1281

> > As long as the relative position of items on the stack didn't change
> > (this var is always 2 from the top), this should be OK.
>
> Well, the reason this problem seems hard to me is exactly because the
> position of items relative to the top of the stack *will* change,
> whenever you execute instructions like FILD, FDIVP, etc.  If they were
> a constant distance, then we could simply assign register numbers to
> ST(0) -- ST(7) in the usual way, and everything would work.

I guess an example would help...

Consider this code where we have doubles a and b allocated to two spots on
the FP stack (excuse the MASM notation... I'm not yet fluent in gas syntax)

fld a_value        ;; a is at bottom_offset(0)
fld b_value        ;; b is at bottom_offset(1)
fld1               ;; temp with no debug info
fadd st2           ;; result of (a + 1)
fstp st1           ;; stored into b, pop the temp

At each instruction, the invariant that a is 0 from the bottom and b is 1
from the bottom holds.  Note, the bottom of the stack can be known by the
debugger via scanning the FPU tag word from the TOP element looking for a FP
register that is empty.  All this info is provided by an FSAVE or FSTENV.

--
Ben Combee, x86/Win32/Novell/Linux CompilerWarrior
http://www.metrowerks.com/


  parent reply	other threads:[~1999-07-09 10:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-08 20:56 Jim Blandy
1999-07-08 22:12 ` Jeffrey A Law
     [not found] ` <000d01bec9c2$06f4fdb0$3404010a@metrowerks.com>
1999-07-08 22:04   ` Jeffrey A Law
1999-07-09  7:04     ` Michael Meissner
1999-07-10 11:00       ` Tom Tromey
1999-07-09 10:53   ` Jim Blandy [this message]
     [not found] <199907091724.SAA31114@phal.cygnus.co.uk>
     [not found] ` <00d401beca31$3d752c10$3404010a@metrowerks.com>
1999-07-09 10:52   ` Jeffrey A Law
1999-07-09 13:50   ` Jim Blandy
1999-07-09 14:00 Michael Meissner
     [not found] <400.931648196@upchuck.cygnus.com>
     [not found] ` <np908ljwht.fsf@zwingli.cygnus.com>
     [not found]   ` <9209.931822541@upchuck.cygnus.com>
1999-07-12 16:50     ` Joern Rennecke
1999-07-12 17:18     ` Robert Lipe
1999-07-12 19:40   ` Richard Henderson
     [not found]     ` <np3dysi9gh.fsf@zwingli.cygnus.com>
1999-07-13 16:05       ` Richard Henderson
     [not found] <9500.931826533@upchuck.cygnus.com>
     [not found] ` <np1zeci6tm.fsf@zwingli.cygnus.com>
     [not found]   ` <npn1ws2xp1.fsf@zwingli.cygnus.com>
1999-07-19 23:41     ` Richard Henderson
1999-07-26 11:43       ` Jim Blandy
1999-07-26 13:15         ` Richard Henderson

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=np3dyxu2ua.fsf@zwingli.cygnus.com \
    --to=jimb@cygnus.com \
    --cc=bcombee@metrowerks.com \
    --cc=egcs@egcs.cygnus.com \
    --cc=gdb@sourceware.cygnus.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