Step-by-step: How to do Xdebug troubleshooting con

2019-02-05 16:12发布

问题:

BACKGROUND

Using Xdebug with PHP and Komodo IDE, and Eclipse PDT.

Xdebug is installed on the server and working properly. This is confirmed because the Xdebug code commands work as expected when inserted into PHP files on the server.

PROBLEM

Connecting to the client workstation is not working, and it is difficult to determine why because it fails with multiple IDEs.

QUESTION

It would be nice to have a step-by-step checklist to troubleshoot the case where you know Xdebug is installed and working on the server, but the client does not connect.

Can anyone help add to this to make a comprehensive troubleshooting checklist?

Specifically, is there any bare-bones way to make sure the network traffic is reaching the client, and is correctly formatted in the way the IDE expects to see the data?

  • SSH into web host and try to reach the client:

    • can host reach client at all? (ping -c 5 xxx.xxx.xxx.xxx )
    • can host reach port 9000? (nmap -p 9000 xxx.xxx.xxx.xxx)
    • if the above two succeed, what should the output be?
    • if the above two fail, what is the next troubleshooting step?
  • Verify settings of software-based firewall on client

  • Verify settings of iptables on linux host
  • Verify hardware firewall b/t client and host

GOAL

The goal is to find some solution where the person on the client machine can at least confirm that something is reaching the client without having to determine whether the IDE is the problem, since IDE is another level of complexity that may be introducing problems.

回答1:

This is something I would definitely want to include in the Xdebug documentation. I think it would work best to have many people collaborate on this, so I've created a file in the xdebug.org github repository (https://github.com/derickr/xdebug.org/blob/master/html/docs/tutorials/troubleshooting.rest) to collect tips. Feel free to fork and extend!

On the Xdebug side, in the upcoming version (2.2) it already dumps in its xdebug.remote_log file a couple of extra diagnostics such as whether it tried to connect and whether the connection was accepted or denied.



回答2:

You can use the debugclient utility to determine if the client can receive Xdebug connections, as you can read in the Xdebug documentation:

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)

You can find more information about the Xdebug 2 initialization protocol here.
A further reference: Howto check xdebug installation.
Unfortunately the debugclient utility is provided only in source form, so you have to build the executable by yourself; this can be done either on Linux (see INSTALL) and Windows (with Visual Studio - see debugclient.dsp).
XAMPP includes a compiled version in xampp/php/debugclient.exe.



回答3:

Netbeans has a very thorough documentation that also covers how to troubleshoot such problems:

http://wiki.netbeans.org/HowToConfigureXDebug



回答4:

Windows users disable your firewall and then try again. If it works, allow Java(TM) Platform SE binary through firewall then enable it again. It will work just fine!

Thank you for the commands, they were very useful on debugging.