vim-vdebug / vdebug

Multi-language DBGP debugger client for Vim (PHP, Python, Perl, Ruby, etc.)
MIT License
1.3k stars 156 forks source link

path_maps path to a local symlink causes ignoring breakpoints, goes straight to completion #435

Open elle-the-dev opened 4 years ago

elle-the-dev commented 4 years ago

EDIT: I hadn't been able to figure out why breakpoints were being skipped when the vdebug connection otherwise worked properly. It turns out if a path_maps path contains a symlink, it will not work properly.

In my case, /var/www is a symlink to /home/derek/www

So this has the issue where breakpoints fail

let g:vdebug_options['path_maps'] = {'/var/www/local.laravel': '/var/www/local.laravel'}

And this works properly

let g:vdebug_options['path_maps'] = {'/var/www/local.laravel': '/home/derek/www/local.laravel'}

Below is the original issue as posted


Sorry if this is the wrong place for this but I don't know where this is failing. I have a successful connection and can step forward in the code. But setting a breakpoint then pressing F5 to go to the breakpoint (or disabling break on entry) will execute the rest of the code without hitting the breakpoint and I can't figure it out.

I've tried various versions of setting path_map without any success.

I am able to successfully configure xdebug without issue outside of Docker. Just when the image is running, the breakpoints don't stop despite being set. I've gone through old issues describing similar things but they seem to eventually reach the conclusion of it being fixed in a later version.

vdebug.log (I removed the lines for keymapper that severely bloated the output, if they're needed I can add them.

- [Debug] {Mon 16 2019 22:19:47} Started
- [Debug] {Mon 16 2019 22:19:47} Listening on port 9000
- [Debug] {Mon 16 2019 22:19:47} Closing the socket
- [Debug] {Mon 16 2019 22:19:47} Closing the socket
- [Debug] {Mon 16 2019 22:20:49} Creating hidden buffer: [' ● [<F5> Start] [<F6> Stop] [:help Vdebug]']
- [Debug] {Mon 16 2019 22:20:49} Creating hidden buffer: ['[0] {main} @ /var/www/local.laravel/public/index.php:10', '']
- [Debug] {Mon 16 2019 22:20:49} Creating hidden buffer: ['[ *Locals ] [ Superglobals ] [ User defined constants ]', '', '- Locals at /var/www/local.laravel/public/index.php:10', '', ' ⬦ $app = (uninitialized)', ' |', ' ⬦ $kernel = (uninitialized)', ' |', ' ⬦ $request = (uninitialized)', ' |', ' ⬦ $response = (uninitialized)', '']
- [Debug] {Mon 16 2019 22:20:52} Finishing socket server
- [Info] {Mon 16 2019 22:20:52} Vdebug stopped waiting for a connection
- [Debug] {Mon 16 2019 22:20:52} Hidden buffer after insert: [' ■ [<F5> Start] [<F6> Stop] [:help Vdebug]']
- [Debug] {Mon 16 2019 22:20:52} Creating hidden buffer: []
- [Debug] {Mon 16 2019 22:21:09} Started
- [Debug] {Mon 16 2019 22:21:09} Listening on port 9000
- [Debug] {Mon 16 2019 22:21:11} Found client, ('172.20.0.2', 57634)
- [Debug] {Mon 16 2019 22:21:11} Finishing socket server
- [Debug] {Mon 16 2019 22:21:11} create session
- [Debug] {Mon 16 2019 22:21:11} start session
- [Debug] {Mon 16 2019 22:21:11} Setting buffer for DebuggerWatch: []
- [Debug] {Mon 16 2019 22:21:11} Setting buffer for DebuggerStack: []
- [Debug] {Mon 16 2019 22:21:11} Setting buffer for DebuggerStatus: []
- [Debug] {Mon 16 2019 22:21:11} Storing existing key mapping, 'vnoremap <F2> :norm@q
' 
- [Debug] {Mon 16 2019 22:21:11} Storing existing key mapping, 'nnoremap <F2> :call Marvim_search()
' 
- [Debug] {Mon 16 2019 22:21:11} Storing existing key mapping, 'vnoremap <F3> y:call Marvim_template_store()
' 
- [Debug] {Mon 16 2019 22:21:11} Storing existing key mapping, 'nnoremap <F3> :call Marvim_macro_store()
' 
- [Info] {Mon 16 2019 22:21:12} Found connection from ('172.20.0.2', 57634)
- [Debug] {Mon 16 2019 22:21:12} Command: context_names -i 1
- [Debug] {Mon 16 2019 22:21:12} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="1"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>
- [Debug] {Mon 16 2019 22:21:12} Available context names: {0: 'Locals', 1: 'Superglobals', 2: 'User defined constants'}
- [Info] {Mon 16 2019 22:21:12} Updated line number of breakpoint 11000 to 16
- [Info] {Mon 16 2019 22:21:12} Registering 1 breakpoints with the debugger
- [Debug] {Mon 16 2019 22:21:12} Command: breakpoint_set -i 2 -t line -f "file:///home/derek/www/local.laravel/routes/web.php" -n 16 -s enabled
- [Debug] {Mon 16 2019 22:21:12} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" state="enabled" id="160002"></response>
- [Debug] {Mon 16 2019 22:21:12} starting with step_into (break_on_open = 1)
- [Debug] {Mon 16 2019 22:21:12} Command: step_into -i 3
- [Debug] {Mon 16 2019 22:21:12} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///var/www/local.laravel/public/index.php" lineno="10"></xdebug:message></response>
- [Debug] {Mon 16 2019 22:21:12} refresh event
- [Debug] {Mon 16 2019 22:21:12} ** RefreshEvent
- [Info] {Mon 16 2019 22:21:12} Getting stack information
- [Debug] {Mon 16 2019 22:21:12} Command: stack_get -i 4
- [Debug] {Mon 16 2019 22:21:12} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="4"><stack where="{main}" level="0" type="file" filename="file:///var/www/local.laravel/public/index.php" lineno="10"></stack></response>
- [Debug] {Mon 16 2019 22:21:12} Replacing remote path (/var/www/local.laravel) with local path (/var/www/local.laravel)
- [Debug] {Mon 16 2019 22:21:12} Replacing local path (/var/www/local.laravel) with remote path (/var/www/local.laravel)
- [Debug] {Mon 16 2019 22:21:12} Replacing remote path (/var/www/local.laravel) with local path (/var/www/local.laravel)
- [Info] {Mon 16 2019 22:21:12} Moving to current position in source window
- [Info] {Mon 16 2019 22:21:12} Setting source file: /var/www/local.laravel/public/index.php
- [Debug] {Mon 16 2019 22:21:12} Setting source line number: 10
- [Info] {Mon 16 2019 22:21:12} Placing pointer sign on line 10
- [Debug] {Mon 16 2019 22:21:12} ** GetContextEvent
- [Info] {Mon 16 2019 22:21:12} Getting Locals variables
- [Debug] {Mon 16 2019 22:21:12} Command: context_get -i 5 -c 0 -d 0
- [Debug] {Mon 16 2019 22:21:12} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="5" context="0"><property name="$app" fullname="$app" type="uninitialized"></property><property name="$kernel" fullname="$kernel" type="uninitialized"></property><property name="$request" fullname="$request" type="uninitialized"></property><property name="$response" fullname="$response" type="uninitialized"></property></response>
- [Info] {Mon 16 2019 22:21:12} Writing 4 properties to the window
- [Debug] {Mon 16 2019 22:21:12} Writing to window:
[ *Locals ] [ Superglobals ] [ User defined constants ]

- Locals at /var/www/local.laravel/public/index.php:10

 ⬦ $app = (uninitialized)
 |
 ⬦ $kernel = (uninitialized)
 |
 ⬦ $request = (uninitialized)
 |
 ⬦ $response = (uninitialized)

- [Debug] {Mon 16 2019 22:21:12} ** TraceRefreshEvent
- [Debug] {Mon 16 2019 22:21:14} ** RunEvent
- [Info] {Mon 16 2019 22:21:14} Running
- [Debug] {Mon 16 2019 22:21:14} Command: run -i 6
- [Debug] {Mon 16 2019 22:21:14} Response: <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="6" status="stopping" reason="ok"></response>
- [Debug] {Mon 16 2019 22:21:14} ** RefreshEvent
- [Info] {Mon 16 2019 22:21:14} Debugging session has ended
- [Info] {Mon 16 2019 22:21:14} closing connection because status is stopped
- [Info] {Mon 16 2019 22:21:14} Closing the connection
- [Debug] {Mon 16 2019 22:21:14} Closing the socket
- [Debug] {Mon 16 2019 22:21:14} ** ListenEvent
- [Debug] {Mon 16 2019 22:21:14} Started
- [Debug] {Mon 16 2019 22:21:14} Closing the socket
- [Debug] {Mon 16 2019 22:21:14} Listening on port 9000
- [Debug] {Mon 16 2019 22:21:14} Closing the socket

.vimrc vdebug config

let g:vdebug_options = {}
let g:vdebug_options['port']=9000
let g:vdebug_options['path_maps']={'/var/www/local.laravel': '/var/www/local.laravel'}

php.ini xdebug

xdebug.remote_host             = host.docker.internal
xdebug.remote_autostart        = 1
xdebug.remote_enable           = 1
xdebug.remote_port             = 9000
xdebug.default_enable          = 1
xdebug.remote_connect_back     = 1
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1

Dockerfile

FROM php:7.4-apache

# install linux packages
RUN apt-get update && apt-get install -y \
    git \
    libzip-dev \
    zip \
    curl

# install and enable PHP extensions
RUN pecl install -o -f xdebug-2.8.1
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install zip
RUN docker-php-ext-enable xdebug

# clear tmp pear install files
RUN rm -rf /tmp/pear;

# copy virtualhost files into the container
COPY ./sites-available/* /etc/apache2/sites-available/

# copy php.ini
ADD ./php.ini /usr/local/etc/php/

# enable the sites
RUN cd /root \
    && ln -s /etc/apache2/sites-available/local.laravel.conf /etc/apache2/sites-enabled/

docker-compose.yml

version: '3.2'
services:
  web:
    build: .
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/www:/var/www:cached
    environment:
      - PATH=/root/bin:/root/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

When it's started with break on entry

image

After I hit F5 with a break in the controller

image

My local and docker PHP version output is the same

PHP 7.4.0 (cli) (built: Nov 28 2019 07:27:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.0, Copyright (c), by Zend Technologies
    with Xdebug v2.8.1, Copyright (c) 2002-2019, by Derick Rethans

Thanks in advance for any suggestions or insight.

BlackIkeEagle commented 4 years ago

Thanks, I'll reproduce this locally and figure out a fix