Yonatan G
Yonatan G

Reputation: 21

Extracting memtraces from c++ programs

I'm interested in extracting memory accesses of a certain program.

I'm looking for the following list for example on a specific execution:

[R\W]  [Address]   [numBytes]     
R         0x0000012d32a21   0x4

I already tried valgrind and mtrace, as well as their related tools.

They are all seem to return back a more general statistics or memory-leakage related statistics.

I'm interested in all memory accesses data.

I googled it for hours, and find many papers dealing with that problem, but not a working open source code.

Appreciate your help

Upvotes: 1

Views: 630

Answers (2)

phd
phd

Reputation: 3807

The valgrind lackey tool should give you the needed information.

See http://www.valgrind.org/docs/manual/lk-manual.html option --trace-mem= [default: no]

Upvotes: 1

Joe Z
Joe Z

Reputation: 17936

You might look into Pin.

From the description:

Pin is a dynamic binary instrumentation framework for the IA-32 and x86-64 instruction-set architectures that enables the creation of dynamic program analysis tools.

You should be able to find or write a pintool that does what you need. For example, this one. The linked example is almost exactly what you ask for. You'll need to add an IARG_MEMORYREAD_SIZE and IARG_MEMORYWRITE_SIZE to the instrumentation, but that looks pretty trivial to do.

Upvotes: 1

Related Questions