|
From: Olly B. <ol...@su...> - 2006-09-07 15:55:23
|
On 2006-09-07, Alex Bennee <ker...@be...> wrote:
> Could be I guess. But that still leads to the initial problem of how do
> identify the thing that is clobbering the variable. The value itself is
> stored in a uint32_t so I tried adding a uint16_t in front of it to see
> if it was getting lucky doing a 32 bit write into that address. However
> nothing came up from that. Setting the variable to a 64 bit one didn't
> pick up a rouge 32 bit write either (if valgrind would pick that up?).
Bear in mind that valgrind works at a lower level than C, so it is
unlikely to be able to trap "wrong-sized" writes in the way you seem to
hope.
For an example of why this can't really be done, the C compiler could
optimise the following code so that f actually performs a single 32-bit
write:
struct {
short a, b;
} foo;
void f(short x, short y) {
foo.a = x;
foo.b = y;
}
(although for this particular example, GCC doesn't seem to actually do
this currently).
You could try inserting the padding into your structure and marking it
"no access" using a valgrind client request. Or just run under gdb and
stick a watchpoint on the struct member which gets changed, as I think
Tom suggested elsewhere.
Cheers,
Olly
|