int hw_breakpoint_error = 0;
int hw_bp_details_reported = 0;
- struct ui_file *tmp_error_stream = mem_fileopen ();
- struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream);
+ string_file tmp_error_stream;
/* Explicitly mark the warning -- this will only be printed if
there was an error. */
- fprintf_unfiltered (tmp_error_stream, "Warning:\n");
+ tmp_error_stream.puts ("Warning:\n");
- save_current_space_and_thread ();
+ struct cleanup *cleanups = save_current_space_and_thread ();
ALL_BP_LOCATIONS (bl, blp_tmp)
{
&& ptid_equal (inferior_ptid, null_ptid))
continue;
- val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks,
+ val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
&hw_breakpoint_error, &hw_bp_details_reported);
if (val)
error_flag = val;
int hw_breakpoint_error = 0;
int hw_bp_error_explained_already = 0;
- struct ui_file *tmp_error_stream = mem_fileopen ();
- struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream);
-
+ string_file tmp_error_stream;
+
/* Explicitly mark the warning -- this will only be printed if
there was an error. */
- fprintf_unfiltered (tmp_error_stream, "Warning:\n");
+ tmp_error_stream.puts ("Warning:\n");
- save_current_space_and_thread ();
+ struct cleanup *cleanups = save_current_space_and_thread ();
ALL_BP_LOCATIONS (bl, blp_tmp)
{
&& ptid_equal (inferior_ptid, null_ptid))
continue;
- val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks,
+ val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
&hw_breakpoint_error, &hw_bp_error_explained_already);
if (val)
error_flag = val;
remove_breakpoint (loc);
hw_breakpoint_error = 1;
- fprintf_unfiltered (tmp_error_stream,
- "Could not insert hardware watchpoint %d.\n",
- bpt->number);
+ tmp_error_stream.printf ("Could not insert "
+ "hardware watchpoint %d.\n",
+ bpt->number);
error_flag = -1;
}
}
message about possibly exhausted resources. */
if (hw_breakpoint_error && !hw_bp_error_explained_already)
{
- fprintf_unfiltered (tmp_error_stream,
- "Could not insert hardware breakpoints:\n\
+ tmp_error_stream.printf ("Could not insert hardware breakpoints:\n\
You may have requested too many hardware breakpoints/watchpoints.\n");
}
target_terminal_ours_for_output ();
struct cleanup *old_chain;
struct bp_location *bl, **blp_tmp;
int val;
- struct ui_file *tmp_error_stream;
int dummy1 = 0, dummy2 = 0, dummy3 = 0;
struct inferior *inf;
struct thread_info *tp;
inferior_ptid = tp->ptid;
- tmp_error_stream = mem_fileopen ();
- make_cleanup_ui_file_delete (tmp_error_stream);
+ string_file tmp_error_stream;
ALL_BP_LOCATIONS (bl, blp_tmp)
{
if (bl->inserted)
{
bl->inserted = 0;
- val = insert_bp_location (bl, tmp_error_stream, &dummy1, &dummy2, &dummy3);
+ val = insert_bp_location (bl, &tmp_error_stream, &dummy1, &dummy2, &dummy3);
if (val != 0)
{
do_cleanups (old_chain);
}
else if (loc)
{
- struct ui_file *stb = mem_fileopen ();
- struct cleanup *stb_chain = make_cleanup_ui_file_delete (stb);
+ string_file stb;
- print_address_symbolic (loc->gdbarch, loc->address, stb,
+ print_address_symbolic (loc->gdbarch, loc->address, &stb,
demangle, "");
uiout->field_stream ("at", stb);
-
- do_cleanups (stb_chain);
}
else
{
{
CORE_ADDR address_start, address_end;
struct bp_location *bl = b->loc;
- struct ui_file *stb = mem_fileopen ();
- struct cleanup *cleanup = make_cleanup_ui_file_delete (stb);
+ string_file stb;
gdb_assert (bl);
address_end = address_start + bl->length - 1;
uiout->text ("\taddress range: ");
- fprintf_unfiltered (stb, "[%s, %s]",
- print_core_address (bl->gdbarch, address_start),
- print_core_address (bl->gdbarch, address_end));
+ stb.printf ("[%s, %s]",
+ print_core_address (bl->gdbarch, address_start),
+ print_core_address (bl->gdbarch, address_end));
uiout->field_stream ("addr", stb);
uiout->text ("\n");
-
- do_cleanups (cleanup);
}
/* Implement the "print_mention" breakpoint_ops method for
{
struct cleanup *old_chain;
struct breakpoint *b;
- struct ui_file *stb;
enum print_stop_action result;
struct watchpoint *w;
struct ui_out *uiout = current_uiout;
b = bs->breakpoint_at;
w = (struct watchpoint *) b;
- stb = mem_fileopen ();
- old_chain = make_cleanup_ui_file_delete (stb);
+ old_chain = make_cleanup (null_cleanup, NULL);
annotate_watchpoint (b->number);
maybe_print_thread_hit_breakpoint (uiout);
+ string_file stb;
+
switch (b->type)
{
case bp_watchpoint:
mention (b);
make_cleanup_ui_out_tuple_begin_end (uiout, "value");
uiout->text ("\nOld value = ");
- watchpoint_value_print (bs->old_val, stb);
+ watchpoint_value_print (bs->old_val, &stb);
uiout->field_stream ("old", stb);
uiout->text ("\nNew value = ");
- watchpoint_value_print (w->val, stb);
+ watchpoint_value_print (w->val, &stb);
uiout->field_stream ("new", stb);
uiout->text ("\n");
/* More than one watchpoint may have been triggered. */
mention (b);
make_cleanup_ui_out_tuple_begin_end (uiout, "value");
uiout->text ("\nValue = ");
- watchpoint_value_print (w->val, stb);
+ watchpoint_value_print (w->val, &stb);
uiout->field_stream ("value", stb);
uiout->text ("\n");
result = PRINT_UNKNOWN;
mention (b);
make_cleanup_ui_out_tuple_begin_end (uiout, "value");
uiout->text ("\nOld value = ");
- watchpoint_value_print (bs->old_val, stb);
+ watchpoint_value_print (bs->old_val, &stb);
uiout->field_stream ("old", stb);
uiout->text ("\nNew value = ");
}
make_cleanup_ui_out_tuple_begin_end (uiout, "value");
uiout->text ("\nValue = ");
}
- watchpoint_value_print (w->val, stb);
+ watchpoint_value_print (w->val, &stb);
uiout->field_stream ("new", stb);
uiout->text ("\n");
result = PRINT_UNKNOWN;
struct breakpoint *tp;
int any = 0;
struct cleanup *cleanup;
- struct ui_file *fp;
int extra_trace_bits = 0;
if (filename == 0 || *filename == 0)
filename = tilde_expand (filename);
cleanup = make_cleanup (xfree, filename);
- fp = gdb_fopen (filename, "w");
- if (!fp)
+
+ stdio_file fp;
+
+ if (!fp.open (filename, "w"))
error (_("Unable to open file '%s' for saving (%s)"),
filename, safe_strerror (errno));
- make_cleanup_ui_file_delete (fp);
if (extra_trace_bits)
- save_trace_state_variables (fp);
+ save_trace_state_variables (&fp);
ALL_BREAKPOINTS (tp)
{
if (filter && !filter (tp))
continue;
- tp->ops->print_recreate (tp, fp);
+ tp->ops->print_recreate (tp, &fp);
/* Note, we can't rely on tp->number for anything, as we can't
assume the recreated breakpoint numbers will match. Use $bpnum
instead. */
if (tp->cond_string)
- fprintf_unfiltered (fp, " condition $bpnum %s\n", tp->cond_string);
+ fp.printf (" condition $bpnum %s\n", tp->cond_string);
if (tp->ignore_count)
- fprintf_unfiltered (fp, " ignore $bpnum %d\n", tp->ignore_count);
+ fp.printf (" ignore $bpnum %d\n", tp->ignore_count);
if (tp->type != bp_dprintf && tp->commands)
{
- fprintf_unfiltered (fp, " commands\n");
+ fp.puts (" commands\n");
- current_uiout->redirect (fp);
+ current_uiout->redirect (&fp);
TRY
{
print_command_lines (current_uiout, tp->commands->commands, 2);
END_CATCH
current_uiout->redirect (NULL);
- fprintf_unfiltered (fp, " end\n");
+ fp.puts (" end\n");
}
if (tp->enable_state == bp_disabled)
- fprintf_unfiltered (fp, "disable $bpnum\n");
+ fp.puts ("disable $bpnum\n");
/* If this is a multi-location breakpoint, check if the locations
should be individually disabled. Watchpoint locations are
for (loc = tp->loc; loc != NULL; loc = loc->next, n++)
if (!loc->enabled)
- fprintf_unfiltered (fp, "disable $bpnum.%d\n", n);
+ fp.printf ("disable $bpnum.%d\n", n);
}
}
if (extra_trace_bits && *default_collect)
- fprintf_unfiltered (fp, "set default-collect %s\n", default_collect);
+ fp.printf ("set default-collect %s\n", default_collect);
if (from_tty)
printf_filtered (_("Saved to file '%s'.\n"), filename);