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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,14db193838d387d7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-17 11:24:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed.stueberl.de!proxad.net!usenet-fr.net!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: what are the created ~b files when using -g with gnatmake Date: Thu, 17 Jul 2003 13:22:25 -0500 Organization: ENST, France Message-ID: References: NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1058466176 12127 137.194.161.2 (17 Jul 2003 18:22:56 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 17 Jul 2003 18:22:56 +0000 (UTC) Cc: srouse To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:40422 Date: 2003-07-17T13:22:25-05:00 ----- Original Message ----- From: "srouse" Newsgroups: comp.lang.ada To: 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."