简体   繁体   English

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

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

I'm using vim with the Vdebug plugin and Xdebug to debug the WebDAV server of a nextcloud instance .我正在使用带有Vdebug 插件和 Xdebug 的 vim 来调试nextcloud 实例的 WebDAV 服务器。 Nextcloud uses SabreDAV, so the WebDAV server is a PHP script. Nextcloud 使用 SabreDAV,所以 WebDAV 服务器是一个 PHP 脚本。 The desktop file synchronization client ( owncloud) which nextcloud uses keeps a local folder in sync with the nextcloud web storage. nextcloud 使用的桌面文件同步客户端 ( owncloud)将本地文件夹与 nextcloud 网络存储保持同步。

I want to debug issues with quota calculation of the nextcloud server upon a WebDAV file upload (presumably PUT ) request.我想根据 WebDAV 文件上传(大概是PUT )请求调试 nextcloud 服务器的配额计算问题。 However, the owncloud client issues multiple WebDAV requests to the server if a local file changes, where the first request(s) is/are not of importance to me (presumably a PROPFIND or similar).但是,如果本地文件发生更改,则 owncloud 客户端会向服务器发出多个 WebDAV 请求,其中第一个请求对我来说并不重要(大概是PROPFIND或类似请求)。 Only after this uninteresting request(s), an upload request is sent.只有在这个无趣的请求之后,才会发送上传请求。 However, if I set up vim to listen for an incoming connection by Xdebug ( :VdebugStart ), the first uninteresting WebDAV request establishes the connection, but I would like to establish the connection for later incoming Xdebug connections.但是,如果我设置 vim 来侦听 Xdebug ( :VdebugStart ) 的传入连接,则第一个无趣的 WebDAV 请求会建立连接,但我想为以后传入的 Xdebug 连接建立连接。 However, I am not fast enough to set vim into listen mode before the owncloud client calls the server again with the interesting WebDAV request.但是,在 owncloud 客户端使用有趣的 WebDAV 请求再次调用服务器之前,我的速度不够快,无法将 vim 设置为侦听模式。

There might be two ways of dealing with this:可能有两种处理方式:

  • Make vim listen for a new Xdebug connection very fast after the first (uninteresting) one ends在第一个(无趣的)连接结束后,让 vim 非常快地侦听新的 Xdebug 连接
  • Make PHP not establish an Xdebug connection right from the start, but only when a certain code block, which corresponds to the interesting upload request by the client, is called.让 PHP 不是一开始就建立 Xdebug 连接,而是只在调用某个代码块时,该代码块对应于客户端感兴趣的上传请求。 I could insert some PHP function xdebug_connect_now_to_client() function instead of Xdebug connecting to vim right from the start.我可以插入一些 PHP 函数xdebug_connect_now_to_client()函数,而不是从一开始xdebug_connect_now_to_client()接到 vim 的 Xdebug。

Do you know a possiblity to archieve one of those goals, or is there another solution?您知道实现其中一个目标的可能性,还是有其他解决方案?


Relevant php.ini entries:相关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

Like you I ran into this issue debugging WebDav requests in NextCloud using xdebug and vdebug.像你一样,我在使用 xdebug 和 vdebug 在 NextCloud 中调试 WebDav 请求时遇到了这个问题。

I like LazyOne's suggestion above to code in a break point.我喜欢上面的 LazyOne 建议在断点处编码。

What I ended up doing was to set我最终做的是设置

xdebug.remote_autostart=0 

and to as much as possible use the addon below to enable debugging only for my request.并尽可能使用下面的插件来仅针对我的请求启用调试。

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

I also found it helpful to enable tracing initially to get at least some idea where in the code I needed to look, which might also help you put in a manual breakpoint.我还发现最初启用跟踪有助于至少了解我需要查看代码中的哪个位置,这也可能有助于您手动设置断点。 Here again you can use the addon to minimize requests that will generate a trace.在这里,您可以再次使用插件来最小化将生成跟踪的请求。

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

I'm using php-fpm I also set我正在使用 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

so that there's not a ton of processes creating trace files and issuing requests这样就不会有大量进程创建跟踪文件和发出请求

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

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