Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ToString() override to Mono.Cecil.Cil.Instruction #14

Closed
KrisVandermotten opened this issue May 12, 2010 · 3 comments
Closed

Add ToString() override to Mono.Cecil.Cil.Instruction #14

KrisVandermotten opened this issue May 12, 2010 · 3 comments

Comments

@KrisVandermotten
Copy link

It does help a lot when debugging.

One implementation that does seem to work has been suggested already, see
http://permalink.gmane.org/gmane.comp.gnome.mono.cecil/1474

Note that this ToString() method requires instructions offsets to be correct.
Forgive me for repeating an earlier request here: please consider recalculating instruction offsets in the OnX methods of Mono.Cecil.Cil.InstructionCollection

@jbevain
Copy link
Owner

jbevain commented May 12, 2010

Recomputing offsets on the fly is not going to happen. ToString is just a debug helper. If you need to print the instructions for debugging purpose, you can pay the price of recomputing the offsets.

@KrisVandermotten
Copy link
Author

If it's not going to happen, so be it.

It's a shame though. Debugging (by which I mean stepping though code in a debugger, not tracing) is very difficult without a ToString(). And branch instructions are unreadable without a correct offset (and that means correct all the time, not just after I fixed them).

To be precise, the offsets don't need to be correct per se, as long as Instruction.Previous.Offset < Instruction.Offset < Instruction.Next.Offset. The index in the collection would be just fine for this purpose, but that is not available in Instruction.ToString().

Anyway, I forked the code. Turns out the offset fixup in InstructionCollection is actually very easy and fast. Looks like I might spend a lot of time merging. But I'm sure I'll still win by being able to debug efficiently.

Thanks anyway.

@jbevain
Copy link
Owner

jbevain commented May 12, 2010

Of course it's easy, of course it's fast, it's just not necessary for a non debugging scenario. Anyway, this enhancement ticket is about getting an Instruction.ToString, which is in now.

radekdoulik pushed a commit to radekdoulik/cecil that referenced this issue Aug 2, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants