aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2023-01-19 21:15:56 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2023-01-19 21:15:56 +0000
commit7aeb03e2d4186d1184050d2ec048301f48255644 (patch)
tree3d2f57b0f5fa23d6f977c7fbaee809c284e7bc5c /gdb/testsuite/gdb.base
parent0fcd58d843ce1b07c8516c51f9120714673003a3 (diff)
downloadgdb-7aeb03e2d4186d1184050d2ec048301f48255644.zip
gdb-7aeb03e2d4186d1184050d2ec048301f48255644.tar.gz
gdb-7aeb03e2d4186d1184050d2ec048301f48255644.tar.bz2
GDB: Allow arbitrary keywords in integer set commands
Rather than just `unlimited' allow the integer set commands (or command options) to define arbitrary keywords for the user to use, removing hardcoded arrangements for the `unlimited' keyword. Remove the confusingly named `var_zinteger', `var_zuinteger' and `var_zuinteger_unlimited' `set'/`show' command variable types redefining them in terms of `var_uinteger', `var_integer' and `var_pinteger', which have the range of [0;UINT_MAX], [INT_MIN;INT_MAX], and [0;INT_MAX] each. Following existing practice `var_pinteger' allows extra negative values to be used, however unlike `var_zuinteger_unlimited' any number of such values can be defined rather than just `-1'. The "p" in `var_pinteger' stands for "positive", for the lack of a more appropriate unambiguous letter, even though 0 obviously is not positive; "n" would be confusing as to whether it stands for "non-negative" or "negative". Add a new structure, `literal_def', the entries of which define extra keywords allowed for a command and numerical values they correspond to. Those values are not verified against the basic range supported by the underlying variable type, allowing extra values to be allowed outside that range, which may or may not be individually made visible to the user. An optional value translation is possible with the structure to follow the existing practice for some commands where user-entered 0 is internally translated to UINT_MAX or INT_MAX. Such translation can now be arbitrary. Literals defined by this structure are automatically used for completion as necessary. So for example: const literal_def integer_unlimited_literals[] = { { "unlimited", INT_MAX, 0 }, { nullptr } }; defines an extra `unlimited' keyword and a user-visible 0 value, both of which get translated to INT_MAX for the setting to be used with. Similarly: const literal_def zuinteger_unlimited_literals[] = { { "unlimited", -1, -1 }, { nullptr } }; defines the same keyword and a corresponding user-visible -1 value that is used for the requested setting. If the last member were omitted (or set to `{}') here, then only the keyword would be allowed for the user to enter and while -1 would still be used internally trying to enter it as a part of a command would result in an "integer -1 out of range" error. Use said error message in all cases (citing the invalid value requested) replacing "only -1 is allowed to set as unlimited" previously used for `var_zuinteger_unlimited' settings only rather than propagating it to `var_pinteger' type. It could only be used for the specific case where a single extra `unlimited' keyword was defined standing for -1 and the use of numeric equivalents is discouraged anyway as it is for historical reasons only that they expose GDB internals, confusingly different across variable types. Similarly update the "must be >= -1" Guile error message. Redefine Guile and Python parameter types in terms of the new variable types and interpret extra keywords as Scheme keywords and Python strings used to communicate corresponding parameter values. Do not add a new PARAM_INTEGER Guile parameter type, however do handle the `var_integer' variable type now, permitting existing parameters defined by GDB proper, such as `listsize', to be accessed from Scheme code. With these changes in place it should be trivial for a Scheme or Python programmer to expand the syntax of the `make-parameter' command and the `gdb.Parameter' class initializer to have arbitrary extra literals along with their internal representation supplied. Update the testsuite accordingly. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/max-value-size.exp2
-rw-r--r--gdb/testsuite/gdb.base/options.exp47
-rw-r--r--gdb/testsuite/gdb.base/settings.exp2
-rw-r--r--gdb/testsuite/gdb.base/with.exp2
4 files changed, 30 insertions, 23 deletions
diff --git a/gdb/testsuite/gdb.base/max-value-size.exp b/gdb/testsuite/gdb.base/max-value-size.exp
index 0a001e9..cc9ae77 100644
--- a/gdb/testsuite/gdb.base/max-value-size.exp
+++ b/gdb/testsuite/gdb.base/max-value-size.exp
@@ -92,4 +92,4 @@ gdb_test "set max-value-size 1" \
gdb_test "set max-value-size 0" \
"max-value-size set too low, increasing to \[0-9\]+ bytes"
gdb_test "set max-value-size -5" \
- "only -1 is allowed to set as unlimited"
+ "integer -5 out of range"
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index 486192e..5a2b6d8 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -98,19 +98,22 @@ proc make_cmd {variant} {
# test-options xxx", with no flag/option set. OPERAND is the expected
# operand.
proc expect_none {operand} {
- return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint 0 -zuint-unl 0 -string '' -- $operand"
+ return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
+ -string '' -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -flag set. OPERAND is the expected operand.
proc expect_flag {operand} {
- return "-flag 1 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint 0 -zuint-unl 0 -string '' -- $operand"
+ return "-flag 1 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
+ -string '' -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -bool set. OPERAND is the expected operand.
proc expect_bool {operand} {
- return "-flag 0 -xx1 0 -xx2 0 -bool 1 -enum xxx -uint 0 -zuint-unl 0 -string '' -- $operand"
+ return "-flag 0 -xx1 0 -xx2 0 -bool 1 -enum xxx -uint-unl 0 -pint-unl 0\
+ -string '' -- $operand"
}
# Return a string for the expected result of running "maint
@@ -118,10 +121,12 @@ proc expect_bool {operand} {
# OPTION determines which option to expect set. OPERAND is the
# expected operand.
proc expect_integer {option val operand} {
- if {$option == "uinteger"} {
- return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint $val -zuint-unl 0 -string '' -- $operand"
- } elseif {$option == "zuinteger-unlimited"} {
- return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint 0 -zuint-unl $val -string '' -- $operand"
+ if {$option == "uinteger-unlimited"} {
+ return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl $val\
+ -pint-unl 0 -string '' -- $operand"
+ } elseif {$option == "pinteger-unlimited"} {
+ return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0\
+ -pint-unl $val -string '' -- $operand"
} else {
error "unsupported option: $option"
}
@@ -138,18 +143,19 @@ proc expect_string {str operand} {
&& [string range $str end end] == "'")} {
set str [string range $str 1 end-1]
}
- return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint 0 -zuint-unl 0 -string '$str' -- $operand"
+ return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
+ -string '$str' -- $operand"
}
set all_options {
"-bool"
"-enum"
"-flag"
+ "-pinteger-unlimited"
"-string"
- "-uinteger"
+ "-uinteger-unlimited"
"-xx1"
"-xx2"
- "-zuinteger-unlimited"
}
# Basic option-machinery + "print" command integration tests.
@@ -604,7 +610,8 @@ proc_with_prefix test-flag {variant} {
# Extract twice the same flag, separated by one space.
gdb_test "$cmd -xx1 -xx2 -xx1 -xx2 -xx1 -- non flags args" \
- "-flag 0 -xx1 1 -xx2 1 -bool 0 -enum xxx -uint 0 -zuint-unl 0 -string '' -- non flags args"
+ "-flag 0 -xx1 1 -xx2 1 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
+ -string '' -- non flags args"
# Extract 2 known flags in front of unknown flags.
gdb_test "$cmd -xx1 -xx2 -a -b -c -xx1 --" \
@@ -822,13 +829,13 @@ proc_with_prefix test-boolean {variant} {
}
# Uinteger option tests. OPTION is which integer option we're
-# testing. Can be "uinteger" or "zuinteger-unlimited".
+# testing. Can be "uinteger-unlimited" or "pinteger-unlimited".
proc_with_prefix test-uinteger {variant option} {
global all_options
set cmd "[make_cmd $variant] -$option"
- # Test completing a uinteger option:
+ # Test completing an integer option:
res_test_gdb_complete_multiple \
"1 [expect_none ""]" \
"$cmd " "" "" {
@@ -852,7 +859,7 @@ proc_with_prefix test-uinteger {variant option} {
gdb_test "$cmd 1 -- 999" [expect_integer $option "1" "999"]
gdb_test "$cmd unlimited -- 999" \
[expect_integer $option "unlimited" "999"]
- if {$option == "zuinteger-unlimited"} {
+ if {$option == "pinteger-unlimited"} {
gdb_test "$cmd -1 --" [expect_integer $option "unlimited" ""]
gdb_test "$cmd 0 --" [expect_integer $option "0" ""]
} else {
@@ -865,7 +872,7 @@ proc_with_prefix test-uinteger {variant option} {
"Expected integer at: unlimitedx --"
# Don't offer completions until we're past the
- # -uinteger/-zuinteger-unlimited argument.
+ # -uinteger-unlimited/-pinteger-unlimited argument.
res_test_gdb_complete_none \
"1 [expect_none ""]" \
"$cmd 1"
@@ -878,15 +885,15 @@ proc_with_prefix test-uinteger {variant option} {
}
# Try "-1".
- if {$option == "uinteger"} {
- # -1 is invalid uinteger.
+ if {$option == "uinteger-unlimited"} {
+ # -1 is invalid uinteger-unlimited.
foreach value {"-1" "-1 "} {
res_test_gdb_complete_none \
"1 [expect_none ""]" \
"$cmd $value"
}
} else {
- # -1 is valid for zuinteger-unlimited.
+ # -1 is valid for pinteger-unlimited.
res_test_gdb_complete_none \
"1 [expect_none ""]" \
"$cmd -1"
@@ -914,7 +921,7 @@ proc_with_prefix test-uinteger {variant option} {
res_test_gdb_complete_none "0 " "$cmd 1 "
}
- # Test completing non-option arguments after "-uinteger 1 ".
+ # Test completing non-option arguments after "-uinteger-unlimited 1 ".
foreach operand {"x" "x " "1a" "1a " "1-" "1- "} {
if {$variant == "require-delimiter"} {
res_test_gdb_complete_none \
@@ -1032,7 +1039,7 @@ foreach_with_prefix cmd {
test-misc $cmd
test-flag $cmd
test-boolean $cmd
- foreach subcmd {"uinteger" "zuinteger-unlimited" } {
+ foreach subcmd {"uinteger-unlimited" "pinteger-unlimited" } {
test-uinteger $cmd $subcmd
}
test-enum $cmd
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index f2215c2..e542039 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -143,7 +143,7 @@ proc test-integer {variant} {
if {$variant == "zuinteger-unlimited"} {
# -1 means unlimited. Other negative values are rejected. -1
# -is tested further below, along the "unlimited" tests.
- gdb_test "$set_cmd -2" "only -1 is allowed to set as unlimited"
+ gdb_test "$set_cmd -2" "integer -2 out of range"
check_type "test-settings $variant" "type = int"
} elseif {$variant == "uinteger" || $variant == "zuinteger"} {
# Negative values are not accepted.
diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp
index 75f4ddc..233dc30 100644
--- a/gdb/testsuite/gdb.base/with.exp
+++ b/gdb/testsuite/gdb.base/with.exp
@@ -104,7 +104,7 @@ with_test_prefix "maint" {
test_with_error "zuinteger" "" \
"Argument required \\(integer to set it to\\)\\."
test_with_error "zuinteger-unlimited" "-2" \
- "only -1 is allowed to set as unlimited"
+ "integer -2 out of range"
test_with_error "zuinteger-unlimited" "" \
"Argument required \\(integer to set it to, or \"unlimited\"\\)\\."
test_with_error "filename" "" \