How can one grab a stack trace in C?
glibc provides backtrace() function. http://www.gnu.org/software/libc/manual/html_node/Backtraces.html
glibc provides backtrace() function. http://www.gnu.org/software/libc/manual/html_node/Backtraces.html
Edit 2 (2017): In all modern browsers you can simply call: console.trace(); (MDN Reference) Edit 1 (2013): A better (and simpler) solution as pointed out in the comments on the original question is to use the stack property of an Error object like so: function stackTrace() { var err = new Error(); return err.stack; } … Read more
Andrew Grant’s answer does not help getting a stack trace of the throwing function, at least not with GCC, because a throw statement does not save the current stack trace on its own, and the catch handler won’t have access to the stack trace at that point any more. The only way – using GCC … Read more
I have module I use for situations like this – where a process will be running for a long time but gets stuck sometimes for unknown and irreproducible reasons. Its a bit hacky, and only works on unix (requires signals): import code, traceback, signal def debug(sig, frame): “””Interrupt running process, and provide a python prompt … Read more
Go into the Properties window for the project where you want to see stack trace line numbers. Click on the Build “vertical tab”. Select “Release” configuration. Check the DEBUG constant parameter. Uncheck the “Optimize code” parameter to avoid the occasional trace issue with inlined code (this step is not essential). Press the Advanced… button and … Read more
You might try the ACRA (Application Crash Report for Android) library: ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form. It is targetted to android applications developers to help them get data from their applications when they crash or behave erroneously. It’s easy to install in your … Read more
You can use Thread.currentThread().getStackTrace(). That returns an array of StackTraceElements that represent the current stack trace of a program.
For Linux and I believe Mac OS X, if you’re using gcc, or any compiler that uses glibc, you can use the backtrace() functions in execinfo.h to print a stacktrace and exit gracefully when you get a segmentation fault. Documentation can be found in the libc manual. Here’s an example program that installs a SIGSEGV … Read more
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace() According to the Javadocs: The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence. A StackTraceElement has getClassName(), getFileName(), getLineNumber() and getMethodName(). You will have to experiment to determine which index you want (probably stackTraceElements[1] or [2]).
This error can occur when the local network system aborts a connection, such as when WinSock closes an established connection after data retransmission fails (receiver never acknowledges data sent on a datastream socket). See this MSDN article. See also Some information about ‘Software caused connection abort’.