Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@delorie.com>
To: edwardp@excitehome.net
Cc: gdb@sources.redhat.com
Subject: Re: watchpoints inside 'commands'
Date: Sun, 08 Apr 2001 01:09:00 -0000	[thread overview]
Message-ID: <200104080808.EAA01801@delorie.com> (raw)
In-Reply-To: <20010407173341.A22145@excitehome.net>

> Date: Sat, 7 Apr 2001 17:33:41 -0700
> From: Edward Peschko <edwardp@excitehome.net>
> 
> > > as soon as the scope changes inside of 'function', the program
> > > breaks... It says 'watchpoint being deleted as the variable goes out
> > > of scope'.
> > 
> > But this is exactly what you want: GDB just warns you about the fact
> > that it deleted the watchpoint because it watches a variable on the
> > stack that is no longer in use.  Why is that a problem?  The message
> > doesn't mean that the program is broken, you should be able to
> > continue it as usual.
> 
> But it *doesn't* continue as usual. It warns (which it shouldn't if I tell it
> to be silent ) and then *stops*. It is transparent to the continue.
> 
> Say I'm running a program and 39,999 out of 40,000 times the variable key 
> is allocated and deallocated successfully.
> 
> Now, I don't want to have the watchpoint stop all of those 40,000
> times; I only want it to stop if something else trounces the memory
> that I don't know about.

Ah, okay, then how about setting a breakpoint near the exit from the
scope where the watchpoint is defined, and setting up the commands of
that breakpoint to silently delete the watchpoint and continue?  Would
that do what you want?

> > You will have to find a repeatable scenario in which the same memory
> > region is trashed, and then watch that memory region.
> > 
> > How do you find out where's the trashed region, if it changes from
> > time to time?  Does it change because you modify your program,
> > perhaps?
> 
> No, it changes because the program is threaded, and hence is
> asynchronous, and hence is not deterministic as to where it
> crashes.

Can you get the trashing if some of the threads don't run?  It's
probably best to have the minimum number of threads that still
reproduce the problem.

Anyway, how many possible memory regions did you find to be trashed
until now?  If it is a relatively small number, watchpoints could
still help (you could watch all or most of them).

> In addition, if I set up a watchpoint on a specific piece
> of memory, there are three points that the watchpoint will break at:
> 
>	1) when the memory is initially allocated.
>	2) when the memory is cleared/deleted.
>	3) when the memory is trounced over.

That's true, but you could handle this with watchpoint commands: they
could simply print their usual stuff and then continue.  Later you
could examine the session script and decide which of the breaks were
false alarms and which not.

> Now, if it stops at #1, then the conditions of the program will have
> changed, and in all probability #3 will not occur at the same
> address because it has changed the state of the program before #3
> occurs.

What you describe sounds like uninitialized pointer somewhere, or some
other source of random addresses being poked.  (Are the regions that
get trashed really random, or do you have only a small set of possible
victims?)  If the address is really random, I'd suggest to think what
could be the source of such randomness.  A random address is not easy
to get by in most programs.


  reply	other threads:[~2001-04-08  1:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20010405200028.A18474@excitehome.net>
2001-04-05 20:05 ` Edward Peschko
2001-04-06  2:09   ` Eli Zaretskii
2001-04-06 11:20     ` Edward Peschko
2001-04-07  0:17       ` Eli Zaretskii
2001-04-07 17:33         ` Edward Peschko
2001-04-08  1:09           ` Eli Zaretskii [this message]
2001-04-08 16:59             ` Edward Peschko
2001-04-08 17:45               ` Daniel Berlin
2001-04-08 23:21               ` Eli Zaretskii
2001-04-17 10:38             ` Andrew Cagney

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=200104080808.EAA01801@delorie.com \
    --to=eliz@delorie.com \
    --cc=edwardp@excitehome.net \
    --cc=gdb@sources.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