From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Gilliam To: Joel Brobecker , gdb-patches@sources.redhat.com Subject: Re: [RFA/RFC] New command: ``start'' Date: Thu, 20 May 2004 20:33:00 -0000 Message-id: <200405201332.20114.pgilliam@us.ibm.com> References: <20040518024700.GV10684@gnat.com> <20040520160259.GV10684@gnat.com> <20040520171404.GA3880@nevyn.them.org> X-SW-Source: 2004-05/msg00615.html On Thursday 20 May 2004 10:14, Daniel Jacobowitz wrote: > On Thu, May 20, 2004 at 09:02:59AM -0700, Joel Brobecker wrote: > > Here is how we find the name of the main procedure: We lookup a certain > > symbol which is created by our binder, __gnat_ada_main_program_name. > > This symbol points to a string holding the name of the main procedure. > > You'll find the code in ada-lang.c:begin_command(). > > OK. So this has the property that I was hoping for; it won't return a > false positive for a non-Ada main program. > > > > I think the best approach may be to iterate over the languages > > > included in the object file, asking each of them whether this language > > > appears to contain a main procedure. Or even to simply skip the > > > langhook complexity and just call an Ada find-main function! For gcj > > > I suspect we will just change the debug information. > > > > I thought about several approaches along the same idea. One of them > > was to implement a sniffing mechanism, with certain sniffers having > > certain priorities. But you know, I really like the idea of dropping > > the langhook, and just call the ada function. Something like this: > > > > char * > > main_name () > > { > > /* If we found the name of main from the debug info, or > > already looked it up, then return the name of main. */ > > if (name_of_main != NULL) > > return name_of_main; > > > > /* Is the main in Ada? */ > > tmp_main_name = ada_find_main_name (); > > if (tmp_main_name != NULL) > > { > > set_main_name (tmp_main_name); > > return name_of_main; > > } > > > > /* Is the main in Java? */ > > tmp_main_name = java_find_main_name (); > > [etc...] > > > > /* Fallback: main_name must be the usual "main". */ > > set_main_name ("main); s/"main);/"main");/ > > return name_of_main; > > } > > > > The only drawback I see from this is that I will need to include > > ada-lang.h. It would have been nice to avoid this, which is possible > > with the langhooks. I could also add the ada_find_main_name() > > declaration in another more common .h file, but that would be a dirty > > trick, IMO. > > This is fine with me. Let's see if anyone else objects to it. > > Since I don't know of any language other than Ada that will have a > fallback for this, I don't think it's worth inventing a lot of > machinery for it. I'm not especially interested in allowing a language > to be compiled out, either.