[PATCH] DW_AT_calling_convention support REV 2

Daniel Jacobowitz drow@mvista.com
Wed Jul 10 12:41:00 GMT 2002


On Wed, Jul 10, 2002 at 03:39:56PM -0400, Petr Sorfa wrote:
> Hi Daniel,
> 
> > > Revised patch for supporting DW_AT_calling_convention. This helps GDB
> > > identify the "main" program for languages that do not have a starting
> > > subroutine called "main". It adds a new API set for keeping track of the
> > > symbol associated with "main". Note that there are 3 checks for
> > > DW_AT_calling_convention. They are all necessary as they are detected at
> > > different times when processing program debug information.
> > 
> > I wasn't quite clear... there's one thing that should be different.
> > 
> > > + /* Determine whether the symbol passed is equivalent to
> > > +    the ``main'' symbol. Returns 0 if not or if there is no ``main''
> > > +    symbol set. */
> > > + int
> > > + is_main_symbol (struct symbol *check_symbol)
> > > + {
> > > +   return (check_symbol == NULL ? 0 : symbol_of_main == check_symbol);
> > > + }
> > >
> > >   void
> > >   _initialize_symtab (void)
> > 
> > I was thinking like:
> > 
> > int
> > is_main_symbol (struct symbol *check_symbol)
> > {
> >   if (symbol_of_main && symbol_of_main == check_symbol)
> >     return 1;
> >   else if (strcmp (SYMBOL_NAME (check_symbol), get_main_name ()) == 0)
> >     return 1;
> >   return 0;
> > }
> Good, I agree, that makes it more generic. Need to check for
> check_symbol for NULL as this might tank GDB at the second if.

Why should NULL be a legitimate argument?  Calling the function without
a symbol is useless...

> > And then change all callers of get_main_name () to use this.
> > 
> > (Note that this requires being careful if symbol_of_main gets
> > unloaded and we load a C program afterwards!)
> > 
> > Make sense?  Sound reasonable?
> Um, you've lost me. There is no get_main_name() function, do you mean
> get_main_symbol() or main_name()? I still not sure what the callers of
> the function should do.

main_name(), I assume.  Basically I would like everywhere that
currently checks by a strcmp/STREQ with main_name() to use
is_main_symbol () instead, etc.  Things that call lookup_symbol on
main_name() should just use get_main_symbol () if possible.  Then
set_main_name () could include calling lookup_symbol(main_name()), so
that get_main_symbol would always be valid, etc....

> Although, I do agree that the patch should catch unloading the
> main_symbol, but how?

I'm not sure :(  Is there a hook for when object files are unloaded?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gdb-patches mailing list