From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26787 invoked by alias); 18 Dec 2014 01:02:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26773 invoked by uid 89); 18 Dec 2014 01:02:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Dec 2014 01:01:58 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1Y1PTX-0001AU-9T from Yao_Qi@mentor.com ; Wed, 17 Dec 2014 17:01:55 -0800 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.181.6; Wed, 17 Dec 2014 17:01:54 -0800 From: Yao Qi To: Pedro Alves CC: Subject: Re: [PATCH 2/3] Refactor gdbarch method print_float_info References: <1418798765-23198-1-git-send-email-yao@codesourcery.com> <1418798765-23198-3-git-send-email-yao@codesourcery.com> <54918406.9050005@redhat.com> Date: Thu, 18 Dec 2014 01:02:00 -0000 In-Reply-To: <54918406.9050005@redhat.com> (Pedro Alves's message of "Wed, 17 Dec 2014 13:24:22 +0000") Message-ID: <87fvcdsrd6.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00508.txt.bz2 Pedro Alves writes: > Thanks! I took another look and I have a few > further comments. Sorry I didn't send them the first > time around. Thanks for the review. Patch below is updated to address all your comments. >> } elseif [istarget "mips*-*-*"] then { >> - gdb_test "info float" "f0:.*flt:.*dbl:.*" "info float" >> + gdb_test_multiple "info float" "info float" { >> + -re "fpu type: none*" { >> + pass "info float (without FPU)" >> + } >> + -re "fpu type:.*cause.*mask.*flags.*round.*flush.*" { >> + pass "info float (with FPU)" >> + } > > Missing "$gdb_prompt $" at the end of those regexs. > > Also, with v2 we still print the register values. > So ISTM that it'd be good if the "f0:.*flt:.*dbl:.*" regex is > still part of the expected output? And if in the none case > we _shouldn't see those, then the test could make sure > that's how things work? I am OK to restrict the pattern. I'll update patch 3/3. --=20 Yao (=E9=BD=90=E5=B0=A7) Subject: [PATCH] Refactor gdbarch method print_float_info 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 simplify the caller of print_float_info, infcmd.c:print_float_info. gdb: 2014-12-18 Yao Qi * 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): Removed. Move code to default_print_float_info. (float_info): Adjust to call gdbarch_print_float_info. * inferior.h (default_print_float_info): Declare it. 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 =3D -1; gdbarch->call_dummy_location =3D AT_ENTRY_POINT; gdbarch->print_registers_info =3D default_print_registers_info; + gdbarch->print_float_info =3D default_print_float_info; gdbarch->register_sim_regno =3D legacy_register_sim_regno; gdbarch->cannot_fetch_register =3D cannot_register_not; gdbarch->cannot_store_register =3D cannot_register_not; @@ -531,7 +532,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of call_dummy_location, invalid_p =3D=3D 0 */ /* Skip verify of push_dummy_code, has predicate. */ /* Skip verify of print_registers_info, invalid_p =3D=3D 0 */ - /* Skip verify of print_float_info, has predicate. */ + /* Skip verify of print_float_info, invalid_p =3D=3D 0 */ /* Skip verify of print_vector_info, has predicate. */ /* Skip verify of register_sim_regno, invalid_p =3D=3D 0 */ /* Skip verify of cannot_fetch_register, invalid_p =3D=3D 0 */ @@ -1089,9 +1090,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file= *file) "gdbarch_dump: pointer_to_address =3D <%s>\n", host_address_to_string (gdbarch->pointer_to_address)= ); fprintf_unfiltered (file, - "gdbarch_dump: gdbarch_print_float_info_p() =3D %d\n= ", - gdbarch_print_float_info_p (gdbarch)); - fprintf_unfiltered (file, "gdbarch_dump: print_float_info =3D <%s>\n", host_address_to_string (gdbarch->print_float_info)); fprintf_unfiltered (file, @@ -2235,13 +2233,6 @@ set_gdbarch_print_registers_info (struct gdbarch *gd= barch, gdbarch->print_registers_info =3D print_registers_info; } =20 -int -gdbarch_print_float_info_p (struct gdbarch *gdbarch) -{ - gdb_assert (gdbarch !=3D NULL); - return gdbarch->print_float_info !=3D NULL; -} - void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, s= truct 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) (stru= ct 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, gdb= arch_print_registers_info_ftype *print_registers_info); =20 -extern int gdbarch_print_float_info_p (struct gdbarch *gdbarch); - typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, st= ruct ui_file *file, struct frame_info *frame, const char *args); extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_f= ile *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, re= al_pc, bp_addr, regcache =20 m:void:print_registers_info:struct ui_file *file, struct frame_info *frame= , int regnum, int all:file, frame, regnum, all::default_print_registers_inf= o::0 -M:void:print_float_info:struct ui_file *file, struct frame_info *frame, co= nst char *args:file, frame, args +m:void:print_float_info:struct ui_file *file, struct frame_info *frame, co= nst char *args:file, frame, args::default_print_float_info::0 M:void:print_vector_info:struct ui_file *file, struct frame_info *frame, c= onst 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..58e4d1f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2864,43 +2864,41 @@ interrupt_command (char *args, int from_tty) } } =20 -static void -print_float_info (struct ui_file *file, - struct frame_info *frame, const char *args) +/* See inferior.h. */ + +void +default_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, + struct frame_info *frame, const char *args) { - struct gdbarch *gdbarch =3D get_frame_arch (frame); + int regnum; + int printed_something =3D 0; =20 - if (gdbarch_print_float_info_p (gdbarch)) - gdbarch_print_float_info (gdbarch, file, frame, args); - else + for (regnum =3D 0; + regnum < gdbarch_num_regs (gdbarch) + + gdbarch_num_pseudo_regs (gdbarch); + regnum++) { - int regnum; - int printed_something =3D 0; - - for (regnum =3D 0; - regnum < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch); - regnum++) + if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup)) { - if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup)) - { - printed_something =3D 1; - gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); - } + printed_something =3D 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"); } + if (!printed_something) + fprintf_filtered (file, "No floating-point info " + "available for this processor.\n"); } =20 static void float_info (char *args, int from_tty) { + struct frame_info *frame; + if (!target_has_registers) error (_("The program has no registers now.")); =20 - print_float_info (gdb_stdout, get_selected_frame (NULL), args); + frame =3D get_selected_frame (NULL); + gdbarch_print_float_info (get_frame_arch (frame), gdb_stdout, frame, arg= s); } =0C static void diff --git a/gdb/inferior.h b/gdb/inferior.h index eebc034..b607fbf 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -106,6 +106,14 @@ extern void default_print_registers_info (struct gdbar= ch *gdbarch, struct frame_info *frame, int regnum, int all); =20 +/* Default implementation of gdbarch_print_float_info. Print + the values of all floating point registers. */ + +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 *, in= t); =20 extern void term_info (char *, int);