Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Eli Zaretskii" <eliz@gnu.org>
To: Orjan Friberg <orjan.friberg@axis.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: recurse.exp: watch on local variable that goes out of scope
Date: Tue, 20 Jul 2004 19:37:00 -0000	[thread overview]
Message-ID: <9787-Tue20Jul2004223539+0300-eliz@gnu.org> (raw)
In-Reply-To: <40FD2E1F.7070403@axis.com> (message from Orjan Friberg on Tue, 20 Jul 2004 16:37:19 +0200)

> Date: Tue, 20 Jul 2004 16:37:19 +0200
> From: Orjan Friberg <orjan.friberg@axis.com>
> 
> Now for the confusing part: bpstat_stop_status is called with 
> stopped_by_watchpoint == 1.  This is because, at this point, 
> i386_stopped_data_address returns the address of the local variable "b" (the 
> address it had in recurse (a=5)), as if it were stopped due to a watchpoint hit. 
>   I would have expected i386_stopped_data_address to return 0 at this point, 
> since it didn't stop due to a watchpoint hit.  What am I missing here?  Does 
> i386_stopped_data_address retain the stopped data address from the previous hit?

No, it shouldn't return a stale address, it should return zero.

I reproduce the entire source of i386_stopped_data_address below; as
you see, it starts by zeroing out `addr' and assigns it a non-zero
value _only_ if I386_DR_WATCH_HIT(i) returns non-zero for some value
of i.  This is supposed to query the debuggee about its debug
registers, and assumes that one of the debug registers will show that
a watchpoint has been hit only if a watchpoint has indeed been hit.

Can you step thru i386_stopped_data_address and see what exactly
happens there in your case?

CORE_ADDR
i386_stopped_data_address (void)
{
  CORE_ADDR addr = 0;
  int i;

  dr_status_mirror = I386_DR_LOW_GET_STATUS ();

  ALL_DEBUG_REGISTERS(i)
    {
      if (I386_DR_WATCH_HIT (i)
	  /* This second condition makes sure DRi is set up for a data
	     watchpoint, not a hardware breakpoint.  The reason is
	     that GDB doesn't call the target_stopped_data_address
	     method except for data watchpoints.  In other words, I'm
	     being paranoiac.  */
	  && I386_DR_GET_RW_LEN (i) != 0)
	{
	  addr = dr_mirror[i];
	  if (maint_show_dr)
	    i386_show_dr ("watchpoint_hit", addr, -1, hw_write);
	}
    }
  if (maint_show_dr && addr == 0)
    i386_show_dr ("stopped_data_addr", 0, 0, hw_write);

  return addr;
}


  reply	other threads:[~2004-07-20 19:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-20 14:37 Orjan Friberg
2004-07-20 19:37 ` Eli Zaretskii [this message]
2004-07-22  9:44   ` Orjan Friberg
2004-07-22 19:19     ` Eli Zaretskii
2004-07-23  9:23       ` Orjan Friberg
2004-07-28 15:52         ` Orjan Friberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9787-Tue20Jul2004223539+0300-eliz@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=orjan.friberg@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox