The PHPub debugger is a Zend engine extension which allows the programmer
to step-by-step debug PHP scripts. The debugger communicates via TCP/IP
sockets, an architecture which allows you to debug:
- Locally or remotely
- On a live web server or against a PHP CGI
- On Linux or Windows web servers
The debugger is based on the code from the
Nexidion project but has been modified to generate a Windows DLL or
a Linux .so, as well as modifying its output to make it easier to work with.
I am still working on this code to suit my needs, so anything you see below
is subject to change at my whim. If you use this code, please do not send
me bug fix patches, since I know there are at least two bugs in the code
which I plan to fix my own way when I get to it.
Source code for my modifications can be downloaded here:
dbgmon_src.zip (Visual C++ Project)
The dbgmon.dll attempts to create an outbound socket connection on port
2134 when Zend starts up. The connection is established when one of two
conditions is true:
- A script compile error occurs
- The first line of a script is about to be executed
The debugger will then begin sending information. A line of information
begins with a keyword (see below) followed by data, terminated by a newline
('\n', ASCII char(10)). Newlines, backslashes, and double quotes in data
will be escaped 'C style' as \n, \\, and \", respetively. Items which may
contain spaces will be enclosed in double quotes.
HELO
Usage: HELO <server name> <server PHP version> <debugger version>
Description: This is the first message sent after the debug server connects to the client.
Example: HELO www.capnbry.net 4.0.4pl1 0.9.1
FILE
Usage: FILE <file ID> <file name>
Description: Sent every time executuion enters a new file, including when the first file is started.
Example: FILE 7d34b0 D:\inetpub\wwwroot\test.php
STMT
Usage: STMT <line number>
Description: Sent before a line of code is executed to indicate the current instructon pointer. Line numers are 1-based.
Example: STMT 23
CERR
Usage: CERR <error type> <line number>
Description: Sent when the Zend engine has a compile-time error. The debugger will precede this statement with a FILE statement indicating the file the error occured in.
Example: CERR 4 71
BEGA
Usage: BEGA
Description: Sent to signal the begining of the debugger's automatic dump of relevant variables. All statements following this will be of type LOCL, THIS, or AUTO until the ENDA statement is received.
Example: BEGA
ENDA
Usage: ENDA
Description: Sent to signal the end of the debugger's automatic dump of relevant variables.
Example: ENDA
LOCL
Usage: LOCL <parent> <name> <value>
Description: The debugger sends all variables in local scope automatically. LOCL indicates the variable $name has the value in value. If the variable has no parent, the parent paramter will be -.
Example: LOCL - $some_var "Aunt Jemima on everything!"
THIS
Usage: THIS <parent> <name> <value>
Description: The debugger sends a description of the $this object self-pointer. Paramters are the same as a LOCL variable.
Example: THIS - $this "(object)"
AUTO
Usage: AUTO <parent> <name> <value>
Description: The debugger sends a auto-watches for all variables on the current line as well as the previous line. Variables may be appear more than once as AUTO variables in the same BEGA..ENDA block. Paramters are the same as a LOCL variable.
Example: AUTO - $test_val 90210
WTCH
Usage: WTCH <parent> <name> <value>
Description: This is the result of a SETW client command keyword and contains the value of the requested watch variable. Paramters are the same as a LOCL variable.
Example: WTCH - $arbitrary_idiom 3.1415
REDY
Usage: REDY
Description: The debugger sends this keyword when it is ready to receive command keywords from the client.
Example: REDY
TODO
|