|
From: Vadim A. <av...@gm...> - 2008-10-08 06:06:08
|
Hi!
I'm a student of the Moscow State University, faculty of computational
mathematics and cybernetics. Now I'm working on valgrind's tool, which can
help to decompile programs. I want to analyze variables' values to
understand, which types these variables have (also I want to analyze
pointers, and I think, that I can do it. The main difference between simple
variables and pointers - their values. Pointers have very specific values).
But I have some troubles with valgrind's core. I can't understand, how to
get variables' values correctly. I'm trying to work with it by follow code:
VG_(track_pre_mem_read) (fb_pre_mem_read);
VG_(track_pre_mem_write) (fb_pre_mem_write);
VG_(track_post_mem_write) (fb_post_mem_write);
void fb_post_mem_write(CorePart part, ThreadId tid, Addr a, SizeT size)
{
if (size == 4)
VG_(message)(Vg_DebugMsg, "post_mem_write %u %d %u\n\r", (unsigned
int)size, *((int*)a), a);
}
void fb_pre_mem_write(CorePart part, ThreadId tid, Addr a, SizeT size)
{
if (size == 4)
VG_(message)(Vg_DebugMsg, "pre_mem_write %u %d %u\n\r", (unsigned
int)size, *((int*)a), a);
}
void fb_pre_mem_read(CorePart part, ThreadId tid, Char* s, Addr a, SizeT
size) {
if (size == 4) {
VG_(message)(Vg_DebugMsg, "%d", (int)*s);
VG_(message)(Vg_DebugMsg, "pre_mem_read %u %d %u\n\r", (unsigned
int)size, *((int*)a), a);
}
}
But I can't understand, why it doesn't work.
Values, which are printed by these code aren't values of my program, which
i'm analyzing.
Can you help me?
P.S. Also I tried to work with registers by VG_(track_pre_reg_read) and
VG_(track_post_reg_write), but I also had only strange values on them...
--
Best regards,
Antonov Vadim
mailto: av...@gm...
mobile: +79099933666
|
|
From: Nicholas N. <nj...@cs...> - 2008-10-12 19:30:23
|
On Wed, 8 Oct 2008, Vadim Antonov wrote: > I'm a student of the Moscow State University, faculty of computational > mathematics and cybernetics. Now I'm working on valgrind's tool, which can > help to decompile programs. I want to analyze variables' values to > understand, which types these variables have (also I want to analyze > pointers, and I think, that I can do it. The main difference between simple > variables and pointers - their values. Pointers have very specific values). > But I have some troubles with valgrind's core. I can't understand, how to > get variables' values correctly. I'm trying to work with it by follow code: I assume by "variables" you mean variables in the programming language you are using, eg. C. However, Valgrind works at the binary level, so its analysis is on registers, memory locations, instructions, etc -- machine-level things, rather than programming language things. You can map from the machine level back to the language level using debugging information -- that's how the various tools report line numbers, for example. But mapping back to variables is harder. There might be some capability for it in Valgrind's libraries, but I'm not certain. Doing analysis that relies heavily on language-level information is difficult in Valgrind. Nick |