1

I'm learning a large code base at the moment, which involves code deployed across several (about 9) physical servers. Due to the overall architecture, I can't roll code up onto one machine with many virtualhosts.

I would find it really useful to be able to launch one debug session in my IDE (either NetBeans or Eclipse), and hit breakpoints when code executes on any of my group of servers. This can happen either by browsing accross servers, or RPC/HTTP calls within server code.

To achieve this, I think I need some kind of dbgp proxy, which will forward debug data between multiple servers (the standard dbgp proxy methods I've found in searches go the other way - multiple users on single server).

Is there an existing way of doing this? Have I missed something obvious (or subtle) that would mean I need more than dbgp proxying?


I'm aware of Debugging 2 servers with php's Xdebug at the same time, however the solution there is completely inappropriate here... running 8 VMs (or getting 8 client machines) isn't a viable option


As a sub question, if I end up rolling my own open-sourced solution, do people care what language I use? Java seems good for IDE integration, C/C++ probably has fewer dependency issues for any non-java-IDE users (maybe vim/xdebug)

1 Answer 1

2

At the time I asked the question, I misunderstood how the protocol works, and a proxy isn't strictly necessary.

XDebug (and the DBGP protocol) initiates a connection from a server back to a client, based on a configured IP address, or (recently, but not recommended) the client IP.

This behaviour is enabled in one of 2 ways:

  • Appending ?XDEBUG_SESSION_START=<something> to a URL
  • Setting the cookie "XDEBUG_SESSION" to <something>

Although it is possible to have a HTTP proxy between the browser and client that inserts one of these (or a browser plugin to do it), a neater solution for me was to use mod_rewrite on a server.

RewriteEngine On

RewriteCond %{HTTP_COOKIE} !XDEBUG_SESSION   [NC]
RewriteRule ^(.*)$ $1?XDEBUG_SESSION_START=mod_rewrite [QSA,L]

As mod_rewrite normally operates on a per-virtualhost basis, this needs enabling on each virtualhost.

The session name doesn't seem to be significant with NetBeans, (other IDEs may vary), but it may be worth changing my value of mod_rewrite to whatever your IDE generates. This is unlikely to work if a DBGP proxy is in use, as there's no easy way to tie IDE session information into the rewrite rule.

That said, the big advantage of using mod_rewrite instead of intercepting requests with a proxy is that this allows debugging of both sides of an RPC call (although whether a single debugger likes multiple concurrent connections is another issue).

It would still be nice to have a DBGP proxy that manages streams from separate servers by adding the servername into the thread field in init packets, but as I have yet to use a debugger that supports multiple threads/servers for PHP, it's a moot point.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.