Questions tagged [stack-trace]

A report of the active stack frames at a certain point in time during the execution of a program.

A stack trace is a report of the active stack frames at a certain point in time during the execution of a program and is often referred to as a stack backtrace.

A stack trace is commonly used during interactive and post-mortem debugging. It typically lists all the functions awaiting return values on the stack at the time of the error. By examining what is on the stack and comparing it to what you expect, you can often determine how the error occurred. By inspecting the function containing the error, you may be able to edit and correct the problem.

A stack trace allows to track the sequence of nested functions called up to the point where the stack trace is generated. In a post-mortem scenario this is up to function where the failure occurred (but not necessarily is caused there). Sibling function calls are not visible in a stack trace.

Before you start

Please browse the list of frequently asked questions to see if your question is similar to one that has already been answered.

The tag should be used to mark questions related to generating, interpreting, debugging, or otherwise understanding stack traces.

2320 questions
1700
votes
32 answers

How can I convert a stack trace to a string?

What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace?
ripper234
  • 222,824
  • 274
  • 634
  • 905
1113
votes
23 answers

How can I get the current stack trace in Java?

How do I get the current stack trace in Java, like how in .NET you can do Environment.StackTrace? I found Thread.dumpStack() but it is not what I want - I want to get the stack trace back, not print it out.
ripper234
  • 222,824
  • 274
  • 634
  • 905
782
votes
7 answers

What is a stack trace, and how can I use it to debug my application errors?

Sometimes when I run my application it gives me an error that looks like: Exception in thread "main" java.lang.NullPointerException at com.example.myproject.Book.getTitle(Book.java:16) at…
Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
766
votes
30 answers

How do I obtain crash-data from my Android application?

How can I get crash data (stack traces at least) from my Android application? At least when working on my own device being retrieved by cable, but ideally from any instance of my application running on the wild so that I can improve it and make it…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
701
votes
25 answers

How can I get a JavaScript stack trace when I throw an exception?

If I throw a JavaScript exception myself (eg, throw "AArrggg"), how can I get the stack trace (in Firebug or otherwise)? Right now I just get the message. edit: As many people below have posted, it is possible to get a stack trace for a JavaScript…
David Wolever
  • 148,955
  • 89
  • 346
  • 502
687
votes
31 answers

How to automatically generate a stacktrace when my program crashes

I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace. My program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are…
KPexEA
  • 16,560
  • 16
  • 61
  • 78
640
votes
12 answers

How to print a stack trace in Node.js?

Does anyone know how to print a stack trace in Node.js?
mike.toString
  • 6,409
  • 2
  • 16
  • 3
633
votes
18 answers

How can I find the method that called the current method?

When logging in C#, how can I learn the name of the method that called the current method? I know all about System.Reflection.MethodBase.GetCurrentMethod(), but I want to go one step beneath this in the stack trace. I've considered parsing the stack…
flipdoubt
  • 13,897
  • 15
  • 64
  • 96
605
votes
12 answers

Get exception description and stack trace which caused an exception, all as a string

How to convert a caught Exception (its description and stack trace) into a str for external use? try: method_that_can_raise_an_exception(params) except Exception as e: print(complete_exception_description(e))
bluish
  • 26,356
  • 27
  • 122
  • 180
440
votes
14 answers

How do I find the caller of a method using stacktrace or reflection?

I need to find the caller of a method. Is it possible using stacktrace or reflection?
Sathish
  • 20,660
  • 24
  • 63
  • 71
428
votes
7 answers

Print current call stack from a method in code

In Python, how can I print the current call stack from within a method (for debugging purposes).
oneself
  • 38,641
  • 34
  • 96
  • 120
425
votes
7 answers

How to print the current Stack Trace in .NET without any exception?

I have a regular C# code. I have no exceptions. I want to programmatically log the current stack trace for debugging purpose. Example: public void executeMethod() { logStackTrace(); method(); }
Ricibald
  • 9,369
  • 7
  • 47
  • 62
393
votes
29 answers

Showing the stack trace from a running Python application

I have this Python application that gets stuck from time to time and I can't find out where. Is there any way to signal Python interpreter to show you the exact code that's running? Some kind of on-the-fly stacktrace? Related questions: Print…
Seb
  • 17,141
  • 7
  • 38
  • 27
392
votes
7 answers

When I catch an exception, how do I get the type, file, and line number?

Catching an exception that would print like this: Traceback (most recent call last): File "c:/tmp.py", line 1, in 4 / 0 ZeroDivisionError: integer division or modulo by zero I want to format it into: ZeroDivisonError, tmp.py, 1
Claudiu
  • 224,032
  • 165
  • 485
  • 680
325
votes
16 answers

Print PHP Call Stack

I'm looking for a way to print the call stack in PHP. Bonus points if the function flushes the IO buffer.
Justin
  • 9,419
  • 7
  • 34
  • 41
1
2 3
99 100