From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10314 invoked by alias); 28 May 2010 02:03:27 -0000 Received: (qmail 10187 invoked by uid 22791); 28 May 2010 02:03:25 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 May 2010 02:03:20 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4S2363W032143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 May 2010 22:03:06 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4S235RE025918; Thu, 27 May 2010 22:03:05 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4S234fP028192; Thu, 27 May 2010 22:03:04 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 32C693780A5; Thu, 27 May 2010 20:03:04 -0600 (MDT) From: Tom Tromey To: Jan Kratochvil Cc: Joel Brobecker , Sergio Durigan Junior , gdb-patches@sourceware.org Subject: Re: [PATCH] Forbid watchpoint on a constant value References: <201005202054.53548.sergiodj@redhat.com> <20100521070500.GA30452@host0.dyn.jankratochvil.net> Reply-To: tromey@redhat.com Date: Fri, 28 May 2010 05:12:00 -0000 In-Reply-To: <20100521070500.GA30452@host0.dyn.jankratochvil.net> (Jan Kratochvil's message of "Fri, 21 May 2010 09:05:00 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00675.txt.bz2 >>>>> "Jan" == Jan Kratochvil writes: I finally read through this thread today. Jan> `watch 5' can never trigger. I cannot agree with creating a Jan> watchpoint which will never trigger. I agree. A watchpoint like that is most likely user error. Jan> The more problematic is the part Jan> const i = 5; Jan> (gdb) watch i Jan> + case OP_VAR_VALUE: Jan> + if (TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_FUNC Jan> + && !TYPE_CONST (SYMBOL_TYPE (s))) Jan> + return 0; Jan> as you are right that a symbol can be tagged by buggy compiler as Jan> DW_TAG_const_type despite its value changes in the compiler output. Jan> Another possibility is a memory corruption. I think that we cannot rely on DW_TAG_const_type in this situation. As you note, programs may cast it away, or there could be corruption -- the latter is exactly when it would be useful to put a watchpoint on such a variable. Also, in C++ I believe you can have a const object with a mutable member, which this test does not detect. Jan> <2><4b>: Abbrev Number: 3 (DW_TAG_variable) Jan> <4c> DW_AT_name : v Jan> <54> DW_AT_const_value : 1 Jan> which would be a GDB internal error if it would ever trigger. Jan> A safer patch would be to check SYMBOL_CLASS for LOC_CONST/etc. of the Jan> variable instead of relying on compiler's DW_TAG_const_type correctness. Yes, I agree. In this situation gdb has no way of detecting any change to the value anyhow. Tom