|
From: Bjoern K. <Bjo...@un...> - 2006-02-22 14:33:12
|
Hallo ! Is there a way to (ab)use valgrind 3.1 to track all write-access to a specific address? I try to debug a memory corruption where a member of an array get overwritten, and try to identify all lines that accidently change that member. What I am looking for is some sort of client request to mark that array-member (after it is initialized) as "report all writes". Regards Bjoern Kahl -- +-----------------------------------------------------------------+ | Dipl.-Phys. Bjoern Kahl +++ Lehrstuhl Angewandte Informatik III | | (Robotik und Eingebettete Systeme) +++ Universitaet Bayreuth | | phone: +49-921-55-5164 +++ www: http://ai3.inf.uni-bayreuth.de | +-----------------------------------------------------------------+ |
|
From: Paul P. <ppl...@gm...> - 2006-02-22 14:48:20
|
On 2/22/06, Bjoern Kahl <Bjo...@un...> wrote: > > Is there a way to (ab)use valgrind 3.1 to track all write-access > to a specific address? At least on x86 and amd64 you don't need VG for that. Gdb hardware watchpoints get you there much faster. Cheers, |
|
From: Joe M. <joe...@me...> - 2006-02-22 17:53:14
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Pluzhnikov wrote: > On 2/22/06, Bjoern Kahl <Bjo...@un...> wrote: >> Is there a way to (ab)use valgrind 3.1 to track all write-access >> to a specific address? > > At least on x86 and amd64 you don't need VG for that. > Gdb hardware watchpoints get you there much faster. However, if you can't use gcc, add this to your source: #include <valgrind/memcheck.h> ... // make valgrind report all reads and writes to an address VALGRIND_MAKE_NOACCESS(addr, numbytes); // make valgrind stop reporting reads to the address VALGRIND_MAKE_READABLE(addr, numbytes); (By default if you allocate some memory, valgrind marks it both READABLE and WRITABLE, so I *think* you have to turn those off with NOACCESS. But I can't recall - MAKE_READABLE might automatically turn off WRITABLE The MAKE_NOACCESS line may not be necessary - MAKE_READABLE might automatically turn off WRITABLE as well.) Joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFD/KT6q5NnQEnPdLcRAouvAJwOP7N+wbsrLdAIqPYVxCvWt+cGeQCffOwt ACv9nuQHbvMJktTiHJoHrNY= =i/// -----END PGP SIGNATURE----- |
|
From: Nicholas N. <nj...@cs...> - 2006-02-22 21:55:41
|
On Wed, 22 Feb 2006, Joe Mason wrote: >>> Is there a way to (ab)use valgrind 3.1 to track all write-access >>> to a specific address? >> >> At least on x86 and amd64 you don't need VG for that. >> Gdb hardware watchpoints get you there much faster. > > However, if you can't use gcc, add this to your source: > > #include <valgrind/memcheck.h> > > ... > // make valgrind report all reads and writes to an address > VALGRIND_MAKE_NOACCESS(addr, numbytes); > // make valgrind stop reporting reads to the address > VALGRIND_MAKE_READABLE(addr, numbytes); > > (By default if you allocate some memory, valgrind marks it both READABLE > and WRITABLE, so I *think* you have to turn those off with NOACCESS. > But I can't recall - MAKE_READABLE might automatically turn off WRITABLE > The MAKE_NOACCESS line may not be necessary - MAKE_READABLE might > automatically turn off WRITABLE as well.) MAKE_NOACCESS is the right thing to use. Our use of the term "readable" is a bit confusing, because it really means "readable and writable". Nick |
|
From: rak <ra...@ho...> - 2006-02-23 21:11:10
|
VALGRIND_MAKE_NOACCESS(addr, numbytes); can this be used with static/global variables |
|
From: Nicholas N. <nj...@cs...> - 2006-02-23 21:24:25
|
On Thu, 23 Feb 2006, rak wrote: > VALGRIND_MAKE_NOACCESS(addr, numbytes); > can this be used with static/global variables Yes. |
|
From: rak <ra...@ho...> - 2006-02-24 17:25:12
|
> On Thu, 23 Feb 2006, rak wrote: > > > VALGRIND_MAKE_NOACCESS(addr, numbytes); > > can this be used with static/global variables > > Yes. MAKE_NOACCESS is the right thing to use. Our use of the term "readable" is a bit confusing, because it really means "readable and writable". Is there any way i can mark certain variables readonly, As i am having problem with static variables. I marked some static variables as noaccess but they were more than 30000 read problems where as i was tring to track writes. Thanks and appreciate your time & help, Rak |
|
From: Paul P. <ppl...@gm...> - 2006-02-24 17:48:14
|
rak wrote: >Is there any way i can mark certain variables readonly, As i am having problem >with static variables. I marked some static variables as noaccess but they were > more than 30000 read problems where as i was tring to track writes. > Are you really in a situation where gdb (and its hardware watchpoints) is not working? As I said before, gdb hardware watchpoints get you there much faster (if you know the address that is being corrupted and if that address is constant from run to run). Cheers, |
|
From: rak <ra...@ho...> - 2006-02-24 18:16:33
|
Paul Pluzhnikov <ppluzhnikov <at> gmail.com> writes: > As I said before, gdb hardware watchpoints get you there much faster > (if you know the address that is being corrupted and if that address > is constant from run to run). > > Cheers, gdb/totalview hardware watchpoint works(sometimes). The address being corrupted depends on the shared library path(i mean not constant), and also want this to be part of the daily test(part of which uses valgrind). Thanks, Rak |
|
From: John R.
|
> gdb/totalview hardware watchpoint works(sometimes). The address being corrupted
> depends on the shared library path(i mean not constant), and also want this to
> be part of the daily test(part of which uses valgrind).
gdb can be run non-interactively [although there may be quirks],
so if the address can be expressed in terms of symbol names,
or in terms of the n-th return value from malloc [etc]:
gdb -batch -x <gdb_command_file>
--
|
|
From: Joe M. <joe...@me...> - 2006-02-24 19:30:47
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 rak wrote: >> On Thu, 23 Feb 2006, rak wrote: >> >>> VALGRIND_MAKE_NOACCESS(addr, numbytes); >>> can this be used with static/global variables >> Yes. > > > MAKE_NOACCESS is the right thing to use. Our use of the term "readable" is > a bit confusing, because it really means "readable and writable". > > Is there any way i can mark certain variables readonly, As i am having problem > with static variables. I marked some static variables as noaccess but they were > more than 30000 read problems where as i was tring to track writes. The problem is that valgrind is really tracking "uninitialized" and "unaccessable" memory, not read-only and write-only. MAKE_NOACCESS means the memory has not even been allocated to the program, and nothing should be reading or writing it. MAKE_WRITABLE means that the memory is allocated but not initialized, so that any attempt to read from it is an error, but writing to it is allowed. (And once it is written to, it will be marked initialized, so all further access is ok.) MAKE_READABLE means that the memory is allocated and fully initialized, so both reading and writing are correct. Joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFD/17Xq5NnQEnPdLcRAn79AKCL0XQv6gBPdhcKCsL2b0du6eyFoACfYNIb gYpS0xotcgfUkHxWzRYygbM= =C/AZ -----END PGP SIGNATURE----- |
|
From: Nicholas N. <nj...@cs...> - 2006-02-25 01:38:52
|
On Fri, 24 Feb 2006, rak wrote: > Is there any way i can mark certain variables readonly. No, sorry -- only noaccess, writable (write-only), and readable (aka readable+writable). We thought about adding support for read-only, but it would have caused to much of a performance slowdown without much benefit. You can fake read-only by marking variables NOACCESS, then in the places where you are supposed to touch them, you temporarily mark them as READABLE, read them, then mark them as NOACCESS again. That way if anything touches them elsewhere you'll detect it. The practicality of this depends on how many places touch the variables. Nick |