aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-01-12 11:52:19 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-01-12 16:00:07 +0000
commit61671e97927dcc1b302bd01fd59bc61c27972839 (patch)
tree1078be11dae50585e6c5716377407c6a75c675da /gdb/python/python.c
parent51eebae32ab1b7bb454c90252edb877211f6fcb4 (diff)
downloadgdb-61671e97927dcc1b302bd01fd59bc61c27972839.zip
gdb-61671e97927dcc1b302bd01fd59bc61c27972839.tar.gz
gdb-61671e97927dcc1b302bd01fd59bc61c27972839.tar.bz2
gdb/python: add gdb.host_charset function
We already have gdb.target_charset and gdb.target_wide_charset. This commit adds gdb.host_charset along the same lines.
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r--gdb/python/python.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e05b99c..4dcda53 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -571,6 +571,16 @@ gdbpy_target_wide_charset (PyObject *self, PyObject *args)
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
}
+/* Implement gdb.host_charset(). */
+
+static PyObject *
+gdbpy_host_charset (PyObject *self, PyObject *args)
+{
+ const char *cset = host_charset ();
+
+ return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
+}
+
/* A Python function which evaluates a string using the gdb CLI. */
static PyObject *
@@ -2281,6 +2291,9 @@ Return the name of the current target charset." },
{ "target_wide_charset", gdbpy_target_wide_charset, METH_NOARGS,
"target_wide_charset () -> string.\n\
Return the name of the current target wide charset." },
+ { "host_charset", gdbpy_host_charset, METH_NOARGS,
+ "host_charset () -> string.\n\
+Return the name of the current host charset." },
{ "rbreak", (PyCFunction) gdbpy_rbreak, METH_VARARGS | METH_KEYWORDS,
"rbreak (Regex) -> List.\n\
Return a Tuple containing gdb.Breakpoint objects that match the given Regex." },