* mi/mi-main.c (get_register): Remove declaration.
	(output_register): Declare.
	(mi_cmd_data_list_register_values): Remove local variable
	'tuple_cleanup'.  Move some code into output_register.
	(get_register): Renamed to ...
	(output_register): ... this.  Output the register's
	"number" ui_out tuple here.
This commit is contained in:
Yao Qi
2013-06-08 00:21:42 +00:00
parent 5576f6ff94
commit 1edebdbff5
2 changed files with 24 additions and 14 deletions

View File

@ -1,3 +1,14 @@
2013-06-08 Pedro Alves <pedro@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* mi/mi-main.c (get_register): Remove declaration.
(output_register): Declare.
(mi_cmd_data_list_register_values): Remove local variable
'tuple_cleanup'. Move some code into output_register.
(get_register): Renamed to ...
(output_register): ... this. Output the register's
"number" ui_out tuple here.
2013-06-07 Pedro Alves <palves@redhat.com> 2013-06-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c: Fix formating in copyright header. * darwin-nat.c: Fix formating in copyright header.

View File

@ -103,7 +103,7 @@ static void mi_execute_async_cli_command (char *cli_command,
char **argv, int argc); char **argv, int argc);
static int register_changed_p (int regnum, struct regcache *, static int register_changed_p (int regnum, struct regcache *,
struct regcache *); struct regcache *);
static void get_register (struct frame_info *, int regnum, int format); static void output_register (struct frame_info *, int regnum, int format);
/* Command implementations. FIXME: Is this libgdb? No. This is the MI /* Command implementations. FIXME: Is this libgdb? No. This is the MI
layer that calls libgdb. Any operation used in the below should be layer that calls libgdb. Any operation used in the below should be
@ -1072,7 +1072,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
struct gdbarch *gdbarch; struct gdbarch *gdbarch;
int regnum, numregs, format; int regnum, numregs, format;
int i; int i;
struct cleanup *list_cleanup, *tuple_cleanup; struct cleanup *list_cleanup;
/* Note that the test for a valid register must include checking the /* Note that the test for a valid register must include checking the
gdbarch_register_name because gdbarch_num_regs may be allocated gdbarch_register_name because gdbarch_num_regs may be allocated
@ -1103,10 +1103,8 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
if (gdbarch_register_name (gdbarch, regnum) == NULL if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0') || *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue; continue;
tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum); output_register (frame, regnum, format);
get_register (frame, regnum, format);
do_cleanups (tuple_cleanup);
} }
} }
@ -1119,26 +1117,25 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
&& regnum < numregs && regnum < numregs
&& gdbarch_register_name (gdbarch, regnum) != NULL && gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000') && *gdbarch_register_name (gdbarch, regnum) != '\000')
{ output_register (frame, regnum, format);
tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
get_register (frame, regnum, format);
do_cleanups (tuple_cleanup);
}
else else
error (_("bad register number")); error (_("bad register number"));
} }
do_cleanups (list_cleanup); do_cleanups (list_cleanup);
} }
/* Output one register's contents in the desired format. */ /* Output register REGNUM's contents in the desired FORMAT. */
static void static void
get_register (struct frame_info *frame, int regnum, int format) output_register (struct frame_info *frame, int regnum, int format)
{ {
struct gdbarch *gdbarch = get_frame_arch (frame); struct gdbarch *gdbarch = get_frame_arch (frame);
struct ui_out *uiout = current_uiout; struct ui_out *uiout = current_uiout;
struct value *val; struct value *val;
struct cleanup *tuple_cleanup;
tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
if (format == 'N') if (format == 'N')
format = 0; format = 0;
@ -1184,6 +1181,8 @@ get_register (struct frame_info *frame, int regnum, int format)
ui_out_field_stream (uiout, "value", stb); ui_out_field_stream (uiout, "value", stb);
do_cleanups (old_chain); do_cleanups (old_chain);
} }
do_cleanups (tuple_cleanup);
} }
/* Write given values into registers. The registers and values are /* Write given values into registers. The registers and values are