Vscode-php-debug: PHP Debug won't stop at breakpoint

Created on 30 Nov 2016  路  25Comments  路  Source: xdebug/vscode-php-debug

The "stopOnEntry" option works as expected, but none of the breakpoints I set are being triggered.

PHP version: 7.0.12
XDebug version: 1.7.2
Adapter version: 1.10.0

Your launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug - Docker",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Listen for XDebug - Web 4",
            "type": "php",
            "request": "launch",
            "serverSourceRoot": "/ebsvol/......../html",
            "localSourceRoot": "${workspaceRoot}/html",
            "port": 9000,
            "stopOnEntry": true,
            "log": true
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

XDebug php.ini config:

zend_extension=xdebug.so

[XDebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"

Adapter logfile (from setting "log": true in launch.json):

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true }
new connection 1
<- threadEvent
ThreadEvent {
  seq: 0,
  type: 'event',
  event: 'thread',
  body: { reason: 'started', threadId: 1 } }
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> threadsRequest
{ command: 'threads', type: 'request', seq: 3 }
<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 1, name: 'Request 1 (12:35:42 PM)' } ] } }
-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { path: '/home/cam/Documents........./html/index.php',
        name: 'index.php' },
     lines: [ 44 ],
     breakpoints: [ { line: 44 } ],
     sourceModified: false },
  type: 'request',
  seq: 4 }
-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { path: '/home/cam/Documents/......./includes/classes/SiteLogic.php',
        name: 'SiteLogic.php' },
     lines: [ 571 ],
     breakpoints: [ { line: 571 } ],
     sourceModified: false },
  type: 'request',
  seq: 5 }
<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setBreakpoints',
  success: true,
  body: { breakpoints: [ { verified: true, line: 44 } ] } }
<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'setBreakpoints',
  success: true,
  body: { breakpoints: [ { verified: true, line: 571 } ] } }
-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 6 }
<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 6,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }
-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [ 'Warning', 'Exception', '*' ] },
  type: 'request',
  seq: 7 }
<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 7,
  command: 'setExceptionBreakpoints',
  success: true }
-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 8 }
<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 8,
  command: 'configurationDone',
  success: true }
<- threadEvent
ThreadEvent {
  seq: 0,
  type: 'event',
  event: 'thread',
  body: { reason: 'exited', threadId: 1 } }

Most helpful comment

@diablodale Same here, it was a capitalization issue.

All 25 comments

I need the xdebug log like described in the issue template

Here you go

Log opened at 2016-11-30 20:40:15
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///ebsvol/......../html/index.php" language="PHP" xdebug:language_version="7.0.12-1+deb.sury.org~trusty+1" protocol_version="1.0" appid="22857" idekey="TGR-XDEBUG"><engine version="2.4.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

<- breakpoint_list -i 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>

<- breakpoint_list -i 2
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>

<- breakpoint_set -i 3 -t line -f file:///ebsvol/......../html/index.php -n 44
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="228570001"></response>

<- breakpoint_set -i 4 -t line -f file:///ebsvol/............./includes/classes/SiteLogic.php -n 571
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="228570002"></response>

<- breakpoint_list -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///ebsvol/.............../includes/classes/SiteLogic.php" lineno="571" state="enabled" hit_count="0" hit_value="0" id="228570002"></breakpoint><breakpoint type="line" filename="file:///ebsvol/............./html/index.php" lineno="44" state="enabled" hit_count="0" hit_value="0" id="228570001"></breakpoint></response>

<- breakpoint_list -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"><breakpoint type="line" filename="file:///ebsvol/............../includes/classes/SiteLogic.php" lineno="571" state="enabled" hit_count="0" hit_value="0" id="228570002"></breakpoint><breakpoint type="line" filename="file:///ebsvol/.............../html/index.php" lineno="44" state="enabled" hit_count="0" hit_value="0" id="228570001"></breakpoint></response>

<- breakpoint_set -i 7 -t exception -x Warning
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="228570003"></response>

<- breakpoint_set -i 8 -t exception -x Exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="228570004"></response>

<- breakpoint_set -i 9 -t exception -x *
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="228570005"></response>

