[mono-cecil] Instrumenting IL code for heap memory access logging

35 views
Skip to first unread message

JochenHuck

unread,
Nov 4, 2011, 10:02:05 AM11/4/11
to mono-cecil
Hi,

I am new to Cecil and therefore I want to clarify if Cecil fits my
needs. This is what I want to do:

I assume a working C# application with source code.

I need a tool that determines if a pair of methods is heap memory
dependent. A pair of methods is heap memory dependent if both methods
access the same heap memory location. I also want to know the kind of
dependence (read-read, read-write, write-write).

I assume it it possible to collect this information during runtime by
instrumenting the IL code before running the applicaion (as opposed to
IL rewriting with the .NET profiling API).

I think that the tool would need to instrument the application by:
- finding every load and store operation that affects heap memory
- pushing the address of the load or store operation onto the stack
- calling a logger function that consumes this address

My questions are:
- Is this the right way?
- Is it possible to instrument IL code this way with Cecil?
- If it is possible - how tricky is it? Do I have to care about tiny/
fat methods, structured exception handling offset recalculation etc?
(This question is inspired by this article:
http://msdn.microsoft.com/en-us/magazine/cc188743.aspx)

Thanks in advance,
Jochen Huck
Reply all
Reply to author
Forward
0 new messages