ActiveState Community

Debugging on Intel Mac

Posted by macmacz on 2006-11-27 14:00

Hi,

I am trying to run Komodo on my new Intel IMac - so far so good, but I can't get debugging working:

As I read in your faq, the Mac OSX build-in php-Version is not compiled with support for dynamic extensions. I installed the supposed php-binary from Marc Liyanage. Unfortunatly he stopped support for the 4.x Versions and the current Version (5.2) doesn't seem to work, even though I compiled xdebug for that php-Version...

I would like to run my PHP/Apache Setup a little bit "Old School" with Apache 1.3 and PHP 4.4 but any suggestions how I can get debugging working on my Intel Mac are much appreciated.

Do I need to compile my PHP myself? If so, which configure-settings are needed to get the debugging module loaded?

thx, macmacz

jeffg | Tue, 2006-11-28 13:13

You might want to look at MAMP instead, as it is a very easy to use solution for getting Apache / PHP / MySQL running on a Mac. For your requirements MAMP also has the advantage of allowing you to use either PHP 4 or PHP 5.

macmacz | Wed, 2006-11-29 15:07

thanx for the hint - but doesn't work either :(
(I will give XAMMP a try ...)

After hours of surfing the net and reading blogposts, tutorials and forum-entries, after compiling debugging-extensions and configuering PHP-Setups I am totaly desparate about (remote) debugging PHP-Applications on a Mac, especially on Intel-based-ones.

I can't belief that nobody figuers out an easy way to set up a reliable webdevelopment environement with PHP, MySQl, Apache and an IDE with integreted Debugger, be it open source or commercial on a system which is unix-based and made by people who claim to build the best machines ever (not your fault - I know)

So thanks for your efforts - maybe I come up with a solution...

m.

jeffg | Thu, 2006-11-30 11:01

Can you please provide some detail as to why MAMP didn't work? It works fine for me on my MacBook Pro. My MAMP setup is as follows:

- I have Apache and MySQL on the default ports 80 and 3306
- I have EAccelerator turned off
- I'm using PHP 5
- I added the following lines to /Applications/MAMP/conf/php5/php.ini:

; xdebug config for Linux and Mac OS X
zend_extension=/Applications/MAMP/Library/share/php/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=jeffg

- I copied xdebug.so from /Applications/Komodo.app/Contents/SharedSupport/php/debugging/5.1/ to /Applications/MAMP/Library/share/php/xdebug.so.
- I re-started MAMP's Apache.

macmacz | Thu, 2006-11-30 14:05

Hi JeffG

Okay - got it working,

I think my problem was that I used the precompiled versions from your website, which doesn't seem to work for me (could it be that the versions in "Komodo-PHPRemoteDebugging-3.5.3-262321-macosx-x86" are actualy the PPC-ones?)

So I started over to compile xdebug myself which fizzled flawlessly (partly cause MAMP comes without sources, partly cause the link to Jason Perkins tutorial on xdebug.org is dead, but mostly because of my own incompetence)

Disapointed from the hassle with xdebug, I switched over to the dbg-based IDEs (PHPEclipse and PHP IDE) which brought me out of the frying pan into the fire.

btw I discoverd your blog, nice reading!

m.

jeffg | Thu, 2006-11-30 15:06

It's funny, one of the things I've been meaning to get to this week has been to post about my experiences using MAMP similar to the last post about XAMPP Lite.

macmacz | Thu, 2006-11-30 15:21

there is a nice article by John vanDyck, who mastered the debugging-issue a little bit more smartly than I did and with Marc's PHP-binary:

Remote PHP Debugging on Intel-based Macs with Komodo

m.

ps: there's no way to tell komodo to run straight to the first breakpoint instead of waiting for me to push "go" in the first line of code?

jeffg | Thu, 2006-11-30 18:03

Not currently, but it is something we have had requested enough for it to be something we will likely do soon ( although maybe not for 4.0 ).

bugger | Fri, 2007-06-01 12:26

I tried Jeff's instructions (which have worked for me in the past) on the newest version of Komodo (version 4.1.0, build 278996, platform macosx-x86) and MAMP (1.6.1) and they don't seem to work.