<- run -i 10
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="10" status="stopping" reason="ok"></response>

<- stop -i 11
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stop" transaction_id="11" status="stopped" reason="ok"></response>

Log closed at 2016-11-30 20:40:15


Appreciate the help!

Are you really on XDebug 1.7.2? Update to 2.4.1

Its now updated to 2.4.1 and still getting the same behavior.

Your paths look correct, maybe the code is just never reached.

It's definitely being reached. If I turn on "stopOnEntry" then it works. If I turn it off and setup a breakpoint on line 1 of the entry file then it doesn't work. Presumably those should stop at the same point.

I send 100% correct file paths to XDebug, but XDebug does not stop at the breakpoints - this is either an error in your code or a bug in XDebug, but anyway out of my control

I have this exact same problem, stopOnEntry works as expected but manual breakpoints don't.

The only manual breakpoints that work are ones that are set after this extension stops at an exception or warning, but not on the first line via stopOnEntry

@QwertyZW please open a new issue with the infos in the issue template

I don't think it's an issue with this extension, another extension I'm using on atom is exhibiting the same behaviour, except it doesn't even stop at the breakpoints set after exception breakpoints

Then it is clearly a configuration or XDebug issue.

Nope, seems like it's a parsing bug on both this adapter and the atom extension, lol.

See https://github.com/felixfbecker/vscode-php-debug/issues/118

I ran into something similar and it was an issue with capitalization on the launch.json localSourceRoot setting. I would go ahead and put in a FQDN path to your source files (ex. "localSourceRoot": "c:\Projects\MyProject\html") and see if that makes a difference

@jasonterando Tried your suggestion and I stopped running into the same issue, it would be weird if that was the problem.

I ran into the same behaviors and problem. And the solution was as @jasonterando wrote above.
For the launch value localSourceRoot ...
I had to match the capitalization of my local windows path -and- and I had to lowercase the drive letter.
So for a local windows path of C:\ubuntu1604\www\html
invalid -> "localSourceRoot": "C:\ubuntu1604\www\html"
valid -> "localSourceRoot": "c:\ubuntu1604\www\html"

Once capitalization was adjusted, it works very well for me.

I had the same issue on Windows. I had to reverse slashes in localSourceRoot:
invalid: "E:/www"
valid: "E:\\www" # double backslash as an escape syntax in json.

@diablodale I can confirm, changing the drive letter to small case worked for me too.

@diablodale Same here, it was a capitalization issue.

Holy c*ap, that issue was driving me nuts. So the lower case drive letter in mapping is a must!!
I would be really glad if that was made more user friendly in the plugin side.

You are welcome to do a PR

Yep, I understand that it's free and opensource plugin and please take NO offence from my comment. I was just expressing my frustratsion-relief. :)

It is truly a capitalization issue.

Brfore update VSCode, I used configuration like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "serverSourceRoot": "/path/to/my/project",
            "localSourceRoot": "${workspaceRoot}"
        }
    ]
}

However it shows some error message below after I update VSCode to 1.20.1

Property serverSourceRoot is deprecated, please use pathMappings to define a server root.

So I changed my configuration and it works correctly:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 2222,
            "pathMappings": {
                "/path/to/my/project":"y:\\"
            }
        }
    ]
}

But I still have a question:

Why

"localSourceRoot": "${workspaceRoot}"

wokrs fine but

"pathMappings": {
    "/path/to/my/project":"${workspaceRoot}"
}

dosen't work ?

@Ceelog Thanks for sharing your config file.

I never had troubles with XDEBUG and Docker ToolBox but now I have them! I see that there are recent issues also

@Ceelog the following works for me on VSCode on MacOs
"pathMappings": {
"/var/www/mysite-on-my-docker-container": "${workspaceRoot}"
}

vscode version Version 1.23.1 (1.23.1)
xdebug 1.12.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bilogic picture bilogic  路  7Comments

nunorcsousa picture nunorcsousa  路  4Comments

QwertyZW picture QwertyZW  路  9Comments

eghoff1 picture eghoff1  路  10Comments

johnbillion picture johnbillion  路  11Comments