comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GDB won't break on constants (was: Any way to turn of constant merging in GCC 2.8.1?)
Date: Mon, 20 Feb 2006 15:55:12 -0600
Date: 2006-02-20T15:55:12-06:00	[thread overview]
Message-ID: <hcydnc9LHvUDpGfenZ2dnUVZ_v6dnZ2d@megapath.net> (raw)
In-Reply-To: lyIJf.284$gh4.197@trnddc06

"Anonymous Coward" <anonymous@coward.org> wrote in message
news:lyIJf.284$gh4.197@trnddc06...
...
> My problem is that the debugger will not break on a definition for a
> constant, and in some cases it will not allow me to override a
> constant value.  It appears that the compiler may be doing some kind
> of optimization, though I'm using the -O0 switch.

This isn't an optimization; it's essentially required by the Ada definition.
That is, "static expressions" have to be evaluated at compile-time. Once
that's done, there is no reason to store the constant in memory; the value
is used wherever it is referenced. A compiler that wastes memory for static
values would be pretty silly; I doubt that there are any that do that.
(Janus/Ada is pretty conservative about our code generation with the
optimizer off, but we don't use memory that we don't need.)

That probably means that there is no chance to break on it, because it has
no presence in memory. I can't speak for GDB, but certainly Janus/Ada and
our debugger can't break on a constant's definition, because nothing
whatsoever is generated for it. It would be like trying to break on "2".

Marking the constant as "aliased" requires that it has a machine address, so
the compiler will generate a variable for it. Then you probably can break on
it.

                           Randy.





      reply	other threads:[~2006-02-20 21:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-10  0:13 Any way to turn of constant merging in GCC 2.8.1? Anonymous Coward
2006-02-10  3:51 ` Keith Thompson
2006-02-10  6:13   ` Anonymous Coward
2006-02-18  3:01 ` Craig Carey
2006-02-18 10:37   ` Craig Carey
2006-02-18 17:10     ` GDB won't break on constants (was: Any way to turn of constant merging in GCC 2.8.1?) Anonymous Coward
2006-02-20 21:55       ` Randy Brukardt [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox