This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]