Xdebug debugger

Last modified: October 30, 2008 - 01:03

For advanced development a debugger may be very useful. Xdebug is the standard tool.

The main site:

http://xdebug.org/

Some articles on setting up and using it:

http://devzone.zend.com/article/2803-Introducing-xdebug

http://community.activestate.com/faq/how-do-i-get-php-debuggin

This Drupal module has additional tools for visualizing the Xdebug call traces:

http://drupal.org/project/visualize_backtrace

building xdebug.so

I downloaded the php package from php.net at http://www.php.net/downloads.php#v5 For Mac 10.4 and 10.5 I have Xcode installed, which includes gcc and other necessary comilation-related packages.

To build xdebug.so I went to the directory (assuming you unpack the PHP source code archive in your home dir):

~/php-5.2.5/bin/bin

and ran:

$ ./pecl install xdebug

this built xdebug.so and placed it in the direcrtory:
~/php-5.2.5/bin/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

For the particular combination of MAMP + Komodo IDE

For my version of MAMP I copied xdebug.so to the following dir
(final dir name may vary by PHP version):

/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/

make sure Zend optimizer is OFF in MAMP preferences.

Make sure to restart apache after making these changes to php.ini. To php.ini add (check dir name):

zend_extension=/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/xdebug.so

you may either add the following to php.ini:

xdebug.remote_enable=on

OR

you can add this to .htaccess in your Drupal root or a parent dir:

php_value xdebug.remote_enable on

These (among others) may also be useful to add to .htaccess if you want to profile
memory usage:

php_value xdebug.auto_trace On
php_value xdebug.show_mem_delta On

To debug in Komodo, make sure Debug >> Listen for Debug Connections is enabled
In Drupal, add the query string: ?XDEBUG_SESSION_START=1

You can follow these

solipsist - January 31, 2009 - 17:47

You can follow these instructions (they apply to PDT):
http://www.eclipse.org/pdt/articles/debugger/os-php-eclipse-pdt-debug-pd...

Then use the compiled XDebug Shared Object binary which is available from ActiveState (works with PDT as well as Komodo):
http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging

--
Jakob Persson
NodeOne

Fails to recognize breakpoints

Darren Oh - February 20, 2009 - 17:56

While debugging a Views 2 plugin, I found that Xdebug does not recognize breakpoints in files included by methods in objects. Since NetBeans supports only Xdebug, I was reluctantly forced to return to Eclipse PDT, which support the Zend debugger.

P.S. This page indicates that what Xdebug really has a problem with is files in different directories using the same name: http://www.rymland.org/en/blogs/boaz/5_mar_08/using-pdt-xdebug-for-debug...

This might fix it

boaz_r - April 25, 2009 - 20:08

Your conclusions seems wrong to me. If your IDE + xDebug is configured correctly, you'll stop at every breakpoint in your project (I'm referring to PDT only here. Not experienced with Netbeans).
See the section titled "Eclipse PDT" in the guide you've just linked. If you configure "Path mapping" correctly, those break points will be regarded. See the second screenshot in that section I just mentioned. Make sure to use file path in the "Path on server" section. Using "http://..." as the path passes PDT validation but will cause PDT/xDebug to ignore your breakpoints altogether (aside from "break first line", if you use that nagging feature :-)

Boaz.

--
Therapeutic PHP sessions

XDebug with Acquia Stack Installer OSX

thomasvum - July 15, 2009 - 12:35

I was able to install XDebug with Acquia Stack Installer on my OSX (localhost)

I downloaded XDebug (2.0.5) Source
http://xdebug.org/download.php

unpacked it on my desktop.

opend Terminal and moved into the directory

cd /Users/yournamehere/Desktop/xdebug-2.0.5/xdebug-2.0.5

I followed the guide, except the downloading part:
http://dlmax.org/2009/01/13/installing-xdebug-204-or-21-on-osx/

I run phpize (NOT phpsize) ;-)

phpize

run the following commands

export MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
export CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe"
export CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe"
export LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load"

./configure --enable-xdebug
make

voila!

now copy the /Desktop/xdebug-2.0.5/xdebug-2.0.5/modules/ Directory to your acquia php bin folder:
/Applications/acquia-drupal/php/bin

Now I have 2 files
xdebug.so and
xdebug.la

in /Applications/acquia-drupal/php/bin/modules/

Edit your php.ini
I used the AcquiaDrupalControlPanel
settings -> config -> edit php.ini

Add the following line to your php.ini

[xdebug]
zend_extension=/Applications/acquia-drupal/php/bin/modules/xdebug.so

when you create a phpinfo(); page (http://www.php.net/phpinfo)

it should show something like

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

and at the bottom xdebug variables

Now set up you programming enviroment with XDebug (another story.... working on it)

cheers
t

 
 

Drupal is a registered trademark of Dries Buytaert.