diff options
author | Mark Kettenis <kettenis@gnu.org> | 2004-01-25 21:00:18 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2004-01-25 21:00:18 +0000 |
commit | bb472c1e0778e84a8b77c34d64363c8f7afe720b (patch) | |
tree | 79cfadcbd31fc390fd2c7ec3afa3684f92195c55 | |
parent | f941662f5e0d8c518f1c08000d77dcf068af1e42 (diff) | |
download | gdb-bb472c1e0778e84a8b77c34d64363c8f7afe720b.zip gdb-bb472c1e0778e84a8b77c34d64363c8f7afe720b.tar.gz gdb-bb472c1e0778e84a8b77c34d64363c8f7afe720b.tar.bz2 |
* infcmd.c (print_return_value): Plug memory leak; delete
ui_stream object. Rename argument `structure_return' to
`struct_return'.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/infcmd.c | 36 |
2 files changed, 23 insertions, 19 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ada362d..b20f0e9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2004-01-25 Mark Kettenis <kettenis@gnu.org> + * infcmd.c (print_return_value): Plug memory leak; delete + ui_stream object. Rename argument `structure_return' to + `struct_return'. + +2004-01-25 Mark Kettenis <kettenis@gnu.org> + * infcmd.c (print_return_value): Wrap long lines. (finish_command_continuation, finish_command): Remove unused variable `funcaddr'. Fix some coding-standards problems. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 9efa193..ebf7f39 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1050,22 +1050,16 @@ advance_command (char *arg, int from_tty) /* Print the result of a function at the end of a 'finish' command. */ static void -print_return_value (int structure_return, struct type *value_type) +print_return_value (int struct_return, struct type *value_type) { + struct cleanup *old_chain; + struct ui_stream *stb; struct value *value; - static struct ui_stream *stb = NULL; - if (!structure_return) + if (!struct_return) { + /* The return value can be found in the inferior's registers. */ value = register_value_being_returned (value_type, stop_registers); - stb = ui_out_stream_new (uiout); - ui_out_text (uiout, "Value returned is "); - ui_out_field_fmt (uiout, "gdb-result-var", "$%d", - record_latest_value (value)); - ui_out_text (uiout, " = "); - value_print (value, stb->stream, 0, Val_no_prettyprint); - ui_out_field_stream (uiout, "return-value", stb); - ui_out_text (uiout, "\n"); } /* FIXME: 2003-09-27: When returning from a nested inferior function call, it's possible (with no help from the architecture vector) @@ -1110,15 +1104,19 @@ print_return_value (int structure_return, struct type *value_type) EXTRACT_RETURN_VALUE (value_type, stop_registers, VALUE_CONTENTS_RAW (value)); } - stb = ui_out_stream_new (uiout); - ui_out_text (uiout, "Value returned is "); - ui_out_field_fmt (uiout, "gdb-result-var", "$%d", - record_latest_value (value)); - ui_out_text (uiout, " = "); - value_print (value, stb->stream, 0, Val_no_prettyprint); - ui_out_field_stream (uiout, "return-value", stb); - ui_out_text (uiout, "\n"); } + + /* Print it. */ + stb = ui_out_stream_new (uiout); + old_chain = make_cleanup_ui_out_stream_delete (stb); + ui_out_text (uiout, "Value returned is "); + ui_out_field_fmt (uiout, "gdb-result-var", "$%d", + record_latest_value (value)); + ui_out_text (uiout, " = "); + value_print (value, stb->stream, 0, Val_no_prettyprint); + ui_out_field_stream (uiout, "return-value", stb); + ui_out_text (uiout, "\n"); + do_cleanups (old_chain); } /* Stuff that needs to be done by the finish command after the target |