Questions tagged [debug-backtrace]

debug_backtrace() is a PHP function that prints the backtrace.

debug_backtrace() is a PHP function that prints the backtrace. A backtrace is a summary of how your program got where it is. It shows one line per call, for many calls, starting with the currently executing call (call zero), followed by its caller (call one), and on up the stack.

67 questions
1
vote
1 answer

Why does debug_backtrace() return nothing?

I have PHP code in PHP 7.4 Part of this code is a top level PHP script (/home/path/a.php) which contains a bunch of try catch blocks and contains verious calls to objects and include files. These try/catch blocks throw on customer errors and runtime…
Martin
  • 22,212
  • 11
  • 70
  • 132
1
vote
0 answers

Is debug_backtrace() crippled in PHP 8?

While preparing to update to PHP 8, once they have released a new version beyond the broken 8.0.0 (I had to downgrade back to 7.4.x because of an IMAP bug which is allegedly patched now), I read this: debug_backtrace() and Exception::getTrace()…
1
vote
0 answers

Why does debug_backtrace() seem to skip over several important "steps", disabling me from debugging where a FATAL error origins?

My end goal is to be able to properly log "FATAL" errors, which are sadly not "seen" by set_error_handler. Currently, all PHP does is log: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65011744 bytes) in…
1
vote
0 answers

__destruct and debug_backtrace() in PHP

I don't understand why class test { function __destruct() { echo "I am the destructor
"; } function __construct() { $this->a=debug_backtrace(); # <=== THIS LINE } } $myclass=new…
user3636110
  • 166
  • 11
1
vote
1 answer

Why does var_dump(debug_backtrace()) within a method triggers object's __debugInfo()?

Could someone explain me why in the following case: class A { public function methodA() { var_dump(debug_backtrace()); } public function __debugInfo() { return []; } public function __clone() { echo…
tonix
  • 6,671
  • 13
  • 75
  • 136
1
vote
2 answers

What is meant by backtrace in php why we use debug_backtrace() and debug_print_backtrace() functions in php?

I am new to php and learning it from php.net and currently I am reading about debugging using debug_backtrace(). Can anyone tell me what is meant by backtrace and why we use debug_backtrace() and debug_print_backtrace() functions in php ?
Stack Overflow
  • 1
  • 5
  • 23
  • 51
1
vote
2 answers

Proper way of tracing error line and file nr. with debug_backtrace() in custom function that uses custom error handle method

I have made custom error handler (see below) that works just fine. I added method add() that is used to print and log error. Basically it handles all the PHP registered errors. I tried to add add_error() function outside the class, for more…
richardev
  • 976
  • 1
  • 10
  • 33
1
vote
0 answers

Issues when combining debug_backtrace with auto_prepend_file

I have a PHP script that will allow me to track which file required it via debug_backtrace(). I wanted to auto prepend (Via auto_prepend_file within php.ini) the file so then I could build a log of the frequency in which each PHP script is ran for…
Ron
  • 181
  • 3
  • 12
1
vote
1 answer

What state of function arguments does debug_backtrace() capture?

Some abstract code: function test($a = 5) { debug_backtrace(); a = 10; } What will debug_trace tell us about arguments of the test function? Will it capture $a as 5 or 10?
mvlabat
  • 577
  • 4
  • 17
1
vote
1 answer

php debug_backtrace() to string with some objects inside the result

I want to debug an application with debug_backtrace() in the __set function. As I need it as a string I tried it with $myStringVar = print_r(debug_backtrace(),true); But this doesn't work. I found out that there are some objects in my array that…
Keksdose
  • 17
  • 6
1
vote
0 answers

Apache/PHP segmentation fault in debug_backtrace()

When performing a specific action in a Drupal project, PHP crashes. In /var/log/apache2/error.log, I can see: [Wed Jul 08 09:51:13.068078 2015] [core:notice] [pid 9130] AH00051: child pid 9135 exit signal Segmentation fault (11), possible coredump…
Sébastien
  • 2,236
  • 2
  • 20
  • 28
1
vote
3 answers

Trying to debug a symfony app showing the list of all the functions called, debug_backtrace() doesn't fits me

im trying to debug a symfony app. I've added a debug_backtrace() calling to this function below. It outputs a list of functions called, but the save() function (that is just before the debug_backtrace() calling) is not that list.. why? any other way…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
1
vote
1 answer

How to get call trace from all CPU's in a multi-core platform

I have a requirement to dump CPU back-trace of all the CPU's. In linux we have dump_stack which can be used to dump the stack of current cpu. My requirement is to print the call stacks of the processes running on all the CPU'S(4 CPU's in my case).…
Sandeep
  • 18,356
  • 16
  • 68
  • 108
1
vote
1 answer

Stack trace from backtrace didn't show method that caused the crash under multithreaded enviroment

I was trying to capture exactly which method, or at least which class crashed my code from messages returned by backtrace after received the SIGSEGV signal. Is it because the crashed method was executing on another thread, therefore backtrace was…
Bryan Fok
  • 3,277
  • 2
  • 31
  • 59
0
votes
0 answers

`debug_backtrace()` reports abstract classes in trace rather than concrete classes. Is there a fix?

I wrote the following code which turns the result of debug_backtrace() into a string: function debug_backtrace_string($skip = 1) { try { $calls = debug_backtrace(); $calls = array_slice($calls, $skip); $str = []; …
Jodes
  • 14,118
  • 26
  • 97
  • 156