From da133047ceb8200900589e1b2fec10ba381e72c7 Mon Sep 17 00:00:00 2001 From: Elena Zannoni Date: Mon, 3 Feb 2003 01:18:37 +0000 Subject: 2003-02-02 Elena Zannoni Fix PR gdb/742 gdb/743 * disasm.c (dump_insns): Use make_cleanup_ui_out_tuple_begin_end. (do_mixed_source_and_assembly): Use make_cleanup_ui_out_tuple_begin_end and make_cleanup_ui_out_tuple_begin_end. (do_mixed_source_and_assembly): Ditto. * thread.c (do_captured_list_thread_ids): Ditto. * ui-out.h (ui_out_table_begin, ui_out_list_begin, ui_out_tuple_begin, ui_out_table_end, ui_out_list_end, ui_out_tuple_end): Delete prototypes. * ui-out.c (ui_out_list_begin, ui_out_tuple_begin, ui_out_list_end, ui_out_tuple_end): Delete. From Kevin Buettner : * ui-out.h (make_cleanup_ui_out_table_begin_end): New function. * ui-out.c (make_cleanup_ui_out_table_begin_end) (do_cleanup_table_end): New functions. * breakpoint.c (print_it_typical, print_one_breakpoint, mention): Use cleanups to invoke_ui_out_tuple_end(). (breakpoint_1): Use cleanup to invoke ui_out_table_end(). * cli/cli-setshow.c (cmd_show_list): Use make_cleanup_ui_out_tuple_begin_end. --- gdb/disasm.c | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'gdb/disasm.c') diff --git a/gdb/disasm.c b/gdb/disasm.c index 4ac22a27a6e..75d1783d13f 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -97,6 +97,7 @@ dump_insns (struct ui_out *uiout, disassemble_info * di, char *name = NULL; int offset; int line; + struct cleanup *ui_out_chain; for (pc = low; pc < high;) { @@ -108,7 +109,7 @@ dump_insns (struct ui_out *uiout, disassemble_info * di, else num_displayed++; } - ui_out_tuple_begin (uiout, NULL); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_core_addr (uiout, "address", pc); if (!build_address_symbolic (pc, 0, &name, &offset, &filename, @@ -131,7 +132,7 @@ dump_insns (struct ui_out *uiout, disassemble_info * di, pc += TARGET_PRINT_INSN (pc, di); ui_out_field_stream (uiout, "inst", stb); ui_file_rewind (stb->stream); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); ui_out_text (uiout, "\n"); } return num_displayed; @@ -157,6 +158,7 @@ do_mixed_source_and_assembly (struct ui_out *uiout, int next_line = 0; CORE_ADDR pc; int num_displayed = 0; + struct cleanup *ui_out_chain; mle = (struct dis_line_entry *) alloca (nlines * sizeof (struct dis_line_entry)); @@ -210,11 +212,14 @@ do_mixed_source_and_assembly (struct ui_out *uiout, they have been emitted before), followed by the assembly code for that line. */ - ui_out_list_begin (uiout, "asm_insns"); + ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); for (i = 0; i < newlines; i++) { + struct cleanup *ui_out_tuple_chain = NULL; + struct cleanup *ui_out_list_chain = NULL; int close_list = 1; + /* Print out everything from next_line to the current line. */ if (mle[i].line >= next_line) { @@ -223,7 +228,9 @@ do_mixed_source_and_assembly (struct ui_out *uiout, /* Just one line to print. */ if (next_line == mle[i].line) { - ui_out_tuple_begin (uiout, "src_and_asm_line"); + ui_out_tuple_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, + "src_and_asm_line"); print_source_lines (symtab, next_line, mle[i].line + 1, 0); } else @@ -231,27 +238,38 @@ do_mixed_source_and_assembly (struct ui_out *uiout, /* Several source lines w/o asm instructions associated. */ for (; next_line < mle[i].line; next_line++) { - ui_out_tuple_begin (uiout, "src_and_asm_line"); + struct cleanup *ui_out_list_chain_line; + struct cleanup *ui_out_tuple_chain_line; + + ui_out_tuple_chain_line + = make_cleanup_ui_out_tuple_begin_end (uiout, + "src_and_asm_line"); print_source_lines (symtab, next_line, next_line + 1, 0); - ui_out_list_begin (uiout, "line_asm_insn"); - ui_out_list_end (uiout); - ui_out_tuple_end (uiout); + ui_out_list_chain_line + = make_cleanup_ui_out_list_begin_end (uiout, + "line_asm_insn"); + do_cleanups (ui_out_list_chain_line); + do_cleanups (ui_out_tuple_chain_line); } /* Print the last line and leave list open for asm instructions to be added. */ - ui_out_tuple_begin (uiout, "src_and_asm_line"); + ui_out_tuple_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, + "src_and_asm_line"); print_source_lines (symtab, next_line, mle[i].line + 1, 0); } } else { - ui_out_tuple_begin (uiout, "src_and_asm_line"); + ui_out_tuple_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, "src_and_asm_line"); print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0); } next_line = mle[i].line + 1; - ui_out_list_begin (uiout, "line_asm_insn"); + ui_out_list_chain + = make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn"); /* Don't close the list if the lines are not in order. */ if (i < (newlines - 1) && mle[i + 1].line <= mle[i].line) close_list = 0; @@ -261,8 +279,8 @@ do_mixed_source_and_assembly (struct ui_out *uiout, how_many, stb); if (close_list) { - ui_out_list_end (uiout); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_list_chain); + do_cleanups (ui_out_tuple_chain); ui_out_text (uiout, "\n"); close_list = 0; } @@ -270,7 +288,7 @@ do_mixed_source_and_assembly (struct ui_out *uiout, if (num_displayed >= how_many) break; } - ui_out_list_end (uiout); + do_cleanups (ui_out_chain); } @@ -280,12 +298,13 @@ do_assembly_only (struct ui_out *uiout, disassemble_info * di, int how_many, struct ui_stream *stb) { int num_displayed = 0; + struct cleanup *ui_out_chain; - ui_out_list_begin (uiout, "asm_insns"); + ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); num_displayed = dump_insns (uiout, di, low, high, how_many, stb); - ui_out_list_end (uiout); + do_cleanups (ui_out_chain); } void -- cgit v1.2.1