From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Move some code into get_register.
Date: Fri, 07 Jun 2013 12:43:00 -0000 [thread overview]
Message-ID: <1370608997-20957-1-git-send-email-yao@codesourcery.com> (raw)
Hi,
This is a refactor patch. This patch moves some common code in
caller of get_register into get_register, and rename it to
output_register. With this patch, the caller of output_register can
be simplified to some extent.
gdb:
2013-06-07 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): ... it.
---
gdb/mi/mi-main.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index f69cd8d..454198b 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -103,7 +103,7 @@ static void mi_execute_async_cli_command (char *cli_command,
char **argv, int argc);
static int register_changed_p (int regnum, 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
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;
int regnum, numregs, format;
int i;
- struct cleanup *list_cleanup, *tuple_cleanup;
+ struct cleanup *list_cleanup;
/* Note that the test for a valid register must include checking the
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
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue;
- 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);
+
+ output_register (frame, regnum, format);
}
}
@@ -1119,26 +1117,25 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
&& regnum < numregs
&& gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000')
- {
- 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);
- }
+ output_register (frame, regnum, format);
else
error (_("bad register number"));
}
do_cleanups (list_cleanup);
}
-/* Output one register's contents in the desired format. */
+/* Output one register REGNUM's contents in the desired FORMAT. */
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 ui_out *uiout = current_uiout;
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')
format = 0;
@@ -1184,6 +1181,8 @@ get_register (struct frame_info *frame, int regnum, int format)
ui_out_field_stream (uiout, "value", stb);
do_cleanups (old_chain);
}
+
+ do_cleanups (tuple_cleanup);
}
/* Write given values into registers. The registers and values are
--
1.7.7.6
next reply other threads:[~2013-06-07 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 12:43 Yao Qi [this message]
2013-06-07 19:58 ` Pedro Alves
2013-06-08 1:53 ` Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370608997-20957-1-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox