Questions tagged [backtrace]

A backtrace is the series of currently active function calls for the program.

On linux and mac, it is possible to obtain the backtrace using the backtrace() function.

417 questions
293
votes
10 answers

How to get name of calling function/method in PHP?

I am aware of function debug_backtrace, but I am looking for some ready to use implementation of function like GetCallingMethodName()? It would be perfect if it gave method's class too (if it is indeed a method).
Dawid Ohia
  • 16,129
  • 24
  • 81
  • 95
225
votes
4 answers

How do I get the backtrace for all the threads in GDB?

Is there an equivalent command in GDB to that of WinDbg's !process 0 7? I want to extract all the threads in a dump file along with their backtraces in GDB. info threads doesn't output the stack traces. So, is there a command that does?
srikantha ks
  • 2,251
  • 2
  • 13
  • 3
106
votes
5 answers

How to make backtrace()/backtrace_symbols() print the function names?

The Linux specific backtrace() and backtrace_symbols() allows you to produce a call trace of the program. However, it only prints function addresses, not their names for my program. How can I make them print the function names as well ? I've tried…
Lyke
  • 4,575
  • 6
  • 27
  • 26
55
votes
12 answers

How can I get PHP to produce a backtrace upon errors?

Trying to debug PHP using its default current-line-only error messages is horrible. How can I get PHP to produce a backtrace (stack trace) when errors are produced?
chaos
  • 122,029
  • 33
  • 303
  • 309
49
votes
3 answers

Win32 - Backtrace from C code

I'm currently looking for a way to get backtrace information under Windows, from C code (no C++). I'm building a cross-platform C library, with reference-counting memory management. It also have an integrated memory debugger that provides…
Macmade
  • 52,708
  • 13
  • 106
  • 123
46
votes
6 answers

How can I save a PHP backtrace to the error log?

I'm using this right now: error_log(serialize(debug_backtrace())); But I have to unserialize it every time. Is there a better way to store backtraces?
Leo Jiang
  • 24,497
  • 49
  • 154
  • 284
35
votes
3 answers

How to unwind the stack to get backtrace for the specified stack pointer (SP)?

I'm writing this for Android (ARM only), but I believe the principle is the same for generic Linux as well. I'm trying to capture the stack trace from within the signal handler, so that I can log it when my app crashes. This is what I've come up…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
35
votes
1 answer

What is the meaning of question marks '?' in Linux kernel panic call traces?

The Call Trace contains entries like that: [] FunctionName+0xAB/0xCD [module_name] [] ? AnotherFunctionName+0x12/0x40 [module_name] [] ClearFunctionName+0x88/0x88 [module_name] What is the meaning of the '?' mark…
qdot
  • 6,195
  • 5
  • 44
  • 95
31
votes
2 answers

Is it possible to print a backtrace in Rust without panicking?

Is it possible to print a backtrace (assuming RUST_BACKTRACE is enabled) without panicking? It seems that the only way of doing that is calling via panic!. If not, is there a reason for it?
ynimous
  • 4,642
  • 6
  • 27
  • 43
30
votes
2 answers

Can one use libSegFault.so to get backtraces for SIGABRT?

The magic incantation LD_PRELOAD=/lib/libSegFault.so someapp runs someapp with libSegFault.so providing backtrace information on a SIGSEGV as described in many different places. Other than using signal(7)-like approaches to cause SIGABRT to invoke…
Rhys Ulerich
  • 1,242
  • 1
  • 12
  • 28
29
votes
4 answers

How to include C backtrace in a kernel module code?

So I am trying to find out what kernel processes are calling some functions in a block driver. I thought including backtrace() in the C library would make it easy. But I am having trouble to load the backtrace. I copied this example function to…
ndasusers
  • 1,131
  • 2
  • 10
  • 6
28
votes
1 answer

What's the difference between a stack-trace and a back-trace?

I really though I'd find an answer online, but I couldn't. Is there any difference at all? People say a 'backtrace' is generated upon something throwing an exception, while a stack trace is a list of method calls from the point when the application…
daremkd
  • 8,244
  • 6
  • 40
  • 66
26
votes
1 answer

What exactly happens when compiling with -funwind-tables?

From: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html -fexceptions: Enable exception handling. Generates extra code needed to propagate exceptions. For some targets, this implies GCC generates frame unwind information for all…
Pendyala
  • 585
  • 1
  • 6
  • 17
25
votes
2 answers

How to pass RUST_BACKTRACE=1 when running a Rust binary installed in Debian?

When I run a binary using cargo, I have the option to run it as follows - bash -c "RUST_BACKTRACE=1 cargo run --bin my_binary" This gives me a stack trace when the binary hits an error. But when I create a Debian package for the same binary, how…
Rajeev Ranjan
  • 3,588
  • 6
  • 28
  • 52
24
votes
3 answers

Wrong line numbers from addr2line

I try to find the exact line of a call in the backtrace in C++ program. Right now I am using these lines (from the man page of backtrace) to get the trace: void *bt_buffer[1000]; char **bt_strings; int bt_nptrs = backtrace(bt_buffer, 1000); …
steffen
  • 8,572
  • 11
  • 52
  • 90
1
2 3
27 28