From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30346 invoked by alias); 21 Aug 2012 21:32:05 -0000 Received: (qmail 30335 invoked by uid 22791); 21 Aug 2012 21:32:03 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Aug 2012 21:31:48 +0000 Received: by vbkv13 with SMTP id v13so376426vbk.0 for ; Tue, 21 Aug 2012 14:31:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=LSXR6tkNcux+7qyd8t2aCHElSQ2ICxcwW5VS/wDhugM=; b=SFExjG7FdTtm7nHu5PROEgApP9pZ5OMcbL0xlwNV0AtTBACRxiU1QBSJN62pS8T0Ei jTw4Cyww7YgaGUeNcuHPd6ridEMjz5PGRNS3Kn9GNq8Qmz1Y6mMl4cvpDvd29EMYw/MJ 5/b6KeQcjZq2g58Ly436OJPt8Eszj0StBADYF8KgXKR0cULenTU1dDDkrToF9h2jAvhN 7El7Y3uj1owtfk+pI6g8RMn2+ek/RHKvzXP7LuxhyVFjLkH4LaOlkkJRxcrJgoz/Mpt4 /CSQMTN7XBtgNmDc1TctLUo5aMm7pugpPadJOYIY6ogqPtuGx9wXD2G+2v7KZdOjQgMF RPwg== Received: by 10.52.34.212 with SMTP id b20mr12359515vdj.115.1345584707781; Tue, 21 Aug 2012 14:31:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.34.212 with SMTP id b20mr12359507vdj.115.1345584707643; Tue, 21 Aug 2012 14:31:47 -0700 (PDT) Received: by 10.52.27.11 with HTTP; Tue, 21 Aug 2012 14:31:47 -0700 (PDT) In-Reply-To: <20120821144916.GB28426@host2.jankratochvil.net> References: <20120821144916.GB28426@host2.jankratochvil.net> Date: Tue, 21 Aug 2012 21:32:00 -0000 Message-ID: Subject: Re: [patch] Implement $_version; for auto-load commands in ~/.gdbinit From: Doug Evans To: Jan Kratochvil Cc: gdb-patches@sourceware.org, Eli Zaretskii Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-Gm-Message-State: ALoCoQl3kGwZ7tdBUCm9B+OercPjZ1A5rbCex8Xy0xGA59hZkgSM9/COsrhitjk95E6LvgcZBB+Za9fec5LQKIGjGZgXbzWzkSziBpohaTIeZOSfhCPZ63OA5FQ1UP/ic4eYzQKtn4FV18tMpeHsJjr7K9EkXII7Q4jlEYrH8TEd8dykbNG+eGdORR+8gtguAo9GN4EsNiybOpRQgzRCZRGrG4Co6cmHvA== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00601.txt.bz2 On Tue, Aug 21, 2012 at 7:49 AM, Jan Kratochvil 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 > > * 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 > > * 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 > > * 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.