comp.lang.ada
 help / color / mirror / Atom feed
From: David Marceau <davidmarceau@sympatico.ca>
Subject: Re: How do package body initializers get run in GNU Ada?
Date: Sat, 02 Nov 2002 21:45:36 -0500
Date: 2002-11-02T21:45:36-05:00	[thread overview]
Message-ID: <3DC48DD0.B01E8DEE@sympatico.ca> (raw)
In-Reply-To: 3DC31EBB.2050809@math.jpl.nasa.gov

Van Snyder wrote:
> 
> In GNU Ada, what mechanism is used to cause execution of package
> body initializers, i.e., the code between begin and end in a
> package body?
> 
> Is it done using some kind of back-patching/overlaying done
> by an otherwise garden-variety ld, by special features added
> to ld to support Ada, by first-time flags at the entries
> to procedures, or by something else?
> 
> --
> Van Snyder                    |  What fraction of Americans believe
> vsnyder@math.jpl.nasa.gov     |  Wrestling is real and NASA is fake?
> Any alleged opinions are my own and have not been approved or
> disapproved by JPL, CalTech, NASA, Sean O'Keefe, George Bush,
> the Pope, or anybody else.
Hi there,

If I understood correctly you have two questions:
1)how do package body initializers get run in ada?
I am going to interpret that you mean what is the sequence of execution
of your ada lines of source code.
Without actually reading any gnat docs, 
IMHO I believe it worthwhile to place tracelog statements at the
beginning of every service including the initialize service even if it
was empty(non-existant).
Some people may find this a waste of time however IMHO you will have a
better understanding of what is going on at runtime if you do this.  In
the long term it certainly makes your code easier to diagnose where a
run-time error is caused.  Keep in mind the tracelog statements should
have a few things: package name, service name, line number.
A trick that some people may not agree with is exceptions info types
actually provide all this so you might embed a "begin fake exception
where fake exception print  exception info end; " block.
Once your program is finished executing you can look in your tracelog
for the order of execution of all your statements including especially
your "initialize" service.
As an alternative to a tracelog, you can achieve what you want by
stepping through your code with gdb. And I do mean "step" and not
"next".  It's long and tedious however it will show you the order of
elaboration, execution... of all your ada source.

2)What mechanism is used to cause execution of package body intializers?
I'm going to interpret that you mean how exactly the mechanism was
designed and written to implement the running of package body
initializers.
I think Mr. Duff's summary was clear and it shows he knows what %�! he's
talking about :)
For the detailed how, if I were you I would look at the gnat sources and
along with all the config makefiles and linker script.  Warning reading
these sources for what you want to know will open a can of worms so it
requires a lot of coffee and some reference books for linkers and
loaders.
Do I really know what I'm talking about?  No.

Cheers :)



  parent reply	other threads:[~2002-11-03  2:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-02  0:39 How do package body initializers get run in GNU Ada? Van Snyder
2002-11-02  1:23 ` Jeffrey Carter
2002-11-02  1:28 ` sk
2002-11-04 15:20   ` Stephen Leake
2002-11-05  1:03     ` sk
2002-11-02 16:00 ` Robert A Duff
2002-11-03  2:45 ` David Marceau [this message]
2002-11-03 11:37 ` Romanov
2002-11-03 20:14   ` Simon Wright
replies disabled

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