aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-arch.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-11-08 15:26:45 +0000
committerPedro Alves <palves@redhat.com>2016-11-08 15:26:45 +0000
commitc92aed165e8af79f51c5165f98f12389bb59a121 (patch)
tree68b7aecd264ec7bcdc148d5a71c7459a62c03a09 /gdb/python/py-arch.c
parent02030646c2a799614d31e52008403d8be067ac5d (diff)
downloadgdb-c92aed165e8af79f51c5165f98f12389bb59a121.zip
gdb-c92aed165e8af79f51c5165f98f12389bb59a121.tar.gz
gdb-c92aed165e8af79f51c5165f98f12389bb59a121.tar.bz2
Use ui_file_as_string in gdb/python/
gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * python/py-arch.c (archpy_disassemble): Use ui_file_as_string and std::string. * python/py-breakpoint.c (bppy_get_commands): Use ui_file_as_string and std::string. * python/py-frame.c (frapy_str): Likewise. * python/py-type.c (typy_str): Likewise. * python/py-unwind.c (unwind_infopy_str): Likewise. * python/py-value.c (valpy_str): Likewise.
Diffstat (limited to 'gdb/python/py-arch.c')
-rw-r--r--gdb/python/py-arch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 4a2dcbf..60cc5a9 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -198,7 +198,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|| (end_obj == NULL && count_obj == NULL && pc == start);)
{
int insn_len = 0;
- char *as = NULL;
struct ui_file *memfile = mem_fileopen ();
PyObject *insn_dict = PyDict_New ();
@@ -232,18 +231,20 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
}
END_CATCH
- as = ui_file_xstrdup (memfile, NULL);
+ std::string as = ui_file_as_string (memfile);
+
if (PyDict_SetItemString (insn_dict, "addr",
gdb_py_long_from_ulongest (pc))
|| PyDict_SetItemString (insn_dict, "asm",
- PyString_FromString (*as ? as : "<unknown>"))
+ PyString_FromString (!as.empty ()
+ ? as.c_str ()
+ : "<unknown>"))
|| PyDict_SetItemString (insn_dict, "length",
PyInt_FromLong (insn_len)))
{
Py_DECREF (result_list);
ui_file_delete (memfile);
- xfree (as);
return NULL;
}
@@ -251,7 +252,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
pc += insn_len;
i++;
ui_file_delete (memfile);
- xfree (as);
}
return result_list;