Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>,
	       Sergio Durigan Junior <sergiodj@redhat.com>,
	       gdb-patches@sourceware.org
Subject: Re: [PATCH] Forbid watchpoint on a constant value
Date: Fri, 28 May 2010 05:12:00 -0000	[thread overview]
Message-ID: <m3sk5ceqav.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20100521070500.GA30452@host0.dyn.jankratochvil.net> (Jan	Kratochvil's message of "Fri, 21 May 2010 09:05:00 +0200")

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> 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


      parent reply	other threads:[~2010-05-28  2:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-18 17:36 Sergio Durigan Junior
2010-05-18 17:49 ` Eli Zaretskii
2010-05-18 19:24   ` Sergio Durigan Junior
2010-05-18 23:08 ` Jan Kratochvil
2010-05-18 23:50   ` Sergio Durigan Junior
2010-05-19 20:26     ` Jan Kratochvil
2010-05-20  6:21       ` Sergio Durigan Junior
2010-05-20 15:50         ` Jan Kratochvil
2010-05-20 16:24           ` Sergio Durigan Junior
2010-05-20 17:03             ` Jan Kratochvil
2010-05-20 17:06               ` Sergio Durigan Junior
2010-05-27 21:54             ` Tom Tromey
2010-05-20 23:23 ` Joel Brobecker
2010-05-20 23:31   ` Sergio Durigan Junior
2010-05-20 23:55     ` Joel Brobecker
2010-05-21  0:09       ` Sergio Durigan Junior
2010-05-21  7:05         ` Eli Zaretskii
2010-05-21  8:44   ` Jan Kratochvil
2010-05-21 21:43     ` Sergio Durigan Junior
2010-05-21 22:20       ` Sergio Durigan Junior
2010-05-29  0:04         ` Joel Brobecker
2010-06-04 13:54           ` Jan Kratochvil
2010-06-04 16:49             ` Tom Tromey
2010-06-05  5:35           ` Sergio Durigan Junior
2010-06-05 14:38             ` Jan Kratochvil
2010-06-06  0:20               ` Sergio Durigan Junior
2010-06-15 17:30             ` Tom Tromey
2010-06-16 18:33               ` Sergio Durigan Junior
2010-06-16 18:36                 ` Jan Kratochvil
2010-05-28  5:12     ` Tom Tromey [this message]

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=m3sk5ceqav.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=sergiodj@redhat.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