|
From: Guilhem B. <gu...@my...> - 2005-03-29 13:16:55
|
Hi,
"It would be great if" (TM) Valgrind could report which bit was not
initialized, not only which byte. For example:
#include <stdio.h>
main()
{
char *buf2;
buf2= (char*)malloc(1);
(*buf2)|= 1|2|4|16|32|64|128;
if (*buf2)
printf("test\n");
}
Here bit 4 ("|8" is missing) is the only one not initialized.
[guilhem 15:09 /home/mysql_src/tmp] gcc -g b.c;valgrind ./a.out
==24801== Memcheck, a memory error detector for x86-linux.
==24801== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==24801== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==24801== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==24801== For more details, rerun with: -v
==24801==
==24801== Conditional jump or move depends on uninitialised value(s)
==24801== at 0x80483FE: main (b.c:7)
If in this error message, Valgrind could say the position of the first
bit not initialized, it would really be helpful. In the MySQL code we
have some variable like this:
uint flags; // 32 "flags"
In some piece of code we set a certain bit of "flags", in some other
separate piece of code we set another bit, etc, and when later we get
"uninitialized value" when using the variable "flags" as a whole, like
this:
if (flags)
it's sometimes hard to know which piece of code is guilty for not
doing its job.
I would like to ask:
does there currently exist some option to make Valgrind print this
information? If not:
is it in the plans? would it be hard to code? would you be
interested in a contributed patch for it? would you have any hints
on how to best do it?
Thanks!
Guilhem
|