Message ID | 83r2aun9mk.fsf@gnu.org |
---|---|
State | New |
Headers | show |
On 2019-03-25 1:31 p.m., Eli Zaretskii wrote: > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -11211,6 +11211,17 @@ > @item $_gthread > The global number of the current thread. @xref{global thread numbers}. > > +@item $_gdb_major > +@itemx $_gdb_minor > +@vindex $_gdb_major@{, convenience variable} > +@vindex $_gdb_minor@{, convenience variable} > +The major and minor version numbers of the running @value{GDBN}. > +Development snapshots and pretest versions have their minor version > +incremented by one; thus, @value{GDBN} pretest 9.11.90 will produce > +the value 12 for @code{$_gdb_minor}. These variables allow you to > +write scripts that work with different versions of @value{GDBN} > +without errors caused by features unavailable in some of those > +versions. > @end table I get this error when trying to "make html": /home/smarchi/src/binutils-gdb/gdb/doc/gdb.texinfo:11216: misplaced } /home/smarchi/src/binutils-gdb/gdb/doc/gdb.texinfo:11217: misplaced } Is it worth having a test for that? If we check that they have the expected value, it would be something to change when a new GDB branch is created, probably (as the master branch will now represent the next version). Maybe our release manager should have a say in this :). Otherwise, this LGTM. Simon
> From: Simon Marchi <simark@simark.ca> > Date: Mon, 25 Mar 2019 13:58:20 -0400 > > > +@item $_gdb_major > > +@itemx $_gdb_minor > > +@vindex $_gdb_major@{, convenience variable} > > +@vindex $_gdb_minor@{, convenience variable} > > +The major and minor version numbers of the running @value{GDBN}. > > +Development snapshots and pretest versions have their minor version > > +incremented by one; thus, @value{GDBN} pretest 9.11.90 will produce > > +the value 12 for @code{$_gdb_minor}. These variables allow you to > > +write scripts that work with different versions of @value{GDBN} > > +without errors caused by features unavailable in some of those > > +versions. > > @end table > > I get this error when trying to "make html": > > /home/smarchi/src/binutils-gdb/gdb/doc/gdb.texinfo:11216: misplaced } > /home/smarchi/src/binutils-gdb/gdb/doc/gdb.texinfo:11217: misplaced } Thanks, fixed. Too many r's... > Is it worth having a test for that? Hmm... how would you test that? > If we check that they have the expected value, it would be something > to change when a new GDB branch is created, probably (as the master > branch will now represent the next version). Maybe our release > manager should have a say in this :). I'm all ears. > Otherwise, this LGTM. Thanks for the review.
On 2019-03-25 14:10, Eli Zaretskii wrote: >> Is it worth having a test for that? > > Hmm... how would you test that? Something like gdb_test "print \$_gdb_major" " = 8" gdb_test "print \$_gdb_minor" " = 4" Simon
On 2019-03-25 14:33, Simon Marchi wrote: > On 2019-03-25 14:10, Eli Zaretskii wrote: >>> Is it worth having a test for that? >> >> Hmm... how would you test that? > > Something like > > gdb_test "print \$_gdb_major" " = 8" > gdb_test "print \$_gdb_minor" " = 4" > > Simon Or, the test could somehow automatically get the current version of GDB and compare $_gdb_major/$_gdb_minor against that, so that we don't need to modify it at every release. Simon
> Date: Mon, 25 Mar 2019 14:33:55 -0400 > From: Simon Marchi <simark@simark.ca> > Cc: gdb-patches@sourceware.org, brobecker@adacore.com > > > Hmm... how would you test that? > > Something like > > gdb_test "print \$_gdb_major" " = 8" > gdb_test "print \$_gdb_minor" " = 4" This would require changes with each new version. I thought you had in mind comparison with output of "gdb --version", suitably edited.
On 2019-03-25 14:43, Eli Zaretskii wrote: >> Date: Mon, 25 Mar 2019 14:33:55 -0400 >> From: Simon Marchi <simark@simark.ca> >> Cc: gdb-patches@sourceware.org, brobecker@adacore.com >> >> > Hmm... how would you test that? >> >> Something like >> >> gdb_test "print \$_gdb_major" " = 8" >> gdb_test "print \$_gdb_minor" " = 4" > > This would require changes with each new version. I thought you had > in mind comparison with output of "gdb --version", suitably edited. Yes, that's why I wondered initially if it was worth adding a test like this, since it would impose an additional burden on the person doing the release. However, comparing the output with gdb --version, or some other automated mean, would be perfect. Simon
> Date: Mon, 25 Mar 2019 14:51:36 -0400 > From: Simon Marchi <simark@simark.ca> > Cc: gdb-patches@sourceware.org, brobecker@adacore.com > > comparing the output with gdb --version, or some other automated > mean, would be perfect. Well, I never wrote any tests for GDB, and I'm not sure I have a system on which to run such a test. So I hope someone else will add this test.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2de1adc..f841e0a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-03-06 Eli Zaretskii <eliz@gnu.org> + + * NEWS: Announce $_gdb_major and $_gdb_minor. + + * top.c (init_gdb_version_vars): New function. + (gdb_init): Call init_gdb_version_vars. + 2019-03-25 Alan Hayward <alan.hayward@arm.com> * s390-linux-nat.c: Add include. diff --git a/gdb/NEWS b/gdb/NEWS index c45b313..676f0a0 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,12 @@ *** Changes since GDB 8.3 +* New built-in convenience variables $_gdb_major and $_gdb_minor + provide the GDB version. They are handy for conditionally using + features available only in or since specific GDB versions, in + scripts that should work error-free with many different versions, + such as in system-wide init files. + *** Changes in GDB 8.3 * GDB and GDBserver now support access to additional registers on diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 1f41498..c384267 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2019-03-06 Eli Zaretskii <eliz@gnu.org> + + * gdb.texinfo (Convenience Vars): Document $_gdb_version. + 2019-03-22 Alan Hayward <alan.hayward@arm.com> Jiong Wang <jiong.wang@arm.com> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 4c1d5e8..115bcf7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11211,6 +11211,17 @@ @item $_gthread The global number of the current thread. @xref{global thread numbers}. +@item $_gdb_major +@itemx $_gdb_minor +@vindex $_gdb_major@{, convenience variable} +@vindex $_gdb_minor@{, convenience variable} +The major and minor version numbers of the running @value{GDBN}. +Development snapshots and pretest versions have their minor version +incremented by one; thus, @value{GDBN} pretest 9.11.90 will produce +the value 12 for @code{$_gdb_minor}. These variables allow you to +write scripts that work with different versions of @value{GDBN} +without errors caused by features unavailable in some of those +versions. @end table @node Convenience Funs diff --git a/gdb/top.c b/gdb/top.c index b10b064..afb77c0 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -2003,6 +2004,17 @@ set_history_filename (const char *args, } static void +init_gdb_version_vars (void) +{ + struct internalvar *major_version_var = create_internalvar ("_gdb_major"); + struct internalvar *minor_version_var = create_internalvar ("_gdb_minor"); + int vmajor = 0, vminor = 0, vrevision = 0; + sscanf (version, "%d.%d.%d", &vmajor, &vminor, &vrevision); + set_internalvar_integer (major_version_var, vmajor); + set_internalvar_integer (minor_version_var, vminor + (vrevision > 0)); +} + +static void init_main (void) { struct cmd_list_element *c; @@ -2206,4 +2218,7 @@ gdb_init (char *argv0) prefix to be installed. Keep things simple and just do final script initialization here. */ finish_ext_lang_initialization (); + + /* Create $_gdb_major and $_gdb_minor convenience variables. */ + init_gdb_version_vars (); }