[v3,2/3] gdb: Tab complete internalvars 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 |
success
|
Test passed
|
Commit Message
For example, 'print $f<tab>' or 'print $fo<tab>+$foo' after running
'set $foo=0' now tab completes.
'print $_siginf<tab>' also now tab completes.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7353
---
gdb/completer.c | 9 ++++++++
gdb/testsuite/gdb.base/completion.exp | 33 +++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
@@ -1099,6 +1099,15 @@ complete_expression (completion_tracker &tracker,
&& expr_completer->complete (exp.get (), tracker))
return;
+ /* If the text is non-empty, see if the word is preceded by '$'. */
+ if (text[0] != '\0' && text[strlen (text) - strlen (word) - 1] == '$')
+ {
+ /* We don't support completion of history indices. */
+ if (!isdigit (word[0]))
+ complete_internalvar (tracker, word);
+ return;
+ }
+
complete_files_symbols (tracker, text, word);
}
@@ -1005,3 +1005,36 @@ foreach_with_prefix spc { " " "" } {
}
}
}
+
+# Test command completion with convenience variables.
+test_gdb_complete_unique \
+ "print \$_sigin" \
+ "print \$_siginfo"
+
+test_gdb_complete_unique \
+ "print \$_siginfo" \
+ "print \$_siginfo"
+
+test_gdb_complete_unique \
+ "print \$_gdb_maj" \
+ "print \$_gdb_major"
+
+test_gdb_complete_unique "print \$_gdb_maint_setting_str" "print \$_gdb_maint_setting_str"
+
+test_gdb_complete_tab_multiple "print \$_gdb_mai" "nt_setting" {
+ "_gdb_maint_setting"
+ "_gdb_maint_setting_str"
+ }
+
+test_gdb_complete_cmd_multiple "" "print \$_gdb_maint_setting" {
+ "print \$_gdb_maint_setting"
+ "print \$_gdb_maint_setting_str"
+ }
+
+# Check that a nonexisting convenience variable is not completed.
+test_gdb_complete_none "print \$unique_variable_1234567"
+test_gdb_complete_none "set \$unique_variable_1234567"
+
+# Check that after defining the convenience variable it is completed.
+gdb_test_no_output "set \$unique_variable_1234567=4"
+test_gdb_complete_unique "print \$unique_variable_123456" "print \$unique_variable_1234567"