Hacker News new | ask | show | jobs
by Jtsummers 2100 days ago
It could be an option when debugging like adding a trace to your function calls. And the amount of tracing (how much is stored) could be configured.

Depending on the loop syntax, presumably you'd want to know (in the case of a for loop) what variables are initialized, what the test condition is and its result, and what is altered. But, in the case of C for loops as an example, this wouldn't be easy to automate since the user can always do something like:

  for(;;) {
    if(condition) break;
    // other logic
  }
In the best case (which would be the most data-ful case and hardest to use) you'd log all changes that occur within the loop. What you really want would be smaller, like detecting the break and the condition leading to it and watch that.

More realistically, you probably want to document your loop invariants with assertions which could be optionally recorded in your trace output.

1 comments

This sounds like watchpoints which can be used both for loops and (tail-)recursive functions.