This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/RFC] New command: ``start''


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]