diff options
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-arch.c | 30 | ||||
-rw-r--r-- | gdb/python/py-breakpoint.c | 13 | ||||
-rw-r--r-- | gdb/python/py-frame.c | 9 | ||||
-rw-r--r-- | gdb/python/py-framefilter.c | 32 | ||||
-rw-r--r-- | gdb/python/py-type.c | 19 | ||||
-rw-r--r-- | gdb/python/py-unwind.c | 24 | ||||
-rw-r--r-- | gdb/python/py-value.c | 16 |
7 files changed, 41 insertions, 102 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 13cc9ba..8d0ec33 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -193,54 +193,38 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) || (end_obj == NULL && count_obj == NULL && pc == start);) { int insn_len = 0; - struct ui_file *memfile = mem_fileopen (); gdbpy_ref insn_dict (PyDict_New ()); if (insn_dict == NULL) - { - ui_file_delete (memfile); - - return NULL; - } + return NULL; if (PyList_Append (result_list.get (), insn_dict.get ())) - { - ui_file_delete (memfile); + return NULL; /* PyList_Append Sets the exception. */ - return NULL; /* PyList_Append Sets the exception. */ - } + string_file stb; TRY { - insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL); + insn_len = gdb_print_insn (gdbarch, pc, &stb, NULL); } CATCH (except, RETURN_MASK_ALL) { - ui_file_delete (memfile); - gdbpy_convert_exception (except); return NULL; } END_CATCH - std::string as = ui_file_as_string (memfile); - if (PyDict_SetItemString (insn_dict.get (), "addr", gdb_py_long_from_ulongest (pc)) || PyDict_SetItemString (insn_dict.get (), "asm", - PyString_FromString (!as.empty () - ? as.c_str () + PyString_FromString (!stb.empty () + ? stb.c_str () : "<unknown>")) || PyDict_SetItemString (insn_dict.get (), "length", PyInt_FromLong (insn_len))) - { - ui_file_delete (memfile); - - return NULL; - } + return NULL; pc += insn_len; i++; - ui_file_delete (memfile); } return result_list.release (); diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index f268b2b..ac64900 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -485,19 +485,16 @@ bppy_get_commands (PyObject *self, void *closure) gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; struct breakpoint *bp = self_bp->bp; long length; - struct ui_file *string_file; PyObject *result; - struct cleanup *chain; BPPY_REQUIRE_VALID (self_bp); if (! self_bp->bp->commands) Py_RETURN_NONE; - string_file = mem_fileopen (); - chain = make_cleanup_ui_file_delete (string_file); + string_file stb; - current_uiout->redirect (string_file); + current_uiout->redirect (&stb); TRY { print_command_lines (current_uiout, breakpoint_commands (bp), 0); @@ -505,17 +502,13 @@ bppy_get_commands (PyObject *self, void *closure) CATCH (except, RETURN_MASK_ALL) { current_uiout->redirect (NULL); - do_cleanups (chain); gdbpy_convert_exception (except); return NULL; } END_CATCH current_uiout->redirect (NULL); - std::string cmdstr = ui_file_as_string (string_file); - result = host_string_to_python_string (cmdstr.c_str ()); - do_cleanups (chain); - return result; + return host_string_to_python_string (stb.c_str ()); } /* Python function to get the breakpoint type. */ diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 048e7c1..8f5ddd0 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -80,13 +80,10 @@ frame_object_to_frame_info (PyObject *obj) static PyObject * frapy_str (PyObject *self) { - PyObject *result; - struct ui_file *strfile; + string_file strfile; - strfile = mem_fileopen (); - fprint_frame_id (strfile, ((frame_object *) self)->frame_id); - std::string s = ui_file_as_string (strfile); - return PyString_FromString (s.c_str ()); + fprint_frame_id (&strfile, ((frame_object *) self)->frame_id); + return PyString_FromString (strfile.c_str ()); } /* Implementation of gdb.Frame.is_valid (self) -> Boolean. diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index bdd9911..9dc01ba 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -208,15 +208,11 @@ py_print_type (struct ui_out *out, struct value *val) TRY { - struct ui_file *stb; - struct cleanup *cleanup; - - stb = mem_fileopen (); - cleanup = make_cleanup_ui_file_delete (stb); check_typedef (value_type (val)); - type_print (value_type (val), "", stb, -1); + + string_file stb; + type_print (value_type (val), "", &stb, -1); out->field_stream ("type", stb); - do_cleanups (cleanup); } CATCH (except, RETURN_MASK_ALL) { @@ -280,14 +276,10 @@ py_print_value (struct ui_out *out, struct value *val, { TRY { - struct ui_file *stb; - struct cleanup *cleanup; + string_file stb; - stb = mem_fileopen (); - cleanup = make_cleanup_ui_file_delete (stb); - common_val_print (val, stb, indent, opts, language); + common_val_print (val, &stb, indent, opts, language); out->field_stream ("value", stb); - do_cleanups (cleanup); } CATCH (except, RETURN_MASK_ALL) { @@ -393,26 +385,22 @@ py_print_single_arg (struct ui_out *out, entry value options. */ if (fa != NULL) { - struct ui_file *stb; + string_file stb; - stb = mem_fileopen (); - make_cleanup_ui_file_delete (stb); - fprintf_symbol_filtered (stb, SYMBOL_PRINT_NAME (fa->sym), + fprintf_symbol_filtered (&stb, SYMBOL_PRINT_NAME (fa->sym), SYMBOL_LANGUAGE (fa->sym), DMGL_PARAMS | DMGL_ANSI); if (fa->entry_kind == print_entry_values_compact) { - fputs_filtered ("=", stb); + stb.puts ("="); - fprintf_symbol_filtered (stb, SYMBOL_PRINT_NAME (fa->sym), + fprintf_symbol_filtered (&stb, SYMBOL_PRINT_NAME (fa->sym), SYMBOL_LANGUAGE (fa->sym), DMGL_PARAMS | DMGL_ANSI); } if (fa->entry_kind == print_entry_values_only || fa->entry_kind == print_entry_values_compact) - { - fputs_filtered ("@entry", stb); - } + stb.puts ("@entry"); out->field_stream ("name", stb); } else diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 7862829..f6e8dd6 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -967,22 +967,13 @@ typy_template_argument (PyObject *self, PyObject *args) static PyObject * typy_str (PyObject *self) { - std::string thetype; + string_file thetype; PyObject *result; TRY { - struct cleanup *old_chain; - struct ui_file *stb; - - stb = mem_fileopen (); - old_chain = make_cleanup_ui_file_delete (stb); - - LA_PRINT_TYPE (type_object_to_type (self), "", stb, -1, 0, + LA_PRINT_TYPE (type_object_to_type (self), "", &thetype, -1, 0, &type_print_raw_options); - - thetype = ui_file_as_string (stb); - do_cleanups (old_chain); } CATCH (except, RETURN_MASK_ALL) { @@ -990,10 +981,8 @@ typy_str (PyObject *self) } END_CATCH - result = PyUnicode_Decode (thetype.c_str (), thetype.length (), - host_charset (), NULL); - - return result; + return PyUnicode_Decode (thetype.c_str (), thetype.size (), + host_charset (), NULL); } /* Implement the richcompare method. */ diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 690412a..d1b63ad 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -198,12 +198,11 @@ pyuw_object_attribute_to_pointer (PyObject *pyo, const char *attr_name, static PyObject * unwind_infopy_str (PyObject *self) { - struct ui_file *strfile = mem_fileopen (); unwind_info_object *unwind_info = (unwind_info_object *) self; - PyObject *result; + string_file stb; - fprintf_unfiltered (strfile, "Frame ID: "); - fprint_frame_id (strfile, unwind_info->frame_id); + stb.puts ("Frame ID: "); + fprint_frame_id (&stb, unwind_info->frame_id); { char *sep = ""; int i; @@ -211,18 +210,18 @@ unwind_infopy_str (PyObject *self) saved_reg *reg; get_user_print_options (&opts); - fprintf_unfiltered (strfile, "\nSaved registers: ("); + stb.printf ("\nSaved registers: ("); for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++) { struct value *value = value_object_to_value (reg->value); - fprintf_unfiltered (strfile, "%s(%d, ", sep, reg->number); + stb.printf ("%s(%d, ", sep, reg->number); if (value != NULL) { TRY { - value_print (value, strfile, &opts); - fprintf_unfiltered (strfile, ")"); + value_print (value, &stb, &opts); + stb.puts (")"); } CATCH (except, RETURN_MASK_ALL) { @@ -231,16 +230,13 @@ unwind_infopy_str (PyObject *self) END_CATCH } else - fprintf_unfiltered (strfile, "<BAD>)"); + stb.puts ("<BAD>)"); sep = ", "; } - fprintf_unfiltered (strfile, ")"); + stb.puts (")"); } - std::string s = ui_file_as_string (strfile); - result = PyString_FromString (s.c_str ()); - ui_file_delete (strfile); - return result; + return PyString_FromString (stb.c_str ()); } /* Create UnwindInfo instance for given PendingFrame and frame ID. diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 8f3164b..8e4d06d 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -867,23 +867,17 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) static PyObject * valpy_str (PyObject *self) { - std::string s; - PyObject *result; struct value_print_options opts; get_user_print_options (&opts); opts.deref_ref = 0; + string_file stb; + TRY { - struct ui_file *stb = mem_fileopen (); - struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); - - common_val_print (((value_object *) self)->value, stb, 0, + common_val_print (((value_object *) self)->value, &stb, 0, &opts, python_language); - s = ui_file_as_string (stb); - - do_cleanups (old_chain); } CATCH (except, RETURN_MASK_ALL) { @@ -891,9 +885,7 @@ valpy_str (PyObject *self) } END_CATCH - result = PyUnicode_Decode (s.c_str (), s.length (), host_charset (), NULL); - - return result; + return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } /* Implements gdb.Value.is_optimized_out. */ |