Re: --with-pkgversion and --with-bugurl support for GDB

Joseph S. Myers
2008-05-20T16:10:02Z

On Tue, 20 May 2008, Eli Zaretskii wrote:

> Sorry, I don't agree. I think the manual should have clear
> instructions on how to report bugs efficiently. I don't like to ask
> users to study Web pages to know that when they are already reading
> documentation.
>
> I don't mind removing obsolete information, but please either update
> the rest to talk about bug-gdb and gdb@sources.redhat.com, or leave it
> intact and I will get to updating it when I have time.

This version keeps the original text if the default BUGURL value is
used. Tested with and without --with-bugurl use. OK to commit?

2008-05-20 Vladimir Prus <vladimir@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>

* acinclude.m4: Include ../config/acx.m4.
* configure.ac: Use ACX_PKGVERSION and ACX_BUGURL.
* configure: Regenerate.
* Makefile.in (PKGVERSION, REPORT_BUGS_TO): Define.
(GDB_CFLAGS): Define to include PKGVERSION and REPORT_BUGS_TO
settings.
* main.c (print_gdb_help): Use REPORT_BUGS_TO for bug-reporting
address.
* top.c (print_gdb_version): Use PKGVERSION and REPORT_BUGS_TO.

doc:
2008-05-20 Vladimir Prus <vladimir@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>

* configure.ac: Include ../../config/acx.m4. Use ACX_PKGVERSION
and ACX_BUGURL.
* configure: Regenerate.
* Makefile.in (PKGVERSION, BUGURL_TEXI): Define.
(GDBvn.texi): Define VERSION_PACKAGE, BUGURL and BUGURL_DEFAULT.
* gdb.texinfo: Use VERSION_PACKAGE and BUGURL. Remove
mailing-list-specific text about bug reporting unless
BUGURL_DEFAULT.

gdbserver:
2008-05-20 Vladimir Prus <vladimir@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>

* acinclude.m4: Include ../../config/acx.m4.
* configure.ac: Use ACX_PKGVERSION and ACX_BUGURL.
* configure: Regenerate.
* Makefile.in (PKGVERSION, REPORT_BUGS_TO): New.
(GLOBAL_CFLAGS): Add them.
(gdbreplay$(EXEEXT)): Add version.o.
* server.c (gdbserver_version): Print PKGVERSION.
(gdbsrever_usage): Add stream parameter. Print REPORT_BUGS_TO.
(main): Adjust gdbserver_usage calls.
* gdbreplay.c (version, host_name): Add declarations.
(gdbreplay_version, gdbreplay_usage): New.
(main): Accept --version and --help options.

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.1021
diff -u -p -r1.1021 Makefile.in
--- gdb/Makefile.in 16 May 2008 12:51:21 -0000 1.1021
+++ gdb/Makefile.in 20 May 2008 16:05:54 -0000
@@ -348,7 +348,11 @@ CONFIG_UNINSTALL = @CONFIG_UNINSTALL@
# your system doesn't have fcntl.h in /usr/include (which is where it
# should be according to Posix).
DEFS = @DEFS@
-GDB_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/config -DLOCALEDIR="\"$(localedir)\"" $(DEFS)
+PKGVERSION := "\"@PKGVERSION@\""
+REPORT_BUGS_TO = "\"@REPORT_BUGS_TO@\""
+GDB_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/config \
+ -DLOCALEDIR="\"$(localedir)\"" -DPKGVERSION=$(PKGVERSION) \
+ -DREPORT_BUGS_TO=$(REPORT_BUGS_TO) $(DEFS)

# MH_CFLAGS, if defined, has host-dependent CFLAGS from the config directory.
GLOBAL_CFLAGS = $(MH_CFLAGS)
Index: gdb/acinclude.m4
===================================================================
RCS file: /cvs/src/src/gdb/acinclude.m4,v
retrieving revision 1.18
diff -u -p -r1.18 acinclude.m4
--- gdb/acinclude.m4 23 Apr 2008 12:21:47 -0000 1.18
+++ gdb/acinclude.m4 20 May 2008 16:05:54 -0000
@@ -20,6 +20,9 @@ sinclude(../config/lib-ld.m4)
sinclude(../config/lib-prefix.m4)
sinclude(../config/lib-link.m4)

+dnl For ACX_PKGVERSION and ACX_BUGURL.
+sinclude(../config/acx.m4)
+
#
# Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
# makes configure think it's cross compiling. If --target wasn't used, then
Index: gdb/configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.68
diff -u -p -r1.68 configure.ac
--- gdb/configure.ac 19 Apr 2008 05:06:54 -0000 1.68
+++ gdb/configure.ac 20 May 2008 16:05:56 -0000
@@ -362,6 +362,9 @@ if test "$enable_profiling" = yes ; then
CFLAGS="$OLD_CFLAGS"
fi

+ACX_PKGVERSION([GDB])
+ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
+
# --------------------- #
# Checks for programs. #
# --------------------- #
Index: gdb/main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.67
diff -u -p -r1.67 main.c
--- gdb/main.c 14 Mar 2008 17:21:07 -0000 1.67
+++ gdb/main.c 20 May 2008 16:05:56 -0000
@@ -966,6 +966,9 @@ Options:\n\n\
fputs_unfiltered (_("\n\
For more information, type \"help\" from within GDB, or consult the\n\
GDB manual (available as on-line info or a printed manual).\n\
-Report bugs to \"bug-gdb@gnu.org\".\
"), stream);
+ if (REPORT_BUGS_TO[0] && stream == gdb_stdout)
+ fprintf_unfiltered (stream, _("\
+Report bugs to \"%s\".\n\
+"), REPORT_BUGS_TO);
}
Index: gdb/top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.141
diff -u -p -r1.141 top.c
--- gdb/top.c 5 May 2008 09:47:46 -0000 1.141
+++ gdb/top.c 20 May 2008 16:05:57 -0000
@@ -1125,7 +1125,7 @@ print_gdb_version (struct ui_file *strea
program to parse, and is just canonical program name and version
number, which starts after last space. */

- fprintf_filtered (stream, "GNU gdb %s\n", version);
+ fprintf_filtered (stream, "GNU gdb %s%s\n", PKGVERSION, version);

/* Second line is a copyright notice. */

@@ -1154,6 +1154,12 @@ and \"show warranty\" for details.\n");
fprintf_filtered (stream, "%s", host_name);
}
fprintf_filtered (stream, "\".");
+
+#ifdef REPORT_BUGS_TO
+ fprintf_filtered (stream,
+ _("\nFor bug reporting instructions, please see:\n"));
+ fprintf_filtered (stream, "%s.\n", REPORT_BUGS_TO);
+#endif
}
\f
/* get_prompt: access method for the GDB prompt string. */
Index: gdb/doc/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/doc/Makefile.in,v
retrieving revision 1.41
diff -u -p -r1.41 Makefile.in
--- gdb/doc/Makefile.in 1 Jan 2008 22:53:14 -0000 1.41
+++ gdb/doc/Makefile.in 20 May 2008 16:05:57 -0000
@@ -61,6 +61,10 @@ TEXI2ROFF=texi2roff
# where to find texi2dvi, ditto
TEXI2DVI=texi2dvi

