[v2,4/5] gdb: Tab-complete registers in expressions
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
fail
|
Test failed
|
Commit Message
---
gdb/completer.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
Comments
On 8/27/24 6:50 PM, Antonio Rische wrote:
Please add a commit message. Since you're adding new functionality,
it would be nice to include an example of it here.
> ---
> gdb/completer.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/completer.c b/gdb/completer.c
> index 3c9f01c84..bff975b36 100644
> --- a/gdb/completer.c
> +++ b/gdb/completer.c
> @@ -52,6 +52,9 @@ static const char *completion_find_completion_word (completion_tracker &tracker,
>
> static void set_rl_completer_word_break_characters (const char *break_chars);
>
> +static void complete_register (completion_tracker &tracker,
> + const char *text, const char *word);
> +
> /* See completer.h. */
>
> class completion_tracker::completion_hash_entry
> @@ -1105,7 +1108,10 @@ complete_expression (completion_tracker &tracker,
> tracker.advance_custom_word_point_by (1);
> /* We don't support completion of history indices. */
> if (!isdigit (word[0]))
> - complete_internalvar (tracker, word);
> + {
> + complete_internalvar (tracker, word);
> + complete_register (tracker, text, word);
This seems odd to me. Wouldn't this produce incorrect output if a user
typed something nonsensical like "p $crea$ecTAB"?
In this case, we should output no matches, I think.
> + }
> tracker.advance_custom_word_point_by (-1);
> return;
> }
> @@ -1872,6 +1878,16 @@ reggroup_completer (struct cmd_list_element *ignore,
> complete_reggroup_names);
> }
>
> +/* Perform completion on register names. */
> +
> +void
> +complete_register (completion_tracker &tracker,
> + const char *text, const char *word)
> +{
> + reg_or_group_completer_1 (tracker, text, word,
> + complete_register_names);
> +}
> +
> /* The default completer_handle_brkchars implementation. */
>
> static void
Keith
@@ -52,6 +52,9 @@ static const char *completion_find_completion_word (completion_tracker &tracker,
static void set_rl_completer_word_break_characters (const char *break_chars);
+static void complete_register (completion_tracker &tracker,
+ const char *text, const char *word);
+
/* See completer.h. */
class completion_tracker::completion_hash_entry
@@ -1105,7 +1108,10 @@ complete_expression (completion_tracker &tracker,
tracker.advance_custom_word_point_by (1);
/* We don't support completion of history indices. */
if (!isdigit (word[0]))
- complete_internalvar (tracker, word);
+ {
+ complete_internalvar (tracker, word);
+ complete_register (tracker, text, word);
+ }
tracker.advance_custom_word_point_by (-1);
return;
}
@@ -1872,6 +1878,16 @@ reggroup_completer (struct cmd_list_element *ignore,
complete_reggroup_names);
}
+/* Perform completion on register names. */
+
+void
+complete_register (completion_tracker &tracker,
+ const char *text, const char *word)
+{
+ reg_or_group_completer_1 (tracker, text, word,
+ complete_register_names);
+}
+
/* The default completer_handle_brkchars implementation. */
static void