From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/3] Refactor gdbarch method print_float_info
Date: Wed, 17 Dec 2014 06:46:00 -0000 [thread overview]
Message-ID: <1418798765-23198-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1418798765-23198-1-git-send-email-yao@codesourcery.com>
This patch is to change print_float_info gdbarch method for the
following two reasons,
1. we want to add a default implementation of print_float_info to
dump the float pointer registers. It can be reused by backend to
print something more than float point registers.
2. we want to simply the caller of print_float_info,
infcmd.c:print_float_info.
gdb:
2014-12-17 Yao Qi <yao@codesourcery.com>
* gdbarch.sh (print_float_info): Change its type from 'M' to 'm'.
* gdbarch.c: Re-generated.
* gdbarch.h: Likewise.
* infcmd.c (default_print_float_info): New function.
(print_float_info): Move code to default_print_float_info and
call it.
* inferior.h (default_print_float_info): Declare it.
---
gdb/gdbarch.c | 13 ++-----------
gdb/gdbarch.h | 2 --
gdb/gdbarch.sh | 2 +-
gdb/infcmd.c | 45 ++++++++++++++++++++++++---------------------
gdb/inferior.h | 5 +++++
5 files changed, 32 insertions(+), 35 deletions(-)
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 657708e..93110af 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -379,6 +379,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->deprecated_fp_regnum = -1;
gdbarch->call_dummy_location = AT_ENTRY_POINT;
gdbarch->print_registers_info = default_print_registers_info;
+ gdbarch->print_float_info = default_print_float_info;
gdbarch->register_sim_regno = legacy_register_sim_regno;
gdbarch->cannot_fetch_register = cannot_register_not;
gdbarch->cannot_store_register = cannot_register_not;
@@ -531,7 +532,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of call_dummy_location, invalid_p == 0 */
/* Skip verify of push_dummy_code, has predicate. */
/* Skip verify of print_registers_info, invalid_p == 0 */
- /* Skip verify of print_float_info, has predicate. */
+ /* Skip verify of print_float_info, invalid_p == 0 */
/* Skip verify of print_vector_info, has predicate. */
/* Skip verify of register_sim_regno, invalid_p == 0 */
/* Skip verify of cannot_fetch_register, invalid_p == 0 */
@@ -1089,9 +1090,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: pointer_to_address = <%s>\n",
host_address_to_string (gdbarch->pointer_to_address));
fprintf_unfiltered (file,
- "gdbarch_dump: gdbarch_print_float_info_p() = %d\n",
- gdbarch_print_float_info_p (gdbarch));
- fprintf_unfiltered (file,
"gdbarch_dump: print_float_info = <%s>\n",
host_address_to_string (gdbarch->print_float_info));
fprintf_unfiltered (file,
@@ -2235,13 +2233,6 @@ set_gdbarch_print_registers_info (struct gdbarch *gdbarch,
gdbarch->print_registers_info = print_registers_info;
}
-int
-gdbarch_print_float_info_p (struct gdbarch *gdbarch)
-{
- gdb_assert (gdbarch != NULL);
- return gdbarch->print_float_info != NULL;
-}
-
void
gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index a40863d..c22fc7d 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -377,8 +377,6 @@ typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, stru
extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
extern void set_gdbarch_print_registers_info (struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info);
-extern int gdbarch_print_float_info_p (struct gdbarch *gdbarch);
-
typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void set_gdbarch_print_float_info (struct gdbarch *gdbarch, gdbarch_print_float_info_ftype *print_float_info);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index a643d00..685f08f 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -479,7 +479,7 @@ v:int:call_dummy_location::::AT_ENTRY_POINT::0
M:CORE_ADDR:push_dummy_code:CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache:sp, funaddr, args, nargs, value_type, real_pc, bp_addr, regcache
m:void:print_registers_info:struct ui_file *file, struct frame_info *frame, int regnum, int all:file, frame, regnum, all::default_print_registers_info::0
-M:void:print_float_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args
+m:void:print_float_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args::default_print_float_info::0
M:void:print_vector_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args
# MAP a GDB RAW register number onto a simulator register number. See
# also include/...-sim.h.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index de0d24d..e51cb7b 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2864,34 +2864,37 @@ interrupt_command (char *args, int from_tty)
}
}
+void
+default_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
+ struct frame_info *frame, const char *args)
+{
+ int regnum;
+ int printed_something = 0;
+
+ for (regnum = 0;
+ regnum < gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
+ regnum++)
+ {
+ if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
+ {
+ printed_something = 1;
+ gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
+ }
+ }
+ if (!printed_something)
+ fprintf_filtered (file, "No floating-point info "
+ "available for this processor.\n");
+}
+
static void
print_float_info (struct ui_file *file,
struct frame_info *frame, const char *args)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- if (gdbarch_print_float_info_p (gdbarch))
- gdbarch_print_float_info (gdbarch, file, frame, args);
- else
- {
- int regnum;
- int printed_something = 0;
+ gdbarch_print_float_info (gdbarch, file, frame, args);
- for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
- {
- if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
- {
- printed_something = 1;
- gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
- }
- }
- if (!printed_something)
- fprintf_filtered (file, "No floating-point info "
- "available for this processor.\n");
- }
}
static void
diff --git a/gdb/inferior.h b/gdb/inferior.h
index eebc034..e10197a 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -106,6 +106,11 @@ extern void default_print_registers_info (struct gdbarch *gdbarch,
struct frame_info *frame,
int regnum, int all);
+extern void default_print_float_info (struct gdbarch *gdbarch,
+ struct ui_file *file,
+ struct frame_info *frame,
+ const char *args);
+
extern void child_terminal_info (struct target_ops *self, const char *, int);
extern void term_info (char *, int);
--
1.9.3
next prev parent reply other threads:[~2014-12-17 6:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 6:46 [PATCH 0/3, V2] MIPS: Provide FPU info and decode FCSR in `info float' Yao Qi
2014-12-17 6:46 ` Yao Qi [this message]
2014-12-17 13:24 ` [PATCH 2/3] Refactor gdbarch method print_float_info Pedro Alves
2014-12-18 1:02 ` Yao Qi
2014-12-18 11:14 ` Pedro Alves
2014-12-17 6:46 ` [PATCH 3/3] MIPS: Provide FPU info and decode FCSR in `info float' Yao Qi
2014-12-17 10:53 ` Pedro Alves
2014-12-17 12:40 ` Yao Qi
2014-12-18 1:07 ` Yao Qi
2014-12-18 11:16 ` Pedro Alves
2014-12-21 0:14 ` Maciej W. Rozycki
2014-12-17 6:46 ` [PATCH 1/3] Remove h8300_print_float_info Yao Qi
2014-12-18 12:52 ` [PATCH 0/3, V2] MIPS: Provide FPU info and decode FCSR in `info float' 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=1418798765-23198-3-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).