+# Package version and bug-reporting URL.
+PKGVERSION = @PKGVERSION@
+BUGURL_TEXI = @REPORT_BUGS_TEXI@
+
# Where is the source dir for the READLINE library doc?
# Traditionally readline is in .. or .
READLINE_DIR = ${gdbdir}/../readline/doc
@@ -279,6 +283,13 @@ refcard.pdf : refcard.tex $(REFEDITS)
# File to record current GDB version number (copied from main dir version.in)
GDBvn.texi : ${gdbdir}/version.in
echo "@set GDBVN `sed q $(srcdir)/../version.in`" > ./GDBvn.new
+ if [ -n "$(PKGVERSION)" ]; then \
+ echo "@set VERSION_PACKAGE $(PKGVERSION)" >> ./GDBvn.new; \
+ fi
+ echo "@set BUGURL $(BUGURL_TEXI)" >> ./GDBvn.new
+ if [ "$(BUGURL_TEXI)" = "@uref{http://www.gnu.org/software/gdb/bugs/}" ]; then \
+ echo "@set BUGURL_DEFAULT" >> ./GDBvn.new; \
+ fi
mv GDBvn.new GDBvn.texi

# Updated atomically
Index: gdb/doc/configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/doc/configure.ac,v
retrieving revision 1.1
diff -u -p -r1.1 configure.ac
--- gdb/doc/configure.ac 7 Jan 2005 21:53:22 -0000 1.1
+++ gdb/doc/configure.ac 20 May 2008 16:05:59 -0000
@@ -1,5 +1,8 @@
AC_PREREQ(2.59)
AC_INIT(refcard.tex)
+sinclude(../../config/acx.m4)
AC_PROG_INSTALL
AC_PROG_LN_S
+ACX_PKGVERSION([GDB])
+ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
AC_OUTPUT(Makefile)
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.495
diff -u -p -r1.495 gdb.texinfo
--- gdb/doc/gdb.texinfo 9 May 2008 17:02:01 -0000 1.495
+++ gdb/doc/gdb.texinfo 20 May 2008 16:06:04 -0000
@@ -49,6 +49,9 @@ This file documents the @sc{gnu} debugge

This is the @value{EDITION} Edition, of @cite{Debugging with
@value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN}
+@ifset VERSION_PACKAGE
+@value{VERSION_PACKAGE}
+@end ifset
Version @value{GDBVN}.

Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@*
@@ -72,11 +75,15 @@ developing GNU and promoting software fr
@subtitle The @sc{gnu} Source-Level Debugger
@sp 1
@subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
+@ifset VERSION_PACKAGE
+@sp 1
+@subtitle @value{VERSION_PACKAGE}
+@end ifset
@author Richard Stallman, Roland Pesch, Stan Shebs, et al.
@page
@tex
{\parskip=0pt
-\hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@gnu.org.)\par
+\hfill (Send bugs and comments on @value{GDBN} to @value{BUGURL}.)\par
\hfill {\it Debugging with @value{GDBN}}\par
\hfill \TeX{}info \texinfoversion\par
}
@@ -116,8 +123,11 @@ software in general. We will miss him.

This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.

-This is the @value{EDITION} Edition, for @value{GDBN} Version
-@value{GDBVN}.
+This is the @value{EDITION} Edition, for @value{GDBN}
+@ifset VERSION_PACKAGE
+@value{VERSION_PACKAGE}
+@end ifset
+Version @value{GDBVN}.

Copyright (C) 1988-2006 Free Software Foundation, Inc.

@@ -22632,6 +22642,8 @@ individuals in the file @file{etc/SERVIC
distribution.
@c should add a web page ref...

+@ifset BUGURL
+@ifset BUGURL_DEFAULT
In any event, we also recommend that you submit bug reports for
@value{GDBN}. The preferred method is to submit them directly using
@uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
@@ -22651,6 +22663,12 @@ problem which can be crucial: a newsgrou
path back to the sender. Thus, if we need to ask for more information,
we may be unable to reach you. For this reason, it is better to send
bug reports to the mailing list.
+@end ifset
+@ifclear BUGURL_DEFAULT
+In any event, we also recommend that you submit bug reports for
+@value{GDBN} to @value{BUGURL}.
+@end ifclear
+@end ifset

The fundamental principle of reporting bugs usefully is this:
@strong{report all the facts}. If you are not sure whether to state a
Index: gdb/gdbserver/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/Makefile.in,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile.in
--- gdb/gdbserver/Makefile.in 3 May 2008 17:16:43 -0000 1.58
+++ gdb/gdbserver/Makefile.in 20 May 2008 16:06:04 -0000
@@ -87,9 +87,13 @@ READLINE_DEP = $$(READLINE_DIR)
# -I$(srcdir)/../regformats for regdef.h.
INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats -I$(INCLUDE_DIR)

+PKGVERSION := "\"@PKGVERSION@\""
+REPORT_BUGS_TO = "\"@REPORT_BUGS_TO@\""
+
# M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
# from the config/ directory.
-GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS}
+GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS} -DPKGVERSION=$(PKGVERSION) \
+ -DREPORT_BUGS_TO=$(REPORT_BUGS_TO)
#PROFILE_CFLAGS = -pg

