Use ui_out_emit_tuple in more places
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.
This commit is contained in:
parent
dc9fe180a4
commit
76f9c9cfd4
@ -1,3 +1,16 @@
|
||||
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.
|
||||
|
@ -82,6 +82,7 @@
|
||||
#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
|
||||
@ -10536,7 +10537,6 @@ works_in_software_mode_watchpoint (const struct breakpoint *b)
|
||||
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;
|
||||
@ -10547,13 +10547,12 @@ print_it_watchpoint (bpstat bs)
|
||||
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:
|
||||
@ -10562,7 +10561,7 @@ print_it_watchpoint (bpstat bs)
|
||||
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);
|
||||
@ -10579,7 +10578,7 @@ print_it_watchpoint (bpstat bs)
|
||||
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);
|
||||
@ -10595,7 +10594,7 @@ print_it_watchpoint (bpstat bs)
|
||||
("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);
|
||||
@ -10608,7 +10607,7 @@ print_it_watchpoint (bpstat bs)
|
||||
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);
|
||||
@ -10620,7 +10619,6 @@ print_it_watchpoint (bpstat bs)
|
||||
result = PRINT_UNKNOWN;
|
||||
}
|
||||
|
||||
do_cleanups (old_chain);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -153,10 +153,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "run-time-clock.h"
|
||||
#include <chrono>
|
||||
#include "progspace-and-thread.h"
|
||||
#include "common/rsp-low.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -2872,36 +2873,25 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc)
|
||||
|
||||
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);
|
||||
|
@ -2064,7 +2064,6 @@ info_spu_event_command (char *args, int from_tty)
|
||||
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;
|
||||
@ -2091,7 +2090,7 @@ info_spu_event_command (char *args, int from_tty)
|
||||
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 ())
|
||||
{
|
||||
@ -2105,8 +2104,6 @@ info_spu_event_command (char *args, int from_tty)
|
||||
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
|
||||
@ -2121,7 +2118,6 @@ info_spu_signal_command (char *args, int from_tty)
|
||||
ULONGEST signal2 = 0;
|
||||
ULONGEST signal2_type = 0;
|
||||
int signal2_pending = 0;
|
||||
struct cleanup *chain;
|
||||
char annex[32];
|
||||
gdb_byte buf[100];
|
||||
LONGEST len;
|
||||
@ -2168,7 +2164,7 @@ info_spu_signal_command (char *args, int from_tty)
|
||||
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 ())
|
||||
{
|
||||
@ -2201,8 +2197,6 @@ info_spu_signal_command (char *args, int from_tty)
|
||||
else
|
||||
printf_filtered (_("(Type Overwrite)\n"));
|
||||
}
|
||||
|
||||
do_cleanups (chain);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2239,7 +2233,6 @@ info_spu_mailbox_command (char *args, int from_tty)
|
||||
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;
|
||||
@ -2250,7 +2243,7 @@ info_spu_mailbox_command (char *args, int from_tty)
|
||||
|
||||
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,
|
||||
@ -2278,8 +2271,6 @@ info_spu_mailbox_command (char *args, int from_tty)
|
||||
|
||||
info_spu_mailbox_list (buf, len / 4, byte_order,
|
||||
"wbox", "SPU Inbound Mailbox");
|
||||
|
||||
do_cleanups (chain);
|
||||
}
|
||||
|
||||
static ULONGEST
|
||||
@ -2475,7 +2466,6 @@ info_spu_dma_command (char *args, int from_tty)
|
||||
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;
|
||||
@ -2503,7 +2493,7 @@ info_spu_dma_command (char *args, int from_tty)
|
||||
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 ())
|
||||
{
|
||||
@ -2542,7 +2532,6 @@ info_spu_dma_command (char *args, int from_tty)
|
||||
}
|
||||
|
||||
info_spu_dma_cmdlist (buf + 40, 16, byte_order);
|
||||
do_cleanups (chain);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2554,7 +2543,6 @@ info_spu_proxydma_command (char *args, int from_tty)
|
||||
ULONGEST dma_info_type;
|
||||
ULONGEST dma_info_mask;
|
||||
ULONGEST dma_info_status;
|
||||
struct cleanup *chain;
|
||||
char annex[32];
|
||||
gdb_byte buf[1024];
|
||||
LONGEST len;
|
||||
@ -2575,8 +2563,7 @@ info_spu_proxydma_command (char *args, int from_tty)
|
||||
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 ())
|
||||
{
|
||||
@ -2607,7 +2594,6 @@ info_spu_proxydma_command (char *args, int from_tty)
|
||||
}
|
||||
|
||||
info_spu_dma_cmdlist (buf + 24, 8, byte_order);
|
||||
do_cleanups (chain);
|
||||
}
|
||||
|
||||
static void
|
||||
|
182
gdb/stack.c
182
gdb/stack.c
@ -1139,7 +1139,7 @@ print_frame (struct frame_info *frame, int print_level,
|
||||
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;
|
||||
@ -1154,107 +1154,107 @@ print_frame (struct frame_info *frame, int print_level,
|
||||
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);
|
||||
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)
|
||||
{
|
||||
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 ");
|
||||
}
|
||||
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))
|
||||
{
|
||||
numargs = gdbarch_frame_num_args (gdbarch, frame);
|
||||
gdb_assert (numargs >= 0);
|
||||
}
|
||||
else
|
||||
uiout->field_string ("addr", "<unavailable>");
|
||||
annotate_frame_address_end ();
|
||||
uiout->text (" in ");
|
||||
}
|
||||
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))
|
||||
{
|
||||
numargs = gdbarch_frame_num_args (gdbarch, frame);
|
||||
gdb_assert (numargs >= 0);
|
||||
}
|
||||
else
|
||||
numargs = -1;
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -3926,9 +3926,7 @@ flash_erase_command (char *cmd, int from_tty)
|
||||
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,
|
||||
@ -3936,7 +3934,6 @@ flash_erase_command (char *cmd, int from_tty)
|
||||
current_uiout->message (", size = ");
|
||||
current_uiout->field_fmt ("size", "%s", hex_string (m->hi - m->lo));
|
||||
current_uiout->message ("\n");
|
||||
do_cleanups (cleanup_tuple);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user