public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: tom@tromey.com
Cc: gdb-patches@sourceware.org
Subject: Re: GDB version as convenience variable
Date: Wed, 20 Mar 2019 19:35:00 -0000	[thread overview]
Message-ID: <83k1gts5it.fsf@gnu.org> (raw)
In-Reply-To: <83imwwc7pj.fsf@gnu.org> (message from Eli Zaretskii on Wed, 06	Mar 2019 18:02:00 +0200)

Ping!

> Date: Wed, 06 Mar 2019 18:02:00 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> CC: gdb-patches@sourceware.org
> 
> > From: Tom Tromey <tom@tromey.com>
> > Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> > Date: Mon, 04 Mar 2019 10:40:46 -0700
> > 
> > >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> > 
> > Eli> What do you think about the idea to add a convenience variable that
> > Eli> would provide the GDB version?
> > 
> > Seems reasonable to me.
> 
> How about the patch below?  Is it okay to go in?  (Note that I took
> this opportunity to clean up whitespace in top.c, I hope it's OK to do
> that as part of unrelated code changes.)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index ac61e65..f2915d0 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,10 @@
> +2019-03-06  Eli Zaretskii  <eliz@gnu.org>
> +
> +	* NEWS: Announce $_gdb_version.
> +
> +	* top.c (init_gdb_version_var): New function.
> +	(gdb_init): Call init_gdb_version_var.
> +
>  2019-03-06  Tom Tromey  <tromey@adacore.com>
>  
>  	* remote-sim.c (gdbsim_target_open): Use result of
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cc7c35c..260e6cc 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -3,6 +3,12 @@
>  
>  *** Changes since GDB 8.3
>  
> +* New built-in convenience variable $_gdb_version provides the GDB
> +  version.  It is 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 0380322..313a061 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-05  Simon Marchi  <simon.marchi@efficios.com>
>  
>  	* python.texi (Values From Inferior): Change synopsys of the
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index f2028f8..9d15337 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -11197,7 +11197,7 @@
>  @vindex $_tlb@r{, convenience variable}
>  The variable @code{$_tlb} is automatically set when debugging
>  applications running on MS-Windows in native mode or connected to
> -gdbserver that supports the @code{qGetTIBAddr} request. 
> +gdbserver that supports the @code{qGetTIBAddr} request.
>  @xref{General Query Packets}.
>  This variable contains the address of the thread information block.
>  
> @@ -11211,6 +11211,17 @@
>  @item $_gthread
>  The global number of the current thread.  @xref{global thread numbers}.
>  
> +@item $_gdb_version
> +@vindex $_gdb_version@r{, convenience variable}
> +The version of the running @value{GDBN}.  The value is an integer
> +number that encodes the major and minor @value{GDBN} versions as
> +@w{@code{@var{major}*100 + @var{minor}}}, so, e.g., @value{GDBN}
> +version 9.10 will produce the value @code{910}.  Development snapshots
> +and pretest versions have their minor version incremented by one;
> +thus, @value{GDBN} pretest 9.11.90 will produce the value 912.  This
> +variable allows 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 22e6f7e..97b349a 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -147,22 +147,22 @@ int server_command;
>  
>  /* Timeout limit for response from target.  */
>  
> -/* The default value has been changed many times over the years.  It 
> -   was originally 5 seconds.  But that was thought to be a long time 
> +/* The default value has been changed many times over the years.  It
> +   was originally 5 seconds.  But that was thought to be a long time
>     to sit and wait, so it was changed to 2 seconds.  That was thought
> -   to be plenty unless the connection was going through some terminal 
> +   to be plenty unless the connection was going through some terminal
>     server or multiplexer or other form of hairy serial connection.
>  
> -   In mid-1996, remote_timeout was moved from remote.c to top.c and 
> +   In mid-1996, remote_timeout was moved from remote.c to top.c and
>     it began being used in other remote-* targets.  It appears that the
>     default was changed to 20 seconds at that time, perhaps because the
>     Renesas E7000 ICE didn't always respond in a timely manner.
>  
>     But if 5 seconds is a long time to sit and wait for retransmissions,
> -   20 seconds is far worse.  This demonstrates the difficulty of using 
> +   20 seconds is far worse.  This demonstrates the difficulty of using
>     a single variable for all protocol timeouts.
>  
> -   As remote.c is used much more than remote-e7000.c, it was changed 
> +   As remote.c is used much more than remote-e7000.c, it was changed
>     back to 2 seconds in 1999.  */
>  
>  int remote_timeout = 2;
> @@ -188,9 +188,9 @@ int (*deprecated_ui_loop_hook) (int);
>  
>  /* Called from print_frame_info to list the line we stopped in.  */
>  
> -void (*deprecated_print_frame_info_listing_hook) (struct symtab * s, 
> +void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
>  						  int line,
> -						  int stopline, 
> +						  int stopline,
>  						  int noerror);
>  /* Replaces most of query.  */
>  
> @@ -237,7 +237,7 @@ ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
>  /* Used by UI as a wrapper around command execution.  May do various
>     things like enabling/disabling buttons, etc...  */
>  
> -void (*deprecated_call_command_hook) (struct cmd_list_element * c, 
> +void (*deprecated_call_command_hook) (struct cmd_list_element * c,
>  				      const char *cmd, int from_tty);
>  
>  /* Called when the current thread changes.  Argument is thread id.  */
> @@ -1339,8 +1339,9 @@ There is NO WARRANTY, to the extent permitted by law.");
>  resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."));
>    fprintf_filtered (stream, "\n\n");
>    fprintf_filtered (stream, _("For help, type \"help\".\n"));
> -  fprintf_filtered (stream, _("Type \"apropos word\" to search for \
> -commands related to \"word\"."));
> +  fprintf_filtered (stream,
> +		    _("Type \"apropos word\" to search for commands \
> +related to \"word\"."));
>  }
>  
>  /* Print the details of GDB build-time configuration.  */
> @@ -1608,7 +1609,7 @@ quit_force (int *exit_arg, int from_tty)
>  
>    undo_terminal_modifications_before_exit ();
>  
> -  /* An optional expression may be used to cause gdb to terminate with the 
> +  /* An optional expression may be used to cause gdb to terminate with the
>       value of that expression.  */
>    if (exit_arg)
>      exit_code = *exit_arg;
> @@ -1998,11 +1999,21 @@ set_history_filename (const char *args,
>       directories the file written will be the same as the one
>       that was read.  */
>    if (!IS_ABSOLUTE_PATH (history_filename))
> -    history_filename = reconcat (history_filename, current_directory, "/", 
> +    history_filename = reconcat (history_filename, current_directory, "/",
>  				 history_filename, (char *) NULL);
>  }
>  
>  static void
> +init_gdb_version_var (void)
> +{
> +  struct internalvar *version_var = create_internalvar ("_gdb_version");
> +  int vmajor = 0, vminor = 0, vrevision = 0;
> +  sscanf (version, "%d.%d.%d", &vmajor, &vminor, &vrevision);
> +  set_internalvar_integer (version_var,
> +			   vmajor * 100 + vminor + (vrevision > 0));
> +}
> +
> +static void
>  init_main (void)
>  {
>    struct cmd_list_element *c;
> @@ -2206,4 +2217,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_version convenience variable.  */
> +  init_gdb_version_var ();
>  }
> 

  reply	other threads:[~2019-03-20 19:35 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  0:16 [PATCH 00/16] Add styling to the gdb CLI and TUI Tom Tromey
2018-11-28  0:14 ` [PATCH 12/16] Style addresses Tom Tromey
2018-11-28  0:14 ` [PATCH 02/16] Add a "context" argument to add_setshow_enum_cmd Tom Tromey
2018-11-28  0:14 ` [PATCH 05/16] Add output styles to gdb Tom Tromey
2018-12-24  4:08   ` Joel Brobecker
2018-12-28 18:55     ` Tom Tromey
2018-11-28  0:14 ` [PATCH 09/16] Style print_address_symbolic Tom Tromey
2018-11-28  0:14 ` [PATCH 14/16] Use wclrtoeol in tui_show_source_line Tom Tromey
2018-12-24  8:03   ` Joel Brobecker
2018-11-28  0:14 ` [PATCH 03/16] Introduce ui_file_style Tom Tromey
2018-12-24  3:40   ` Joel Brobecker
2018-12-28 18:54     ` Tom Tromey
2018-11-28  0:14 ` [PATCH 10/16] Style the gdb welcome message Tom Tromey
2018-11-28  0:14 ` [PATCH 06/16] Reset terminal styles Tom Tromey
2018-12-24  4:16   ` Joel Brobecker
2018-12-28 19:01     ` Tom Tromey
2018-11-28  0:16 ` [PATCH 11/16] Style the "Reading symbols" message Tom Tromey
2018-11-28  0:16 ` [PATCH 13/16] Make ANSI terminal escape sequences work in TUI Tom Tromey
2018-12-24  8:02   ` Joel Brobecker
2018-12-28 19:42   ` Tom Tromey
2018-11-28  0:16 ` [PATCH 16/16] Document the "set style" commands Tom Tromey
2018-11-28  6:51   ` Eli Zaretskii
2018-12-28 19:19     ` Tom Tromey
2018-11-28  0:16 ` [PATCH 07/16] Style variable names Tom Tromey
2018-11-28  0:16 ` [PATCH 15/16] Highlight source code using GNU Source Highlight Tom Tromey
2019-11-16  0:58   ` Andrew Pinski
2019-11-16  8:19     ` Eli Zaretskii
2019-11-24 17:41     ` Tom Tromey
2019-11-24 18:13       ` Christian Biesinger via gdb-patches
2019-11-24 19:53         ` Tom Tromey
2018-11-28  0:16 ` [PATCH 08/16] Style locations when setting a breakpoint Tom Tromey
2018-11-28  0:16 ` [PATCH 04/16] Change gdb test suite's TERM setting Tom Tromey
2018-11-28  0:19 ` [PATCH 01/16] Change wrap buffering to use a std::string Tom Tromey
2018-12-23 15:26   ` Joel Brobecker
2018-12-28 18:47     ` Tom Tromey
2018-11-28  7:02 ` [PATCH 00/16] Add styling to the gdb CLI and TUI Eli Zaretskii
2018-11-29 22:44   ` Tom Tromey
2018-11-30  7:02     ` Eli Zaretskii
2018-11-30 16:17       ` Tom Tromey
2018-12-23 10:49         ` Joel Brobecker
2019-03-01 13:10         ` Pedro Alves
2019-03-01 13:56           ` Eli Zaretskii
2019-03-01 14:10             ` Pedro Alves
2019-03-01 14:50               ` Eli Zaretskii
2019-03-01  7:47     ` Eli Zaretskii
2019-03-01 18:42       ` Tom Tromey
2019-03-01 19:40         ` Eli Zaretskii
2019-03-01 21:04           ` Tom Tromey
2019-03-02  7:15             ` Eli Zaretskii
2019-03-03 15:42             ` Eli Zaretskii
2019-03-04 15:08               ` Tom Tromey
2019-03-04 15:57                 ` Eli Zaretskii
2019-03-04 16:16                   ` Tom Tromey
2019-03-05 15:38                     ` Eli Zaretskii
2019-03-08 14:55                       ` Eli Zaretskii
2019-03-08 16:14                         ` Hannes Domani via gdb-patches
2019-03-08 21:08                           ` Tom Tromey
2019-03-08 21:11                         ` Tom Tromey
2019-03-09  6:49                           ` Eli Zaretskii
2019-03-03 15:53             ` Eli Zaretskii
2019-03-03 16:16               ` Matt Rice
2019-03-03 17:13                 ` Eli Zaretskii
2019-03-03 18:04                   ` Matt Rice
2019-03-04 15:01               ` Tom Tromey
2019-03-04 17:37                 ` Eli Zaretskii
2019-03-04 17:40                   ` Tom Tromey
2019-03-06 16:02                     ` Eli Zaretskii
2019-03-20 19:35                       ` Eli Zaretskii [this message]
2019-03-25 17:31                         ` GDB version as convenience variable Eli Zaretskii
2019-03-25 17:58                           ` Simon Marchi
2019-03-25 18:10                             ` Eli Zaretskii
2019-03-25 18:33                               ` Simon Marchi
2019-03-25 18:37                                 ` Simon Marchi
2019-03-25 18:43                                 ` Eli Zaretskii
2019-03-25 18:51                                   ` Simon Marchi
2019-03-25 19:19                                     ` Eli Zaretskii
2019-03-26 14:47                                       ` Simon Marchi
2019-03-26 20:57                                         ` Joel Brobecker
2019-03-27  3:34                                           ` Eli Zaretskii
2019-03-27 12:56                                             ` Joel Brobecker
2019-03-30 17:25                                               ` Simon Marchi
2019-03-30 10:01                                         ` Eli Zaretskii
2019-03-21  1:55                       ` [PATCH 00/16] Add styling to the gdb CLI and TUI Simon Marchi
2019-03-21 14:38                         ` Eli Zaretskii
2019-03-21 15:02                           ` Simon Marchi
2019-03-21 16:01                             ` Eli Zaretskii
2019-03-21 16:06                               ` Simon Marchi
2019-03-21 16:12                                 ` Pedro Alves
2019-03-21 16:54                                   ` John Baldwin
2019-03-21 17:02                                   ` Eli Zaretskii
2019-03-21 18:08                                     ` Simon Marchi
2019-03-21 18:19                                       ` Pedro Alves
2019-03-21 18:38                                         ` Eli Zaretskii
2019-03-07  6:02                   ` Joel Brobecker
2019-03-07 14:53                     ` Eli Zaretskii
2019-03-08  5:40                       ` Joel Brobecker
2019-03-04 16:04       ` Eli Zaretskii
2018-12-24  9:27 ` Joel Brobecker
2018-12-28 20:57   ` Tom Tromey

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=83k1gts5it.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).