|
From: Leung Ngai-H. Z. <leu...@co...> - 2006-02-05 05:30:40
|
I'm doing a project on virtual memory, and decided to use Valgrind to help
me track the memory references made by a program. I added a little to
what Nick did with Lackey. Basically, whenever I do an instruction
fetch, a read or a write, I call the relevant functions below.
static VG_REGPARM(1) void trace_ins_read(Addr addr)
{
VG_(printf)("i %p\n", addr);
}
static VG_REGPARM(1) void trace_load(Addr addr)
{
VG_(printf)("r %p %d\n", addr, VG_(seginfo_sect_kind)(addr));
}
static VG_REGPARM(1) void trace_store(Addr addr)
{
VG_(printf)("w %p %d\n", addr, VG_(seginfo_sect_kind)(addr));
}
I'm puzzled because I cannot explain some of the details of the trace I
collect. Here is some of the output:
i 0x458008
w 0x45F278 0
r 0xFDF1E90C 0
r 0x45B7A4 1
r 0x43253DC 2
r 0x584D4C 2
w 0x586058 3
In case you're not well acquainted with VG_(seginfo_sect_kind), 0 means
unknown, 1 means text, 2 means data, 3 means BSS.
(1) Why does a program read from the text part?
(2) Why is "w 0x45F278 0" unknown, if it is between the text and BSS?
Shouldn't it be data?
(3) Why is "r 0x43253DC 2" in the data region? I thought the data region
is between the text and BSS, but it appears that the data region is a lot
higher than the BSS! The other data read "r 0x584D4C 2" seems to be the
real data region. Is there an error in VG_(seginfo_sect_kind)?
Thanks in advance for any help!
Zac
|