Vscode-php-debug: Debugger does not allow to `move around`, doesn't display locals

Created on 22 Nov 2017  路  13Comments  路  Source: xdebug/vscode-php-debug

PHP version: PHP 7.1.11
XDebug version: php_xdebug-2.5.4-7.1-vc14.dll
Adapter version: 1.12.1

Your 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",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

XDebug php.ini config:

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.profiler_enable = 0
xdebug.remote_handler="dbgp"
xdebug.profiler_enable_trigger = Off
xdebug.show_local_vars=0

Code snippet to reproduce:
any

I'm having trouble with the latest version of your debugger. I can make breakpoints, and debugger will stop on these breakpoints, but I can't do much else. Can't move around with F10, F11. All my locals are 'uninitialiazed':

https://i.imgur.com/Mo6R0L8.png

It was working fine yesterday and it suddenly stopped working. Today I updated to latest version and it still happening.

needs more info

Most helpful comment

I solved by remove all Watch Variables.

All 13 comments

Please include the logs

xdebug log:

Log opened at 2017-11-22 15:46:26
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
W: Remote address not found, 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:///X:/test/test.php" language="PHP" xdebug:language_version="7.1.1-dev" protocol_version="1.0" appid="1240" idekey="koperkiewicz.ma"><engine version="2.5.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2017 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 conditional -f file:///X:/test/report.php -n 161 -- JHByb2pla3QgPT0gIkQwMjUzOTEwIg==
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="12400001"></response>

<- breakpoint_set -i 4 -t line -f file:///X:/test/test.php -n 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="12400002"></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:///X:/test/test.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="12400002"></breakpoint><breakpoint type="conditional" filename="file:///X:/test/report.php" lineno="161" state="enabled" hit_count="0" hit_value="0" id="12400001"><expression encoding="base64"><![CDATA[JHByb2pla3QgPT0gIkQwMjUzOTEwIg==]]></expression></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:///X:/test/test.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="12400002"></breakpoint><breakpoint type="conditional" filename="file:///X:/test/report.php" lineno="161" state="enabled" hit_count="0" hit_value="0" id="12400001"><expression encoding="base64"><![CDATA[JHByb2pla3QgPT0gIkQwMjUzOTEwIg==]]></expression></breakpoint></response>

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

<- run -i 8
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="8" status="break" reason="ok"><xdebug:message filename="file:///X:/test/test.php" lineno="3"></xdebug:message></response>

<- stack_get -i 9
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="9"><stack where="{main}" level="0" type="file" filename="file:///X:/test/test.php" lineno="3"></stack></response>

<- eval -i 10 -- JHRoaXMtPmRhdGU=
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10" status="break" reason="ok"><xdebug:message filename="file://X:/test/xdebug:/debug-eval" lineno="1" exception="Error"><![CDATA[Using $this when not in object context]]></xdebug:message></response>

<- context_names -i 11 -d 0
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="11"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

<- context_get -i 12 -d 0 -c 0
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="12" context="0"><property name="$array" fullname="$array" type="uninitialized"></property><property name="$date" fullname="$date" type="uninitialized"></property></response>

<- step_over -i 13
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="10" status="running" reason="ok"><error code="206"><message><![CDATA[error evaluating code]]></message></error></response>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="13" status="break" reason="ok"><xdebug:message filename="file:///X:/test/test.php" lineno="5"></xdebug:message></response>

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

Log closed at 2017-11-22 15:46:34

adapter log:

<- 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 (4:46:26 PM)' } ] } }

-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { name: 'test.php',
        path: 'x:\\test\\test.php' },
     lines: [ 3 ],
     breakpoints: [ { line: 3 } ],
     sourceModified: false },
  type: 'request',
  seq: 5 }

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

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

-> 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: [ 'Error' ] },
  type: 'request',
  seq: 7 }

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

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

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

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 9,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 1, name: 'Request 1 (4:46:26 PM)' } ] } }

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

<- stoppedEvent
StoppedEvent {
  seq: 0,
  type: 'event',
  event: 'stopped',
  body: { reason: 'breakpoint', threadId: 1, allThreadsStopped: false } }

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

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 10,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 1, name: 'Request 1 (4:46:26 PM)' } ] } }

-> stackTraceRequest
{ command: 'stackTrace',
  arguments: { threadId: 1, startFrame: 0, levels: 20 },
  type: 'request',
  seq: 11 }

<- stackTraceResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 11,
  command: 'stackTrace',
  success: true,
  body: 
   { stackFrames: 
      [ { id: 1,
          name: '{main}',
          source: 
           { name: 'test.php',
             path: 'X:\\test\\test.php' },
          line: 3,
          column: 1 } ] } }

