From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Jacobowitz To: Joel Brobecker Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA/RFC] New command: ``start'' Date: Thu, 20 May 2004 17:14:00 -0000 Message-id: <20040520171404.GA3880@nevyn.them.org> References: <20040518024700.GV10684@gnat.com> <20040518214712.GD4036@nevyn.them.org> <20040518222740.GZ10684@gnat.com> <20040518224131.GA6026@nevyn.them.org> <20040519153615.GD10684@gnat.com> <20040519154155.GA8567@nevyn.them.org> <20040520010145.GQ10684@gnat.com> <20040520134600.GA11705@nevyn.them.org> <20040520160259.GV10684@gnat.com> X-SW-Source: 2004-05/msg00612.html 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); > 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. -- Daniel Jacobowitz