From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8065 invoked by alias); 8 Jun 2009 19:30:40 -0000 Received: (qmail 8051 invoked by uid 22791); 8 Jun 2009 19:30:39 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-gx0-f205.google.com (HELO mail-gx0-f205.google.com) (209.85.217.205) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Jun 2009 19:30:26 +0000 Received: by gxk1 with SMTP id 1so5925015gxk.0 for ; Mon, 08 Jun 2009 12:30:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.138.7 with SMTP id l7mr524439and.141.1244489420872; Mon, 08 Jun 2009 12:30:20 -0700 (PDT) Date: Mon, 08 Jun 2009 19:30:00 -0000 Message-ID: Subject: suggestions for node "(gdb)Set Watchpoints" From: Samuel Bronson To: Eli Zaretskii Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00075.txt.bz2 Hi Eli, Pedro Alves told me to prod you if I wanted to make suggestions for the manual? This paragraph is found very close to the end of the node "(gdb)Set Watchpoints" in the GDB 6.8 manual: /---- GDB automatically deletes watchpoints that watch local (automatic) variables, or expressions that involve such variables, when they go out of scope, that is, when the execution leaves the block in which these variables were defined. In particular, when the program being debugged terminates, _all_ local variables go out of scope, and so only watchpoints that watch global variables remain set. If you rerun the program, you will need to set all such watchpoints again. One way of doing that would be to set a code breakpoint at the entry to the `main' function and when it breaks, set all the watchpoints. \---- I actually didn't see this until I claimed it wasn't in the documentation, and Pedro quoted the beginning of the paragraph to me and linked me to that node of the online manual to me in #gdb. I think this kind of thing might be prevented by moving it much nearer to the bulleted list at the top of the node -- especially with the paragraph that was already added between 6.8 and CVS HEAD (as of a few days ago), which also discusses scope: /--- 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 `*global_ptr' before `global_ptr' is initialized. GDB will stop when your program sets `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 `*global_ptr' becomes readable as the result of a `malloc' call), GDB may not stop until the next time the expression changes. \---- This paragraph does make things a lot better, but at the same time makes it even stranger that the other paragraph is so far away from the description of what kinds of expressions to watch. I think the other paragraph should be moved up to be with this one -- probably after it. It would also be nice to have a more in-depth description of exactly which watchpoint-related events GDB is actually able to intercept.