|
From: Nicholas N. <nj...@cs...> - 2007-10-21 23:02:17
|
On Sun, 21 Oct 2007, Julio M. Merino Vidal wrote: >> I'm currently writing an instrumentation tool for a class assignment >> using Valgrind. I'm interested in tracking all memory loads and >> stores to later depict them in some form of graph. So far I've added >> the necessary "hooks" to Store statements and Load expressions to the >> guest code. For example, this is for the Store: >> >> UInt size = sizeofIRType(typeOfIRExpr(sb->tyenv, st- >>> Ist.Store.data)); >> argv = mkIRExprVec_2(mkIRExpr_HWord((HWord)st- >>> Ist.Store.addr), >> mkIRExpr_HWord(size)); >> di = unsafeIRDirty_0_N(1, "trace_mem", >> VG_(fnptr_to_fnentry)(&trace_mem), >> argv); >> addStmtToIRSB(sb, IRStmt_Dirty(di)); >> >> But I can't find the correct way to interpret the address expressions >> I pass to the trace_mem function. How am I supposed to process the >> value of Ist.Store.addr (or the address of the Load in its case) to >> get the real address where the guest program is going to access? > > OOOK, I reply myself after having read memcheck's code for a while. > That conversion of the address to an HWord is bogus. Removing that > and leaving the addr parameter alone makes things work as expected :-) I'm glad to hear you worked it out. Vex's IR does take some time to understand -- C's cumbersome support for tagged unions doesn't help -- but everything is done for a reason, and it does make sense if you stare at it long enough :) Nick |