xdebug won't stop at breakpoint

2019-01-23 13:00发布

问题:

I spend some hours to set up my IDE to debug PHP with eclipse and xdebug.. Everything is ok except the breakpoint I set on eclipse. If I double-click on a line to add a breakpoint, the debugger want not to stop.. If a add the line xdebug_break() the debugger stops well at the line...

It's maybe a problem with the configuration. Could anyone help me ?

  • Eclipse: Eclipse PDT 2.2.0 All In Ones Windows 32 bits
  • Xdebug: 5.3 VC6 (32 bit)
  • PHP: PHP Version 5.3.3

PHP.ini

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:/temp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on

xdebug.show_local_vars = 1

回答1:

If xdebug do not stop in any part of your code, add xdebug_break() to this part of the code.



回答2:

There seem to be several issues that could be the root of this problem. In my case it was the fact that I thought I needed to set some path mapping.

The settings found under
rightclick-project->properties->PHP Debug
and then
server->edit->path mapping
were wrong.

I had manually added something I though was correct, but Eclipse can do this all by its self it seems. Removing the mapping made it work.



回答3:

I’ve had a similar problem with Eclipse PDT and Xdebug. The cause was that Eclipse was listening via IPv6 but Xdebug tried to connect via IPv4:

chriki@machine:~$ netstat -an | grep 9000
tcp6       0      0 :::9000                 :::*                    LISTEN

Xdebug doesn’t seem to support IPv6, yet.

After adding the line

-Djava.net.preferIPv4Stack=true

after the -vmargs line in my eclipse.ini file, Eclipse started to listen via IPv4:

chriki@machine:~$ netstat -an | grep 9000
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN

Debugging now works flawlessly.



回答4:

I have fixed myself the problem.

On my php.ini, I have add the xdebug as an extension instead of a zend_extension.

php.ini

zend_extension=C:\EasyPHP-5.3.3\php\ext\php_xdebug.dll

Note: the path must be the full path instead of a relative path.

The debugger works great. Yummy!



回答5:

I was having the same problem, PDT would start up the debug session, even breaking on the first line of the script and allowing stepping from there, but it would happily run through any manual breakpoints I had set if I clicked on Resume. After fiddling around with it and reading a bunch of other replies, I fixed it.

I had been trying to setup a Path Map (in the PHP server configuration) as my project path and web server paths were different, but this was not working for some reason so I ended up adding an alias to the apache config to match the location PDT was asking for. However, I had not removed this path map setting. When I removed the path map, breakpoints started to work!

Probably a symptom of something else not working properly ( the path map setting ) but breakpoints and debugging are all working for me now :)



回答6:

This problem popped for me after moving some of my local project folders around. I could get xdebugger to break at the beginning of the file, but it would skip the rest of my breakpoints.

If you are using Netbeans, check that your Project Url ( Project Properties->Run Configuration ) points to the correct location. With the Project URL pointed to the right folder, breakpoints starting working as expected.



回答7:

I had the same problem. The solution is to open correct file and add breakpoint in it.

My local server is on my virtual Z: drive (I'm using denwer instead of WAMP). Z drive points to my D:/webserver folder. So I can open my file as 1) Z:/myproject/script.php and as 2) D:/webserver/myproject/script.php

For some reasons debugger stops on breakpoints only in openned Z:/myproject/script.php file.

How to test my solution??? Do next:

  1. Open any php file you want to debug
  2. Add xdebug_break() to any line and save file
  3. Run debug

In my case after debug process has started my phpDesigner IDE open correct file in IDE and stops at xdebug_break() line. So in this new opened file you can add breakpoints and they will work. Use opened file for debug.



回答8:

I had the same problem for days (!) since I realized that the problem was the most trivial one.

Configuration:

  • (Windows 7 Host)
  • Ubuntu 12.04 on VirtualBox Machine
  • LAMP installed manually
  • Eclipse Indigo + PDT
  • php5-xdebug

/etc/php5/apache2/php.ini

[XDebug]
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_output_dir=/tmp

The Debugger did't stop at breakpoints and neither at xdebug_break();

...it was due to the default Apache DocumentRoot folder's /var/www permissions

I changed it to /home/user/Documents/www.



回答9:

Quick answer: remove all white spaces on the path to your php script.

Context:
There is a bug on PDT plug-in version 3.7.0 which prevents the debugger from stopping at breakpoints.
And it happens when the path to your script contains a white space!
It has been fixed but I guess the target version, which is 4.0.0, has not been released yet.
The comment which saved my day is at https://bugs.eclipse.org/bugs/show_bug.cgi?id=489646#c7 ("Comment 7").



回答10:

This has been pissing me off for about 3 hours, just worked it out. So before you put a gun to your head, try this. When Eclipse starts, choose a new workspace, and setup your project again!

After I did this my break points got hit again! My break points were working fine, then all-of-a-sudden they stopped working. I Tried:

  1. removing all break points

  2. cleaning project

  3. re installing eclipse

NONE of the above worked for me!

BTW I am using window 7.

I hope this information saves someone's life!

BTW: here are the steps you take to setup, centos 7 with xdebug and vmwere, with a window 7 client with eclipse:

download vmwere

downlaod and setup vmwere with: CentOS-7-x86_64-Everything-1511.iso

disable Firewall

systemctl disable firewalld

systemctl stop firewalld

systemctl status firewalld

connect via ftp

ifconfig to find out Ip

ifconfig

eno16777736: flags=4163 mtu 1500

inet 192.168.170.128 netmask 255.255.255.0 broadcast 192.168.170.255

inet6 fe80::20c:29ff:fec4:b8ca prefixlen 64 scopeid 0x20

ether 00:0c:29:c4:b8:ca txqueuelen 1000 (Ethernet)

RX packets 254 bytes 20919 (20.4 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 95 bytes 10225 (9.9 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

192.168.170.128 is the ip

setup LAMP

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

yum -y install epel-release

yum -y install mariadb-server mariadb

systemctl start mariadb.service

systemctl enable mariadb.service

mysql_secure_installation

yum -y install httpd

systemctl start httpd.service

systemctl enable httpd.service

yum -y install php

service httpd restart

yum -y install php-mysql

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring

php-snmp php-soap curl curl-devel

service httpd restart

yum install phpMyAdmin

on windows open cmd, type ipconfig

find

Ethernet adapter VMware Network Adapter VMnet8:

Connection-specific DNS Suffix  . : localdomain

Link-local IPv6 Address . . . . . : fe80::94b8:9e5c:c772:3d47%19

IPv4 Address. . . . . . . . . . . : 192.168.170.1 [ this is the widnows ip to allow ]

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Default Gateway .

in /etc/httpd/conf.d/phpMyAdmin.conf change:

AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>

  # Apache 2.4

  <RequireAny>

    Require ip 127.0.0.1

    Require ip ::1

  </RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

  # Apache 2.2

  Order Deny,Allow

  Deny from All

  Allow from 127.0.0.1

  Allow from ::1

</IfModule>

to:

AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>

  # Apache 2.4

  <RequireAny>

    Require ip 127.0.0.1

    Require ip ::1

  </RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

  # Apache 2.2

  Order Deny,Allow

  Deny from All

  Allow from 127.0.0.1

  Allow from ::1

</IfModule>

<IfModule mod_authz_core.c>

  # Apache 2.4

  <RequireAny>

    Require ip [ WINDOWS IP TO ALLOW GOES HERE ]

    Require ip ::1

  </RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

  # Apache 2.2

  Order Deny,Allow

  Deny from All

  Allow from [ WINDOWS IP TO ALLOW GOES HERE ]

  Allow from ::1

</IfModule>

service httpd restart

change $cfg['Servers'][$i]['auth_type'] = 'cookie'; to $cfg['Servers'][$i] ['auth_type'] = 'http';

service httpd restart

/etc/selinux/config change

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=enforcing

SELINUXTYPE= can take one of three two values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

to

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=disabled

SELINUXTYPE= can take one of three two values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

reboot centos

IN WINDOWS POINT BROWSER TO: http://192.168.170.128/phpmyadmin, should be all good

copy website to: /var/www/html/[ WEBSITE NAME ]

chmod -R 777 html

in etc/httpd/ add ( this allows permalinks to work with post name )

Options FollowSymLinks

AllowOverride All

Order allow,deny

Allow from all

yum install php-devel ( to allow pipsize )

make php file with: and copy to website root run it and copy the htl into https://xdebug.org/wizard.php then click analysis source button

https://xdebug.org/wizard.php will give Instructions like this: ( follow them )

...... Download xdebug-2.4.1.tgz

  • Unpack the downloaded file with tar -xvzf xdebug-2.4.1.tgz

  • Run: cd xdebug-2.4.1

  • Run: phpize (See the FAQ if you don't have phpize.

  • Run: ./configure

  • Run: make

  • Run: cp modules/xdebug.so /usr/lib64/php/modules

  • Edit /etc/php.ini and add the lines

  • zend_extension = /usr/lib64/php/modules/xdebug.so

  • xdebug.remote_enable=On

  • xdebug.remote_host=192.168.170.1

  • xdebug.remote_port=9000

  • xdebug.remote_handler=dbgp

..... service httpd restart

run file and you should see an XDebug section, if so the server is ready to go!

Download Eclipse Neon

File > Open projects from file system

Finish ( and wait )

Window Preferences > php > servers > new

  • Server Tab

    • Server Name [ what ever you like ]

    • Base Url [ IP or name of your server ]

    • Document Root [ Location on your hard drive where all the code is, must be same as what you have on the server]

    Debugger Tab

    • Debugger: Xdebug

    • port: 9000

    Server Mapping tab ( click add)

    • Path on Server: [the whole path to your website] EG: /var/www/html/website

    • Path in Workspace [find the project you added with: Open projects from file system]

go to eclipse main window > click drop down arrow beside the bug icon > debug configerations

  • Server Tab

    • File: [ this should be the first file in your local project that will be run when you app opens ]

    • URL: turn off auto generate : uncheck it

      • URL first text box: [ The IP or name of your server where you website is running ]

      • URL second text box: [ If your website is not in the root direcory, the direcory where it is goes here ]

  • Common Tab

    • Display in Favorites Menu

      • Click Debug ( checkbox )

window > prespective > open prespective > php

Put a break point in the php file that gets hit first ( by clicking on the vertial scrollbar on a line of code )

Finally click the debug icon in eclipse, and your break point should get hit ( the line of code with the break point on it will go green )


Open up Centos 7 on Vemware to the world


Change VMeere network setting to bridged

Add a rule to router to port foward any traffic to the vmweare IP that cetnos is running on

Add an inbound rule to the widnows firewall allowing http

PS: I dont have time to check my gammer and speiing, deal with it



回答11:

If you are using Eclipse, it may be that the debugger configured for a specific launch (see Debugger tab) is the Zend Debugger, and NOT XDebug. Fix your debug launch and try again. That solved the problem for me.

Unfortunately I cannot post the screenshot. However, in Eclipse, you can go to: Debug Configurations > PHP Web Application > then select your launch > Debugger Tab > use the Server Debugger drop down to select XDebug > hit the Apply button and retry.



回答12:

I had the same problem and either one of two things fixed it...

I removed a duplicate zend_extension definition in my PHP.ini

or more likely I just upgraded to the latest xdebug version from here: http://xdebug.org/download.php

(I was running xdebug that came with XAMPP v1.7.1)

THIS STARTED AGAIN... tried all different versions of xdebug dlls, etc... turned out that what was causing this to not work was having the Expressions window open... so keep it closed when you debug stuff... you can add a watch temporarily and then close the Expressions window before you "step"...

bogus...



回答13:

1- check xdebug config on php.ini
2- eclipse->project->properties->phpDebug-> Enable project specific setting

phpDebugger->configurattion->port or widndow->preference->php->debug->installedDebuggers

3-widndow->preference->php->

Interpreter->version executables-> path to php-win.exe
point : for each debug lib (xdebug,zend_debugger,...) you can have a default php executable.

4-your application server work on different port with 80 . widndow->preference->php-> PHP servers



回答14:

Just to mention the simple solution for me, when my freshly installed and configured xdebug didn't work with PhpStorm: I simply forgot to restart apache after updating the php.ini file.



回答15:

I add the same problem on fedora release 20 Heisenbug, php-ZendFramework2-Debug-2.3.9-1.fc20.noarch, php-pecl-xdebug-2.2.7-1.fc20.i686, and eclipse Version: Mars.1 Release (4.5.1). I used the previous answers, discovered that eclipse use ipv6, I changed as described within eclipse.ini for -Djava.net.preferIPv4Stack=true. Same for xdebug.ini, and still not working, until I discovered that I had 2 xdebug.ini files, one in /etc/php-zts.d/ which is the wrong one, and one in /etc/php.d/ which is the one used by apache. I modified it to include the following setting

; Enable xdebug extension module
zend_extension=xdebug.so

xdebug.remote_enable=on
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.remote_autostart=1
xdebug.idekey=

restarted the network sudo service network restart and now breakpoints are detected and I may debug as expected.



回答16:

I have fixed this too. Using zend_extension instead of extension.

zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"


回答17:

I'm on windows, eclipse Oxygen. After spending fair amount of time, I discovered that simple delete and recreation of Debug Configuration helped.



回答18:

I had the same issue using eclipse-php-oxygen The issue lies on eclipse. I have installed eclipse-php-luna-SR2-win32 and tested xdebug and it works fine.

Installed: xampp-win32-7.0.30-0-VC14-installer.exe Java 8 Update 171

The following are my settings on php.ini:

[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.6.0-7.0-vc14.dll
;zend_extension = C:\xampp\php\ext\php_xdebug-2.5.5-7.0-vc14.dll
;zend_extension = "c:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000

I hope this will help.

Br, Ali



回答19:

For me the problem seemed to php 7.2 with Xdebug v2.7.0beta2-dev, notice the beta part. This was installed using puphpet.com. I tried php 7.1 and the problem vanished. Took me hours to find this!