Understanding XDebug using Message Sequence Charts (mscgen)
These Message Sequence charts will help us to better understand the communication that happens between the IDE and XDebug during a debugging session. These charts are generated using the awesome mscgen_js
library.
Single User/Static IP
- IDE/Editor starts a debug client server on PORT 9000
- User sends session initiation command to the XDebug using GET/POST/COOKIE parameters or environment variables
- XDebug connects to remote IDE using
xdebug.remote_host
andxdebug.remote_port
values. It sends aninit
packet and waits without executing any code. - IDE negotiates features or set any breakpoints
- IDE send commands to interactively walk through the code
- When finished, XDebug sends response back to browser.
Multi User/Unknown IP
- IDE/Editor starts a debug client server on PORT 9000
- User sends session initiation command to the XDebug using GET/POST/COOKIE parameters
- XDebug connects to remote IDE using
$_SERVER['HTTP_X_FORWARDED_FOR']
or$_SERVER['REMOTE_ADDR']
values. It sends aninit
packet and waits without executing any code. - IDE negotiates features or set any breakpoints
- IDE send commands to interactively walk through the code
- When finished, XDebug sends response back to browser.
DBGp Proxy
- IDE/Editor starts a debug client server on PORT 9002
- IDE sends a
proxyinit
command to the proxy server on port9001
along with aidekey
and an address to connect back to IDE on port9002
- Proxy server stores the
idekey
and the IDE address where deubg clien is listening - User sends session initiation command to the XDebug using GET/POST/COOKIE parameters
- XDebug connects to proxy server using
xdebug.remote_host
andxdebug.remote_port
values. It sends aninit
packet withidekey
and waits without executing any code. - Proxy server looks up the
idekey
and finds the IDE address. It then sends the sameinit
command to the IDE - IDE negotiates features or set any breakpoints with the proxy server and proxy server sends the same commands to the XDebug
- IDE send commands to proxy server to interactively walk through the code. Proxy server proxies all commands and response to XDebug
- When finished, XDebug sends response back to browser.
Just-in-time Debugging (JIT)
- IDE/Editor starts a debug client server on PORT 9000
- XDebug starts code execution and stops when an error occurs
- XDebug connects to remote IDE using
xdebug.remote_host
andxdebug.remote_port
values. It sends aninit
packet withidekey
- IDE negotiates features or set any breakpoints
- IDE send commands to interactively walk through the code
- When finished, XDebug sends response back to browser.