I'm trying to debug an error that the client has reported to us. The stacktrace only has byte offsets, not line numbers.
e.g.
[NullReferenceException: Object reference not set to an instance of an object.]
Foo.Bar(FooFoo p) +32
Foo.BarBar() +191
Foo.BarBarBar() +15
How can I reverse engineer these byte offsets into lines of code / method calls etc?
How can I find where the NullReferenceException is being thrown?
Here is a solution that might work (or may be not :) ). The problem is that the mapping between offset and line numbers is contained in pdb (aka the debug symbols)
ildasm
, either add it to PATH
or copy it somewhere.ildasm /LINENUM /SOURCE YourFile.exe
. It will output IL with offset and source line mapping.The only problem that I see that you will not be able to produce exactly same binaries and mapping might fluctate.
The only tool I can remember off the top of my head would be the .NET Reflector. Open the exactly same binary as your client has in it, and change the language in the Options dialog into IL, and it should show (AFAIK) the same byte offsets as labels on each line.
You'll have to read IL instead of C# or anything though, but it's better than nothing.
Edit: Andreys solution is probably better tho :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With