* Info reg sp
@ 2007-05-22 15:24 Robert Norton
2007-05-22 15:34 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Robert Norton @ 2007-05-22 15:24 UTC (permalink / raw)
To: gdb
Hi,
I'm porting GDB 6.6 to our target and one of my users reported a problem
with the command 'info reg sp'. Having done some digging it seems the
following code in infcmd.c is causing me problems:
int regnum = frame_map_name_to_regnum (deprecated_selected_frame,
start, end - start);
if (regnum >= 0)
{
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
deprecated_selected_frame, regnum, fpregs);
continue;
}
The problem is that frame_map_name_to_regnum returns a value greater
than NUM_REGS+NUM_PSEUDO_REGS because there is a builtin user reg by
that name which is returned by user_reg_map_name_to_regnum. The question
is: should my print_registers_info be able to handle this (if so how? I
suppose by calling value_of_user_reg) or is this code broken?
Many thanks,
Robert Norton
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Info reg sp
2007-05-22 15:24 Info reg sp Robert Norton
@ 2007-05-22 15:34 ` Daniel Jacobowitz
2007-05-22 15:58 ` Robert Norton
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-05-22 15:34 UTC (permalink / raw)
To: Robert Norton; +Cc: gdb
On Tue, May 22, 2007 at 08:24:34AM -0700, Robert Norton wrote:
> The problem is that frame_map_name_to_regnum returns a value greater
> than NUM_REGS+NUM_PSEUDO_REGS because there is a builtin user reg by
> that name which is returned by user_reg_map_name_to_regnum. The question
> is: should my print_registers_info be able to handle this (if so how? I
> suppose by calling value_of_user_reg) or is this code broken?
Hmm, good question. I could make an argument either way. Every port
has this same problem, but then again only the default
print_registers_info and those with their own print_registers_info
would have to be fixed.
Still, it's nasty that value_of_register can handle user registers but
nothing else can. Maybe frame.c should also?
I've been starting to use user registers more heavily lately, since
pseudo registers have strange problems - they only come from a
regcache, not from a frame.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Info reg sp
2007-05-22 15:34 ` Daniel Jacobowitz
@ 2007-05-22 15:58 ` Robert Norton
2007-05-22 16:32 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Robert Norton @ 2007-05-22 15:58 UTC (permalink / raw)
To: gdb
Thanks for your response.
> -----Original Message-----
> From: Daniel Jacobowitz [mailto:drow@false.org]
> Sent: 22 May 2007 16:34
>
> Hmm, good question. I could make an argument either way.
> Every port has this same problem, but then again only the
> default print_registers_info and those with their own
> print_registers_info would have to be fixed.
The default print_registers seems to be immune to this by virtue of the
(slightly weird) for loop which compares every number less than
NUM_REGS+NUM_PSEUDO_REGS to regnum when printing a value! Design or
happy coincidence -- who can tell?
> Still, it's nasty that value_of_register can handle user
> registers but nothing else can. Maybe frame.c should also?
>
> I've been starting to use user registers more heavily lately,
> since pseudo registers have strange problems - they only come
> from a regcache, not from a frame.
I'm not clear on the meaning of PSEUDO_REGS vs. user regs but it seems
that if something like this can happen it should at least be documented.
There isn't currently any documentation on the meaning of
print_registers_info in gdbarch.sh, where I would expect to find it, but
the following found in infcmd.c doesn't mention this possibility:
/* Print out the machine register regnum. If regnum is -1, print all
registers (print_all == 1) or all non-float and non-vector
registers (print_all == 0).
For most machines, having all_registers_info() print the
register(s) one per line is good enough. If a different format is
required, (eg, for MIPS or Pyramid 90x, which both have lots of
regs), or there is an existing convention for showing all the
registers, define the architecture method PRINT_REGISTERS_INFO to
provide that format. */
Cheers,
Robert
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Info reg sp
2007-05-22 15:58 ` Robert Norton
@ 2007-05-22 16:32 ` Daniel Jacobowitz
2007-05-22 16:47 ` Robert Norton
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-05-22 16:32 UTC (permalink / raw)
To: Robert Norton; +Cc: gdb
On Tue, May 22, 2007 at 08:58:28AM -0700, Robert Norton wrote:
> The default print_registers seems to be immune to this by virtue of the
> (slightly weird) for loop which compares every number less than
> NUM_REGS+NUM_PSEUDO_REGS to regnum when printing a value! Design or
> happy coincidence -- who can tell?
Not a very satisfactory immunity; it will just print nothing. I think
this was reported as a bug before.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Info reg sp
2007-05-22 16:32 ` Daniel Jacobowitz
@ 2007-05-22 16:47 ` Robert Norton
0 siblings, 0 replies; 5+ messages in thread
From: Robert Norton @ 2007-05-22 16:47 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
> -----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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-05-22 16:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-22 15:24 Info reg sp Robert Norton
2007-05-22 15:34 ` Daniel Jacobowitz
2007-05-22 15:58 ` Robert Norton
2007-05-22 16:32 ` Daniel Jacobowitz
2007-05-22 16:47 ` Robert Norton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox