0

I got a WSOD (white screen of death) in my Drupal site for a single page for a single user. I have learned that it is due to segmentation error. I couldnt spot where the error is?? How do I debug my PHP code using gdb???

ceejayoz
  • 176,543
  • 40
  • 303
  • 368

4 Answers4

2

In extreme circumstances, I end up using Linux strace, but I do this mainly when the issue concerns internal stuff (such as headers, stack issues and crashes).

The more PHP-esque way is to use xdebug, since it's specifically for PHP.

To use GDB, use like any other program you would use under GDB. If you can't get that far, I'm pretty sure you won't get far in actually using GDB either.

Oh, and here's a life-saver PHP snippet:

function the_end(){
    if(($err=error_get_last()))
        die('<pre>'.print_r($err,true).'</pre>');
}
register_shutdown_function('the_end');

Note 1: If you're dealing with server crashes, there's a good chance the above won't work. This is quite rare though.

Note 2: If register_shutdown_function is already used elsewhere, be sure to repeat it, in order to ensure final execution, example:

function my_other_final_function(){ /* ... */ }
register_shutdown_function('my_final_function');

function the_end(){ /* ... */ }
function the_end2(){ register_shutdown_function('the_end'); }
register_shutdown_function('the_end2');
Christian
  • 27,509
  • 17
  • 111
  • 155
0

I dont know how to do it with gdb, but this could be usefull:

index.php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

And i guess XDebug could help you further

Strae
  • 18,807
  • 29
  • 92
  • 131
0

I tried to set display_errors true for the site which didnt work for me. But luckily I didnt have to go for the debugging, issue was with view that I had created.

Thank you all

-1

The error is most likely in you web server error logs. Look there first.

Dave
  • 385
  • 1
  • 3
  • If it's a segmentation fault, as described in the post, the web server's error logs aren't going to be at all useful. – ceejayoz Mar 28 '11 at 17:59