Home > PHP > XDebug PHP Eclipse – Error No appropriate file located or no file selected

XDebug PHP Eclipse – Error No appropriate file located or no file selected

Well… I was trying to remotely debug a PHP web app. But Eclipse flooded me with a bunch of popups like this:

Debugger Error: “No appropriate file located or no file selected. Debug Terminated”

Debugger Error: "No appropriate file located or no file selected. Debug Terminated

What’s a frustrating thing! In the beginning I wrote a question on stackoverflow.
No answer. No comments. Is there anybody that had same problem? Yup. But most of all received quite academic (read useless) answers. Aaaargh. “Ok I have to solve this problem on my own” I thought.

I have to admit honestly that I like very much this kind of challenges. Maybe because, at start you do not have much clues or suggestions useful to bring you on the right way. Or because, you must put all your experience, a bit of hacking, a lot of patience to figure out what’s wrong.

In any case, after few minutes spent googling around and a lot of time trying all different configurations, I decided for the hard way. Like digging into the core :)
This article is the step by step story, and may be interesting for someone who like hacking its computer.

Supposing that Xdebug was correctly installed, even because I see it enabled in phpinfo() output,
I started to trace Eclipse system calls.

Well, to trace a process, you must first find its process id. My Eclipse running process was:

$ ps -ef | grep eclipse
501 15160 373 0 4:21PM ?? 2:57.19 /Users/myuser/apps/eclipse/Eclipse.app/Contents/MacOS/eclipse -psn_0_651423

Then traced system calls:

$ sudo dtruss -fp 15160

And after hundred (or even thousands) of lines I found these that are quite interesting.

[... omissis ...]
accept(0xA0, 0x1224C37E8, 0x1224C37E4) = 103 0
setsockopt(0x67, 0xFFFF, 0x1002) = 0 0
setsockopt(0x67, 0xFFFF, 0x1001) = 0 0
read(0x67, "4", 0x1) = 1 0
read(0x67, "7", 0x1) = 1 0
read(0x67, "7", 0x1) = 1 0
read(0x67, "", 0x1) = 1 0
read(0x67, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<init xmlns=\"urn:debugger_protocol_v1\" xmlns:xdebug=\"http://xdebug.org/dbgp/xdebug\" fileuri=\"file:///opt/local/var/db/php5/pear/pear-ini.php\" language=\"PHP\" protocol_version=\"1.0\" appid=\"14961\" idekey=\"ECLIPSE_DB", 0x1DD)		 = 477 0
read(0x67, "", 0x1) = 1 0
[... omissis ...]

Here I’ve caught the first line sent from Xdebug. Here eclipse is accepting a connection and receiving the first part of an XML. This piece of XML should be the DBGp part.

Here you can see it better.

<?xml version="1.0"             encoding="iso-8859-1"?>
<xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="file:///opt/local/var/db/php5/pear/pear-ini.php"
language="PHP"
protocol_version="1.0"
appid="14961"
idekey="ECLIPSE_DB

Here we start to see the interesting part. Looking at fileuri attribute I discovered Xdebug is starting its debug session with `/opt/local/var/db/php5/pear/pear-ini.php`.
But the file `pear-ini.php` does not exist in my eclipse projects!

So I create a new project inside my Eclipse workspace and here I have copied the file `/opt/local/var/db/php5/pear/pear-ini.php`

Amazing. It worked, Eclipse PDT finally have found the file it was looking for and the debugger started correctly.
It was even asking me if I would like to switch into Debug perspective.

Conclusion

If you bump into this strange error: “No appropriate file located or no file selected.“, well it means exactly what’s written, even if the file it is looking for not is into your Eclipse workspace.
So, what to do when you receive this error? Try with a different Xdebug client that give you a clue about the file used to start the Xdebug session. Or at least be sure to have all files you need into your workspace.

May be the missing file is loaded from the PHP engine for some strange reason.
In my case `pear-ini.php` is added automatically by `pear.ini`

$ cat pear.ini
; Do not edit this file; it is automatically generated by MacPorts.
; Any changes you make will be lost if you upgrade or uninstall php5-pear.
; To configure PHP, edit /opt/local/etc/php5/php.ini.
auto_prepend_file = '/opt/local/var/db/php5/pear/pear-ini.php'

Hope this helps somebody.

  1. Non c'è ancora nessun commento.
  1. ottobre 14, 2016 alle 05:07

Lascia un commento

Effettua il login con uno di questi metodi per inviare il tuo commento:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger cliccano Mi Piace per questo: