vscode-php-debug: Breakpoints not working when performing remote debugging

Everithing seems to be working ok. Adapter connects and detects scripts running but it NEVER stops on set breakpoints. Details:

  • When setting a breakpoint it always states “unverified”.
  • Next, after a script is executed the log indicates that it’s working (started, exited) but it seems that any breakpoint is actually set/reached.
  • Mapped routes seems to be OK too.
  • Nothing is logged on XDEBUG logs
  • XDdebug / Webserver running under a Vagrant VM
  • Server is running on port 8081 (http://127.0.0.1:8081)

Has somebody an idea of what to try next? I’ve been fighting this for two days, I’m a little frustrated 😦 Thank you in advance!


PHP version: 7.0.22-0ubuntu0.16.04.1 XDebug version: 2.4.0 Adapter version: 1.12.1

Your launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "pathMappings": {
              "/var/www/html": "{workspaceRoot}/repo/html",
            },
            "port": 9000,
            "log": true
        },
    ]
}

XDebug php.ini config:

xdebug support	enabled
Version	2.4.0
IDE Key	vscode
Supported protocols	Revision
DBGp - Common DeBuGger Protocol	$Revision: 1.145 $
Directive	Local Value	Master Value
xdebug.auto_trace	Off	Off
xdebug.cli_color	0	0
xdebug.collect_assignments	Off	Off
xdebug.collect_includes	On	On
xdebug.collect_params	0	0
xdebug.collect_return	Off	Off
xdebug.collect_vars	Off	Off
xdebug.coverage_enable	On	On
xdebug.default_enable	On	On
xdebug.dump.COOKIE	no value	no value
xdebug.dump.ENV	no value	no value
xdebug.dump.FILES	no value	no value
xdebug.dump.GET	no value	no value
xdebug.dump.POST	no value	no value
xdebug.dump.REQUEST	no value	no value
xdebug.dump.SERVER	no value	no value
xdebug.dump.SESSION	no value	no value
xdebug.dump_globals	On	On
xdebug.dump_once	On	On
xdebug.dump_undefined	Off	Off
xdebug.extended_info	On	On
xdebug.file_link_format	no value	no value
xdebug.force_display_errors	Off	Off
xdebug.force_error_reporting	0	0
xdebug.halt_level	0	0
xdebug.idekey	no value	no value
xdebug.max_nesting_level	1000	1000
xdebug.max_stack_frames	-1	-1
xdebug.overload_var_dump	On	On
xdebug.profiler_aggregate	Off	Off
xdebug.profiler_append	Off	Off
xdebug.profiler_enable	Off	Off
xdebug.profiler_enable_trigger	Off	Off
xdebug.profiler_enable_trigger_value	no value	no value
xdebug.profiler_output_dir	/tmp	/tmp
xdebug.profiler_output_name	cachegrind.out.%p	cachegrind.out.%p
xdebug.remote_addr_header	no value	no value
xdebug.remote_autostart	On	On
xdebug.remote_connect_back	Off	Off
xdebug.remote_cookie_expire_time	3600	3600
xdebug.remote_enable	On	On
xdebug.remote_handler	dbgp	dbgp
xdebug.remote_host	10.0.2.2	10.0.2.2
xdebug.remote_log	/var/log/xdebug.log	/var/log/xdebug.log
xdebug.remote_mode	req	req
xdebug.remote_port	9000	9000
xdebug.scream	Off	Off
xdebug.show_error_trace	Off	Off
xdebug.show_exception_trace	Off	Off
xdebug.show_local_vars	Off	Off
xdebug.show_mem_delta	Off	Off
xdebug.trace_enable_trigger	Off	Off
xdebug.trace_enable_trigger_value	no value	no value
xdebug.trace_format	0	0
xdebug.trace_options	0	0
xdebug.trace_output_dir	/tmp	/tmp
xdebug.trace_output_name	trace.%c	trace.%c
xdebug.var_display_max_children	128	128
xdebug.var_display_max_data	512	512
xdebug.var_display_max_depth	3	3

XDebug logfile (from setting xdebug.remote_log in php.ini):

Log opened at 2018-01-18 15:09:01
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Time-out connecting to client. :-(
Log closed at 2018-01-18 15:09:01

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 (11:59:58 AM)' } ] } }

-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 4 }

<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }

-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [ '*' ] },
  type: 'request',
  seq: 5 }

<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'setExceptionBreakpoints',
  success: true }

-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 6 }

-> threadsRequest
{ command: 'threads', type: 'request', seq: 7 }

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 7,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 1, name: 'Request 1 (11:59:58 AM)' } ] } }

<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 6,
  command: 'configurationDone',
  success: true }

<- threadEvent
ThreadEvent {
  seq: 0,
  type: 'event',
  event: 'thread',
  body: { reason: 'exited', threadId: 1 } }

-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { name: 'phpinfo.php',
        path: 'c:\\Users\\s.veggiani\\Work\\projects\\yog18\\repo\\html\\phpinfo.php' },
     lines: [ 3 ],
     breakpoints: [ { line: 3 } ],
     sourceModified: false },
  type: 'request',
  seq: 8 }

