繁体   English   中英

当连接被先前无趣的服务器调用“浪费”时如何使用 XDebug 和 vim

[英]How to use XDebug and vim when the connection is "wasted" by a prior uninteresting server call

我正在使用带有Vdebug 插件和 Xdebug 的 vim 来调试nextcloud 实例的 WebDAV 服务器。 Nextcloud 使用 SabreDAV,所以 WebDAV 服务器是一个 PHP 脚本。 nextcloud 使用的桌面文件同步客户端 ( owncloud)将本地文件夹与 nextcloud 网络存储保持同步。

我想根据 WebDAV 文件上传(大概是PUT )请求调试 nextcloud 服务器的配额计算问题。 但是,如果本地文件发生更改,则 owncloud 客户端会向服务器发出多个 WebDAV 请求,其中第一个请求对我来说并不重要(大概是PROPFIND或类似请求)。 只有在这个无趣的请求之后,才会发送上传请求。 但是,如果我设置 vim 来侦听 Xdebug ( :VdebugStart ) 的传入连接,则第一个无趣的 WebDAV 请求会建立连接,但我想为以后传入的 Xdebug 连接建立连接。 但是,在 owncloud 客户端使用有趣的 WebDAV 请求再次调用服务器之前,我的速度不够快,无法将 vim 设置为侦听模式。

可能有两种处理方式:

  • 在第一个(无趣的)连接结束后,让 vim 非常快地侦听新的 Xdebug 连接
  • 让 PHP 不是一开始就建立 Xdebug 连接,而是只在调用某个代码块时,该代码块对应于客户端感兴趣的上传请求。 我可以插入一些 PHP 函数xdebug_connect_now_to_client()函数,而不是从一开始xdebug_connect_now_to_client()接到 vim 的 Xdebug。

您知道实现其中一个目标的可能性,还是有其他解决方案?


相关php.ini条目:

zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
; have to set this, because owncloud does not set the
; XDEBUG_START_SESSION=true GET parameter
xdebug.remote_autostart=on
xdebug.idekey=netbeans-xdebug

像你一样,我在使用 xdebug 和 vdebug 在 NextCloud 中调试 WebDav 请求时遇到了这个问题。

我喜欢上面的 LazyOne 建议在断点处编码。

我最终做的是设置

xdebug.remote_autostart=0 

并尽可能使用下面的插件来仅针对我的请求启用调试。

https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/

我还发现最初启用跟踪有助于至少了解我需要查看代码中的哪个位置,这也可能有助于您手动设置断点。 在这里,您可以再次使用插件来最小化将生成跟踪的请求。

xdebug.remote_log=/tmp/xdebug_remote.log
xdebug.trace_options=1
# Write a trace file per process
xdebug.trace_output_name=trace.%p
# Only trace if we get XDEBUG_TRACE
xdebug.auto_trace=0
xdebug.trace_enable_trigger=1

我正在使用 php-fpm 我也设置了

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
pm = static

这样就不会有大量进程创建跟踪文件和发出请求

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM