private void InstrumentMethodAtThrow(CilWorker worker, Instruction throwInstruction, MethodReference profilerMethod) { Instruction newThrowInstruction = worker.Create(throwInstruction.OpCode); throwInstruction.OpCode = OpCodes.Call; throwInstruction.Operand = profilerMethod; worker.InsertAfter(throwInstruction, newThrowInstruction); }
private void InstrumentMethodAtReturn(CilWorker worker, Instruction exitInstruction, MethodReference exitingMethod, MethodDefinition methodToInstrument) { exitInstruction.OpCode = OpCodes.Ldstr; exitInstruction.Operand = MethodName(methodToInstrument); Instruction callToProfiler = worker.Create(OpCodes.Call, exitingMethod); worker.InsertAfter(exitInstruction, callToProfiler); worker.InsertAfter(callToProfiler, worker.Create(OpCodes.Ret)); }