Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Yves Jaradin <yves.jaradin@uclouvain.be>
To: gdb@sourceware.org
Subject: Watching memory adress given by an expression
Date: Mon, 12 Jan 2009 12:57:00 -0000	[thread overview]
Message-ID: <496B3DF1.2060303@uclouvain.be> (raw)

Hi,

Recently, I stumbled upon a dangling pointer in some code I'm maintaining.
The best reproducible crash was still very time sensitive (order of a 
few seconds at most),
so I couldn't really debug interactively.
Some structure on the heap was corrupted, so I set up a breakpoint when 
the structure was correctly initialized with commands to set up a 
watchpoint on the memory that would be corrupted.
Unfortunately, the expression I had for the to-be-corrupted memory was 
going out of scope before the corruption.
I resorted to this:

break emulate.cc:316
ignore $bpnum 9
commands
print entry
x &(entry.pc)
set $targetpc=$_
watch *($targetpc)
continue
end
continue


Which is ugly because:
I works only for a single triggering of the breakpoint.
It prints an extra value.
The $_ business I'm doing is really a hack.

I could remove the first problem using shell, source, etc. but this 
isn't cleaner.

Is there a cleaner way to do this kind of debugging?

I would have liked to have a command like:
watchmem &(entry.pc)
which would immediately evaluate it's expression to a pointer and set a 
watcher to the pointed space.

Regards,
Yves


             reply	other threads:[~2009-01-12 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12 12:57 Yves Jaradin [this message]
2009-01-12 15:15 ` Andreas Schwab

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=496B3DF1.2060303@uclouvain.be \
    --to=yves.jaradin@uclouvain.be \
    --cc=gdb@sourceware.org \
    /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