Debugging Information

Hello there!

For a long time, we have been thinking about how to improve the debugging experience by providing more information about the structure of the bytecode. We would like to tackle this big problem incrementally, and because of that, I would like to ask which information would provide the biggest benefit.

We are currently thinking about the following:

  • provide a list of byte offsets of internal function entry points
  • for each function, provide a list of local variables together with
    • the byte offsets of their lifetime (plus the point from which on their are fully initialized)
    • their stack offset relative to function start
  • for each opcode, list the AST nodes they were generated from (instead of just the source location)

All of the above get more complicated and are maybe not even correct anymore if the optimizer is activated.

Also, do you have other ideas about meta-information you would like to extract from the compiler?


This sounds great!

I think the other big thing I would want to see is jump tags on non-jump instructions, as discussed on this PR. This would be useful not only for functions inlined by the optimizer but also constructors, fallback functions, etc.

I think the big question to my mind is, how would lifetimes work with modifiers? For Truffle Debugger, other than optimized code, this is the trickiest case. Lifetimes would seem to be something of a problem for modifiers due to the fact that modifiers are inlined into their respective functions rather than being jumped to. And it’s not just lifetimes; for instance, stack offsets are complicated by the potential for the same modifier to be used on the same function multiple times (something I’ve actually seen in the wild, although I forget where), or to be used both on a constructor and its base constructor. Basically, modifiers are tricky, and so you’d have to make sure that whatever you come up with also works for them. (Really, modifiers are the only thing I’m not confident we get right at the moment… except for optimized code, but you said that this info might also not work for optimized code, so…)