This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA/RFC] New command: ``start''
On Tue, May 18, 2004 at 03:27:40PM -0700, Joel Brobecker wrote:
> > > As briefly discussed on gdb@ and gdb-patches@, here is a first proposal
> > > for the addition of a new command: ``start''.
> > >
> > > I handled the language-dependent issue by adding a new method to the
> > > language vector. I returns a newly allocated string that tells GDB
> > > where to insert the breakpoint. I named it "main_program_name" because
> > > I would expect it to always return the name of a procedure. However,
> > > it can actually return any location expression. So a language could
> > > use a different approach and return something like "*0xdeadbeef" or
> > > "source.c:10" for instance.
> >
> > We already have a function for this: main_name. Is it adequate for
> > Ada?
>
> I forgot about this function. But I don't think it's adequate for the
> start command. If I understand everything correctly, this function
> relies on some information provided in stabs via N_MAIN symbols.
> Otherwise, it defaults to "main". This wouldn't necessarily work
> with any debug format.
You're right, GDB doesn't currently set this from dwarf2 data. Fortran
has a dwarf tag for something similar, but it doesn't look like it's
quite the same: DW_AT_calling_convention DW_CC_program.
> Also, the purpose of this function is slightly different from what
> I am trying to achieve with the language method: Despite the fact that
> most users see Ada programs starting at the begining of their main
> procedure, a closer approximation is that it starts inside procedure
> main() too.
I would say that this was the meaning of main_name, rather than the
entry point. Global constructors for C++ traditionally happen before
the "main program" and don't appear on the backtrace; same seems
reasonable for Ada. Without "set backtrace past-main on" you can't see
the caller of the user's code; that seems reasonable for Ada also. Do
you need backtraces to continue to "main"?
I don't want to proliferate mechanisms. It would be nice if the debug
readers could fill this in, and (if necessary, to support existing
tools) a language specific hook could be called as a fallback.
> So, even though most Ada users will usually only care about their
> own main procedure, I occasionally need to go up the stack up
> to procedure "main" to inspect it.
>
> Adapting main_name() to fit the purpose of the start command would
> cause the backtrace (amount other things) to be a bit shorter, and
> also depend on the current language.
The same points apply to Java; gcj even uses pretty much the same
mechanism as gnatbind.
--
Daniel Jacobowitz