|
From: Rahul R. <ra...@ya...> - 2004-11-21 07:36:47
|
Hi, I have been trying to modify cachegrind for a project of mine. I wanted to do 2 things: * Check for uninitialized memory at a word level(though this is done at a bit level in memcheck, my requirement was to do it at L1, L2 caches at a word level) * Check for Write after Write (without any intermediate REad) I attached a bit vector(which recorded the sequence of writes and reads to every word in the L1 , and L2 cache). I find that for a test program, there are some memory reads to addresses which had not been previously written. Are some of the words prepared by a program loader, in Coregrind(that is, are some addresses initialized in coregrind and then probably read during the startup of the test program)? Any insight into the same would be greatly appreciated. Thanks, ~Rahul. |
|
From: Nicholas N. <nj...@ca...> - 2004-11-22 12:45:20
|
On Sun, 21 Nov 2004, Rahul Ravindran wrote: > I have been trying to modify cachegrind for a project of mine. I wanted to do > 2 things: > * Check for uninitialized memory at a word level(though this is done at a bit > level in memcheck, my requirement was to do it at L1, L2 caches at a word level) > * Check for Write after Write (without any intermediate REad) > > I attached a bit vector(which recorded the sequence of writes and reads to every > word in the L1 , and L2 cache). > > I find that for a test program, there are some memory reads to addresses which > had not been previously written. Are some of the words prepared by a program > loader, in Coregrind(that is, are some addresses initialized in coregrind and > then probably read during the startup of the test program)? Most memory accesses are visible from the UCode, eg. by instrumenting LOAD, STORE, etc. There are some cases where Valgrind's core touches memory, and this cannot be seen in the UCode. Instead, a tool can know about them via the pre_mem_read/post_mem_read events -- a tool registers a callback function, which gets called whenever this happens. Have a look in Memcheck for examples of use. This may account for what you're seeing. N |
|
From: Rahul R. <ra...@ya...> - 2004-11-23 00:04:22
|
Hi Nicholas, Thanks for the information. However, I find that the methods pre_mem_read and pre_mem_write are called before all memory reads and writes. This does not give me any address range which has been initialized by the core for execution of the test program. Is there any way, I can find any memory address which has been initialized by the core. I need to suppress any errors which are detected in the above range of addresses. Hence, I require the above range of addresses. Also, is there any module in core which does the translation from a virtual address to the physical address? Thanks and Regards, ~Rahul. |
|
From: Nicholas N. <nj...@ca...> - 2004-11-23 11:05:49
|
On Tue, 23 Nov 2004, Rahul Ravindran wrote: > However, I find that the methods pre_mem_read and pre_mem_write are > called before all memory reads and writes. This does not give me any > address range which has been initialized by the core for execution of > the test program. Is there any way, I can find any memory address which > has been initialized by the core. I need to suppress any errors which > are detected in the above range of addresses. Hence, I require the above > range of addresses. I don't understand what you are asking for. > Also, is there any module in core which does the translation from a virtual > address to the physical address? No; only the OS can do that. N |
|
From: Rahul R. <ra...@ya...> - 2004-11-23 01:22:09
|
To add a lil more detail to the above question, I guess that coregrind would be preparing execution by writing into the text segment, BBS etc. I guess I would need to check only for uninitialized memory accesses for words only in the stack and the heap. is there any way of finding the bounds of the stack and the heap. I also see that , the heap can be initialized. Why is this? ~Rahul. |
|
From: Nicholas N. <nj...@ca...> - 2004-11-23 11:05:53
|
On Tue, 23 Nov 2004, Rahul Ravindran wrote: > To add a lil more detail to the above question, I guess that coregrind > would be preparing execution by writing into the text segment, BBS etc. > I guess I would need to check only for uninitialized memory accesses for > words only in the stack and the heap. is there any way of finding the > bounds of the stack and the heap. The stack bounds: Have a look at the function VG_(first_matching_thread_stack)(); it can be (mis)used for this... have a look at how it is used in massif/ms_main.c. Note that a multi-threaded program will have multiple stacks. The heap bounds: The top of the heap can be found with brk() or sbrk(), as usual. However, "heap" memory (ie. that allocated by malloc()) doesn't always live in the real process heap; it can also come out of arbitrary mapped segments which are allocated with mmap(). So "the bounds of the heap" doesn't really mean anything, unless you are talking strictly about the process heap. > I also see that , the heap can be initialized. Why is this? ~Rahul. I don't understand what you mean by this. N |