From 61671e97927dcc1b302bd01fd59bc61c27972839 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 12 Jan 2022 11:52:19 +0000 Subject: 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. --- gdb/python/python.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gdb/python/python.c') 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." }, -- cgit v1.1