|
From: Bart V. A. <bar...@gm...> - 2006-08-10 15:46:22
|
Hello,
Regarding the drd (data-race detection) tool I'm working on: I
have a question about how to obtain the name of a stack variable,
given its address.
Below there is an example of how the drd tool currently reports
data races. The information it reports is as follows, for each two
conflicting segments:
- Stack trace of the first instruction of the first segment.
- Stack trace of the first instruction of the second segment.
- A list of address ranges for which a race has been detected.
In order for this output to be useful, the user must be able to
correlate the output to the program text. This means reporting only
the addresses of conflicting data accesses is not enough. For static
variables I could obtain the variable name via VG_(find_seginfo)() and
VG_(seginfo_syms_getidx)(). For dynamically allocated variables I can
record the stack trace at the time malloc() is called. But how to
convert the address of a stack variable into the name of a variable ?
$ VALGRIND_LIB=.in_place coregrind/valgrind --tool=drd drd/tests/fp_race
...
==5449== Examining thread 2 (vc [ 1: 3, 2: 1 ]) versus thread 1 (vc [
1: 4 ]) 0 0
==5449== Thread 2:
==5449== 1st segment start
==5449== at: 0x4216648: clone (in /lib/libc-2.4.so)
==5449==
==5449== Thread 1:
==5449== 2nd segment start
==5449== at: 0x4216648: clone (in /lib/libc-2.4.so)
==5449== by: 0x403E9BD: pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.4.so)
==5449== by: 0x401C8AA: pthread_create@* (vg_preloaded.c:116)
==5449== by: 0x804867B: main (fp_race.cpp:67)
==5449== by: 0x416E87C: (below main) (in /lib/libc-2.4.so)
==5449== by: 0x8048511: (within
/home/bart/software/valgrind-svn/drd/tests/fp_race)
==5449== 0x0401B310 sz 4 W W (segment ld-linux.so.2, symbol
_rtld_local @ 0x401B020 size 1524)
==5449== 0x0403817D sz 1 R W (heap)
==5449== 0x04A7BD9C sz 4 R W (stack with VG thread ID 2; kernel thread
ID 5450; POSIX thread ID 78101408)
==5449== 0x08049A08 sz 8 W W (segment NONE, symbol s_d3 @ 0x8049A08 size 8)
==5449== 0xBEC41FD4 sz 8 R W (stack with VG thread ID 1; kernel thread
ID 5449; POSIX thread ID 69704976)
--
Regards,
Bart Van Assche.
|