delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/09/05:48:35

Sender: bill AT taniwha DOT tssc DOT co DOT nz
Message-ID: <361DD47F.D65BF6C3@taniwha.tssc.co.nz>
Date: Fri, 09 Oct 1998 22:16:47 +1300
From: Bill Currie <bill AT taniwha DOT tssc DOT co DOT nz>
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.1.117 i486)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: can't track variables in RHGDB
References: <ranla DOT 7 DOT 0045FF7E AT post DOT tau DOT ac DOT il>
Reply-To: djgpp AT delorie DOT com

Tal Lavi wrote:
> 
> >On Tue, 6 Oct 1998, Tal Lavi wrote:
> 
> >> I guess it's my fault, but I can't track certain variables in RHGDB!
> >> it says they are not available, even though I entered the names correctly.
> 
> >Check out some of the cases described in sections 12.7-12.9 of the DJGPP
> >FAQ list, and see if yours is one of those cases.  If it is, and if you
> >have GCC 2.8.1 installed, try compiling with -gstubs3 or -gstubs+ instead
> >of -g, and see if the problems go away.

That should be stabs rather than stubs, I beleive (CMIIW).

> I haven't checked it thouroughly yet, but if I'm not mistaken, putting those
> makes no difference, disabling the optimization(-O2 -ffast-math) does!
> 
> funny thing is, you told me that putting optimizations won't screw up the
> program...

Program, no; debug info, yes.

> do you know why this is happening?

I do (mostly).  gcc produces debug info that states where the variable
lives for *MOST* of its life.  In unoptimised code, this is only ever in
one place (at the source level of course, assembly level the var moves
from mem->reg->mem).  In optimised code, the variable can move around
(sometimes in memory, sometimes in a reg) from line to line, making it
bloody difficult to track.  In fact, even function parameters can get
lost (ie, you get the wrong values in certain places)!!  Appearently,
only dwarf2 debug info provides enough info to track a variable for it's
entire live and, unfortunatly, gcc's (or at least egcs) dwarf2 support
is currently buggy (last I heard, there's been a fair bit of dwarf2
activity in the egcs lists).  Also, if the variable is not used [much],
it can get optimised out of existence. eg:

void foo (char *s)
{
    int i;
    for (i=0; i<10 && *s; i++, s++) {
        /* do something with s, no reference to i */
    }
}

`i' will (might?) get optimised out of existance.  NOTE, this may not be
the best example, but I *HAVE* seen loop counter variables vanish.

I don't know about coff debug info (I only ever used fsdb and edebug32
in djgpp), but I know from experience that stabs and dwarf DO NOT work
well with optimised code.  Infact, sometimes the line number info
doesn't always make sense due to sceduling operations (eg on PA-RISC,
the cpu I've been doing most of my work on currently (work machine, home
is 486/Linux)), ie the source line jumps around between two lines. 
Really disconcerting.

HTH
Bill
-- 
Leave others their otherness.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019