diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 25 | ||||
-rw-r--r-- | gdb/breakpoint.c | 56 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 21 | ||||
-rw-r--r-- | gdb/disasm.c | 51 | ||||
-rw-r--r-- | gdb/thread.c | 5 | ||||
-rw-r--r-- | gdb/ui-out.c | 49 | ||||
-rw-r--r-- | gdb/ui-out.h | 18 |
7 files changed, 133 insertions, 92 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ab8db86..dc183a9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,28 @@ +2003-02-02 Elena Zannoni <ezannoni@redhat.com> + + 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 <kevinb@redhat.com>: + * 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. + 2003-02-02 Andrew Cagney <ac131313@redhat.com> * frame.c (frame_unwind_register): New function. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4544ed5..cd671a9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2002,7 +2002,7 @@ top: static enum print_stop_action print_it_typical (bpstat bs) { - struct cleanup *old_chain; + struct cleanup *old_chain, *ui_out_chain; struct ui_stream *stb; stb = ui_out_stream_new (uiout); old_chain = make_cleanup_ui_out_stream_delete (stb); @@ -2163,14 +2163,14 @@ print_it_typical (bpstat bs) if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "watchpoint-trigger"); mention (bs->breakpoint_at); - ui_out_tuple_begin (uiout, "value"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value"); ui_out_text (uiout, "\nOld value = "); value_print (bs->old_val, stb->stream, 0, Val_pretty_default); ui_out_field_stream (uiout, "old", stb); ui_out_text (uiout, "\nNew value = "); value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default); ui_out_field_stream (uiout, "new", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); ui_out_text (uiout, "\n"); value_free (bs->old_val); bs->old_val = NULL; @@ -2183,11 +2183,11 @@ print_it_typical (bpstat bs) if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "read-watchpoint-trigger"); mention (bs->breakpoint_at); - ui_out_tuple_begin (uiout, "value"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value"); ui_out_text (uiout, "\nValue = "); value_print (bs->breakpoint_at->val, stb->stream, 0, Val_pretty_default); ui_out_field_stream (uiout, "value", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); ui_out_text (uiout, "\n"); return PRINT_UNKNOWN; break; @@ -2199,7 +2199,7 @@ print_it_typical (bpstat bs) if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "access-watchpoint-trigger"); mention (bs->breakpoint_at); - ui_out_tuple_begin (uiout, "value"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value"); ui_out_text (uiout, "\nOld value = "); value_print (bs->old_val, stb->stream, 0, Val_pretty_default); ui_out_field_stream (uiout, "old", stb); @@ -2212,12 +2212,12 @@ print_it_typical (bpstat bs) mention (bs->breakpoint_at); if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "access-watchpoint-trigger"); - ui_out_tuple_begin (uiout, "value"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value"); ui_out_text (uiout, "\nValue = "); } value_print (bs->breakpoint_at->val, stb->stream, 0,Val_pretty_default); ui_out_field_stream (uiout, "new", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); ui_out_text (uiout, "\n"); return PRINT_UNKNOWN; break; @@ -3229,9 +3229,10 @@ print_one_breakpoint (struct breakpoint *b, char wrap_indent[80]; struct ui_stream *stb = ui_out_stream_new (uiout); struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb); + struct cleanup *bkpt_chain; annotate_record (); - ui_out_tuple_begin (uiout, "bkpt"); + bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt"); /* 1 */ annotate_field (0); @@ -3469,12 +3470,14 @@ print_one_breakpoint (struct breakpoint *b, if ((l = b->commands)) { + struct cleanup *script_chain; + annotate_field (9); - ui_out_tuple_begin (uiout, "script"); + script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script"); print_command_lines (uiout, l, 4); - ui_out_tuple_end (uiout); + do_cleanups (script_chain); } - ui_out_tuple_end (uiout); + do_cleanups (bkpt_chain); do_cleanups (old_chain); } @@ -3542,6 +3545,7 @@ breakpoint_1 (int bnum, int allflag) register struct breakpoint *b; CORE_ADDR last_addr = (CORE_ADDR) -1; int nr_printable_breakpoints; + struct cleanup *bkpttbl_chain; /* Compute the number of rows in the table. */ nr_printable_breakpoints = 0; @@ -3554,9 +3558,13 @@ breakpoint_1 (int bnum, int allflag) } if (addressprint) - ui_out_table_begin (uiout, 6, nr_printable_breakpoints, "BreakpointTable"); + bkpttbl_chain + = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints, + "BreakpointTable"); else - ui_out_table_begin (uiout, 5, nr_printable_breakpoints, "BreakpointTable"); + bkpttbl_chain + = make_cleanup_ui_out_table_begin_end (uiout, 5, nr_printable_breakpoints, + "BreakpointTable"); if (nr_printable_breakpoints > 0) annotate_breakpoints_headers (); @@ -3598,7 +3606,7 @@ breakpoint_1 (int bnum, int allflag) print_one_breakpoint (b, &last_addr); } - ui_out_table_end (uiout); + do_cleanups (bkpttbl_chain); if (nr_printable_breakpoints == 0) { @@ -4390,7 +4398,7 @@ static void mention (struct breakpoint *b) { int say_where = 0; - struct cleanup *old_chain; + struct cleanup *old_chain, *ui_out_chain; struct ui_stream *stb; stb = ui_out_stream_new (uiout); @@ -4412,39 +4420,39 @@ mention (struct breakpoint *b) break; case bp_watchpoint: ui_out_text (uiout, "Watchpoint "); - ui_out_tuple_begin (uiout, "wpt"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); ui_out_field_int (uiout, "number", b->number); ui_out_text (uiout, ": "); print_expression (b->exp, stb->stream); ui_out_field_stream (uiout, "exp", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); break; case bp_hardware_watchpoint: ui_out_text (uiout, "Hardware watchpoint "); - ui_out_tuple_begin (uiout, "wpt"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); ui_out_field_int (uiout, "number", b->number); ui_out_text (uiout, ": "); print_expression (b->exp, stb->stream); ui_out_field_stream (uiout, "exp", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); break; case bp_read_watchpoint: ui_out_text (uiout, "Hardware read watchpoint "); - ui_out_tuple_begin (uiout, "hw-rwpt"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt"); ui_out_field_int (uiout, "number", b->number); ui_out_text (uiout, ": "); print_expression (b->exp, stb->stream); ui_out_field_stream (uiout, "exp", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); break; case bp_access_watchpoint: ui_out_text (uiout, "Hardware access (read/write) watchpoint "); - ui_out_tuple_begin (uiout, "hw-awpt"); + ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt"); ui_out_field_int (uiout, "number", b->number); ui_out_text (uiout, ": "); print_expression (b->exp, stb->stream); ui_out_field_stream (uiout, "exp", stb); - ui_out_tuple_end (uiout); + do_cleanups (ui_out_chain); break; case bp_breakpoint: if (ui_out_is_mi_like_p (uiout)) diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 6fe2ff0..1d68ae4 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -1,6 +1,6 @@ /* Handle set and show GDB commands. - Copyright 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -353,28 +353,35 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c) void cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix) { - ui_out_tuple_begin (uiout, "showlist"); + struct cleanup *showlist_chain; + + showlist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "showlist"); for (; list != NULL; list = list->next) { /* If we find a prefix, run its list, prefixing our output by its prefix (with "show " skipped). */ if (list->prefixlist && !list->abbrev_flag) { - ui_out_tuple_begin (uiout, "optionlist"); + struct cleanup *optionlist_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, "optionlist"); ui_out_field_string (uiout, "prefix", list->prefixname + 5); cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5); - ui_out_tuple_end (uiout); + /* Close the tuple. */ + do_cleanups (optionlist_chain); } if (list->type == show_cmd) { - ui_out_tuple_begin (uiout, "option"); + struct cleanup *option_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, "option"); ui_out_text (uiout, prefix); ui_out_field_string (uiout, "name", list->name); ui_out_text (uiout, ": "); do_setshow_command ((char *) NULL, from_tty, list); - ui_out_tuple_end (uiout); + /* Close the tuple. */ + do_cleanups (option_chain); } } - ui_out_tuple_end (uiout); + /* Close the tuple. */ + do_cleanups (showlist_chain); } diff --git a/gdb/disasm.c b/gdb/disasm.c index 4ac22a2..75d1783 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 diff --git a/gdb/thread.c b/gdb/thread.c index f36def1..2c70ee5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -261,11 +261,12 @@ do_captured_list_thread_ids (struct ui_out *uiout, { struct thread_info *tp; int num = 0; + struct cleanup *cleanup_chain; prune_threads (); target_find_new_threads (); - ui_out_tuple_begin (uiout, "thread-ids"); + cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "thread-ids"); for (tp = thread_list; tp; tp = tp->next) { @@ -273,7 +274,7 @@ do_captured_list_thread_ids (struct ui_out *uiout, ui_out_field_int (uiout, "thread-id", tp->num); } - ui_out_tuple_end (uiout); + do_cleanups (cleanup_chain); ui_out_field_int (uiout, "number-of-threads", num); return GDB_RC_OK; } diff --git a/gdb/ui-out.c b/gdb/ui-out.c index d98cf16..ed32da3 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -273,7 +273,7 @@ static void init_ui_out_state (struct ui_out *uiout); /* Mark beginning of a table */ -void +static void ui_out_table_begin (struct ui_out *uiout, int nbrofcols, int nr_rows, const char *tblid) @@ -318,7 +318,7 @@ columns."); uo_table_body (uiout); } -void +static void ui_out_table_end (struct ui_out *uiout) { if (!uiout->table.flag) @@ -351,6 +351,22 @@ and before table_body."); uo_table_header (uiout, width, alignment, col_name, colhdr); } +static void +do_cleanup_table_end (void *data) +{ + struct ui_out *ui_out = data; + + ui_out_table_end (ui_out); +} + +struct cleanup * +make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, int nr_cols, + int nr_rows, const char *tblid) +{ + ui_out_table_begin (ui_out, nr_cols, nr_rows, tblid); + return make_cleanup (do_cleanup_table_end, ui_out); +} + void ui_out_begin (struct ui_out *uiout, enum ui_out_type type, @@ -388,19 +404,6 @@ specified after table_body."); } void -ui_out_list_begin (struct ui_out *uiout, - const char *id) -{ - ui_out_begin (uiout, ui_out_type_list, id); -} - -void -ui_out_tuple_begin (struct ui_out *uiout, const char *id) -{ - ui_out_begin (uiout, ui_out_type_tuple, id); -} - -void ui_out_end (struct ui_out *uiout, enum ui_out_type type) { @@ -408,18 +411,6 @@ ui_out_end (struct ui_out *uiout, uo_end (uiout, type, old_level); } -void -ui_out_list_end (struct ui_out *uiout) -{ - ui_out_end (uiout, ui_out_type_list); -} - -void -ui_out_tuple_end (struct ui_out *uiout) -{ - ui_out_end (uiout, ui_out_type_tuple); -} - struct ui_out_end_cleanup_data { struct ui_out *uiout; @@ -458,7 +449,7 @@ struct cleanup * make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, const char *id) { - ui_out_tuple_begin (uiout, id); + ui_out_begin (uiout, ui_out_type_tuple, id); return make_cleanup_ui_out_end (uiout, ui_out_type_tuple); } @@ -466,7 +457,7 @@ struct cleanup * make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, const char *id) { - ui_out_list_begin (uiout, id); + ui_out_begin (uiout, ui_out_type_list, id); return make_cleanup_ui_out_end (uiout, ui_out_type_list); } diff --git a/gdb/ui-out.h b/gdb/ui-out.h index c8ed9dd..a52c345 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -88,31 +88,21 @@ extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout, implied structure: ``table = { hdr = { header, ... } , body = [ { field, ... }, ... ] }''. If NR_ROWS is negative then there is at least one row. */ - -extern void ui_out_table_begin (struct ui_out *uiout, int nbrofcols, - int nr_rows, const char *tblid); - extern void ui_out_table_header (struct ui_out *uiout, int width, enum ui_align align, const char *col_name, const char *colhdr); extern void ui_out_table_body (struct ui_out *uiout); -extern void ui_out_table_end (struct ui_out *uiout); - +extern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out, + int nr_cols, + int nr_rows, + const char *tblid); /* Compatibility wrappers. */ -extern void ui_out_list_begin (struct ui_out *uiout, const char *id); - -extern void ui_out_list_end (struct ui_out *uiout); - extern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout, const char *id); -extern void ui_out_tuple_begin (struct ui_out *uiout, const char *id); - -extern void ui_out_tuple_end (struct ui_out *uiout); - extern struct cleanup *make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout, const char *id); |