Get stack trace
-
Hi.
I have an error on my application, it doesn't crash, it just calls a function when it shouldn't, but this function is called from many places and I want to kwnow where is this function called, so I want to save the stack trace in a file.
Is there any way to get the stack trace?
Thanks.
-
Hi Gerolf.
I saw debuging tools in Qt creator are great!, but in this case I can't debug, it's an occasional error we can't reproduce any time we want, and it's a remote device and debuging does application go very slow and it needs to send frames in high frequency. I can execute my application compiled in debug mode.
I would like to print stack trace like debuging does it.
I'm using Linux (Debian 7.6).Thanks.
-
AFAIK, that is not possible without instrumenting your application. A debugger would do that, but you could also create your own. It is a PITA though.
We've build some code that we can use for similar cases. The idea is that you keep around a thread-global stack of function names. In every function that you wish to include in your stack, you make sure that at the start of that function (or scope, if you wish) you push the name of the function on to the stack, and you pop it off again on exit of the function. A RAII approach for making sure the pop actually happens is recommended.
You'll need to put such a statement everywhere where you suspect code may pass that eventually leads to your wrong function call. At the location of the wrong function call, you can then dump the contents of the stack to a log file.
-
Hi and welcome to devnet,
What about inspecting it with "GammaRay":http://www.kdab.com/kdab-products/gammaray/ ?