Re: [rfc] Allow watchpoints on inaccessible memory

Daniel Jacobowitz
2008-03-02T04:24:56Z

On Fri, Feb 29, 2008 at 12:10:00PM +0200, Eli Zaretskii wrote:
> > Date: Thu, 28 Feb 2008 11:17:49 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: Eli Zaretskii <eliz@gnu.org>, Jim Blandy <jimb@red-bean.com>
> >
> > Eli, is the NEWS entry OK?
>
> Yes, but I think we should mention this feature in the manual as well.

What do you think of the attached?

> Btw, are there any command, either CLI or MI, that print the current
> value of the watched expression? If there are, we need to fix them
> somehow in the case struct value is NULL.

No, there are no commands that do this; I checked all the uses of
struct breakpoint's val field.

> Also, maybe we should display <PENDING> in "info break" in this case,
> like we do with breakpoints.

That goes in the address field, which we don't use for other
watchpoints. And we don't print the current value in info break,
so I think this is a full-fledged watchpoint; everything is
displayed as if we could read the value.

--
Daniel Jacobowitz
CodeSourcery

2008-03-01 Daniel Jacobowitz <dan@codesourcery.com>

* doc/gdb.texinfo (Set Watchpoints): Mention watchpoints on
unreadable memory. Delete obsolete SPARClite reference.

Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.471
diff -u -p -r1.471 gdb.texinfo
--- doc/gdb.texinfo 28 Feb 2008 16:26:18 -0000 1.471
+++ doc/gdb.texinfo 2 Mar 2008 04:23:36 -0000
@@ -3211,6 +3211,16 @@ expression can use any operators valid i
language (@pxref{Languages}).
@end itemize

+You can set a watchpoint on an expression even if the expression can
+not be evaluated yet. For instance, you can set a watchpoint on
+@samp{*global_ptr} before @samp{global_ptr} is initialized.
+@value{GDBN} will stop when your program sets @samp{global_ptr} and
+the expression produces a valid value. If the expression becomes
+valid in some other way than changing a variable (e.g.@: if the memory
+pointed to by @samp{*global_ptr} becomes readable as the result of a
+@code{malloc} call), @value{GDBN} may not stop until the next time
+the expression changes.
+
@cindex software watchpoints
@cindex hardware watchpoints
Depending on your system, watchpoints may be implemented in software or
@@ -3338,17 +3348,6 @@ exhaust the resources available for hard
That's because @value{GDBN} needs to watch every variable in the
expression with separately allocated resources.

-The SPARClite DSU will generate traps when a program accesses some data
-or instruction address that is assigned to the debug registers. For the
-data addresses, DSU facilitates the @code{watch} command. However the
-hardware breakpoint registers can only take two data watchpoints, and
-both watchpoints must be the same kind. For example, you can set two
-watchpoints with @code{watch} commands, two with @code{rwatch} commands,
-@strong{or} two with @code{awatch} commands, but you cannot set one
-watchpoint with one command and the other with a different command.
-@value{GDBN} will reject the command if you try to mix watchpoints.
-Delete or disable unused watchpoint commands before setting new ones.
-
If you call a function interactively using @code{print} or @code{call},
any watchpoints you have set will be inactive until @value{GDBN} reaches another
kind of breakpoint or the call completes.