The only thing I changed was I copied xdebug.so out of the 5.2 directory rather than the 5.1 directory (since MAMP runs PHP 5.2.1), and I had to create the MAMP/Library/shared/php directory first, since it didn't already exist.

Any idea why that isn't working properly?

jeffg | Fri, 2007-06-01 13:00

Can you be a bit more specific about what 'doesn't work'? I'm running MAMP 1.6.1 and it works fine. To get it set up I did the following:

1. I copied xdebug from the '5.2' directory in Komodo's .app to

/Applications/MAMP/bin/php5/xdebug/xdebug.so

2. I then added this to the top of MAMP's php.ini file**:

; xdebug config for Linux and Mac OS X
zend_extension=/Applications/MAMP/bin/php5/xdebug/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=jeffg

** /Applications/MAMP/conf/php5/php.ini

3. I re-started MAMP's servers, then opened the 'Start Page' and checked phpinfo. You should see the xdebug copyright notice added to the php copyright notice near the top of the page, and the xdebug configuration info towards the bottom.

--
JeffG

bugger | Fri, 2007-06-01 15:20

You're right, that was the worst bug report ever. :) What I should've said is, "When I look at phpinfo, there's nothing about Xdebug in there as I would expect."

So here's what I did:

  1. Downloaded newest MAMP/MAMP Pro bundle from http://www.living-e.com/products/MAMP-PRO/download.php.
  2. Dragged the MAMP folder into the Applications directory from the little installer deal.
  3. From the command-line, did:
    mkdir /Applications/MAMP/bin/php5/xdebug
    cp /Applications/Komodo\ IDE.app/Contents/SharedSupport/php/debugging/5.2/xdebug.so /Applications/MAMP/bin/php5/xdebug/xdebug.so
  4. vim /Applications/MAMP/conf/php5/php.ini

    and at the very top (previously I had this at the very bottom), I put:

    ; xdebug config for Linux and Mac OS X
    zend_extension=/Applications/MAMP/bin/php5/xdebug/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    xdebug.idekey=komodo
  5. Saved the php.ini file, then stopped/restarted MAMP's servers from MAMP.app.

The only other thing I remember having to do before was disable eAccelerator in the MAMP.app interface ... but I notice in this new one that caching defaults to off and it gives you a choice of either APC, eAccelerator, or XCache.

Any ideas where I'm going wrong?

jeffg | Fri, 2007-06-01 13:03

As an aside, earlier in this thread macmacz requested a way to get the debugger to simply run to the first breakpoint instead of stopping at the first line of code. This is now available as an option in Komodo's preferences at

Preferences / Debugger / 'Initial Break Behavior'

--
JeffG

jeffg | Mon, 2007-06-04 17:30

What happens if you run the php interpreter from MAMP from the command-line like this:

php -c vim /Applications/MAMP/conf/php5/php.ini -m

Do you see any errors?

--
JeffG

bugger | Wed, 2007-06-06 08:07

php -c vim /Applications/MAMP/conf/php5/php.ini -m

Parse error: parse error in /Applications/MAMP/conf/php5/php.ini on line 79

Line 79 was:

; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.

So I deleted that line, since it's just a comment, restarted the servers and same thing. ;( Great idea though. :)

jeffg | Wed, 2007-06-06 09:07

The line you quoted doesn't seem dangerous, plus I got that command wrong:

php -c /Applications/MAMP/conf/php5/php.ini -m

What happens when you run the above (corrected) command?

--
JeffG

tim.cosgrove@dr... | Thu, 2007-07-05 17:31

...I ran the command above, and got the following:

tim$ php -c /Applications/MAMP/conf/php5/php.ini -m
dyld: NSLinkModule() error
dyld: Symbol not found: _OnUpdateLong
Referenced from: /Applications/MAMP/Library/share/php/xdebug.so
Expected in: flat namespace

Trace/BPT trap

---

Any ideas? My setup is exactly as suggested.

jeffg | Thu, 2007-07-05 18:08

That error looks distinctly like you are calling /usr/bin/php instead of /Applications/MAMP/bin/php5/bin/php.

Is that the case?

--
JeffG

tim.cosgrove@dr... | Thu, 2007-07-05 18:32

since running this:

dsl092-009-053:~ tim$ /Applications/MAMP/bin/php5/bin/php -c /Applications/MAMP/conf/php5/php.ini -m
[PHP Modules]

gave me a list of modules.

So, here's what I've got:
MAMP 1.6.1, running PHP 5.2.1
Komodo 4.1.1
xdebug.so out of the Komodo package, 5.2 version, copied to the location specified below. The following is in my php.ini at /Applications/MAMP/conf/php5:

; xdebug config for Linux and Mac OS X
zend_extension=/Applications/MAMP/Library/share/php/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=tim

PHP caching is off. Zend Optimizer is off.
Komodo Debugging is listening on port 9000.

What else should I be looking for? Thanks for your help!

tim.cosgrove@dr... | Thu, 2007-07-05 18:42

I know this CAN work because I had it working before my harddrive fail yesterday. (Do I do backups? Well, NOW I do...) But, I had a Drupal core developer help me set it up, and I'm probably missing a key detail.

Thanks!

jeffg | Fri, 2007-07-06 07:57

The other thing to check is the output of phpinfo form MAMP's start page - make sure that Apache is really really loading xdebug. If it is and if all the port settings line up you shoul just be able to add

XDEBUG_SESSION_START=tim

as a GET variable and it should 'just work'.

--
JeffG

tim.cosgrove@dr... | Fri, 2007-07-06 15:01

Not sure what you mean by adding a GET variable. To php.ini? I've always initiated debug sessions from Komodo, not via PHP code additions.

Is it possible I need to do what was suggested elsewhere, which is download xdebug.so directly from the source and not use the version bundled with Komodo? When this was working before, I did in fact use the Komodo version; I'm just thinking of trying every last thing at this point.

It's a little frustrating when it's supposed to 'just work', and in fact it did just work before, but not at the moment. :/ No one's fault, obviously there's something wrong with my configuration somewhere, but I'm not really sure how to go about troubleshooting.

Thanks...really do appreciate you taking time to chat about this.

jeffg | Fri, 2007-07-06 17:38

Sorry, I thought you meant remote debugging. With Komodo you can debug a script remotely by appending the GET variable 'XDEBUG_SESSION_START=$ide_key' to the and of the url in your web browser, eg:

http://localhost/drupal/node/edit/?XDEBUG_SESSION_START=tim

This will cause xdebug to start up and contact Komodo on the configured port and request a debugging session. Is this what you meant originally? Regardless I recommend this as the preferred way to debug Drupal code.

--
JeffG

tim.cosgrove@dr... | Fri, 2007-07-06 22:51

Previously I didn't need to pass in the GET variable; I just told Komodo to listen for debugging, established my breakpoints, and loaded/ran the PHP in browser that I wanted to test. But, this works; this saves my bacon. Thanks!

jockox3 | Wed, 2007-09-12 07:49

I went and bought MAMP PRO 1.7 (mainly for the vhosts configuration facilities) and could not get xdebug to load at all.

The server disregards any alternate php.ini created by the latest Komodo PHP debugging setup wizard. Even so, you would think it would be okay to edit the /Applications/MAMP/conf/php5/php.ini directly but no, it ignores this as well. It seems MAMP PRO will always load its php.ini from a file in /Library/Application Support/living-e/MAMP PRO/conf so I tried editing this. Still no luck.

It would appear that if you are determined to use MAMP PRO you need to do File->Edit Template->PHP5 php.ini (ignoring the warnings about editing the template), put the various xdebug directives noted in previous posts at the top of this file and only then will it pick up the location of xdebug and load it.

I've yet to get the Komodo to prove to me that it then debugs properly but I thought folk might like to know about this little clash of personalities between the latest MAMP Pro (1.7) and the latest KomododIDE (4.1.1, build 279677) in case they are left completely confused about why they can't even get xdebug to appear in their phpinfo output!

Jock Coats
Novice Drupaller in Oxford, UK

aaustin | Mon, 2007-09-17 11:56

I am somewhat of a noob here. So please have patience.

I added this to my php.ini

; xdebug config for Linux and Mac OS X
zend_extension=/Applications/MAMP/bin/php5/xdebug/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=komodo

Restarted the MAMP services.

The phpinfo() page was not showing any xdebug information so I tried:

/Applications/MAMP/bin/php5/bin/php  -c /Applications/MAMP/conf/php5/php.ini

And got this error message:

Failed loading /Applications/MAMP/bin/php5/xdebug/xdebug.so:  (null)

Does it matter that if I do Get Info on the xdebug.so file it says: Kind: Unix Executable File(Power PC) and I had downloaded the x86 on for my Intel Mac?

jeffg | Mon, 2007-09-17 12:41

Where id you get that xdebug.so from? Please instead download the latest Komodo 4.2 PHP debugging package:

http://downloads.activestate.com/Komodo/RemoteDebugging/4.2/MacOSX/Komod...

I just now have verified this package contains the right bits.

--
JeffG

p2409 | Fri, 2007-12-28 17:23

Hi I think the PowerPC version was accidentally included in the x86 xdebug.so for Komodo 3.5 too - I made a new posting on this last night, so this reply is just for people's info.

If you get the error message Unable to load xdebug.so when you run your
php -m , check (ctrl-click) the xdebug.so file in your tar download to get file info. If it says PowerPc executable and your on an Intel - this is your problem.

That posting is here:
http://community.activestate.com/forum-topic/php-remote-debugger-3-5-3-2...

aaustin@drupal.org | Mon, 2007-09-24 11:39

I don't know how I got that xdebug.so file. I tried downloading it several times trying to make sure I got the correct file. Who knows?

But it works now, thanks.

NimaiMalle | Thu, 2007-11-15 10:36

That's the message I see in the Debugger Configuration box, in Languages | PHP.

I'm new to Mac and Komodo. I'm using MAMP PHP Version 5.2.3 with Komodo 4.2.0. I followed all of the tips and instructions here, and some things are working fine. I can add XDEBUG_SESSION_START in FireFox and Komodo comes right up, ready to debug. Everything works from there: stepping, watching, etc.
I figured I'd try to get Komodo initiating the debugging working as well, and get rid of that annoying WARNING! in the PHP configuration.
I have /Applications/MAMP/bin/php5/bin/php specified as the Default PHP Interpreter and Directory containing php.ini

When I click on Debugger Config Wizard, I again put /Applications/MAMP/bin/php5/bin/php in the Setup this installation: edit box, and click Continue. That beings up a message that reads:

"The version of the selected PHP executable () is not supported by Komodo"

I assume there's supposed to be a version number between those empty parenthesis? Is it not able to find php.ini? When I try to initiate debugging from Komodo, it says, "PHP is not configured for 'debugging'."
Thanks in advance for any suggestions.

NimaiMalle | Thu, 2007-11-15 11:06

I noticed that running php from the terminal resulted in:

dyld: NSLinkModule() error
dyld: Library not loaded: /Users/severin/Dev/Projects/MAMP_1.7_src/lib/libltdl.3.dylib
  Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/mcrypt.so
  Reason: image not found
Trace/BPT trap

Some Googling later, and I found I needed to add this:

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"

It made the error in the terminal go away, and putting it in my Komodo Environment made my PHP Debugging Configuration Wizard work, and everything followed from there. Hope this helps someone!

ToddW | Thu, 2007-11-15 13:11

I'm sure other people will also find this useful. Good to hear you have things working.

Cheers,
Todd

jeffg | Mon, 2007-11-19 18:38

I dug into the code that deals with reporting errors in the PHP prefs with Trent today and we came up with a better solution for the time being:

- if your PHP returns something on stderr when we try to run it to get the version number, we log the output of stderr
- the other side effect of a broken PHP is that the php version is not set in the internal object used to store php config information, so we detect this in the JavaScript layer and give you a better error message:

"Error determining PHP version; your PHP install may be broken, please check the Komodo Error log for more details."

Hopefully this will improve our ability to help people detect PHP problems in the future.

Edit: these changes should see the light of day in 4.3 Beta builds in a month or so, or post here if you want the changed files.

--
JeffG