I have been using part of the code of msos to display the disassembly code for BenchmarkDotNet and I have realized, that always the last line of source code was printed.
The bug fix was trivial: when you find smaller distance, set the current distance to it. So far the value of distance was always int.Max, so the value of if (dist < distance) was always true, so the loop was going to the end, and returning the last line.
I also added more defensive way of looking for the source lines in the file, which can handle "nop" (clrmd reports some another magic number for it)
I implemented the support for printing epilogue. It looks like always the first element of method.ILOffsetMap with ILOffset == -2 is prolog, and the last one with ILOffset == -3 is epilogue.
Hi!
I have been using part of the code of msos to display the disassembly code for BenchmarkDotNet and I have realized, that always the last line of source code was printed.
The bug fix was trivial: when you find smaller distance, set the current distance to it. So far the value of distance was always int.Max, so the value of
if (dist < distance)
was always true, so the loop was going to the end, and returning the last line.I also added more defensive way of looking for the source lines in the file, which can handle "nop" (clrmd reports some another magic number for it)
I implemented the support for printing epilogue. It looks like always the first element of
method.ILOffsetMap
withILOffset == -2
is prolog, and the last one withILOffset == -3
is epilogue.