debugging Xdebug正在忽略VSCode中的断点(尝试调试PHP文件)

svujldwt  于 2023-08-06  发布在  Vscode
关注(0)|答案(1)|浏览(118)

我遵循了这个指南:

Download xdebug-3.0.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-3.0.2.tgz
Run: cd xdebug-3.0.2

Run: phpize (See the FAQ if you don't have phpize).

As part of its output it should show:

Configuring for:
...
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20190902
Update /etc/php/7.4/cli/php.ini and change the line
zend_extension = /usr/lib/php/20190902/xdebug.so
Make sure that zend_extension = /usr/lib/php/20190902/xdebug.so is below the line for OPcache.
Please also update php.ini files in adjacent directories, as your system seems to be configured with a separate php.ini file for the web server and command line.

字符串
https://xdebug.org/wizard,我把我的phpinfo()服务器信息关于我的系统。完成后,我的/etc/php/7.4/cli/php.ini有这些行:

[opcache]
1768 zend_extension = /usr/lib/php/20190902/xdebug.so
1769 remote_enable=1
1770 remote_autostart=1
1771 report_zend_debug=1
...


但是,如果我尝试在VSCode中生成这个launch.json(默认)配置:

{
    "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
        }
    ]
}


Launch current open script(VSCode调试器)忽略断点。我不知道当Xdebuger安装时我应该知道什么。在VSCode中生成config .json文件,以便不忽略断点。有什么想法吗
xdebug wizard的输出(包含指南的页面):

Installation Wizard
Summary

    Xdebug installed: 3.0.2
    Server API: Apache 2.0 Handler
    Windows: no
    Zend Server: no
    PHP Version: 7.4.9
    Zend API nr: 320190902
    PHP API nr: 20190902
    Debug Build: no
    Thread Safe Build: no
    OPcache Loaded: yes
    Configuration File Path: /etc/php/7.4/apache2
    Configuration File: /etc/php/7.4/apache2/php.ini
    Extensions directory: /usr/lib/php/20190902

You're already running the latest Xdebug version
...


然而,在将上面的设置粘贴到/etc/php/7.4/cli/php.ini/etc/php/7.4/apache2/php.ini之后,断点不起作用。
编辑:
phpinfo()(xdebug部分):

Feature Enabled/Disabled    Docs
Development Aids    ✔ enabled   🖹
Coverage    ✘ disabled  🖹
GC Stats    ✘ disabled  🖹
Profiler    ✘ disabled  🖹
Step Debugger   ✘ disabled  🖹
Tracing ✘ disabled  🖹
Directive   Local Value Master Value
xdebug.auto_trace   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.cli_color    0   0
xdebug.client_discovery_header  no value    no value
xdebug.client_host  localhost   localhost
xdebug.client_port  9003    9003
xdebug.cloud_id no value    no value
xdebug.collect_assignments  Off Off
xdebug.collect_includes (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.collect_params   (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.collect_return   Off Off
xdebug.collect_vars (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.connect_timeout_ms   200 200
xdebug.coverage_enable  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.default_enable   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.discover_client_host Off Off
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.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  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.gc_stats_output_name gcstats.%p  gcstats.%p
xdebug.halt_level   0   0
xdebug.idekey   no value    no value
xdebug.log  no value    no value
xdebug.log_level    7   7
xdebug.max_nesting_level    256 256
xdebug.max_stack_frames -1  -1
xdebug.mode develop develop
xdebug.output_dir   /tmp    /tmp
xdebug.overload_var_dump    (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.profiler_append  Off Off
xdebug.profiler_enable  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger_value    (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_output_dir  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
xdebug.remote_autostart (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_connect_back  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_enable    (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_host  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_log   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_log_level (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_mode  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_port  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_timeout   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
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   (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.start_upon_error default default
xdebug.start_with_request   default default
xdebug.trace_enable_trigger (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.trigger_value    no value    no value
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3

x759pob2

x759pob21#

对我来说,关键的一句话是:

xdebug.start_with_request = yes

字符串
xdebug.start_with_request文档
来自StackOverflow线程的有用相关答案
对于https://xdebug.org/docs/install#linux下显示的php7.4-xdebug包,我的完整配置是/etc/php/7.4/mods-available/xdebug.ini

zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.mode = debug
xdebug.start_with_request = yes

相关问题