Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Function argument no longer in register
@ 2004-03-29 14:21 Orjan Friberg
  2004-03-29 14:25 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Orjan Friberg @ 2004-03-29 14:21 UTC (permalink / raw)
  To: gdb-patches

Hi all,

What should happen when a function argument goes out of scope because 
the register used to pass it is now used for something else?  I 
encountered the following situation:

foo (char *str)
{
   ...
   i = bar ();
   ...
}

The str argument is passed in register r10, which is then overwritten 
with the return value from bar.  If I stop somewhere after the call to 
bar and try to "print str", GDB will try to read from the address 
pointed out by r10 (i.e. sends an 'm' packet to the remote stub).

I don't know what kind of problem I'm looking at here.  Could it be that 
the debug information is wrong?  I'm guessing GDB somehow fails to 
realize that the function argument is out of scope at this point.

-- 
Orjan Friberg
Axis Communications


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

* Re: Function argument no longer in register
  2004-03-29 14:21 Function argument no longer in register Orjan Friberg
@ 2004-03-29 14:25 ` Daniel Jacobowitz
  2004-03-29 14:44   ` Orjan Friberg
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2004-03-29 14:25 UTC (permalink / raw)
  To: Orjan Friberg; +Cc: gdb-patches

On Mon, Mar 29, 2004 at 04:21:19PM +0200, Orjan Friberg wrote:
> Hi all,
> 
> What should happen when a function argument goes out of scope because 
> the register used to pass it is now used for something else?  I 
> encountered the following situation:
> 
> foo (char *str)
> {
>   ...
>   i = bar ();
>   ...
> }
> 
> The str argument is passed in register r10, which is then overwritten 
> with the return value from bar.  If I stop somewhere after the call to 
> bar and try to "print str", GDB will try to read from the address 
> pointed out by r10 (i.e. sends an 'm' packet to the remote stub).
> 
> I don't know what kind of problem I'm looking at here.  Could it be that 
> the debug information is wrong?  I'm guessing GDB somehow fails to 
> realize that the function argument is out of scope at this point.

Nothing's wrong - eventually, versions of GCC with proper location list
will tell GDB that the variable is out of scope, but no released
version does that.  I think 3.5 snapshots will.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

* Re: Function argument no longer in register
  2004-03-29 14:25 ` Daniel Jacobowitz
@ 2004-03-29 14:44   ` Orjan Friberg
  0 siblings, 0 replies; 3+ messages in thread
From: Orjan Friberg @ 2004-03-29 14:44 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
>>
>>I don't know what kind of problem I'm looking at here.  Could it be that 
>>the debug information is wrong?  I'm guessing GDB somehow fails to 
>>realize that the function argument is out of scope at this point.
> 
> 
> Nothing's wrong - eventually, versions of GCC with proper location list
> will tell GDB that the variable is out of scope, but no released
> version does that.  I think 3.5 snapshots will.

Ah, ok.  Thanks.  The setup is a remote stub debugging a Linux kernel, 
and the first page (8k for CRIS) is read/write-protected.  So, I guess I 
need to filter out these bogus reads in the stub to prevent the kernel 
from oopsing.

-- 
Orjan Friberg
Axis Communications


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

end of thread, other threads:[~2004-03-29 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-29 14:21 Function argument no longer in register Orjan Friberg
2004-03-29 14:25 ` Daniel Jacobowitz
2004-03-29 14:44   ` Orjan Friberg

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