From: Joel Brobecker <brobecker@gnat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFA/RFC] New command: ``start''
Date: Tue, 18 May 2004 22:27:00 -0000 [thread overview]
Message-ID: <20040518222740.GZ10684@gnat.com> (raw)
In-Reply-To: <20040518214712.GD4036@nevyn.them.org>
> > 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.
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.
To give you a better understanding how who it works in Ada (as defined
in the Reference Manual [RM for short]), the execution of an Ada program
has 3 important phases: 1. Elaboration
2. Program execution
3. Finalization
The RM says that the elaboration should be performed inside a procedure
called "adainit", and that the finalization should be performed by a
procedure called "adafinal". The elaboration and finalization order
is computed by a tool called the "binder" that checks all the
dependencies, and generate a small source file that looks like this:
void
adainit (void)
{
/* Do the program elaboration here. */
}
void
adafinal (void)
{
/* Finalize the program. */
}
void
int
main (...)
{
adainit ();
the_user_main_program ();
adafinal ();
}
The last step when building a program is then to call the gnat linker
that will do 2 things: compile the file generated by the binder,
and then do the link. (this is all automated by our gnatmake tool :).
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.
One thing that might be worthwhile, though, is call it from
xdefault_main_program_name, instead of hard-coding "main" a second time.
But that might introduce an unwanted dependency.
--
Joel
next prev parent reply other threads:[~2004-05-18 22:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-18 2:47 Joel Brobecker
2004-05-18 6:32 ` Eli Zaretskii
2004-05-18 17:05 ` Joel Brobecker
2004-05-18 18:42 ` Eli Zaretskii
2004-05-18 19:03 ` Andrew Cagney
2004-05-19 5:39 ` Eli Zaretskii
2004-05-18 19:22 ` Joel Brobecker
2004-05-18 21:47 ` Daniel Jacobowitz
2004-05-18 22:27 ` Joel Brobecker [this message]
2004-05-18 22:41 ` Daniel Jacobowitz
2004-05-19 15:36 ` Joel Brobecker
2004-05-19 15:42 ` Daniel Jacobowitz
2004-05-19 16:10 ` Joel Brobecker
2004-05-20 1:01 ` Joel Brobecker
2004-05-20 5:29 ` Eli Zaretskii
2004-05-20 13:46 ` Daniel Jacobowitz
2004-05-20 16:03 ` Joel Brobecker
2004-05-20 17:14 ` Daniel Jacobowitz
2004-05-20 20:33 ` Paul Gilliam
2004-05-20 22:12 ` Joel Brobecker
2004-05-21 0:26 ` Daniel Jacobowitz
2004-05-21 1:31 ` Joel Brobecker
2004-05-24 22:24 ` Daniel Jacobowitz
2004-05-24 23:57 ` Joel Brobecker
2004-05-19 14:30 ` Andrew Cagney
2004-05-19 15:39 ` Joel Brobecker
2004-05-19 20:02 ` Eli Zaretskii
2004-05-21 18:57 ` Andrew Cagney
2004-05-18 19:30 Michael Elizabeth Chastain
2004-05-18 19:45 ` Joel Brobecker
2004-05-18 20:21 Michael Elizabeth Chastain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040518222740.GZ10684@gnat.com \
--to=brobecker@gnat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox