From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PUSHED] gdb/doc: fix the example for get_set_string in Python API docs
Date: Thu, 18 Mar 2021 16:56:13 +0000 [thread overview]
Message-ID: <20210318165613.1991044-1-andrew.burgess@embecosm.com> (raw)
The small example for gdb.Parameter.get_set_string does not return a
string. The documentation is very clear that this method must return
a string, and indeed, inspecting the code in gdb/python/py-param.c
shows that a string return value is required (if an exception is not
thrown).
While inspecting the code in gdb/python/py-param.c I noticed that the
comment for the C++ code that invokes the Python get_set_string method
is wrong, so I updated that too.
gdb/ChangeLog:
* python/py-param.c (get_set_value): Update header comment.
gdb/doc/ChangeLog:
* python.texinfo (Parameters In Python): Return empty string in
small example code.
---
gdb/ChangeLog | 4 ++++
gdb/doc/ChangeLog | 5 +++++
gdb/doc/python.texi | 1 +
gdb/python/py-param.c | 9 ++++-----
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index ba3d2f92a43..9135d415dd1 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4041,6 +4041,7 @@
self.value = self.saved_value
raise gdb.GdbError('Failed to validate')
self.saved_value = self.value
+ return ""
@end smallexample
@end defun
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 49819ce4f10..ab9e883dc2d 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -368,11 +368,10 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
}
/* A callback function that is registered against the respective
- add_setshow_* set_doc prototype. This function will either call
- the Python function "get_set_string" or extract the Python
- attribute "set_doc" and return the contents as a string. If
- neither exist, insert a string indicating the Parameter is not
- documented. */
+ add_setshow_* set_doc prototype. This function calls the Python function
+ "get_set_string" if it exists, which will return a string. That string
+ is then printed. If "get_set_string" does not exist, or returns an
+ empty string, then nothing is printed. */
static void
get_set_value (const char *args, int from_tty,
struct cmd_list_element *c)
--
2.25.4
reply other threads:[~2021-03-18 16:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210318165613.1991044-1-andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).