|
From: Peter O. <kum...@ar...> - 2009-01-09 17:44:37
|
Hi, I use VALGRIND_CHECK_MEM_IS_DEFINED request to check if all data in a structure is initialized before putting the data into a list. When such a structure is allocated on stack the error message is pretty meaningless since it only tells the address of the element on the stack. Much more useful would be where the memory was uninitialized relative to the start address of the VALGRIND_CHECK_MEM_IS_DEFINED request. So i hacked together this quick patch. I would guess it is not ready for inclusion as is stands now. But it might be useful for somebody. In the attached sample output is easy to see that the first unitialized byte is a offset 4. Now we can go hunt which stucture member resides at that offset (use pahole or look at the source) Another possibility for this would be a custom macro that wraps around VALGRIND_CHECK_MEM_IS_DEFINED but this has the disadvantage that the each project needs it's own print function and it is possibly separated from the valgrind output. Greetings Peter |