Stack Trace
MilchRatchet opened this issue · comments
I figured out how I could implement a pseudo stack trace tacker. I simply keep a static stack of strings containing the name of the function. Then whenever a function is entered we call a function that puts the name of the function onto the stack. Whenever a crash_message call happens we can then print the whole stack. This should be quite elegant and performant since we could simply allocate a large enough stack so reallocation are never necessary. The only issue is that we need to keep track of when a function returnes. It would be simple to just add a function call at the end of each function but that would be messy and error prone. With that said I am not quite sure yet how else to do that.
foo* bar(...) {
PUSH_FUNC();
/* Do very exquisite instruction execution */
POP_FUNC();
return foobar;
}
One way to resolve the pop is as follows:
#define return POP_FUNC(); return
However, this has some issues as things like
if (foo)
return bar;
would no longer work. Also this means we would have to add the stack trace feature to every small function which could be detrimental to performance.
Due to this, I think this is something that while it is interesting, is mostly superflous and probably a bad idea. This issue will be closed.