简体   繁体   中英

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 . Nextcloud uses SabreDAV, so the WebDAV server is a PHP script. The desktop file synchronization client ( owncloud) which nextcloud uses keeps a local folder in sync with the nextcloud web storage.

I want to debug issues with quota calculation of the nextcloud server upon a WebDAV file upload (presumably PUT ) request. 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). 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. 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.

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
  • 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. I could insert some PHP function xdebug_connect_now_to_client() function instead of Xdebug connecting to vim right from the start.

Do you know a possiblity to archieve one of those goals, or is there another solution?


Relevant php.ini entries:

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.

I like LazyOne's suggestion above to code in a break point.

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/

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

; 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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