Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Problem setting registers if stack point or frame pointer is 0
@ 2008-04-04  2:21 Antony KING
  2008-04-04  2:30 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Antony KING @ 2008-04-04  2:21 UTC (permalink / raw)
  To: gdb

Hi,

I have a problem trying to set a CPU register (using the GDB convenience 
variable mechanism) if the stack pointer (SP) or frame pointer (FP) CPU 
registers are 0. For example on an SH-4 device, where the FP register is 
R14 and the SP register is R15, I see the following error from GDB (6.7.1):

(gdb) <commands to connect to SH-4 target>
(gdb) set $r15 = 0
(gdb) set $pc = 0xa0000000
Value being assigned to is no longer active.
(gdb)

The error is being generated by value_assign() (valops.c) in the 
following code sequence:

      case lval_register:
        {
          struct frame_info *frame;
          int value_reg;

          /* Figure out which frame this is in currently.  */
          frame = frame_find_by_id (VALUE_FRAME_ID (toval));
          value_reg = VALUE_REGNUM (toval);

          if (!frame)
            error (_("Value being assigned to is no longer active."));

I can make the problem "go away" if I insert the following after the 
call to frame_find_by_id() in the above code:

          if (!frame)
            frame = get_current_frame();

This solution was "suggestion" by a source comment in the implementation 
of frame_find_by_id(). Is this the right solution do you think ?

(I am not familiar with the frame management of GDB so I thought I 
would ask those more in the know about this aspect of GDB internals :-).

Cheers,

Antony.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem setting registers if stack point or frame pointer is 0
  2008-04-04  2:21 Problem setting registers if stack point or frame pointer is 0 Antony KING
@ 2008-04-04  2:30 ` Daniel Jacobowitz
  2008-04-04 11:43   ` Antony KING
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-04-04  2:30 UTC (permalink / raw)
  To: Antony KING; +Cc: gdb

On Thu, Apr 03, 2008 at 10:35:41PM +0100, Antony KING wrote:
> Hi,
>
> I have a problem trying to set a CPU register (using the GDB convenience  
> variable mechanism) if the stack pointer (SP) or frame pointer (FP) CPU  
> registers are 0. For example on an SH-4 device, where the FP register is  
> R14 and the SP register is R15, I see the following error from GDB 
> (6.7.1):

This is an unfortunate design problem in GDB.  You've found the right
comment, but in fact the comment lies.

  /* ZERO denotes the null frame, let the caller decide what to do
     about it.  Should it instead return get_current_frame()?  */

It doesn't denote just the null frame (nothing running).  It also
denotes the last frame (can not unwind past here, outermost).  We've
really got to get rid of that ambiguity.

I use a terrible hack in find_frame_by_id in our tools, since I
still haven't found time to return to this problem :-(

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem setting registers if stack point or frame pointer is  0
  2008-04-04  2:30 ` Daniel Jacobowitz
@ 2008-04-04 11:43   ` Antony KING
  2008-04-04 17:37     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Antony KING @ 2008-04-04 11:43 UTC (permalink / raw)
  To: gdb

Thanks for the information. Is the hack you mention the suggestion (you 
gave to my colleague) in the following response?

    http://www.cygwin.com/ml/gdb-patches/2006-05/msg00018.html

We did have this patch applied at some point in earlier versions of our 
GDB but we seem to have lost it along the way :-(.

Anyway it looks to be a better solution than the one I suggested (as 
every user of frame_find_by_id() will benefit), so I will reapply it to 
our version of GDB (unless you have a better version).

Cheers,

Antony.

Daniel Jacobowitz wrote:
> On Thu, Apr 03, 2008 at 10:35:41PM +0100, Antony KING wrote:
>> Hi,
>>
>> I have a problem trying to set a CPU register (using the GDB convenience  
>> variable mechanism) if the stack pointer (SP) or frame pointer (FP) CPU  
>> registers are 0. For example on an SH-4 device, where the FP register is  
>> R14 and the SP register is R15, I see the following error from GDB 
>> (6.7.1):
> 
> This is an unfortunate design problem in GDB.  You've found the right
> comment, but in fact the comment lies.
> 
>   /* ZERO denotes the null frame, let the caller decide what to do
>      about it.  Should it instead return get_current_frame()?  */
> 
> It doesn't denote just the null frame (nothing running).  It also
> denotes the last frame (can not unwind past here, outermost).  We've
> really got to get rid of that ambiguity.
> 
> I use a terrible hack in find_frame_by_id in our tools, since I
> still haven't found time to return to this problem :-(


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem setting registers if stack point or frame pointer is  0
  2008-04-04 11:43   ` Antony KING
@ 2008-04-04 17:37     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-04-04 17:37 UTC (permalink / raw)
  To: Antony KING; +Cc: gdb

On Fri, Apr 04, 2008 at 12:25:14PM +0100, Antony KING wrote:
> Thanks for the information. Is the hack you mention the suggestion (you  
> gave to my colleague) in the following response?
>
>    http://www.cygwin.com/ml/gdb-patches/2006-05/msg00018.html
>
> We did have this patch applied at some point in earlier versions of our  
> GDB but we seem to have lost it along the way :-(.
>
> Anyway it looks to be a better solution than the one I suggested (as  
> every user of frame_find_by_id() will benefit), so I will reapply it to  
> our version of GDB (unless you have a better version).

Yes, that's it.  I still think it's gross and nasty, but I also still
haven't managed to come up with a better fix.  Maybe after I'm done
with my current set of unwinder changes.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-04 11:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-04  2:21 Problem setting registers if stack point or frame pointer is 0 Antony KING
2008-04-04  2:30 ` Daniel Jacobowitz
2008-04-04 11:43   ` Antony KING
2008-04-04 17:37     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox