[RFA] Version 2 of patch to add 'maint profile-gdb' command

Jason Molenda
2001-09-16T17:45:00Z

Here is a minor rewrite of the profiling patch. I removed the
PARAMS, fixed the NEWS entry, and added a check for moncontrol()
with -pg - if this fails to compile (as it fails on sources.redhat.com),
an error message is spit out and the configure aborts. If a warning
is desirable, it's a minor change from calling AC_MSG_ERROR to
AC_MSG_WARN, but I found that to be too subtle in my testing (the
warning was lost among the configure output and people would be
confused why their --enable-profiling gdb isn't actually profiling.)
I amended the gdbint.texinfo documentation to note that the gmon.out
file is overwritten each time gdb is started.

The one notable change I did not incorporate was compiling with
-pg, linking without -pg, and using monstartup() to enable the
profiling. I have two problems with this - one, I _suspect_ (but
I do not know for certain) that linking without -pg and just calling
monstartup() is going to be unportable. The second problem is
that, off-hand, I don't know how a program should determine the
start and end addresses of its TEXT section portably (which are
required to use monstartup).

I agree that using monstartup() would be convenient, as developers
would not constantly overwrite their existing gmon.out file whenever
they start gdb, but I'd like to see this patch committed and someone
who understands the mechanisms of profiling across different systems
could tackle it in the future. In my opinion, monstartup() as a nice
refinement which a motivated person could tackle in the future. I'd
rather not complicate the basic feature with this at this point.
This patch was written nearly two years ago - it'd be good to get
it integrated.

NB - autoconf and autoheader must both be run after applying this patch.

Thanks for your help,

Jason
From eliz@is.elta.co.il Sun Sep 16 22:36:00 2001
From: Eli Zaretskii <eliz@is.elta.co.il>
To: jason-swarelist@molenda.com
Cc: gdb-patches@sources.redhat.com, tromey@cygnus.com
Subject: Re: [RFA] Version 2 of patch to add 'maint profile-gdb' command
Date: Sun, 16 Sep 2001 22:36:00 -0000
Message-id: <200109170536.HAA21988@is.elta.co.il>
References: <20010910003022.A21681@shell17.ba.best.com> <3B9CE0C6.5060700@cygnus.com> <20010910115244.A25119@shell17.ba.best.com> <3B9FACDA.6070407@cygnus.com> <20010916174433.A3258@shell17.ba.best.com>
X-SW-Source: 2001-09/msg00204.html
Content-length: 1311

> Date: Sun, 16 Sep 2001 17:44:33 -0700
> From: Jason Molenda <jason-swarelist@molenda.com>
>
> The one notable change I did not incorporate was compiling with
> -pg, linking without -pg, and using monstartup() to enable the
> profiling. I have two problems with this - one, I _suspect_ (but
> I do not know for certain) that linking without -pg and just calling
> monstartup() is going to be unportable. The second problem is
> that, off-hand, I don't know how a program should determine the
> start and end addresses of its TEXT section portably (which are
> required to use monstartup).

Emacs uses monstartup and manages to solve both of these problems.
See the file src/emacs.c (search for "etext") for the details.

> diff -u -p -r1.39 gdbint.texinfo
> --- doc/gdbint.texinfo 8 Sep 2001 10:53:45 -0000 1.39
> +++ doc/gdbint.texinfo 17 Sep 2001 00:34:26 -0000

I'd like the documentation of the "maint profile-gdb" command to be in
gdb.texinfo, not gdbint.texinfo. The latter doesn't document user
commands, and users might not readily know to look in gdbint. (It's
okay to have it described in both manuals, if you think it will be
useful.)

> +
> +@section Profiling GDB

Please replace "GDB" with "@value{GDBN}" everywhere.

Other than the last two comments, the patches to the docs are
approved.