-> evaluateRequest
{ command: 'evaluate',
  arguments: { expression: '$this->date', frameId: 1, context: 'watch' },
  type: 'request',
  seq: 12 }

<- evaluateResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 12,
  command: 'evaluate',
  success: true,
  body: 
   { result: 'Using $this when not in object context',
     variablesReference: 0 } }

-> scopesRequest
{ command: 'scopes',
  arguments: { frameId: 1 },
  type: 'request',
  seq: 13 }

<- scopesResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 13,
  command: 'scopes',
  success: true,
  body: 
   { scopes: 
      [ Scope { name: 'Locals', variablesReference: 1, expensive: false },
        Scope { name: 'Superglobals', variablesReference: 2, expensive: false },
        Scope {
          name: 'User defined constants',
          variablesReference: 3,
          expensive: false } ] } }

-> variablesRequest
{ command: 'variables',
  arguments: { variablesReference: 1 },
  type: 'request',
  seq: 14 }

<- variablesResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 14,
  command: 'variables',
  success: true,
  body: 
   { variables: 
      [ { name: '$array',
          value: 'uninitialized',
          type: 'uninitialized',
          variablesReference: 0 },
        { name: '$date',
          value: 'uninitialized',
          type: 'uninitialized',
          variablesReference: 0 } ] } }

-> nextRequest
{ command: 'next',
  arguments: { threadId: 1 },
  type: 'request',
  seq: 15 }

-> stepInRequest
{ command: 'stepIn',
  arguments: { threadId: 1 },
  type: 'request',
  seq: 16 }

-> disconnectRequest
{ command: 'disconnect',
  arguments: { restart: false },
  type: 'request',
  seq: 17 }

<- nextResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 15,
  command: 'next',
  success: true }

<- stoppedEvent
StoppedEvent {
  seq: 0,
  type: 'event',
  event: 'stopped',
  body: { reason: 'step', threadId: 1, allThreadsStopped: false } }

<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body: { category: 'stdout', output: '6 in array' } }

6 in array
<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body: { category: 'console', output: 'connection 1 closed\n' } }

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

<- disconnectResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 17,
  command: 'disconnect',
  success: true }


Once debugger pause at breakpoint I can only stop debugger - can't continue, step over, step into, step out. Weird thing is that "stop" only stops debugging, not the execution of script.

I have same issue.

I solved by remove all Watch Variables.

I see same issue, my case stopped by static function
static function change to local function, push F10 is debugger moved.

Had same issue appear recently.
I tried @duckhan suggestion to remove watched existing values (and I removed all breakpoints too), and suddenly I can step, continue, hover mouse and see variable values (rather than undefined), etc.

@duckhan: Thank you, your suggestion was a timely answer to frustrated prayer!

For me the same, I also think I have narrowed the bug.
As soon you have an instance method (e.g. $messageStack->size('test')) in watch and you get out of context so the instance gets null, "call to a member function size() on null" appears as evaluation value and the debugger hangs. After this you can restart as often you want and get only the first breakpoint out of this context and the uninitialized variables.
After removing this call from watch and restart of debugger, all is normal again.

@duckhan : Worked like a charm - thanks a lot !

For me the same, I also think I have narrowed the bug.
As soon you have an instance method (e.g. $messageStack->size('test')) in watch and you get out of context so the instance gets null, "call to a member function size() on null" appears as evaluation value and the debugger hangs. After this you can restart as often you want and get only the first breakpoint out of this context and the uninitialized variables.
After removing this call from watch and restart of debugger, all is normal again.

I can confirm and replicate exactly what @Manusan42 is doing. A null returned on an instance method makes the debugger hang.

Same issue. @duckhan's hint works!
What is about the label "needs more information"? This issue is from Nov 2017.

It worked for me a soon as I cleared the watched items also.

This bug is still very much alive. Using Visual Code 1.52.1and PHP Debug v1.14.5 on MacOS. I'm also running PHP 7.2.24-0ubuntu0.18.04.7 on a container in Docker.

I had non-existent variable, called $non_existent, in Watch window and when debugging I couldn't see any value when hovering over PHP variables. Now that I cleared the Watch window I can see values when in a breakpoint and I hover on a local variable that is in the scope.

In PHP logs I get this:

ERROR - 2021-01-13 19:23:13 --> Severity: Notice --> Undefined variable: non_existent xdebug://debug-eval 1

So clearly some misbehaviour is happening when there is non-existent variables in Watch.

I'm testing this with Xdebug 3. PHP8. Non-existing variables in watch just show up as null.
But I can config this is happening on Xdebug 2.
I'll try to look at it, but honestly since Xdebug 2 is out of support I'm hesitant to invest much time into this - since I have a feeling it would require a fix on that level.

Was this page helpful?
0 / 5 - 0 ratings