This changes more places to use ui_out_emit_tuple, removing cleanups.
ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>
* target.c (flash_erase_command): Use ui_out_emit_tuple.
* stack.c (print_frame): Use ui_out_emit_tuple.
* spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple.
(info_spu_mailbox_command, info_spu_dma_command)
(info_spu_proxydma_command): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Use
ui_out_emit_tuple, gdb::byte_vector, bin2hex.
* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
ui_out_emit_tuple.
* breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple.
+2017-09-09 Tom Tromey <tom@tromey.com>
+
+ * target.c (flash_erase_command): Use ui_out_emit_tuple.
+ * stack.c (print_frame): Use ui_out_emit_tuple.
+ * spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple.
+ (info_spu_mailbox_command, info_spu_dma_command)
+ (info_spu_proxydma_command): Likewise.
+ * mi/mi-main.c (mi_cmd_trace_frame_collected): Use
+ ui_out_emit_tuple, gdb::byte_vector, bin2hex.
+ * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
+ ui_out_emit_tuple.
+ * breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple.
+
2017-09-09 Tom Tromey <tom@tromey.com>
* ui-out.h (make_cleanup_ui_out_table_begin_end): Remove.
#include <algorithm>
#include "progspace-and-thread.h"
#include "common/array-view.h"
+#include "common/gdb_optional.h"
/* Enums for exception-handling support. */
enum exception_event_kind
static enum print_stop_action
print_it_watchpoint (bpstat bs)
{
- struct cleanup *old_chain;
struct breakpoint *b;
enum print_stop_action result;
struct watchpoint *w;
b = bs->breakpoint_at;
w = (struct watchpoint *) b;
- old_chain = make_cleanup (null_cleanup, NULL);
-
annotate_watchpoint (b->number);
maybe_print_thread_hit_breakpoint (uiout);
string_file stb;
+ gdb::optional<ui_out_emit_tuple> tuple_emitter;
switch (b->type)
{
case bp_watchpoint:
uiout->field_string
("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
mention (b);
- make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
watchpoint_value_print (bs->old_val, &stb);
uiout->field_stream ("old", stb);
uiout->field_string
("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
mention (b);
- make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ tuple_emitter.emplace (uiout, "value");
uiout->text ("\nValue = ");
watchpoint_value_print (w->val, &stb);
uiout->field_stream ("value", stb);
("reason",
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
mention (b);
- make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
watchpoint_value_print (bs->old_val, &stb);
uiout->field_stream ("old", stb);
uiout->field_string
("reason",
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
- make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ tuple_emitter.emplace (uiout, "value");
uiout->text ("\nValue = ");
}
watchpoint_value_print (w->val, &stb);
result = PRINT_UNKNOWN;
}
- do_cleanups (old_chain);
return result;
}
if (pattern != NULL && !re_exec (so->so_name))
continue;
- struct cleanup *tuple_clean_up
- = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout, NULL);
mi_output_solib_attribs (uiout, so);
-
- do_cleanups (tuple_clean_up);
}
}
#include "run-time-clock.h"
#include <chrono>
#include "progspace-and-thread.h"
+#include "common/rsp-low.h"
enum
{
for (i = 0; VEC_iterate (mem_range_s, available_memory, i, r); i++)
{
- struct cleanup *cleanup_child;
- gdb_byte *data;
struct gdbarch *gdbarch = target_gdbarch ();
- cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout, NULL);
uiout->field_core_addr ("address", gdbarch, r->start);
uiout->field_int ("length", r->length);
- data = (gdb_byte *) xmalloc (r->length);
- make_cleanup (xfree, data);
+ gdb::byte_vector data (r->length);
if (memory_contents)
{
- if (target_read_memory (r->start, data, r->length) == 0)
+ if (target_read_memory (r->start, data.data (), r->length) == 0)
{
- int m;
- char *data_str, *p;
-
- data_str = (char *) xmalloc (r->length * 2 + 1);
- make_cleanup (xfree, data_str);
-
- for (m = 0, p = data_str; m < r->length; ++m, p += 2)
- sprintf (p, "%02x", data[m]);
- uiout->field_string ("contents", data_str);
+ std::string data_str = bin2hex (data.data (), r->length);
+ uiout->field_string ("contents", data_str.c_str ());
}
else
uiout->field_skip ("contents");
}
- do_cleanups (cleanup_child);
}
do_cleanups (list_cleanup);
struct frame_info *frame = get_selected_frame (NULL);
ULONGEST event_status = 0;
ULONGEST event_mask = 0;
- struct cleanup *chain;
gdb_byte buf[100];
char annex[32];
LONGEST len;
buf[len] = '\0';
event_mask = strtoulst ((char *) buf, NULL, 16);
- chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoEvent");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoEvent");
if (current_uiout->is_mi_like_p ())
{
printf_filtered (_("Event Status 0x%s\n"), phex (event_status, 4));
printf_filtered (_("Event Mask 0x%s\n"), phex (event_mask, 4));
}
-
- do_cleanups (chain);
}
static void
ULONGEST signal2 = 0;
ULONGEST signal2_type = 0;
int signal2_pending = 0;
- struct cleanup *chain;
char annex[32];
gdb_byte buf[100];
LONGEST len;
buf[len] = '\0';
signal2_type = strtoulst ((char *) buf, NULL, 16);
- chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoSignal");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoSignal");
if (current_uiout->is_mi_like_p ())
{
else
printf_filtered (_("(Type Overwrite)\n"));
}
-
- do_cleanups (chain);
}
static void
struct frame_info *frame = get_selected_frame (NULL);
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct cleanup *chain;
char annex[32];
gdb_byte buf[1024];
LONGEST len;
id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
- chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoMailbox");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoMailbox");
xsnprintf (annex, sizeof annex, "%d/mbox_info", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
info_spu_mailbox_list (buf, len / 4, byte_order,
"wbox", "SPU Inbound Mailbox");
-
- do_cleanups (chain);
}
static ULONGEST
ULONGEST dma_info_status;
ULONGEST dma_info_stall_and_notify;
ULONGEST dma_info_atomic_command_status;
- struct cleanup *chain;
char annex[32];
gdb_byte buf[1024];
LONGEST len;
dma_info_atomic_command_status
= extract_unsigned_integer (buf + 32, 8, byte_order);
- chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "SPUInfoDMA");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoDMA");
if (current_uiout->is_mi_like_p ())
{
}
info_spu_dma_cmdlist (buf + 40, 16, byte_order);
- do_cleanups (chain);
}
static void
ULONGEST dma_info_type;
ULONGEST dma_info_mask;
ULONGEST dma_info_status;
- struct cleanup *chain;
char annex[32];
gdb_byte buf[1024];
LONGEST len;
dma_info_mask = extract_unsigned_integer (buf + 8, 8, byte_order);
dma_info_status = extract_unsigned_integer (buf + 16, 8, byte_order);
- chain = make_cleanup_ui_out_tuple_begin_end (current_uiout,
- "SPUInfoProxyDMA");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoProxyDMA");
if (current_uiout->is_mi_like_p ())
{
}
info_spu_dma_cmdlist (buf + 24, 8, byte_order);
- do_cleanups (chain);
}
static void
struct ui_out *uiout = current_uiout;
char *funname = NULL;
enum language funlang = language_unknown;
- struct cleanup *old_chain, *list_chain;
+ struct cleanup *old_chain;
struct value_print_options opts;
struct symbol *func;
CORE_ADDR pc = 0;
annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
gdbarch, pc);
- list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
+ {
+ ui_out_emit_tuple tuple_emitter (uiout, "frame");
- if (print_level)
- {
- uiout->text ("#");
- uiout->field_fmt_int (2, ui_left, "level",
- frame_relative_level (frame));
- }
- get_user_print_options (&opts);
- if (opts.addressprint)
- if (!sal.symtab
- || frame_show_address (frame, sal)
- || print_what == LOC_AND_ADDRESS)
+ if (print_level)
{
- annotate_frame_address ();
- if (pc_p)
- uiout->field_core_addr ("addr", gdbarch, pc);
- else
- uiout->field_string ("addr", "<unavailable>");
- annotate_frame_address_end ();
- uiout->text (" in ");
+ uiout->text ("#");
+ uiout->field_fmt_int (2, ui_left, "level",
+ frame_relative_level (frame));
}
- annotate_frame_function_name ();
-
- string_file stb;
- fprintf_symbol_filtered (&stb, funname ? funname : "??",
- funlang, DMGL_ANSI);
- uiout->field_stream ("func", stb);
- uiout->wrap_hint (" ");
- annotate_frame_args ();
-
- uiout->text (" (");
- if (print_args)
- {
- struct gdbarch *gdbarch = get_frame_arch (frame);
- int numargs;
-
- if (gdbarch_frame_num_args_p (gdbarch))
+ get_user_print_options (&opts);
+ if (opts.addressprint)
+ if (!sal.symtab
+ || frame_show_address (frame, sal)
+ || print_what == LOC_AND_ADDRESS)
{
- numargs = gdbarch_frame_num_args (gdbarch, frame);
- gdb_assert (numargs >= 0);
+ annotate_frame_address ();
+ if (pc_p)
+ uiout->field_core_addr ("addr", gdbarch, pc);
+ else
+ uiout->field_string ("addr", "<unavailable>");
+ annotate_frame_address_end ();
+ uiout->text (" in ");
}
- else
- numargs = -1;
-
+ annotate_frame_function_name ();
+
+ string_file stb;
+ fprintf_symbol_filtered (&stb, funname ? funname : "??",
+ funlang, DMGL_ANSI);
+ uiout->field_stream ("func", stb);
+ uiout->wrap_hint (" ");
+ annotate_frame_args ();
+
+ uiout->text (" (");
+ if (print_args)
{
- ui_out_emit_list list_emitter (uiout, "args");
- TRY
- {
- print_frame_args (func, frame, numargs, gdb_stdout);
- }
- CATCH (e, RETURN_MASK_ERROR)
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int numargs;
+
+ if (gdbarch_frame_num_args_p (gdbarch))
{
+ numargs = gdbarch_frame_num_args (gdbarch, frame);
+ gdb_assert (numargs >= 0);
}
- END_CATCH
+ else
+ numargs = -1;
+
+ {
+ ui_out_emit_list list_emitter (uiout, "args");
+ TRY
+ {
+ print_frame_args (func, frame, numargs, gdb_stdout);
+ }
+ CATCH (e, RETURN_MASK_ERROR)
+ {
+ }
+ END_CATCH
- /* FIXME: ARGS must be a list. If one argument is a string it
- will have " that will not be properly escaped. */
+ /* FIXME: ARGS must be a list. If one argument is a string it
+ will have " that will not be properly escaped. */
+ }
+ QUIT;
}
- QUIT;
- }
- uiout->text (")");
- if (sal.symtab)
- {
- const char *filename_display;
+ uiout->text (")");
+ if (sal.symtab)
+ {
+ const char *filename_display;
- filename_display = symtab_to_filename_for_display (sal.symtab);
- annotate_frame_source_begin ();
- uiout->wrap_hint (" ");
- uiout->text (" at ");
- annotate_frame_source_file ();
- uiout->field_string ("file", filename_display);
- if (uiout->is_mi_like_p ())
- {
- const char *fullname = symtab_to_fullname (sal.symtab);
+ filename_display = symtab_to_filename_for_display (sal.symtab);
+ annotate_frame_source_begin ();
+ uiout->wrap_hint (" ");
+ uiout->text (" at ");
+ annotate_frame_source_file ();
+ uiout->field_string ("file", filename_display);
+ if (uiout->is_mi_like_p ())
+ {
+ const char *fullname = symtab_to_fullname (sal.symtab);
- uiout->field_string ("fullname", fullname);
- }
- annotate_frame_source_file_end ();
- uiout->text (":");
- annotate_frame_source_line ();
- uiout->field_int ("line", sal.line);
- annotate_frame_source_end ();
- }
+ uiout->field_string ("fullname", fullname);
+ }
+ annotate_frame_source_file_end ();
+ uiout->text (":");
+ annotate_frame_source_line ();
+ uiout->field_int ("line", sal.line);
+ annotate_frame_source_end ();
+ }
- if (pc_p && (funname == NULL || sal.symtab == NULL))
- {
- char *lib = solib_name_from_address (get_frame_program_space (frame),
- get_frame_pc (frame));
+ if (pc_p && (funname == NULL || sal.symtab == NULL))
+ {
+ char *lib = solib_name_from_address (get_frame_program_space (frame),
+ get_frame_pc (frame));
- if (lib)
- {
- annotate_frame_where ();
- uiout->wrap_hint (" ");
- uiout->text (" from ");
- uiout->field_string ("from", lib);
- }
- }
+ if (lib)
+ {
+ annotate_frame_where ();
+ uiout->wrap_hint (" ");
+ uiout->text (" from ");
+ uiout->field_string ("from", lib);
+ }
+ }
+ }
- /* do_cleanups will call ui_out_tuple_end() for us. */
- do_cleanups (list_chain);
uiout->text ("\n");
do_cleanups (old_chain);
}
found_flash_region = true;
target_flash_erase (m->lo, m->hi - m->lo);
- struct cleanup *cleanup_tuple
- = make_cleanup_ui_out_tuple_begin_end (current_uiout,
- "erased-regions");
+ ui_out_emit_tuple tuple_emitter (current_uiout, "erased-regions");
current_uiout->message (_("Erasing flash memory region at address "));
current_uiout->field_fmt ("address", "%s", paddress (gdbarch,
current_uiout->message (", size = ");
current_uiout->field_fmt ("size", "%s", hex_string (m->hi - m->lo));
current_uiout->message ("\n");
- do_cleanups (cleanup_tuple);
}
}