Xdebug Ignores Breakpoints

Xdebug ignores breakpoints

It looks like there is something wrong with the path to the file containing the breakpoint.

<- breakpoint_set -i 452 -t line -s enabled 
-f file:///http:/development.xxx.de/users/itsame/index.php -n 15 ->

I've had a similar problem with Eclipse. Only my breakpoints in the index file were accepted and breakpoints in other files—that were included in the index—were ignored.

I looked in the remote_log file and saw the following:

<- breakpoint_set -i 260 -t line 
-f file:///~jeroen/workspace/fieg/wp-content/plugins/fieg/fieg.php -n 22->
<response xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set"
transaction_id="260" id="48060002"></response>

I noticed that the path for the breakpoint was all wrong. It turned out that I had to setup Port Mapping in Eclipse. After setting the correct mapping the breakpoints started working. Also my remote_log now shows the correct path:

<- breakpoint_set -i 333 -t line 
-f file:///Users/jeroen/Workspace/fieg/wp-content/plugins/fieg/fieg.php -n 12->
<response xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set"
transaction_id="333" id="48080005"></response>

I'm not sure if there is an equivalent of the Eclipse Port Mapping configuration in Netbeans, but hopefully I pointed you in the good direction.

Xdebug with Visual Studio Code ignores some breakpoints

Running it in PhpStorm, but as Xdebug runs on PHP, the behavior is the same.

Xdebug stops when stuff is "done", on the lines that things are "done". This can be function calls, variable assignments, data transformations, etc. All these have in common that they must be explicit. Implicit assignments are ignored.

Xdebug does not pause execution for breakpoints placed "in" an action. Which is why the first breakpoint in your code will not work, and the second will.

Explicit & implicit example:

$attributes = [                   // this is implicitly an array, no pausing execution
'business_name' => 'DANONE' // this is explicitly assigned a string, execution paused
];

With some screenshots (code is from Symfony 4 public/index.php, with some obvious additions - blue background is paused execution "current line"):

example 1

Clearly executing functions inside an if() statement - it pauses

example 2

As we can see, breakpoints on all 3 lines of this array. However, the only one it pauses on is the assignment of the key/value pair. This is explicitly done, the array itself is implicitly declared.

example 3

Here we explicitly declare $testArray to be an array. So: it pauses.

example 4

This is to be complete, could've added it above. Implicit setting of type array, but explicit assigning of key/value.


So: yes.

If you had placed your breakpoints slightly different, they would've paused the execution. Not pausing on the implicit ones is normal behavior.


To be complete:

On local Apache installation I've got the following config:

[XDEBUG]
zend_extension = C:\xampp\php\ext\php_xdebug-2.7.1-7.3-vc15-x86_64.dll

xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.max_nesting_level = 200;

But I normally run this in Docker. In the docker-compose PHP image:

environment:
PHP_XDEBUG_ENABLED: ${XDEBUG_ENABLED:-0}
PHP_IDE_CONFIG: ${PHP_IDE_CONFIG:-serverName=ProjectName}
XDEBUG_CONFIG: >
idekey=PHPSTORM
remote_host=${XDEBUG_REMOTE_HOST_IP:-host.docker.internal}
remote_port=${XDEBUG_REMOTE_PORT:-9000}
remote_enable=1
  • (to enable xdebug, set XDEBUG_ENABLED environment config to 1 in application when starting using docker-compose up)
  • (replace "ProjectName" with the name of the project, use that name in your "servers" config in PhpStorm settings for Xdebug)

and in the Dockerfile

pecl install xdebug-2.7.2 redis && \
docker-php-ext-enable xdebug redis && \
  • (make sure to replace xdebug-2.7.2 with a version you want / is compatible with your PHP version, check that here)

Edit: additional based on comments on OP's question.

There's plenty of bug reports (see those comments, credit to LazyOne for finding them).

The last URL he provided is interesting as it's about the upcoming V2.8.0 (currently in 2.8.0beta1, not general release), about which he comments in this ticket about Xdebug not pausing execution on the implicit assignments:

I've just merged this into the master branch, which will become part of 2.8.0. I will release 2.7.2 soon (this week, today?!), and then probably next week a 2.8alpha1 release so that people can try this out.

(quote from 2019-05-06 12:49 by Derick, writer of Xdebug)

You can have a look at the changelog page or the roadmap for Xdebug.

The roadmap shows all of the features / fixes which will be included.

For 2.8.0 it shows that support for IDE's will be added for IDE's to show whether or not a breakpoint can be resolved. It's current release date is set for 2019-09-30.

Released

Xdebug ignores breakpoints (browser and CLI)

You are on Mac and you are using nginx... This means that most likely you do have php-fpm installed and running. Problem is that php-fpm also uses TCP 9000 port by default ... so right now Xdebug is connecting there instead of PhpStorm (the xdebug log gives a good hint here, if you have seen such response before).

Unfortunately PhpStorm is unable (for whatever reason) to detect that Xdebug port is already used by another app on Mac (but does it fine on Windows/Linux).

You can verify that manually with this sort of command (look for the entry that uses Xdebug port and see the process name):

sudo lsof -nP -iTCP -sTCP:LISTEN

The solution is to change Xdebug port to be 9001 (or any other meaningful number) in both php.ini and PhpStorm settings.

P.S. You will need to restart all debug sessions / disable and enable "phone handle" icon if you are using it. Alternatively just restart the IDE.

Xdebug ignores breakpoints in Netbeans for Php project created inside Docker container

Finally I solved the issue on my own.

As I expected, the solution was to set Path Mapping properly in Netbeans.

After analysing xdebug.log again today, I have noticed that the beginning of the log contains interesting information - a value for attribute fileuri of init element:

<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///mnt/deployments/my-project/application/bootstrap_http.php" language="PHP" protocol_version="1.0" appid="139" idekey="netbeans-xdebug"><engine version="2.1.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>

The way I shared a directory of my Docker host, containing my-project, with Docker container, during run docker subcommand for my Docker container was: docker run ... -v /home/pkowalski/clients/deployments:/mnt/deployment.

So what I did to solve the problem with Netbeans ignoring breakpoints for my-project, was I just set Path Mapping inside Netbeans (Project Properties -> Run Configurtion -> Advanced) as follows:

Server Path: /mnt/deployments/my-project

Project Path: /home/pkowalski/clients/deployments/my-project

Because I have a soft link created inside my Docker container for the mounted directory: ln -s /mnt/deployments /home/devteam/deployments, initially I tried to put /home/devteam/deployments/my-project as a Server Path value, but it did not work.

Apart from that, now it works for me with no xdebug.remote_host set at all and with xdebug.remote_autostart set either to zero or one.

Here is the final working content of my /etc/php.d/xdebug.ini inside Docker container:

zend_extension=/usr/lib64/php/modules/xdebug.so 
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp

Why is XDebug ignoring breakpoints from NetBeans 6.8?

Xdebug (through PHP) doesn't support symbolic links yet (there is an issue at http://bugs.xdebug.org/view.php?id=627). PHP/Xdebug always uses the fully expanded link so you will need to make sure netbeans sets up a breakpoint like:

breakpoint_set -i 1014 -t line -s enabled -f file:///common/rsync/Dropbox/active-archives/code/Locus/mockup/test.php

You will have to set-up a path mapping. After you've verified that the breakpoint_set include the correct path, it should work.



Related Topics



Leave a reply



Submit