![]() |
|||||
|
XDEBUG EXTENSION FOR PHP | DOCUMENTATION
home |
updates |
documentation |
license |
support
» Documentation for: Xdebug 2 » Feature: Remote Debugging Xdebug provides an interface for debugger clients that interact with running PHP scripts. This section explains how to set-up PHP and Xdebug to allow this, and introduces a few clients. IntroductionXdebug's (remote) debugger allows you to examine data structure, interactively walk through your and debug your code. There are two different protocols to communicate with the debugger: the old GDB-like command protocol (GDB) which is implemented in Xdebug 1.3 and 2; and the DBGp protocol which is implemented in Xdebug 2. ClientsXdebug 2 is bundled with a simple command line client for the DBGp protocol. There are a few other client implementations (both free and commercial) as well:
A simple command line client for the GDB protocol is bundled with Xdebug 1.3. A client implementation of the deprecated GDB protocol can also be found in the free editor WeaverSlave. Starting The DebuggerIn order to enable Xdebug's debugger you need to make some configuration settings in php.ini. These settings are xdebug.remote_enable to enable the debugger, xdebug.remote_host and xdebug.remote_port to configure the IP address and port where the debugger should connect to and xdebug.remote_handler to configure which debug backend to use ("gdb" or "dbgp"). If you want the debugger to initiate a session when an error situation occurs (php error or exception) then you also need to change the xdebug.remote_mode setting. Allowed values for this setting are "req" (the default) which makes the debugger initiate a session as soon as a script is started, or "jit" when a session should only be initiated on an error. After made all those settings Xdebug will still not start a debugging session automatically when a script is run. You need to activate Xdebug's debugger and you can do that in two ways:
Before you start your script you will need to tell your client that it can receive debug connections, please refer to the documentation of the specific client on how to do this. To use the bundled client simply start it after compiling and installing it. You can start it by running "debugclient". If you want to use the GDB commandset to debug your scripts, make sure you use a debugclient as bundled with Xdebug 1.3 as the one bundled with Xdebug 2 only works with the DBGp commandset. When the debugclient starts it will show the following information and then waits until a connection is initiated by the debug server: Xdebug Simple DBGp client (0.10.0) Copyright 2002-2007 by Derick Rethans. - libedit support: enabled Waiting for debug server to connect. After a connection is made the output of the debug server is shown:
Connect
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="file:///home/httpd/www.xdebug.org/html/docs/index.php"
language="PHP"
protocol_version="1.0"
appid="13202"
idekey="derick">
<engine version="2.0.0RC4-dev"><![CDATA[Xdebug]]></engine>
<author><![CDATA[Derick Rethans]]></author>
<url><![CDATA[http://xdebug.org]]></url>
<copyright><![CDATA[Copyright (c) 2002-2007 by Derick Rethans]]></copyright>
</init>
(cmd)
Now you can use the commandset as explained on the DBGp documentation page. When the script ends the debug server disconnects from the client and the debugclient resumes with waiting for a new connection. HTTP Debug SessionsXdebug contains functionality to keep track of a debug session when started through a browser: cookies. This works like this:
There is also a FireFox 2 extension that allows you to trigger Xdebug's debugger or profiler without having to use XDEBUG_SESSION_START as parameter. You can configure which IDE key it uses. You can find this extension here. Related Settingsxdebug.extended_info
Type: integer, Default value: 1
Controls whether Xdebug should enforce 'extended_info' mode for the PHP
parser; this allows Xdebug to do file/line breakpoints with the remote
debugger. When tracing or profiling scripts you generally want to turn off this
option as PHP's generated oparrays will increase with about a third of the size
slowing down your scripts. This setting can not be set in your scripts with
ini_set(), but only in php.ini.
xdebug.idekey
Type: string, Default value: *complex*
Controls which IDE Key Xdebug should pass on to the DBGp debugger handler.
The default is based on environment settings. First the environment setting
DBGP_IDEKEY is consulted, then USER and as last USERNAME. The default is set
to the first environment variable that is found. If none could be found the
setting has as default ''.
xdebug.remote_autostart
Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start
remote debugging (see Remote Debugging). When
this setting is set to 'On' Xdebug will always attempt to start a remote
debugging session and try to connect to a client, even if the GET/POST/COOKIE
variable was not present.
xdebug.remote_enable
Type: boolean, Default value: 0
This switch controls whether Xdebug should try to contact a debug client
which is listening on the host and port as set with the settings
xdebug.remote_host and
xdebug.remote_port. If a connection can not be established the script will just
continue as if this setting was Off.
xdebug.remote_handler
Type: string, Default value: dbgp
Can be either 'php3' which selects the old PHP 3 style debugger
output, 'gdb' which enables the GDB like debugger interface or 'dbgp' - the
brand new debugger protocol. The DBGp protocol is
more widely supported by clients. See more information in the introduction for
Remote Debugging.
xdebug.remote_host
Type: string, Default value: localhost
Selects the host where the debug client is running, you can either use a
host name or an IP address.
xdebug.remote_log
Type: string, Default value: none
If set to a value, it is used as filename to a file to which all remote
debugger communications are logged. The file is always opened in append-mode,
and will therefore not be overwritten by default. There is no concurrency
protection available. The format of the file looks something like:
Log opened at 2007-05-27 14:28:15 -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/x ... ight></init> <- step_into -i 1 -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/db ... ></response> xdebug.remote_mode
Type: string, Default value: req
Selects when a debug connection is initiated. This setting can have two different values:
xdebug.remote_port
Type: integer, Default value: 9000
The port to which Xdebug tries to connect on the remote host. Port
9000 is the default for both the client and the bundled debugclient.
As many clients use this port number, it is best to leave this setting
unchanged.
Related Functionsbool xdebug_break( )
Emits a breakpoint to the debug client.
This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line. |
|
||||
|
This site and all of its contents are
Copyright © 2002-2007 by Derick Rethans.
All rights reserved. |
|||||
