aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorEnze Li <enze.li@hotmail.com>2022-06-12 13:25:31 +0800
committerEnze Li <enze.li@hotmail.com>2022-06-18 11:23:16 +0800
commit3f52a09075e3c62f2150375bb7fca338e7db45e7 (patch)
tree634d8aeccb4849832ed116c34762167c530bd750 /gdb/python
parent153b3c1117d02c2893c5be1b3af53ec7f161a211 (diff)
downloadfsf-binutils-gdb-3f52a09075e3c62f2150375bb7fca338e7db45e7.zip
fsf-binutils-gdb-3f52a09075e3c62f2150375bb7fca338e7db45e7.tar.gz
fsf-binutils-gdb-3f52a09075e3c62f2150375bb7fca338e7db45e7.tar.bz2
gdb/python: Export nibbles to python layer
This patch makes it possible to allow Value.format_string() to return nibbles output. When we set the parameter of nibbles to True, we can achieve the displaying binary values in groups of every four bits. Here's an example: (gdb) py print (gdb.Value (1230).format_string (format='t', nibbles=True)) 0100 1100 1110 (gdb) Note that the parameter nibbles is only useful if format='t' is also used. This patch also includes update to the relevant testcase and documentation. Tested on x86_64 openSUSE Tumbleweed.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-value.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 0f70033..12e9562 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -640,6 +640,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
"unions", /* See set print union on|off. */
"address", /* See set print address on|off. */
"styling", /* Should we apply styling. */
+ "nibbles", /* See set print nibbles on|off. */
/* C++ options. */
"deref_refs", /* No corresponding setting. */
"actual_objects", /* See set print object on|off. */
@@ -685,13 +686,14 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
PyObject *unions_obj = NULL;
PyObject *address_obj = NULL;
PyObject *styling_obj = Py_False;
+ PyObject *nibbles_obj = NULL;
PyObject *deref_refs_obj = NULL;
PyObject *actual_objects_obj = NULL;
PyObject *static_members_obj = NULL;
char *format = NULL;
if (!gdb_PyArg_ParseTupleAndKeywords (args,
kw,
- "|O!O!O!O!O!O!O!O!O!O!O!IIIs",
+ "|O!O!O!O!O!O!O!O!O!O!O!O!IIIs",
keywords,
&PyBool_Type, &raw_obj,
&PyBool_Type, &pretty_arrays_obj,
@@ -701,6 +703,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
&PyBool_Type, &unions_obj,
&PyBool_Type, &address_obj,
&PyBool_Type, &styling_obj,
+ &PyBool_Type, &nibbles_obj,
&PyBool_Type, &deref_refs_obj,
&PyBool_Type, &actual_objects_obj,
&PyBool_Type, &static_members_obj,
@@ -725,6 +728,8 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
return NULL;
if (!copy_py_bool_obj (&opts.addressprint, address_obj))
return NULL;
+ if (!copy_py_bool_obj (&opts.nibblesprint, nibbles_obj))
+ return NULL;
if (!copy_py_bool_obj (&opts.deref_ref, deref_refs_obj))
return NULL;
if (!copy_py_bool_obj (&opts.objectprint, actual_objects_obj))