[plt-scheme] Suggestion: Backtrace Remembers Last, not First Tail-Recursive Procedure

From: Synx (plt at synx.us.to)
Date: Thu Apr 8 02:07:32 EDT 2010

On 04/07/2010 08:01 PM, Matthew Flatt wrote:
> The built-in backtrace does keep track of the most recent call, only.
> A typical reason that functions disappear in the stack trace is inlining
> by the compiler.

Oh, I hadn't considered inlining. Dang...

 Could it be that `stat:fold-files' and the functions
> that call it are all inlined into `main'?

It's possible. Does PLT do inlining on procedures across different modules?

> In general, the backtrace that you get from the core system (as opposed
> to one from DrScheme in debugging more or from `errortrace') is
> approximate, and it can be affected in lots of ways by optimization.
> It's definitely in the "vague and heuristic" category.

Yeah I struggle with it a lot. End up putting a bunch of "display"
statements in my code to try to find out just how far it's getting. I
hadn't considered inlined procedures though. If I could disable
inlining, but preserve tail-call optimization, I wouldn't blow my stack
but could still more accurately debug programs.

Thanks for mentioning errortrace. I hadn't known about that before. All
I knew was Drscheme's "debug" mode. I'll probably stick with the latter
though, for the easily clickable stack traces. I bet there's a flag I
can enable in drscheme that disables that "inlining" behavior that I
thought was simply optimizing out the wrong procedure name in tail calls.

Posted on the users mailing list.