Info reg sp

Robert Norton rnorton@broadcom.com
Tue May 22 16:47:00 GMT 2007


 

> -----Original Message-----
> From: Daniel Jacobowitz [mailto:drow@false.org] 
> Sent: 22 May 2007 17:32
> 
> Not a very satisfactory immunity; it will just print nothing. 
>  I think this was reported as a bug before.

True. I think the correct fix is not target specific (hence the original
email). Either at the frame level (as you suggest) or simply by changing
the code in infcmd.c (but this is less general).

In any case this is fixed for me for now by the following code in my
print_registers_info:

if (regnum > NUM_REGS+NUM_PSEUDO_REGS) {
          /* this happens when user types e.g. 'info reg sp' 
           * because sp is a builtin user reg -- try to handle
           * it elegantly */
        struct value *user_val = value_of_user_reg (regnum, frame);
        /* we assume that user_val is a long, is this valid? */
        LONGEST user_val_long = value_as_long(user_val);
        const char *regname =
user_reg_map_regnum_to_name(get_frame_arch(frame), regnum);
        fputs_filtered (regname, gdb_stdout);
        /* 12 is magic: it's appropriate for the maximum length of a
register name */
        print_spaces_filtered (12 - strlen (regname), gdb_stdout);
        printf_filtered("0x%llx\n", user_val_long);
        return;
  }

As a secondary thought a 'print_user_reg' function would be nice.

Thanks again,

Robert



More information about the Gdb mailing list