PengYu.UT wrote:
Usually assert only print the current function. But I also need to know
which function called the current function. Is there anyway to make it
print out the whole stack?
There are implementation-specific ways to walk the stack and find each
frame. They suck because finding the name of a function will be super-hard.
You may be familiar with languages designed to be interpreted, such as Java.
Languages designed to compile to machine language optimize much of their
data out.
I can write a system that does it with __FUNCTION__ (which is variously
supported), and a call to a macro at the top of each function to record its
name to a list. However, all of my assertions trigger a debugging
breakpoint. If you run your program in a debugger, it has a system to print
out the stack trace.
(You might also write a test case on the failing function directly, and then
find yourself tracing and debugging less...)
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!