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.
This commit is contained in:
parent
02030646c2
commit
c92aed165e
7 changed files with 30 additions and 31 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue