In this text, xXX means x86 or x64 depending on the required build version.
To compile:
- Visual C++ 11.0 (Visual Studio 2012 SP1+)
Install Visual Studio 2012 with at least SP1.
Open the VS2012 xXX Native Tools Command Prompt.
- Get XDebug sources:
xdebug-2.5.5.tgz
Unpack XDebug sources archive into directory: c:\php-sdk\extensions\
Now XDebug sources need to be patched to support Windows XP. You can either apply a provided patch file or go over all changes manually.
- Copy XDebug patch
extensions\xdebug-2.5.5.patch
toextensions\
- Get
patch.exe
utility fromdownloads\
or from UnxUtils - Open the command prompt and switch to working directory:
cd c:\php-sdk\extensions
- Apply the patch:
patch.exe -p0 -u <xdebug-2.5.5.patch
Notes about patch.exe
:
- If running
patch.exe
brings up UAC prompt - try renaming the program, for example top.exe
. - If you get a runtime error as below - it may be due to your
.patch
file using non-Windows line endings. Open it in a text editor such as Notepad 2e, convert line endings to CR/LF, save and re-runpatch
.
patching file ...
Assertion failed: hunk, file ..., line ...
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
- Replace includes in .c files:
# old:
#include "SAPI.h"
# new:
#include "main/SAPI.h"
- Remove code from
xdebug_com.c
:
# define poll WSAPoll
- Add code to
xdebug_com.c
beforexdebug_create_socket()
:
typedef struct pollfd {
SOCKET fd;
short events;
short revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
#define POLLRDNORM 0x0100
#define POLLRDBAND 0x0200
#define POLLIN (POLLRDNORM | POLLRDBAND)
#define POLLPRI 0x0400
#define POLLWRNORM 0x0010
#define POLLOUT (POLLWRNORM)
#define POLLWRBAND 0x0020
#define POLLERR 0x0001
#define POLLHUP 0x0002
#define POLLNVAL 0x0004
static int poll(struct pollfd fds[], int nfds, int timeout)
{
int retval;
fd_set rset, wrset, exset;
struct timeval tv, *ptv;
FD_ZERO(&rset);
FD_ZERO(&wrset);
FD_ZERO(&exset);
FD_SET(fds[0].fd, &rset);
FD_SET(fds[0].fd, &wrset);
FD_SET(fds[0].fd, &exset);
fds[0].revents = 0;
if (timeout >= 0) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
ptv = &tv;
} else {
ptv = NULL;
}
retval = select(0, &rset, &wrset, &exset, ptv);
if (retval == 1) {
if (FD_ISSET(fds[0].fd, &rset)) {
fds[0].revents |= POLLIN;
}
if (FD_ISSET(fds[0].fd, &wrset)) {
fds[0].revents |= POLLOUT;
}
if (FD_ISSET(fds[0].fd, &exset)) {
fds[0].revents |= POLLERR;
}
}
return retval;
}
- Replace condition in
xdebug_com.c
, inxdebug_create_socket()
:
# old:
if (errno == WSAEINPROGRESS || errno == WSAEWOULDBLOCK) {
# new:
if (errno == WSAEINPROGRESS) {
- Build PHP as described in build_php.md
- Open the command prompt and switch to the build directory:
cd c:\php-sdk\extensions
- Run:
buildxdebugXX.bat