xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
768 stars 175 forks source link

feature request: data breakpoints #903

Open Ernestopheles opened 1 year ago

Ernestopheles commented 1 year ago

I am missing a feature to set data breakpoints, i.e. have debugging stop when a condition comes true, especially a variable changes its value (in generell or to a specific value). As far as I can see this is now only possible at a specific code line but not globally.

zobo commented 1 year ago

Hello. I do not think this is possible with Xdebug. But you could probably implement a setter magic function and set up a conditional breakpoint there.

Ernestopheles commented 1 year ago

Thanks, but the setter does not help in this case. What reasons are there that hinders xdebug to have data breakpoints? Is it PHP itself, the IDE or the plugin?

zobo commented 1 year ago

First this is not supported in Xdebug. You can open a feature request here https://bugs.xdebug.org/ , but I'm sure this will not be a small task and Derick has little time for extra Xdebug features sadly (sponsors can help...)

Second it seems that the DAP has support for this https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetDataBreakpoints and https://microsoft.github.io/debug-adapter-protocol/specification#Requests_DataBreakpointInfo .

However I do not think I have seen UI support for this in VS Code. That would also need to be implemented (by Microsoft) https://github.com/microsoft/vscode/issues

I think the only way to get this is to structure your code in such way that you can set a file/line breakpoint or add xdebug_break() code...

Ernestopheles commented 1 year ago

Thanks for bringing light into this.

Going to open issues at the places you mentioned and trying to work around in the maybe long lasting meanwhile.

Ernestopheles commented 1 year ago

https://github.com/microsoft/vscode/issues/185985#event-9617725345

zobo commented 1 year ago

Hi! Apparently I was wrong here, sorry for letting you run circles. I'm traveling and will try to look at again this as soon as I can.