Docker,VScode不会在断点处进行远程调试

时间:2018-10-11 01:51:55

标签: php docker debugging visual-studio-code xdebug

远程debugging不会在断点处停止。

远程调试如何在断点处停止?

用法

  • Visual Studio代码(具有php-debug扩展名)
  • xdebug(版本2.6.0)
  • Docker(版本18.09.0-ce-beta1)
  • docker-compose(版本1.22.0)

xdebug配置

我可以在phpinfo中看到with Xdebug v2.6.0和xdebug配置, 所以xdebug配置正确设置了!

这是xdebug配置

$ php -i | grep xdebug                                                                                                                        
xdebug                                                                                                                                        
xdebug support => enabled                                                                                                                     
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.filename_format => no value => no value                                                                                                
xdebug.force_display_errors => Off => Off                                                                                                     
xdebug.force_error_reporting => 0 => 0                                                                                                        
xdebug.gc_stats_enable => Off => Off                                                                                                          
xdebug.gc_stats_output_dir => /tmp => /tmp                                                                                                    
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p                                                                                       
xdebug.halt_level => 0 => 0
xdebug.idekey => vscode => vscode
xdebug.max_nesting_level => 256 => 256  
xdebug.max_stack_frames => -1 => -1    
xdebug.overload_var_dump => 2 => 2
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 => host.docker.internal => host.docker.internal
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 90055555 => 90055555
xdebug.remote_timeout => 200 => 200
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

VSCode配置

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "stackOverflow",
            "type": "php",
            "request": "launch",
            "port": 9005,
            "pathMappings": {
                "/app": "/home/user/test"
              }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

注意

  • xdebug也不会在xdebug_break()处停止; 这是否意味着xdebug和docker主机未连接?

  • 将xdebug_remote_host从host.docker.internal更改为127.18.0.4也会失败

0 个答案:

没有答案