From 6ad4a2cfb3c7a64bff8df4750c03f796b9a431c4 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 23 Oct 2002 21:17:51 +0000 Subject: [PATCH] 2002-10-23 Jeff Johnston * mi-cmd-var.c: Change all remaining occurrences of ui_out_tuple_begin to make_cleanup_ui_out_tuple_begin_end. Change all remaining occurrences of ui_out_list_begin to make_cleanup_ui_out_list_begin_end. Use do_cleanups instead of ui_out_list_end or ui_out_tuple_end. This is a fix for PR gdb/680. * mi-cmd-stack.c: Ditto. * mi-main.c: Ditto. --- gdb/mi/ChangeLog | 10 ++++++++++ gdb/mi/mi-cmd-stack.c | 26 ++++++++++++++++---------- gdb/mi/mi-cmd-var.c | 10 ++++++---- gdb/mi/mi-main.c | 25 +++++++++++++++---------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog index 5a89d5f23dc..3c7e527b2a0 100644 --- a/gdb/mi/ChangeLog +++ b/gdb/mi/ChangeLog @@ -1,3 +1,13 @@ +2002-10-23 Jeff Johnston + + * mi-cmd-var.c: Change all remaining occurrences of ui_out_tuple_begin + to make_cleanup_ui_out_tuple_begin_end. Change all remaining + occurrences of ui_out_list_begin to make_cleanup_ui_out_list_begin_end. + Use do_cleanups instead of ui_out_list_end or ui_out_tuple_end. This + is a fix for PR gdb/680. + * mi-cmd-stack.c: Ditto. + * mi-main.c: Ditto. + 2002-10-22 Keith Seitz * mi-main.c (mi_cmd_thread_select): Only return MI_CMD_CAUGHT_ERROR diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index b4bae47716d..74cb126af80 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -45,6 +45,7 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc) int frame_low; int frame_high; int i; + struct cleanup *cleanup_stack; struct frame_info *fi; if (!target_has_stack) @@ -76,7 +77,7 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc) if (fi == NULL) error ("mi_cmd_stack_list_frames: Not enough frames in stack."); - ui_out_list_begin (uiout, "stack"); + cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "stack"); /* Now let;s print the frames up to frame_high, or until there are frames in the stack. */ @@ -95,7 +96,7 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc) 0 /* args */ ); } - ui_out_list_end (uiout); + do_cleanups (cleanup_stack); if (i < frame_high) error ("mi_cmd_stack_list_frames: Not enough frames in stack."); @@ -155,6 +156,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) int frame_high; int i; struct frame_info *fi; + struct cleanup *cleanup_stack_args; if (argc < 1 || argc > 3 || argc == 2) error ("mi_cmd_stack_list_args: Usage: PRINT_VALUES [FRAME_LOW FRAME_HIGH]"); @@ -182,7 +184,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) if (fi == NULL) error ("mi_cmd_stack_list_args: Not enough frames in stack."); - ui_out_list_begin (uiout, "stack-args"); + cleanup_stack_args = make_cleanup_ui_out_list_begin_end (uiout, "stack-args"); /* Now let's print the frames up to frame_high, or until there are frames in the stack. */ @@ -190,14 +192,15 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) fi && (i <= frame_high || frame_high == -1); i++, fi = get_prev_frame (fi)) { + struct cleanup *cleanup_frame; QUIT; - ui_out_tuple_begin (uiout, "frame"); + cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); ui_out_field_int (uiout, "level", i); list_args_or_locals (0, atoi (argv[0]), fi); - ui_out_tuple_end (uiout); + do_cleanups (cleanup_frame); } - ui_out_list_end (uiout); + do_cleanups (cleanup_stack_args); if (i < frame_high) error ("mi_cmd_stack_list_args: Not enough frames in stack."); @@ -214,13 +217,14 @@ list_args_or_locals (int locals, int values, struct frame_info *fi) struct block *block; struct symbol *sym; int i, nsyms; + struct cleanup *cleanup_list; static struct ui_stream *stb = NULL; stb = ui_out_stream_new (uiout); block = get_frame_block (fi, 0); - ui_out_list_begin (uiout, locals ? "locals" : "args"); + cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args"); while (block != 0) { @@ -262,8 +266,10 @@ list_args_or_locals (int locals, int values, struct frame_info *fi) } if (print_me) { + struct cleanup *cleanup_tuple = NULL; if (values) - ui_out_tuple_begin (uiout, NULL); + cleanup_tuple = + make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "name", SYMBOL_NAME (sym)); if (values) @@ -278,7 +284,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi) sym2 = sym; print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); - ui_out_tuple_end (uiout); + do_cleanups (cleanup_tuple); } } } @@ -287,7 +293,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi) else block = BLOCK_SUPERBLOCK (block); } - ui_out_list_end (uiout); + do_cleanups (cleanup_list); ui_out_stream_delete (stb); } diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 114906609ef..ee65deb773f 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -254,6 +254,7 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) struct varobj *var; struct varobj **childlist; struct varobj **cc; + struct cleanup *cleanup_children; int numchild; char *type; @@ -271,11 +272,12 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) if (numchild <= 0) return MI_CMD_DONE; - ui_out_tuple_begin (uiout, "children"); + cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children"); cc = childlist; while (*cc != NULL) { - ui_out_tuple_begin (uiout, "child"); + struct cleanup *cleanup_child; + cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child"); ui_out_field_string (uiout, "name", varobj_get_objname (*cc)); ui_out_field_string (uiout, "exp", varobj_get_expression (*cc)); ui_out_field_int (uiout, "numchild", varobj_get_num_children (*cc)); @@ -283,10 +285,10 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) /* C++ pseudo-variables (public, private, protected) do not have a type */ if (type) ui_out_field_string (uiout, "type", varobj_get_type (*cc)); - ui_out_tuple_end (uiout); + do_cleanups (cleanup_child); cc++; } - ui_out_tuple_end (uiout); + do_cleanups (cleanup_children); xfree (childlist); return MI_CMD_DONE; } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index a866042fdc0..5e8b13bda17 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -915,19 +915,22 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) /* Build the result as a two dimentional table. */ { struct ui_stream *stream = ui_out_stream_new (uiout); + struct cleanup *cleanup_list_memory; int row; int row_byte; - ui_out_list_begin (uiout, "memory"); + cleanup_list_memory = make_cleanup_ui_out_list_begin_end (uiout, "memory"); for (row = 0, row_byte = 0; row < nr_rows; row++, row_byte += nr_cols * word_size) { int col; int col_byte; - ui_out_tuple_begin (uiout, NULL); + struct cleanup *cleanup_tuple; + struct cleanup *cleanup_list_data; + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_core_addr (uiout, "addr", addr + row_byte); /* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + row_byte); */ - ui_out_list_begin (uiout, "data"); + cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data"); for (col = 0, col_byte = row_byte; col < nr_cols; col++, col_byte += word_size) @@ -944,7 +947,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) ui_out_field_stream (uiout, NULL, stream); } } - ui_out_list_end (uiout); + do_cleanups (cleanup_list_data); if (aschar) { int byte; @@ -964,10 +967,10 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc) } ui_out_field_stream (uiout, "ascii", stream); } - ui_out_tuple_end (uiout); + do_cleanups (cleanup_tuple); } ui_out_stream_delete (stream); - ui_out_list_end (uiout); + do_cleanups (cleanup_list_memory); } do_cleanups (cleanups); return MI_CMD_DONE; @@ -1419,17 +1422,18 @@ mi_load_progress (const char *section_name, strcmp (previous_sect_name, section_name) : 1); if (new_section) { + struct cleanup *cleanup_tuple; xfree (previous_sect_name); previous_sect_name = xstrdup (section_name); if (last_async_command) fputs_unfiltered (last_async_command, raw_stdout); fputs_unfiltered ("+download", raw_stdout); - ui_out_tuple_begin (uiout, NULL); + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "section", section_name); ui_out_field_int (uiout, "section-size", total_section); ui_out_field_int (uiout, "total-size", grand_total); - ui_out_tuple_end (uiout); + do_cleanups (cleanup_tuple); mi_out_put (uiout, raw_stdout); fputs_unfiltered ("\n", raw_stdout); gdb_flush (raw_stdout); @@ -1438,18 +1442,19 @@ mi_load_progress (const char *section_name, if (delta.tv_sec >= update_threshold.tv_sec && delta.tv_usec >= update_threshold.tv_usec) { + struct cleanup *cleanup_tuple; last_update.tv_sec = time_now.tv_sec; last_update.tv_usec = time_now.tv_usec; if (last_async_command) fputs_unfiltered (last_async_command, raw_stdout); fputs_unfiltered ("+download", raw_stdout); - ui_out_tuple_begin (uiout, NULL); + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "section", section_name); ui_out_field_int (uiout, "section-sent", sent_so_far); ui_out_field_int (uiout, "section-size", total_section); ui_out_field_int (uiout, "total-sent", total_sent); ui_out_field_int (uiout, "total-size", grand_total); - ui_out_tuple_end (uiout); + do_cleanups (cleanup_tuple); mi_out_put (uiout, raw_stdout); fputs_unfiltered ("\n", raw_stdout); gdb_flush (raw_stdout); -- 2.30.2