public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH] gdb: new --with-pkgversion-suffix configure option
Date: Fri, 11 Nov 2022 11:24:52 +0000	[thread overview]
Message-ID: <86a03c4f56f167a7c08ce40200425d92a2ac39e8.1668165880.git.aburgess@redhat.com> (raw)

Once GDB 13.1 is released, then the version string, for a build of GDB
made from the release branch should look like this:

  $ gdb --version
  GNU gdb (GDB) 13.1

We provide a configure option, --with-pkgversion, which allows control
over the 'GDB' string within '(GDB) ', and so, if we configure like
this:

  $ ../src/configure --with-pkgversion="My Distro"

then the final GDB's version string would look like this:

  $ gdb --version
  GNU gdb (My Distro) 13.1

It is not unreasonable to think that somebody building a distribution
specific version of GDB like this might want to also augment the
version number (13.1) in order to indicate a local patch level.

Now, the existing configure option, --with-pkgversion, clearly seems
to indicate that the package specific version number should be
included here, however, I don't find this result satisfactory.

Here are some possibilities.  I could include the full version number,
including my local patch number, like this:

  GNU gdb (My Distro 13.1.5) 13.1

I don't like this because of the duplication.  I could drop the
upstream version number, like this:

  GNU gdb (My Distro 5) 13.1

But I don't like this because it (IMHO) can lead to confusion, is this
GDB version 5?  Version 13.1?  I think this can potentially cause
confusion for a user.

I propose that a far better solution is to add a new configure option
that will allow me to attach additional content at the end of the
version string, like this:

  GNU gdb (My Distro) 13.1.5

This, I think, is much clearer.  To support this I propose adding a
new configure option, --with-pkgversion-suffix.  This option takes a
string, which is then appended to the version number.  And so, we now
configure like this:

  $ ../src/configure --with-pkgversion="My Distro" \
                     --with-pkgversion-suffix=".xx.yy"

And we now get the desired version output from both GDB and GDBServer:

  $ gdb --version
  GNU gdb (My Distro) 13.1.xx.yy
  $ gdbserver --version
  GNU gdbserver (My Distro) 13.1.xx.yy

Obviously, the new configure option is optional.  When it is not used
the suffix defaults to the empty string, so GDB's output will be
unchanged.
---
 gdb/acinclude.m4                |  3 +++
 gdb/config.in                   |  3 +++
 gdb/configure                   | 27 +++++++++++++++++++++++++--
 gdb/configure.ac                |  2 ++
 gdb/top.c                       |  3 ++-
 gdbserver/acinclude.m4          |  3 +++
 gdbserver/config.in             |  3 +++
 gdbserver/configure             | 23 +++++++++++++++++++++++
 gdbserver/configure.ac          |  2 ++
 gdbserver/server.cc             |  4 ++--
 gdbsupport/pkgversion-suffix.m4 | 33 +++++++++++++++++++++++++++++++++
 11 files changed, 101 insertions(+), 5 deletions(-)
 create mode 100644 gdbsupport/pkgversion-suffix.m4

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 62fa66c7af3..f9812c182eb 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -21,6 +21,9 @@ m4_include(../gdbsupport/compiler-type.m4)
 # This gets AM_GDB_WARNINGS.
 m4_include(../gdbsupport/warning.m4)
 
+dnl This gets GDB_PKGVERSION_SUFFIX.
+m4_include(../gdbsupport/pkgversion-suffix.m4)
+
 # AM_GDB_UBSAN
 m4_include(sanitize.m4)
 
diff --git a/gdb/config.in b/gdb/config.in
index 736e6be1c48..163e780aa7f 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -642,6 +642,9 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* A string to append to the version number */
+#undef PKGVERSION_SUFFIX
+
 /* Define to 1 if the "%H, %D and %DD" formats work to print decfloats. */
 #undef PRINTF_HAS_DECFLOAT
 
diff --git a/gdb/configure b/gdb/configure
index b54ac671fe3..65caca4bdf5 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -923,6 +923,7 @@ enable_profiling
 enable_codesign
 with_pkgversion
 with_bugurl
+with_pkgversion_suffix
 with_system_zlib
 with_zstd
 enable_rpath
@@ -1682,6 +1683,8 @@ Optional Packages:
                           library
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
+  --with-pkgversion-suffix=STRING
+                          Append STRING to the end of the version number
   --with-system-zlib      use installed libz
   --with-zstd             support zstd compressed debug sections
                           (default=auto)
@@ -11451,7 +11454,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11454 "configure"
+#line 11457 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11557,7 +11560,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11560 "configure"
+#line 11563 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16997,6 +17000,26 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+# Check whether --with-pkgversion-suffix was given.
+if test "${with_pkgversion_suffix+set}" = set; then :
+  withval=$with_pkgversion_suffix; case "$withval" in
+    yes) as_fn_error $? "version suffix not specified" "$LINENO" 5 ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac
+else
+  PKGVERSION_SUFFIX=""
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define PKGVERSION_SUFFIX "$PKGVERSION_SUFFIX"
+_ACEOF
+
+
+
 # --------------------- #
 # Checks for programs.  #
 # --------------------- #
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 12561d4d2de..eaa79c6701a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -427,6 +427,8 @@ ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
 
+GDB_PKGVERSION_SUFFIX
+
 # --------------------- #
 # Checks for programs.  #
 # --------------------- #
