From: Daniel Gutson <daniel.gutson@tallertechnologies.com>
To: gdb-patches <gdb-patches@sourceware.org>
Subject: [PATCH] Add autocompletion for convenience vars in print and set
Date: Tue, 20 May 2014 15:51:00 -0000 [thread overview]
Message-ID: <CAF5HaEUYNe60EPby2Mxbgxy68unMpoxYr8BnQAQNUV_z04wVsw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
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 <daniel.gutson@tallertechnologies.com>
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.
[-- Attachment #2: completer.patch --]
[-- Type: text/x-patch, Size: 2241 bytes --]
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
next reply other threads:[~2014-05-20 15:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 15:51 Daniel Gutson [this message]
2014-05-20 15:52 ` Daniel Gutson
2014-05-20 16:36 ` Tom Tromey
2014-05-22 15:17 ` Daniel Gutson
2014-05-27 15:18 ` Daniel Gutson
2014-05-27 16:46 ` Andrew Burgess
2014-05-27 20:24 ` Daniel Gutson
2016-02-25 21:23 ` Daniel Gutson
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=CAF5HaEUYNe60EPby2Mxbgxy68unMpoxYr8BnQAQNUV_z04wVsw@mail.gmail.com \
--to=daniel.gutson@tallertechnologies.com \
--cc=gdb-patches@sourceware.org \
/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