Re: [RFA] patch to add 'maint profile-gdb' command

Eli Zaretskii
2001-09-12T06:00:00Z

> Date: Tue, 11 Sep 2001 23:59:55 -0700
> From: Jason Molenda <jason-swarelist@molenda.com>
>
> On Tue, Sep 11, 2001 at 10:57:34AM +0200, Eli Zaretskii wrote:
>
> > What I meant is that given you did compile with -pg, monstartup should do
> > the same as linking with -pg, with the possible exception of linking in
> > libc_p.a. (I don't think profiling the library is something you would
> > want to do in this case. IIRC, many systems don't even have libc_p
> > installed.)
>
> Are you suggesting that a program linked with -pg should call monstartup()?

No, I mean that a program _compiled_ with -pg, but linked _without_ -pg
will not start profiling until it calls monstartup. When you _link_
with -pg, you link into your program a module, normally called gcrt0.o,
which calls monstartup (or its equivalent) right from the beginning.

> There isn't any point - you're already profiling when you hit main() in a
> program compiled -pg.

Program compiled with -pg, but linked without -pg will not
automatically profile itself, AFAIK.

> #ifdef ENABLE_PROFILING
> #ifdef HAVE_MONCONTROL
> moncontrol (0);
> #endif
> #endif
>
> (or a compound #if, whatever.) I really don't see much point to
> bothering wiith a check for moncontrol. I suppose it means a gdb
> developer who tries to enable profiling without the necessary
> moncontrol() function will find out about his folly at configure-time
> instead of link-time, but that's the only benefit I can see.

I think this benefit should not be disposed off too easily. A person
who tries to configure with --enable-profiling might not realize we
require moncontrol, since usually building a profiling version of a
program doesn't require moncontrol, just -pg.