diff --git a/gdb/top.c b/gdb/top.c
index e9794184f07..9ead29be033 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1444,7 +1444,8 @@ print_gdb_version (struct ui_file *stream, bool interactive)
      program to parse, and is just canonical program name and version
      number, which starts after last space.  */
 
-  std::string v_str = string_printf ("GNU gdb %s%s", PKGVERSION, version);
+  std::string v_str = string_printf ("GNU gdb %s%s%s", PKGVERSION, version,
+				     PKGVERSION_SUFFIX);
   gdb_printf (stream, "%ps\n",
 	      styled_string (version_style.style (), v_str.c_str ()));
 
diff --git a/gdbserver/acinclude.m4 b/gdbserver/acinclude.m4
index 32d5d14ca6e..d49e606a88f 100644
--- a/gdbserver/acinclude.m4
+++ b/gdbserver/acinclude.m4
@@ -13,6 +13,9 @@ m4_include(../gdbsupport/compiler-type.m4)
 dnl This gets AM_GDB_WARNINGS.
 m4_include(../gdbsupport/warning.m4)
 
+dnl This gets GDB_PKGVERSION_SUFFIX.
+m4_include(../gdbsupport/pkgversion-suffix.m4)
+
 dnl codeset.m4 is needed for common.m4, but not for
 dnl anything else in gdbserver.
 m4_include(../config/codeset.m4)
diff --git a/gdbserver/config.in b/gdbserver/config.in
index 39ddc7c0edb..14414ff4ffa 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -402,6 +402,9 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* A string to append to the version number */
+#undef PKGVERSION_SUFFIX
+
 /* Define to 1 if the "%ll" format works to print long longs. */
 #undef PRINTF_HAS_LONG_LONG
 
diff --git a/gdbserver/configure b/gdbserver/configure
index 050264ed7da..0644a058d76 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -761,6 +761,7 @@ enable_build_warnings
 enable_gdb_build_warnings
 with_pkgversion
 with_bugurl
+with_pkgversion_suffix
 with_libthread_db
 enable_inprocess_agent
 '
@@ -1425,6 +1426,8 @@ Optional Packages:
   --with-ust-lib=PATH   Specify the directory for the installed UST library
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
+  --with-pkgversion-suffix=STRING
+                          Append STRING to the end of the version number
   --with-libthread-db=PATH
                           use given libthread_db directly
 
@@ -10276,6 +10279,26 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+# Check whether --with-pkgversion-suffix was given.
+if test "${with_pkgversion_suffix+set}" = set; then :
+  withval=$with_pkgversion_suffix; case "$withval" in
+    yes) as_fn_error $? "version suffix not specified" "$LINENO" 5 ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac
+else
+  PKGVERSION_SUFFIX=""
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define PKGVERSION_SUFFIX "$PKGVERSION_SUFFIX"
+_ACEOF
+
+
+
 # Check for various supplementary target information (beyond the
 # triplet) which might affect the choices in configure.srv.
 case "${target}" in
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index dc33f1a235b..d53ea96316f 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -194,6 +194,8 @@ ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
 
+GDB_PKGVERSION_SUFFIX
+
 # Check for various supplementary target information (beyond the
 # triplet) which might affect the choices in configure.srv.
 case "${target}" in
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index aaef38e0062..c76edae08f2 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3412,12 +3412,12 @@ handle_status (char *own_buf)
 static void
 gdbserver_version (void)
 {
-  printf ("GNU gdbserver %s%s\n"
+  printf ("GNU gdbserver %s%s%s\n"
 	  "Copyright (C) 2022 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);
+	  PKGVERSION, version, PKGVERSION_SUFFIX, host_name);
 }
 
 static void
diff --git a/gdbsupport/pkgversion-suffix.m4 b/gdbsupport/pkgversion-suffix.m4
new file mode 100644
index 00000000000..f05ac495ab3
--- /dev/null
+++ b/gdbsupport/pkgversion-suffix.m4
@@ -0,0 +1,33 @@
+dnl Autoconf configure script for GDB, the GNU debugger.
+dnl Copyright (C) 2022 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GDB.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Add support for the --with-pkgversion-suffix configure option.  Allows
+dnl the user to specify a string that is appended to the version number.
+AC_DEFUN([GDB_PKGVERSION_SUFFIX],[
+  AC_ARG_WITH(pkgversion-suffix,
+    AS_HELP_STRING([--with-pkgversion-suffix=STRING],
+                   [Append STRING to the end of the version number]),
+  [case "$withval" in
+    yes) AC_MSG_ERROR([version suffix not specified]) ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac],
+    PKGVERSION_SUFFIX="")
+  AC_DEFINE_UNQUOTED([PKGVERSION_SUFFIX], ["$PKGVERSION_SUFFIX"],
+                     [A string to append to the version number])
+])

base-commit: db2e277d1a840091f56185d94f9d39c6736d2556
-- 
2.25.4


             reply	other threads:[~2022-11-11 11:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 11:24 Andrew Burgess [this message]
2022-11-16 16:19 ` Tom Tromey
2022-11-16 16:58 ` Mike Frysinger
2022-11-17 15:49   ` Andrew Burgess
2022-11-17 16:26   ` Sam James

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=86a03c4f56f167a7c08ce40200425d92a2ac39e8.1668165880.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).