aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-param.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-param.c')
-rw-r--r--gdb/python/py-param.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 763680e..7ba0070 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -170,8 +170,7 @@ make_setting (parmpy_object *s)
gdb_assert_not_reached ("unhandled var type");
}
-extern PyTypeObject parmpy_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
+extern PyTypeObject parmpy_object_type;
/* Some handy string constants. */
static PyObject *set_doc_cst;
@@ -297,7 +296,7 @@ set_parameter_value (parmpy_object *self, PyObject *value)
{
cmp = PyObject_IsTrue (value);
if (cmp < 0 )
- return -1;
+ return -1;
if (cmp == 1)
self->value.autoboolval = AUTO_BOOLEAN_TRUE;
else
@@ -495,7 +494,11 @@ get_doc_string (PyObject *object, enum doc_string_type doc_type,
}
}
- if (result == nullptr)
+ /* For the set/show docs, if these strings are empty then we set then to
+ a non-empty string. This ensures that the command has some sane
+ documentation for its 'help' text. */
+ if (result == nullptr
+ || (doc_type != doc_string_description && *result == '\0'))
{
if (doc_type == doc_string_description)
result.reset (xstrdup (_("This command is not documented.")));
@@ -904,6 +907,18 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
show_doc = get_doc_string (self, doc_string_show, name);
doc = get_doc_string (self, doc_string_description, cmd_name.get ());
+ /* The set/show docs should always be a non-empty string. */
+ gdb_assert (set_doc != nullptr && *set_doc != '\0');
+ gdb_assert (show_doc != nullptr && *show_doc != '\0');
+
+ /* For the DOC string only, if it is the empty string, then we convert it
+ to NULL. This means GDB will not even display a blank line for this
+ part of the help text, instead the set/show line is all the user will
+ get. */
+ gdb_assert (doc != nullptr);
+ if (*doc == '\0')
+ doc = nullptr;
+
Py_INCREF (self);
try
@@ -937,8 +952,8 @@ parmpy_dealloc (PyObject *obj)
}
/* Initialize the 'parameters' module. */
-static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
-gdbpy_initialize_parameters (void)
+static int
+gdbpy_initialize_parameters ()
{
int i;