|
||||
Title: Stack Trace Information Post by nks on Aug 11th, 2010, 7:53am How can I find stack trace info without using any system function? Ex f1(){ .. f2(); } f2(){ f3(); } When we say f3.It should track f3->f2->f1. |
||||
Title: Re: Stack Trace Information Post by Grimbal on Aug 11th, 2010, 9:13am In what language? If f3() is a function, what is f3.It? |
||||
Title: Re: Stack Trace Information Post by nks on Aug 11th, 2010, 10:19am In C/C++. f3() is also a function called in f2(). |
||||
Title: Re: Stack Trace Information Post by towr on Aug 11th, 2010, 10:53am You could make a global stack and have every function push its name on when it is called, and have them take it off when they're done. Or you could do something incredibly dirty like trying to read the function stack, by working down from the address of the parameters or something. |
||||
Title: Re: Stack Trace Information Post by Grimbal on Aug 11th, 2010, 2:58pm Do you mean to call the "show stack" function from within the call to f3, in which case I second towr's propositions, or do you mean to call f3 as an argument? In that case it is a matter of analyzing the source code and finding call references, which may not be unique. |
||||
Title: Re: Stack Trace Information Post by nks on Aug 11th, 2010, 6:42pm Quote:
You mean I need to push the function name in stack before calling the function? In that way I need to modify the existing function. Is there any way I can do it without modification of existing function? |
||||
Title: Re: Stack Trace Information Post by Grimbal on Aug 12th, 2010, 1:06am But are you willing to modify f3? You could run your program in a debugger, you can then set a breakpoint in f3, it will display the stack trace. In java there is a library function that returns the stack trace. I guess such a library exists in C/C++. It could do so without calling the OS, since all necessary data is on the stack. So it wouldn't be a system call. What is the context? What is it you are trying to do? |
||||
Title: Re: Stack Trace Information Post by nks on Aug 16th, 2010, 5:47pm Sorry for late reply. Quote:
No. Existing function is not supposed to modify. Yes there is function stacktrace() in c/c+. But All the compiler may not have this. Quote:
I m wriying plugin which maintains the execution path in server. |
||||
Title: Re: Stack Trace Information Post by Grimbal on Aug 20th, 2010, 7:07am If you are worrying stacktrace() might not be available everywhere, that means you want it portable. But your only chance to make it portable is to have the compiler or the runtime library get the information for you. |
||||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |