Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans:
Using the Right Debugging Tools
Oct 10, 2018 @ 14:47:42

Derick Rethans has a new post with his own suggestion about using the right debugging tools to help track down a problem (based on some of his own experience debugging the MongoDB PHP extension).

A while ago, we updated the MongoDB PHP driver's embedded C library to a new version. The C library handles most of the connection management and other low level tasks that the PHP driver needs to successfully talk to MongoDB deployments, especially in replicated environments where servers might disappear for maintenance or hardware failures.

After upgrading a related library, he ended up with a failing test related to Atlas connectivity. He walks through the process he took to try and debug the issue using GDB to see where the execution was failing using various techniques. This included looking through the backtrace and, not noticing anything out of the ordinary, going for a walk. Upon returning he noticed an odd line in the backtrace that, after some additional tracking using a GDB helper, showed the problem to be with how the query options are defined and not reset in a loop.

tagged: debugging tools gdb mongodb driver backtrace execution

Link: https://derickrethans.nl/debugging-with-tools.html

Phil Sturgeon's Blog:
Power dump() on your PHP applications
Sep 30, 2010 @ 16:04:03

Phil Sturgeon has a quick new post with a code snippet that could make your debugging life a bit simpler - a "dump" function that can give you a bit more information about your error than a standard var_dump.

When trying to work out what the hell is going wrong in your PHP application the first thing most of us start doing is madly start var_dump()'ing everything possible to work out where the problem is. var_dump() is fine, but by default it comes out in one line. So then we need to echo <pre> tags. Then we can't always see whats going on, especially if the background is black and bla bla bla so it goes on.

He mentions an alternative like XDebug, but that also requires access to install it on the server. His alternative, the "dump" function, catches the error, pulls out a backtrace of the path your script took to get there and echoes it out with the line number of the error and filename.

tagged: debug snippet vardump backtrace

Link:

Derick Rethans' Blog:
PHP's segmentation faults GDB-fu
Oct 08, 2008 @ 14:32:09

Derick Rethans has shared a quick tip for locating a code crashing kind of problem with your application when something like XDebug isn't around.

However, because we as PHP developers are lazy, provide a few GDB tricks to make this easier. First of all, it's only really going to work if you haven't stripped the symbols from your PHP and Apache binaries. Secondly, you still need to have the PHP source lying around somewhere.

He suggests using GDB to run the backtraces and create a file to help you track down the infinite recursion problem that could be giving you issues.

tagged: segfault gdb infinite recursion source backtrace

Link:

Pierre-Alain Joye's Blog:
How to generate backtraces on windows without compiler
Jun 11, 2007 @ 16:08:00

In a new tutorial posted to his blog today, Pierre-Alain Joye shows how to generate backtraces on a Windows machine without the need for a compiler installed.

How to get a back trace on windows without having to compile PHP has been an impossible task for many of us. The difficulty was to first succeed to compile php (given that you have a visual C++ installed). If you are in the middle of a bug hunting session, no need to say that setting up a windows build system is the last thing you like, especially if it is your first time. Thanks to Edin's window binary and MS Diagnostic Debug , it is now possible to have a backtrace in a couple of clicks.

To use the method you will need a few pieces of software to help out but all are available for free. Next up are the steps to get things set up (simple) and the creation of the backtrace to catch the error, complete with screenshots for the whole way. The end result is a nice, pretty error message output to the browser (Internet Explorer) that also dumps the backtrace for you to use.

tagged: backtrace windows compiler debug diagnostic tool screenshot backtrace windows compiler debug diagnostic tool screenshot

Link:

Pierre-Alain Joye's Blog:
How to generate backtraces on windows without compiler
Jun 11, 2007 @ 16:08:00

In a new tutorial posted to his blog today, Pierre-Alain Joye shows how to generate backtraces on a Windows machine without the need for a compiler installed.

How to get a back trace on windows without having to compile PHP has been an impossible task for many of us. The difficulty was to first succeed to compile php (given that you have a visual C++ installed). If you are in the middle of a bug hunting session, no need to say that setting up a windows build system is the last thing you like, especially if it is your first time. Thanks to Edin's window binary and MS Diagnostic Debug , it is now possible to have a backtrace in a couple of clicks.

To use the method you will need a few pieces of software to help out but all are available for free. Next up are the steps to get things set up (simple) and the creation of the backtrace to catch the error, complete with screenshots for the whole way. The end result is a nice, pretty error message output to the browser (Internet Explorer) that also dumps the backtrace for you to use.

tagged: backtrace windows compiler debug diagnostic tool screenshot backtrace windows compiler debug diagnostic tool screenshot

Link:

J. Scott Johnson's Blog:
Your PHP Command of the Day - debug_backtrace()
Apr 12, 2006 @ 11:57:04

J. Scott Johnson shares, in this new blog post, about a handy little function that any PHP developer out there would do well to remember when it comes to debugging their code - debug_backtrace.

When you’re massively and rapidly refactoring a code base, mere hours before a demo* and you utterly and completely hose yourself then just plain trot out debug_backtrace() and whammo! Your debugging problems go away!

This function generates a backtrace from the function it's inside, making it easy to tracke backwards the path that the data's taking to get to that location. Very handy for tracking down which functionality it is that's causing the issues...

tagged: command day debug_backtrace generate backtrace command day debug_backtrace generate backtrace

Link:

J. Scott Johnson's Blog:
Your PHP Command of the Day - debug_backtrace()
Apr 12, 2006 @ 11:57:04

J. Scott Johnson shares, in this new blog post, about a handy little function that any PHP developer out there would do well to remember when it comes to debugging their code - debug_backtrace.

When you’re massively and rapidly refactoring a code base, mere hours before a demo* and you utterly and completely hose yourself then just plain trot out debug_backtrace() and whammo! Your debugging problems go away!

This function generates a backtrace from the function it's inside, making it easy to tracke backwards the path that the data's taking to get to that location. Very handy for tracking down which functionality it is that's causing the issues...

tagged: command day debug_backtrace generate backtrace command day debug_backtrace generate backtrace

Link:


Trending Topics: