Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: Re: [patch] Implement $_version; for auto-load commands in ~/.gdbinit
Date: Tue, 21 Aug 2012 21:32:00 -0000	[thread overview]
Message-ID: <CADPb22Q_-tvdtv4MMrhehCeca1rLr_me+PH8CjwAHo-9_Ycrgw@mail.gmail.com> (raw)
In-Reply-To: <20120821144916.GB28426@host2.jankratochvil.net>

On Tue, Aug 21, 2012 at 7:49 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Hi,
>
> it was requested by Eli in mail:
>         Re: GDB 7.5: Problems with the auto-load safe-path feature
>         http://sourceware.org/ml/gdb-patches/2012-08/msg00508.html
>         D:\usr\eli/.gdbinit:1: Error in sourced command file: "on" or "off" expected.
>
> IIRC it was already discussed even in the past.
>
> One solution would be some new mode where errors are only printed and script
> execution does not stop there.
>
> I have implemented a way to explicitly check for GDB version instead.

There is already gdb.VERSION in the Python API, but I guess $_version
could be useful to access for those without Python.

> No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2012-08-21  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>         * top.c (init_main): New variables val, type, version_count, version_i
>         and version_a.  Create internal variable $_version.
>         * valarith.c (value_logical_not): Return 0 for lval_internalvar in
>         c_style_arrays being of type TYPE_CODE_ARRAY.
>
> gdb/testsuite/
> 2012-08-21  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>         * gdb.base/default.exp (show convenience): Cope with array types.
>         ($_version works without inferior, $_version is >= 7): New tests.
>
> gdb/doc/
> 2012-08-21  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>         * gdb.texinfo (Convenience Vars): New item $_version with new anchor
>         Convenience variable $_version.
>         (Auto-loading safe path): Make two references to $_version.
>
> diff --git a/gdb/top.c b/gdb/top.c
> index 8251d1b..2d1a8cf 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -1574,6 +1574,11 @@ set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
>  static void
>  init_main (void)
>  {
> +  struct value *val;
> +  struct type *type;
> +  int version_count, version_i;
> +  unsigned version_a[4];
> +
>    /* Initialize the prompt to a simple "(gdb) " prompt or to whatever
>       the DEFAULT_PROMPT is.  */
>    set_prompt (DEFAULT_PROMPT);
> @@ -1681,6 +1686,25 @@ When set, GDB uses the specified path to search for data files."),
>                             set_gdb_datadir, NULL,
>                             &setlist,
>                             &showlist);
> +
> +  /* Set up the $_version array.  */
> +  version_count = sscanf (version, "%u.%u.%u.%u", &version_a[0], &version_a[1],
> +                         &version_a[2], &version_a[3]);
> +  if (version_count < 2)
> +    internal_error (__FILE__, __LINE__, _("Cannot parse GDB version \"%s\"!"),
> +                   version);
> +  type = create_range_type (NULL, builtin_type (target_gdbarch)->builtin_int,
> +                           0, version_count - 1);
> +  type = create_array_type (NULL,
> +                           builtin_type (target_gdbarch)->builtin_long,
> +                           type);
> +  val = allocate_value (type);
> +  for (version_i = 0; version_i < version_count; version_i++)
> +    pack_long ((value_contents_writeable (val)
> +               + TYPE_LENGTH (TYPE_TARGET_TYPE (type)) * version_i),
> +              TYPE_TARGET_TYPE (type),
> +              version_a[version_i]);
> +  set_internalvar (lookup_internalvar ("_version"), val);
>  }

If there are concerns of $_version decaying to a pointer if the
current language is C, may it should be a vector.


  parent reply	other threads:[~2012-08-21 21:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 14:49 Jan Kratochvil
2012-08-21 17:59 ` Eli Zaretskii
2012-08-21 21:32 ` Doug Evans [this message]
2012-08-22 20:06 ` Tom Tromey
2012-08-23 18:05   ` Pedro Alves
2012-08-24 16:32   ` Jan Kratochvil
2012-08-24 16:39     ` Jan Kratochvil
2012-08-24 16:54       ` dje
2012-08-24 16:57         ` Jan Kratochvil
2012-08-24 18:12           ` Doug Evans
2012-08-24 17:41       ` Tom Tromey
2012-08-24 17:50         ` Jan Kratochvil
2012-08-24 18:00           ` Tom Tromey
2012-08-24 18:20       ` Eli Zaretskii
2012-08-24 18:26         ` Jan Kratochvil
2012-08-24 18:50           ` Eli Zaretskii
2012-08-24 19:00             ` Jan Kratochvil
2012-08-24 19:03               ` Eli Zaretskii
2012-09-02 15:12               ` Joel Brobecker

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=CADPb22Q_-tvdtv4MMrhehCeca1rLr_me+PH8CjwAHo-9_Ycrgw@mail.gmail.com \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.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