mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-01 20:12:01 +08:00
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:
@ -1,3 +1,14 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2016-11-08 Pedro Alves <palves@redhat.com>
|
2016-11-08 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* printcmd.c (eval_command): Use ui_file_as_string and
|
* printcmd.c (eval_command): Use ui_file_as_string and
|
||||||
|
@ -198,7 +198,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|| (end_obj == NULL && count_obj == NULL && pc == start);)
|
|| (end_obj == NULL && count_obj == NULL && pc == start);)
|
||||||
{
|
{
|
||||||
int insn_len = 0;
|
int insn_len = 0;
|
||||||
char *as = NULL;
|
|
||||||
struct ui_file *memfile = mem_fileopen ();
|
struct ui_file *memfile = mem_fileopen ();
|
||||||
PyObject *insn_dict = PyDict_New ();
|
PyObject *insn_dict = PyDict_New ();
|
||||||
|
|
||||||
@ -232,18 +231,20 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
as = ui_file_xstrdup (memfile, NULL);
|
std::string as = ui_file_as_string (memfile);
|
||||||
|
|
||||||
if (PyDict_SetItemString (insn_dict, "addr",
|
if (PyDict_SetItemString (insn_dict, "addr",
|
||||||
gdb_py_long_from_ulongest (pc))
|
gdb_py_long_from_ulongest (pc))
|
||||||
|| PyDict_SetItemString (insn_dict, "asm",
|
|| PyDict_SetItemString (insn_dict, "asm",
|
||||||
PyString_FromString (*as ? as : "<unknown>"))
|
PyString_FromString (!as.empty ()
|
||||||
|
? as.c_str ()
|
||||||
|
: "<unknown>"))
|
||||||
|| PyDict_SetItemString (insn_dict, "length",
|
|| PyDict_SetItemString (insn_dict, "length",
|
||||||
PyInt_FromLong (insn_len)))
|
PyInt_FromLong (insn_len)))
|
||||||
{
|
{
|
||||||
Py_DECREF (result_list);
|
Py_DECREF (result_list);
|
||||||
|
|
||||||
ui_file_delete (memfile);
|
ui_file_delete (memfile);
|
||||||
xfree (as);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -251,7 +252,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
pc += insn_len;
|
pc += insn_len;
|
||||||
i++;
|
i++;
|
||||||
ui_file_delete (memfile);
|
ui_file_delete (memfile);
|
||||||
xfree (as);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result_list;
|
return result_list;
|
||||||
|
@ -487,9 +487,8 @@ bppy_get_commands (PyObject *self, void *closure)
|
|||||||
struct breakpoint *bp = self_bp->bp;
|
struct breakpoint *bp = self_bp->bp;
|
||||||
long length;
|
long length;
|
||||||
struct ui_file *string_file;
|
struct ui_file *string_file;
|
||||||
struct cleanup *chain;
|
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
char *cmdstr;
|
struct cleanup *chain;
|
||||||
|
|
||||||
BPPY_REQUIRE_VALID (self_bp);
|
BPPY_REQUIRE_VALID (self_bp);
|
||||||
|
|
||||||
@ -514,9 +513,8 @@ bppy_get_commands (PyObject *self, void *closure)
|
|||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
ui_out_redirect (current_uiout, NULL);
|
ui_out_redirect (current_uiout, NULL);
|
||||||
cmdstr = ui_file_xstrdup (string_file, &length);
|
std::string cmdstr = ui_file_as_string (string_file);
|
||||||
make_cleanup (xfree, cmdstr);
|
result = host_string_to_python_string (cmdstr.c_str ());
|
||||||
result = host_string_to_python_string (cmdstr);
|
|
||||||
do_cleanups (chain);
|
do_cleanups (chain);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -80,17 +80,13 @@ frame_object_to_frame_info (PyObject *obj)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
frapy_str (PyObject *self)
|
frapy_str (PyObject *self)
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
struct ui_file *strfile;
|
struct ui_file *strfile;
|
||||||
|
|
||||||
strfile = mem_fileopen ();
|
strfile = mem_fileopen ();
|
||||||
fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
|
fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
|
||||||
s = ui_file_xstrdup (strfile, NULL);
|
std::string s = ui_file_as_string (strfile);
|
||||||
result = PyString_FromString (s);
|
return PyString_FromString (s.c_str ());
|
||||||
xfree (s);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
|
/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
|
||||||
|
@ -1010,8 +1010,7 @@ typy_template_argument (PyObject *self, PyObject *args)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
typy_str (PyObject *self)
|
typy_str (PyObject *self)
|
||||||
{
|
{
|
||||||
char *thetype = NULL;
|
std::string thetype;
|
||||||
long length = 0;
|
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
@ -1025,18 +1024,17 @@ typy_str (PyObject *self)
|
|||||||
LA_PRINT_TYPE (type_object_to_type (self), "", stb, -1, 0,
|
LA_PRINT_TYPE (type_object_to_type (self), "", stb, -1, 0,
|
||||||
&type_print_raw_options);
|
&type_print_raw_options);
|
||||||
|
|
||||||
thetype = ui_file_xstrdup (stb, &length);
|
thetype = ui_file_as_string (stb);
|
||||||
do_cleanups (old_chain);
|
do_cleanups (old_chain);
|
||||||
}
|
}
|
||||||
CATCH (except, RETURN_MASK_ALL)
|
CATCH (except, RETURN_MASK_ALL)
|
||||||
{
|
{
|
||||||
xfree (thetype);
|
|
||||||
GDB_PY_HANDLE_EXCEPTION (except);
|
GDB_PY_HANDLE_EXCEPTION (except);
|
||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
result = PyUnicode_Decode (thetype, length, host_charset (), NULL);
|
result = PyUnicode_Decode (thetype.c_str (), thetype.length (),
|
||||||
xfree (thetype);
|
host_charset (), NULL);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -236,12 +236,9 @@ unwind_infopy_str (PyObject *self)
|
|||||||
}
|
}
|
||||||
fprintf_unfiltered (strfile, ")");
|
fprintf_unfiltered (strfile, ")");
|
||||||
}
|
}
|
||||||
{
|
|
||||||
char *s = ui_file_xstrdup (strfile, NULL);
|
|
||||||
|
|
||||||
result = PyString_FromString (s);
|
std::string s = ui_file_as_string (strfile);
|
||||||
xfree (s);
|
result = PyString_FromString (s.c_str ());
|
||||||
}
|
|
||||||
ui_file_delete (strfile);
|
ui_file_delete (strfile);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -896,7 +896,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
valpy_str (PyObject *self)
|
valpy_str (PyObject *self)
|
||||||
{
|
{
|
||||||
char *s = NULL;
|
std::string s;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
struct value_print_options opts;
|
struct value_print_options opts;
|
||||||
|
|
||||||
@ -910,7 +910,7 @@ valpy_str (PyObject *self)
|
|||||||
|
|
||||||
common_val_print (((value_object *) self)->value, stb, 0,
|
common_val_print (((value_object *) self)->value, stb, 0,
|
||||||
&opts, python_language);
|
&opts, python_language);
|
||||||
s = ui_file_xstrdup (stb, NULL);
|
s = ui_file_as_string (stb);
|
||||||
|
|
||||||
do_cleanups (old_chain);
|
do_cleanups (old_chain);
|
||||||
}
|
}
|
||||||
@ -920,8 +920,7 @@ valpy_str (PyObject *self)
|
|||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
result = PyUnicode_Decode (s, strlen (s), host_charset (), NULL);
|
result = PyUnicode_Decode (s.c_str (), s.length (), host_charset (), NULL);
|
||||||
xfree (s);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user