Slightly structured plain text to enable lightweight, language-agnostic time-travel debugging #14
Replies: 7 comments 16 replies
-
Hi Kartik! That's a cool idea! I've done something along those lines for my temporal programming environment Quadrant, where metadata about blocks of code are embeded into the compiled bytecode, and the runtime can signal the execution of each block. Currently I'm only using that to highlight blocks in the editor as they are executed, but it would also allow for logging and replay in the future. It seems you intend to define meaningful "units" of execution on a line-by-line basis. What about statements that are broken into multiple lines for readability, or lines that contain multiple meaningful chunks of execution (e.g. several calls that are part of a larger expression)? Granted, it's also a problem with standard debuggers since they're line based, but since you're intending to use a more structured format, that's maybe something to take into consideration. I also think being able to log blocks of code (with timestamps) can give you a clearer picture of what's going on compared to having to mentally reconstruct that from a trace of individual lines (but the viewer can also help with that). By the way, what are your thoughts about keeping it plain-text+markers vs. having a more structured format? Since it would need a special-purpose editor to be really useful, it seems to me that plain-text compatibility is not necessarily a strong argument, but maybe there are other reasons for you to prefer a plain-text approach. How would the program provide a way to render datatypes? Would data be serialized into the log, and the client provides callbacks to the debugger to render various data types from the logs? I'm not sure I have a good picture of what you have in mind here, but it does seem interesting. For long execution runs, maybe you could just have the log be a ring buffer, and the time travel is limited to some amout of time in the past, configurable at startup. Anyway, I'm very interested in seeing what you'll come up with! Cheers, Martin |
Beta Was this translation helpful? Give feedback.
-
Thanks for those great questions! I'm glad to see another mind prepared for this strange idea.
|
Beta Was this translation helpful? Give feedback.
-
It might be worth throwing out an alternative approach. Instead of tagging metadata per line, just designate one level of "hidden lines". Positives:
Negatives:
|
Beta Was this translation helpful? Give feedback.
-
hey kartik! |
Beta Was this translation helpful? Give feedback.
-
This looks like a cool project! You mention Smalltalk among the notable project, but I think you should in particular have a look at Beacon (https://github.com/pharo-project/pharo-beacon), well described here. Note in particular the possibility to log stack frames. It's probably the closest in spirit to what you want to do, except that it's for a Smalltalk environment rather than for a text-based language. A nice feature of Beacon is that event sends have a very small overhead. You can leave them in your code and just remove the listener, which is the costly part (because it stores all events). |
Beta Was this translation helpful? Give feedback.
-
[just lurking] Obligatory mention to Jonathan Edwards's demo of Reified execution idea (even if people here are likely aware of it). |
Beta Was this translation helpful? Give feedback.
-
@akkartik |
Beta Was this translation helpful? Give feedback.
-
2 weeks before jam
Status: still welcoming collaborators. Leave a comment if you're interested.
Platform and tools: I'm thinking Lua and LÖVE. It's fast enough, it's been easy to get up and running and the docs are excellent.
Debugging tools today tend to be language-specific, require lots of knowledge of the internals of a language runtime, and therefore the tools tend to be quite complex even without including the ability to go backwards in time. The focus is on debugging heavyweight programs with low overhead, and the predominant paradigm is to slow time down and permit stopping at specific lines (breakpoints). Time-travel debugging remains esoteric, as do user-configurable views of datatypes.
A complementary approach is debug by print. It requires no tooling support and naturally lays out a program run over time. However, you have to choose to either clutter up your codebase with debug prints (maybe disabled) or delete them and re-add them every time, which makes it harder to disseminate debugging tricks.
In this project I'd like to explore a way to address the drawbacks of debug by print for a simple, extensible, language-agnostic debug framework that renders logs over time using user-definable views of datatypes while putting up with potentially significant overheads in run time and disk space.
Experience
In brief, the experience will look like this:
Code to render datatypes will be completely open to and extensible by the source codebase.
Drawbacks
Handmade projects
Notable projects
gdb
allegedly supports time-travel debugging. I kicked the wheels on it 12 years ago and couldn't get it working. It's not clear if there's been any progress since.ddd
is a frontend togdb
that supports graphical views of datatypes that are smart enough to traverse pointers. No time-travel, though.rr
is now a commercial tool for time-travel debugging in C. Again, this is a heavyweight tool. Lots of engineering effort devoted to minimizing debug overhead for large applications. It doesn't look like it supports graphical views of datatypes.Smalltalk and Glamorous Toolkit are excellent at user-configurable views of data. They also seem to have all the tools needed to support debug by print with their notion of transcripts. Programming in Smalltalk is an incomparable experience, but you do have to program in Smalltalk. It's also not exactly lightweight. There's a non-trivial learning curve.
Details for the jam
Simplifying assumptions to manage scope
print
/log
statements in the source language.;
. Lua has the nice property that the grammar is always unambiguous even without any statement separator, so that we can just delete some tokens usingsed
.Open questions
for
statements naturally span multiple lines. What does it mean to "run" a line containing thefor
keyword. I think the metadata should trigger on every iteration through the loop. This might be a lot of work, though.Beta Was this translation helpful? Give feedback.
All reactions