From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,7c47766edd175974 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-02 18:42:09 PST Message-ID: <3DC48DD0.B01E8DEE@sympatico.ca> From: David Marceau X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.4.17-10mdksmp i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How do package body initializers get run in GNU Ada? References: <3DC31EBB.2050809@math.jpl.nasa.gov> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Sat, 02 Nov 2002 21:45:36 -0500 NNTP-Posting-Host: 65.92.166.96 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1036291223 65.92.166.96 (Sat, 02 Nov 2002 21:40:23 EST) NNTP-Posting-Date: Sat, 02 Nov 2002 21:40:23 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:30315 Date: 2002-11-02T21:45:36-05:00 List-Id: 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 :)