aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/NEWS4
-rw-r--r--gdb/doc/python.texi14
-rw-r--r--gdb/python/py-param.c11
-rw-r--r--gdb/testsuite/gdb.python/py-parameter.exp4
4 files changed, 17 insertions, 16 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 5b5c467..b4afd89 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -46,6 +46,10 @@ set|show record btrace cpu
gdb.set_convenience_variable can be used to get and set the value
of convenience variables.
+ ** A gdb.Parameter will no longer print the "set" help text on an
+ ordinary "set"; instead by default a "set" will be silent unless
+ the get_set_string method returns a non-empty string.
+
* New targets
RiscV ELF riscv*-*-elf
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 60e016a..584b909 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3748,14 +3748,16 @@ parameter. It can be read and assigned to just as any other
attribute. @value{GDBN} does validation when assignments are made.
@end defvar
-There are two methods that should be implemented in any
-@code{Parameter} class. These are:
+There are two methods that may be implemented in any @code{Parameter}
+class. These are:
@defun Parameter.get_set_string (self)
-@value{GDBN} will call this method when a @var{parameter}'s value has
-been changed via the @code{set} API (for example, @kbd{set foo off}).
-The @code{value} attribute has already been populated with the new
-value and may be used in output. This method must return a string.
+If this method exists, @value{GDBN} will call it when a
+@var{parameter}'s value has been changed via the @code{set} API (for
+example, @kbd{set foo off}). The @code{value} attribute has already
+been populated with the new value and may be used in output. This
+method must return a string. If the returned string is not empty,
+@value{GDBN} will present it to the user.
@end defun
@defun Parameter.get_show_string (self, svalue)
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 22b26b2..ef5c91b 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -401,15 +401,10 @@ get_set_value (const char *args, int from_tty,
return;
}
}
- else
- {
- /* We have to preserve the existing < GDB 7.3 API. If a
- callback function does not exist, then attempt to read the
- set_doc attribute. */
- set_doc_string = get_doc_string (obj, set_doc_cst);
- }
- fprintf_filtered (gdb_stdout, "%s\n", set_doc_string.get ());
+ const char *str = set_doc_string.get ();
+ if (str != nullptr && str[0] != '\0')
+ fprintf_filtered (gdb_stdout, "%s\n", str);
}
/* A callback function that is registered against the respective
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 1ea79b8..0508544 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -151,7 +151,7 @@ gdb_py_test_multiple "Simple gdb booleanparameter" \
"end"
gdb_test "show print test-nodoc-param" "This command is not documented.*" "show parameter on"
-gdb_test "set print test-nodoc-param off" "This command is not documented.*" "turn off parameter"
+gdb_test_no_output "set print test-nodoc-param off" "turn off parameter"
gdb_test "show print test-nodoc-param" "This command is not documented.*.*" "show parameter off"
gdb_test "python print (test_nodoc_param.value)" "False" "test parameter value"
gdb_test "help show print test-nodoc-param" "This command is not documented.*" "test show help"
@@ -173,7 +173,7 @@ gdb_py_test_multiple "Simple gdb booleanparameter" \
gdb_test "python print (test_param.value)" "True" "test parameter value"
gdb_test "show print test-param" "State of the Test Parameter on.*" "show parameter on"
-gdb_test "set print test-param off" "Set the state of the Test Parameter.*" "turn off parameter"
+gdb_test_no_output "set print test-param off" "turn off parameter"
gdb_test "show print test-param" "State of the Test Parameter off.*" "show parameter off"
gdb_test "python print (test_param.value)" "False" "test parameter value"
gdb_test "help show print test-param" "State of the Test Parameter.*" "test show help"