From patchwork Tue May 20 15:51:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gutson X-Patchwork-Id: 1032 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 2346836007B for ; Tue, 20 May 2014 08:51:56 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 6A9506146B39; Tue, 20 May 2014 08:51:55 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 4E7485D5D569 for ; Tue, 20 May 2014 08:51:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; q=dns; s=default; b=G2VeQU+IJ5fptZLIbjHqx7o9XFBYg NQz1EP+udLr6M+kc5rr1RbU01+EseNBHpF+uOVdGbyTIsYB8cY0Qojr6yKRJvjFr Y2k0ZseR7sfo5x9Auwb1w0xmhMv0iQORG7DNSxUaNsyV8I9ypZY7JKOCNS/Oz9/D fEAdxeVNAkHt3Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; s=default; bh=qAJaDW5OzDa5HAD+unmfdaJAvMY=; b=IcB PZBIyfhG7Jvn7Z0s/YXAgw4LW9zuYEnDqMGgmA3sEDF3vbuzWgGcWrEaUD4qPlmR hnfHfHjxYKBgCE7+OuG7P7JSNShVBflYCbiPuWcLhx39oWs3BshO6j5xUYvMFORQ P211lHqH5IYdVq5WO4kA0v9CViVaw5/wIVlx00u4= Received: (qmail 10561 invoked by alias); 20 May 2014 15:51:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10545 invoked by uid 89); 20 May 2014 15:51:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mail-lb0-f180.google.com Received: from mail-lb0-f180.google.com (HELO mail-lb0-f180.google.com) (209.85.217.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 20 May 2014 15:51:50 +0000 Received: by mail-lb0-f180.google.com with SMTP id p9so550980lbv.25 for ; Tue, 20 May 2014 08:51:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=NTdIUljlGqjFbUW6D0bXBU+ASKKH8s7k2idb/0juvpg=; b=QiFWf4zwUO6/HzJKDiwILhXGwhI7FEkHkI9/0O1HECKNPVojZS2+pCggt6htZcMxb6 B98cmUJwTPOyYdFNq1qVxxHMu4eF+s4qxefTamW95d/bvqDzf2+gBhffyogXmFvehh7H SsxDVvgg2lO5LfTmZyU4TozOyFOVcBsbeSp7yybIeukku0LZayOdoIGrhQ3KxpgodRhl DQvNZ3sq0uSRlnPp3kHUojkx+i7i7opSmin8eFf4krDwjJQgqWs8X8n2iuZ3TieHeghT 0b1HjCZD0KIB5Mz8Jidmbxn53XUaGh/WrP5bobfEXtQNlFPGYahKKzISdx+iJ/TBep9V cfIg== X-Gm-Message-State: ALoCoQnbb5HQljZps8yAnZu3z0ua9k1ob3UeXA+UdzhBwBcg5qfl5uaPeKXpJF5175107SAeaLPa MIME-Version: 1.0 X-Received: by 10.152.43.167 with SMTP id x7mr1992711lal.85.1400601107044; Tue, 20 May 2014 08:51:47 -0700 (PDT) Received: by 10.112.9.5 with HTTP; Tue, 20 May 2014 08:51:46 -0700 (PDT) Date: Tue, 20 May 2014 12:51:46 -0300 Message-ID: Subject: [PATCH] Add autocompletion for convenience vars in print and set From: Daniel Gutson To: gdb-patches X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, this small patch adds autocompletion for convenience variables for 'print' and 'set' commands. I guess other commands using the same completers will be benefited as well. I could not find any testsuite where to add tests for this; if there are, please let me know. 2014-05-20 Daniel Gutson gdb/ * c-exp.y (exp): Do not create an internal var when completing. * completer.c (expression_completer): Call complete_internalvar. * symtab.c (make_symbol_completion_list): Call complete_internalvar. diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 0191067..3ae969f 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -777,7 +777,8 @@ exp : variable exp : VARIABLE { - write_dollar_variable (pstate, $1); + if (!parse_completion) + write_dollar_variable (pstate, $1); } ; diff --git a/gdb/completer.c b/gdb/completer.c index 94f70a9..6c5cdf8 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -20,6 +20,7 @@ #include "symtab.h" #include "gdbtypes.h" #include "expression.h" +#include "value.h" #include "filenames.h" /* For DOSish file names. */ #include "language.h" #include "gdb_assert.h" @@ -446,8 +447,11 @@ expression_completer (struct cmd_list_element *ignore, p--) ; - /* Not ideal but it is what we used to do before... */ - return location_completer (ignore, p, word); + if (p != NULL && *p == '$') + return complete_internalvar (p + 1); + else + /* Not ideal but it is what we used to do before... */ + return location_completer (ignore, p, word); } /* Here are some useful test cases for completion. FIXME: These diff --git a/gdb/symtab.c b/gdb/symtab.c index 15ac3d1..5ceaf46 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4542,14 +4542,21 @@ default_make_symbol_completion_list (const char *text, const char *word, } /* Return a vector of all symbols (regardless of class) which begin by - matching TEXT. If the answer is no symbols, then the return value - is NULL. */ + matching TEXT. If the answer is no symbols, then check whether the + text is an internal var ($foo), if so, return what complete_internalvar + returns; otherwise the return value is NULL. */ VEC (char_ptr) * make_symbol_completion_list (const char *text, const char *word) { - return current_language->la_make_symbol_completion_list (text, word, - TYPE_CODE_UNDEF); + VEC (char_ptr) * ret = current_language->la_make_symbol_completion_list ( + text, word, + TYPE_CODE_UNDEF); + + if (ret == NULL && *text == '$') + ret = complete_internalvar (text + 1); + + return ret; } /* Like make_symbol_completion_list, but only return STRUCT_DOMAIN