This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: info registers output
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: palves at redhat dot com (Pedro Alves)
- Cc: palves at redhat dot com (Pedro Alves), sergiodj at redhat dot com (Sergio Durigan Junior), gdb-patches at sourceware dot org (GDB Patches), tromey at redhat dot com (Tom Tromey), jan dot kratochvil at redhat dot com (Jan Kratochvil)
- Date: Tue, 28 Aug 2012 02:41:27 +0200 (CEST)
- Subject: Re: info registers output
Pedro Alves wrote:
> On 08/01/2012 09:49 PM, Ulrich Weigand wrote:
> > Would make sense to me. (In fact, there probably ought to be a single
> > routine to print a register, called by both code paths, to avoid having
> > the code diverge again in the future ...)
>
> Here's a patch that does that. If some arch wants to print user regs
> differently, we'll either have to add a new gdbarch, or make
> gdbarch_print_registers_info handle user regs.
>
> We now get, for amd64:
>
> (gdb) info registers pc rip sp rsp fp rbp
> pc 0x45762b 0x45762b <main+15>
> rip 0x45762b 0x45762b <main+15>
> sp 0x7fffffffdbe0 0x7fffffffdbe0
> rsp 0x7fffffffdbe0 0x7fffffffdbe0
> fp 0x7fffffffdc10 0x7fffffffdc10
> rbp 0x7fffffffdc10 0x7fffffffdc10
>
> Before we'd get:
>
> (gdb) info registers pc rip sp rsp fp rbp
> pc: 0x45762b
> rip 0x45762b 0x45762b <main+15>
> sp: 0x7fffffffdbe0
> rsp 0x7fffffffdbe0 0x7fffffffdbe0
> fp: 0x7fffffffdc10
> rbp 0x7fffffffdc10 0x7fffffffdc10
>
> How does it look?
Looks good to me. The only minor nit would be:
> +/* Print out the register NAME, of GDBARCH, with value VAL, to FILE,
> + in the default fashion. */
> +
> +static void
> +default_print_one_register_info (struct gdbarch *gdbarch,
> + struct ui_file *file,
> + const char *name,
> + struct value *val)
Does this really need a GDBARCH argument? It's only used here:
> + for (j = 0; j < TYPE_LENGTH (regtype); j++)
> + {
> + int idx;
> +
> + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
> + idx = j;
> + else
> + idx = TYPE_LENGTH (regtype) - 1 - j;
> + fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]);
> + }
where we really want the type's byte order anyway ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com