View Issue Details

IDProjectCategoryView StatusLast Update
0002161XdebugStep Debuggingpublic2024-08-07 13:41
ReporterAlex_Wells Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status acknowledgedResolutionopen 
PlatformDocker/Linux on MacOSOSLinux 
Product Version3.2.0 
Target Version3.4dev 
Summary0002161: Breakpoints not updated when process is running
Description

When a PHP is process is already running and you add a new breakpoint, it will never be triggered unless a script is restarted.

With the rise of popularity of Swoole, RoadRunner, AmPHP and related tools like Laravel Octane, this becomes increasingly more of a problem because debugging gets much harder. In case of Swoole, they've recently added support for XDebug, but it's still hard to actually make use of it because of having to constantly restart the server to make it reload the breakpoints.

There are workarounds for that, but all are suboptimal:

  • you can either run php-fpm alongside Swoole solely for debugging (which makes it unnecessarily complex and sometimes doesn't allow reproducing the problem the same way as in Swoole)
  • or you can reload Swoole every time you add a breakpoint, which kills the developer experience

Are there any possible workarounds XDebug can implement to address this issue?

Steps To Reproduce

See https://github.com/swoole/swoole-src/issues/4969

Ask me if you want me to prepare a repository to reproduce this.

TagsNo tags attached.
Operating System
PHP Version8.1.5-8.1.9

Activities

derick

2023-08-01 10:08

administrator   ~0006622

Hi,

This is not a simple thing to change. Right now, the protocol very much works in a command -> response fashion, where each time Xdebug has paused the script (which includes the state when it starts), an IDE can send more commands (including setting breakpoints). Once the IDE sends a "run" Xdebug will then run until 1. the script has ended; or 2. a breakpoint has been hit. During that time, Xdebug can also send the IDE notifications, but there is no way for Xdebug to receive data as it is not implemented as an asynchronous protocol. Changing that would require a lot of work, on both the Xdebug side, as well as on the IDEs sides.

A workaround would be for you to introduce xdebug_break() calls in your code, which would make Xdebug pause the script, and then the IDE can send more breakpoints. That does mean that currently you'll have to press step over or run yourself to get the script moving again. I know it's not ideal, but I don't have a really good solution here either.

cheers,
Derick

derick

2024-04-15 13:26

administrator   ~0006903

I have made an experimental implementation of a "control socket" (https://bugs.xdebug.org/view.php?id=2219), that could be used to inject new breakpoints. Once IDEs have support for this, I will write up how this works, and how to use it.

Issue History

Date Modified Username Field Change
2023-02-23 13:50 Alex_Wells New Issue
2023-08-01 10:08 derick Severity minor => feature
2023-08-01 10:08 derick Note Added: 0006622
2023-08-01 10:08 derick Assigned To => derick
2023-08-01 10:08 derick Status new => acknowledged
2024-04-15 13:26 derick Note Added: 0006903
2024-08-07 13:41 derick Target Version => 3.4dev