comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
To: <comp.lang.ada@ada.eu.org>
Cc: srouse <srouse@iastate.edu>
Subject: Re: what are the created ~b files when using -g with gnatmake
Date: Thu, 17 Jul 2003 13:22:25 -0500
Date: 2003-07-17T13:22:25-05:00	[thread overview]
Message-ID: <mailman.14.1058466165.24167.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: baac6198.0307161404.6bd6342d@posting.google.com


----- Original Message ----- 
From: "srouse" <srouse@iastate.edu>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Wednesday, July 16, 2003 5:04 PM
Subject: Re: what are the created ~b files when using -g with gnatmake


> Thank you for your help!
>
> Sorry about the "~b" typo!
>
> I have a couple more questions though...
>
> I'm creating an IDE for Ada in Eclipse and working on the debugger
> right now, so I'm trying to get a knowledge of how to debug Ada
> programs.  All my code is programmed in Java so I'm very familiar with
> how to debug Java programs.  With a Java program I step through the
> code that I have written.
>
> This is what I don't understand:
>
> If I have a project in GPS and go to debug it, I step through the
> created b~xxx.adb file.  Why would I not step through the xxx.adb
> file?
>
> I have been looking through the gnat user guide and gnatgdb debugger
> doc a great deal, but I still don't understand why the debugger steps
> through the b~xxx.adb file and not the xxx.adb file.
>
Here is a fragment of the file b~wc.adb produyced by building a small
program of mine.

Every b~*.adb file will have such a "main" function to correspond to
the "main" function of a typeical "C" program.

They are all pretty much alike except for the names of entities related to
the name of your main (Ada) procedure.

Your main procedure is given the name "Ada_Main_Program" within this
file, and you will see that "main" calls it after having called Initialize,
adainit, and Break_Start.

   function main
     (argc : Integer;
      argv : System.Address;
      envp : System.Address)
      return Integer
   is
      procedure initialize;
      pragma Import (C, initialize, "__gnat_initialize");

      procedure finalize;
      pragma Import (C, finalize, "__gnat_finalize");


      procedure Ada_Main_Program;
      pragma Import (Ada, Ada_Main_Program, "_ada_wc");

      Ensure_Reference : System.Address := Ada_Main_Program_Name'Address;

   begin
      gnat_argc := argc;
      gnat_argv := argv;
      gnat_envp := envp;

      Initialize;
      adainit;
      Break_Start;
      Ada_Main_Program;
      Do_Finalize;
      Finalize;
      return (gnat_exit_status);
   end;


You probably need to do some reading on the subject of "elaboration" in Ada,
which is what is being cone by the "adainit" procedure.

If you want to skip stepping through the elaboration code, you can set a
breakpoint
on the Break_Start procedure (which exists just for this purpose), and from
there
you will step into your main program.

Sometimes, however, there can be problems in elaboration code (e.g., in
someone's
library that you "withed" into your program).  Then, you will need to step
through
that elaboration code which will be one of the procedures called from within
"adainit."

This is admittedly just a cursory ecplanation of what goes on, and actually
stepping
through an "adainit" procedure will teach you a lot about what's going on
"under the
hood."






      parent reply	other threads:[~2003-07-17 18:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 15:59 what are the created ~b files when using -g with gnatmake srouse
2003-07-16 17:45 ` David C. Hoos
2003-07-16 22:04   ` srouse
2003-07-17 17:43     ` Jano
2003-07-17 18:22     ` David C. Hoos [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