WARN_CFLAGS = -Wall
@@ -194,9 +198,9 @@ gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} $
${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \
$(GDBSERVER_LIBS) $(XM_CLIBS)

-gdbreplay$(EXEEXT): gdbreplay.o
+gdbreplay$(EXEEXT): gdbreplay.o version.o
rm -f gdbreplay$(EXEEXT)
- ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) gdbreplay.o \
+ ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $^ \
$(XM_CLIBS)

# Put the proper machine-specific files first, so M-. on a machine
Index: gdb/gdbserver/acinclude.m4
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/acinclude.m4,v
retrieving revision 1.6
diff -u -p -r1.6 acinclude.m4
--- gdb/gdbserver/acinclude.m4 23 Apr 2008 12:21:50 -0000 1.6
+++ gdb/gdbserver/acinclude.m4 20 May 2008 16:06:04 -0000
@@ -4,6 +4,9 @@ sinclude(../../bfd/bfd.m4)
dnl This gets autoconf bugfixes
sinclude(../../config/override.m4)

+dnl For ACX_PKGVERSION and ACX_BUGURL.
+sinclude(../../config/acx.m4)
+
AC_DEFUN([SRV_CHECK_THREAD_DB],
[AC_CACHE_CHECK([for libthread_db],[srv_cv_thread_db],
[old_LIBS="$LIBS"
Index: gdb/gdbserver/configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.ac,v
retrieving revision 1.22
diff -u -p -r1.22 configure.ac
--- gdb/gdbserver/configure.ac 14 Apr 2008 18:04:00 -0000 1.22
+++ gdb/gdbserver/configure.ac 20 May 2008 16:06:05 -0000
@@ -68,6 +68,9 @@ AC_CHECK_TYPES(socklen_t, [], [],
#include <sys/socket.h>
])

+ACX_PKGVERSION([GDB])
+ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
+
. ${srcdir}/configure.srv

if test "${srv_mingwce}" = "yes"; then
Index: gdb/gdbserver/gdbreplay.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/gdbreplay.c,v
retrieving revision 1.16
diff -u -p -r1.16 gdbreplay.c
--- gdb/gdbserver/gdbreplay.c 1 Jan 2008 22:53:14 -0000 1.16
+++ gdb/gdbserver/gdbreplay.c 20 May 2008 16:06:05 -0000
@@ -69,6 +69,10 @@ typedef int socklen_t;
/* Sort of a hack... */
#define EOL (EOF - 1)

+/* Version information, from version.c. */
+extern const char version[];
+extern const char host_name[];
+
static int remote_desc;

#ifdef __MINGW32CE__
@@ -387,16 +391,44 @@ play (FILE *fp)
}
}

+static void
+gdbreplay_version (void)
+{
+ printf ("GNU gdbreplay %s%s\n"
+ "Copyright (C) 2008 Free Software Foundation, Inc.\n"
+ "gdbserver is free software, covered by the GNU General Public License.\n"
+ "This gdbserver was configured as \"%s\"\n",
+ PKGVERSION, version, host_name);
+}
+
+static void
+gdbreplay_usage (FILE *stream)
+{
+ fprintf (stream, "Usage:\tgdbreplay <logfile> <host:port>\n");
+ if (REPORT_BUGS_TO[0] && stream == stdout)
+ fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
+}
+
int
main (int argc, char *argv[])
{
FILE *fp;
int ch;

+ if (argc >= 2 && strcmp (argv[1], "--version") == 0)
+ {
+ gdbreplay_version ();
+ exit (0);
+ }
+ if (argc >= 2 && strcmp (argv[1], "--help") == 0)
+ {
+ gdbreplay_usage (stdout);
+ exit (0);
+ }
+
if (argc < 3)
{
- fprintf (stderr, "Usage: gdbreplay <logfile> <host:port>\n");
- fflush (stderr);
+ gdbreplay_usage (stderr);
exit (1);
}
fp = fopen (argv[1], "r");
Index: gdb/gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.72
diff -u -p -r1.72 server.c
--- gdb/gdbserver/server.c 9 May 2008 17:37:36 -0000 1.72
+++ gdb/gdbserver/server.c 20 May 2008 16:06:05 -0000
@@ -1178,26 +1178,28 @@ myresume (char *own_buf, int step, int *
static void
gdbserver_version (void)
{
- printf ("GNU gdbserver %s\n"
+ printf ("GNU gdbserver %s%s\n"
"Copyright (C) 2007 Free Software Foundation, Inc.\n"
"gdbserver is free software, covered by the GNU General Public License.\n"
"This gdbserver was configured as \"%s\"\n",
- version, host_name);
+ PKGVERSION, version, host_name);
}

static void
-gdbserver_usage (void)
+gdbserver_usage (FILE *stream)
{
- printf ("Usage:\tgdbserver [OPTIONS] COMM PROG [ARGS ...]\n"
- "\tgdbserver [OPTIONS] --attach COMM PID\n"
- "\tgdbserver [OPTIONS] --multi COMM\n"
- "\n"
- "COMM may either be a tty device (for serial debugging), or \n"
- "HOST:PORT to listen for a TCP connection.\n"
- "\n"
- "Options:\n"
- " --debug\t\tEnable debugging output.\n"
- " --wrapper WRAPPER --\tRun WRAPPER to start new programs.\n");
+ fprintf (stream, "Usage:\tgdbserver [OPTIONS] COMM PROG [ARGS ...]\n"
+ "\tgdbserver [OPTIONS] --attach COMM PID\n"
+ "\tgdbserver [OPTIONS] --multi COMM\n"
+ "\n"
+ "COMM may either be a tty device (for serial debugging), or \n"
+ "HOST:PORT to listen for a TCP connection.\n"
+ "\n"
+ "Options:\n"
+ " --debug\t\tEnable debugging output.\n"
+ " --wrapper WRAPPER --\tRun WRAPPER to start new programs.\n");
+ if (REPORT_BUGS_TO[0] && stream == stdout)
+ fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
}

#undef require_running
@@ -1234,7 +1236,7 @@ main (int argc, char *argv[])
}
else if (strcmp (*next_arg, "--help") == 0)
{
- gdbserver_usage ();
+ gdbserver_usage (stdout);
exit (0);
}
else if (strcmp (*next_arg, "--attach") == 0)
@@ -1251,7 +1253,7 @@ main (int argc, char *argv[])

if (next_arg == wrapper_argv || *next_arg == NULL)
{
- gdbserver_usage ();
+ gdbserver_usage (stderr);
exit (1);
}

@@ -1280,7 +1282,7 @@ main (int argc, char *argv[])
next_arg++;
if (port == NULL || (!attach && !multi_mode && *next_arg == NULL))
{
- gdbserver_usage ();
+ gdbserver_usage (stderr);
exit (1);
}

@@ -1305,7 +1307,7 @@ main (int argc, char *argv[])

if (bad_attach)
{
- gdbserver_usage ();
+ gdbserver_usage (stderr);
exit (1);
}

--
Joseph S. Myers
joseph@codesourcery.com