+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.
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);
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;
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;
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);
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;
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);
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);
}
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;
}
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 ();
print_one_breakpoint (b, &last_addr);
}
- ui_out_table_end (uiout);
+ do_cleanups (bkpttbl_chain);
if (nr_printable_breakpoints == 0)
{
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);
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))
/* 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
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);
}
char *name = NULL;
int offset;
int line;
+ struct cleanup *ui_out_chain;
for (pc = low; pc < high;)
{
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,
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;
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));
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)
{
/* 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
/* 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;
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;
}
if (num_displayed >= how_many)
break;
}
- ui_out_list_end (uiout);
+ do_cleanups (ui_out_chain);
}
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
{
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)
{
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;
}
/* Mark beginning of a table */
-void
+static void
ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
int nr_rows,
const char *tblid)
uo_table_body (uiout);
}
-void
+static void
ui_out_table_end (struct ui_out *uiout)
{
if (!uiout->table.flag)
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,
uo_begin (uiout, type, new_level, id);
}
-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)
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;
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);
}
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);
}
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);