<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 8,
  command: 'setBreakpoints',
  success: true,
  body: { breakpoints: [ { verified: false, line: 3 } ] } }

new connection 2
<- threadEvent
ThreadEvent {
  seq: 0,
  type: 'event',
  event: 'thread',
  body: { reason: 'started', threadId: 2 } }

<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }

-> threadsRequest
{ command: 'threads', type: 'request', seq: 9 }

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 9,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 2, name: 'Request 2 (12:01:14 PM)' } ] } }

-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { name: 'phpinfo.php',
        path: 'c:\\Users\\s.veggiani\\Work\\projects\\yog18\\repo\\html\\phpinfo.php' },
     lines: [ 3 ],
     breakpoints: [ { line: 3 } ],
     sourceModified: false },
  type: 'request',
  seq: 10 }

<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 10,
  command: 'setBreakpoints',
  success: true,
  body: { breakpoints: [ { verified: true, line: 3 } ] } }

-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 11 }

<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 11,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }

-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [ '*' ] },
  type: 'request',
  seq: 12 }

<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 12,
  command: 'setExceptionBreakpoints',
  success: true }

-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 13 }

-> threadsRequest
{ command: 'threads', type: 'request', seq: 14 }

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 14,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 2, name: 'Request 2 (12:01:14 PM)' } ] } }

<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 13,
  command: 'configurationDone',
  success: true }

<- threadEvent
ThreadEvent {
  seq: 0,
  type: 'event',
  event: 'thread',
  body: { reason: 'exited', threadId: 2 } }

Code snippet to reproduce:

<?php
$foo = 'hey!';
$bar = 'hou!';
echo '<h1>Hello!</h1>';

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 27 (6 by maintainers)

Most upvoted comments

I met the same problem on Mac OSX Mojave, But I sloved it by adding these code like below:

[Xdebug]
zend_extension="xdebug.so"
xdebug.remote_autorestart=1
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.remote_connect_back=1

Before I only add xdebug.remote_autorestart=1 line, the debug not working . When I both add the two line

xdebug.remote_autostart=1
xdebug.remote_autorestart=1

It’s work for me . I dont know why , but it can works now .

xdebug.remote_connect_back	Off	Off

this seems bad.

try settings in your php.ini

xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1

and fix pathMappings in your launch.json

 {
     "version": "0.2.0",
     "configurations": [
         {
             "name": "Listen for XDebug",
             "type": "php",
             "request": "launch",
             "pathMappings": {
-             "/var/www/html": "{workspaceRoot}/repo/html",
+             "/var/www/html": "${workspaceRoot}/repo/html",
             },
             "port": 9000,
             "log": true
         },
     ]
 }

if you using Vagrant. you also need port-forwarding in your Vagrantfile.

config.vm.network "forwarded_port", guest: 9000, host: 9000

This is quite crazy. One more thing I see. It used to be, that zend_extension required an absolute path not relative. I’m not sure if this is still the case… Also try to add "stopOnEntry": true to your launch.json just in case if Xdebug can connect to vscode… There are some obsolete and unneeded directives in the ini file… Try to remove discover_client_host as the host is fixed. Remove remote_handler and remote_enable as they are obsolete (Xdebug 2). Add back xdebug.mode=debug.

Try to make a simple test.php and add a phpinfo() in there to check that Xdebug is loaded and all the defines are ok. Try it with php cli and web… Maybe you have a conflicting ini somewhere.

Try to read this page if you see something I don’t: https://xdebug.org/docs/step_debug

I am having a very similar issue, except I get the xdebug logging to work. Everything is working fine, except it just won’t stop at breakpoints, errors, warnings, etc. What’s also weird is that this config was working a few weeks ago.

Vagrantfile:

Vagrant.configure("2") do |config|
    config.vm.box = "goodfolk/gf-lamp-5.6"
    config.vm.box_version = "1.0.1"
    config.vm.network "private_network", ip: "192.168.33.17"
    config.vm.network "forwarded_port", guest: 9000, host: 9000
    config.vm.hostname = "ybc.gfdev"
    config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=755"]
    config.vm.provision "shell", path: "setupcron.sh"
end

Debug Console (after starting and manually stopping debug)

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true }
-> disconnectRequest
{ command: 'disconnect',
  arguments: { restart: false },
  type: 'request',
  seq: 3 }
<- disconnectResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'disconnect',
  success: true }

launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    { 
      "name": "Listen for XDebug", 
      "type": "php", 
      "request": "launch", 
      "log": true, 
      "port": 9000, 
      "pathMappings": { 
        "/var/www/public": "${workspaceRoot}/public" 
      } 
    }
  ]
}

php.ini, xdebug related lines:

[xdebug]
zend_extension="/usr/lib/php/20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_host=10.0.2.2
xdebug.remote_log = /var/www/xdebug.log

I know there was an issue with VS Code a few weeks ago, could this be related? Everything seems to be working, except that it won’t stop execution no matter what. I tried @sveggiani’s fix but it didn’t work for me.