Xdebug in Netbeans: not stopping on breakpoint inside file in "web root's" parent folder - netbeans

I have a netbeans project with a directory tree like this:
<source folder>
|
|---> gui <web root folder>
| |
| L---> datos.php
|
L---> index.php
datos.php changes the working directory to .. (source folder) and includes index.php like this:
chdir('..');
require 'index.php';
If I put a breakpoint inside datos.php, the debugger breaks on it correctly, but when putting one in index.php it ignores it.
The strange thing is 6 months ago I had the same problem and I was able to fix it. Now I don't know why it stopped working and what I did back then to fix it.
More info:
xdebug log shows the following command for breakpoint setting:
breakpoint_set -i 315 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php -n 51
breakpoint_set -i 316 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/gui/datos.php -n 39
In both cases xdebug responds with state="enabled"
And if I debug manually, I can use the following command to set the breakpoint, which works:
breakpoint_set -i 315 -t line -s enabled -f file:///../index.php -n 51
But I don't know how could I make netbeans issue the breakpoint_set command with the same file:///../index.php argument and not file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php or any other way I can make this work.
Thanks in advance for any help!

You always can try using xdebug_break();
For example :
<?php
for ( $i=1, $j=0; $i<10; $i++) {
xdebug_break();
echo "<br>Line $i"; // will stop here
}
?>
will add a breakpoint in the following line.
Hope that helps a little...

Breakpoints are working again. I don't have any clues to why they didn't worked before but now they do. I can't remember doing any changes in xdebug or Netbeans either.
xdebug.log shows me the same as before, but now it stops at the setted breakpoint:
<- breakpoint_set -i 4 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php -n 51
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" state="enabled" id="14290001"></response>
<- run -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php" lineno="51"></xdebug:message></response>
However, if anyone knows why this could had happend, sharing it could be helpful either way: probably me or someone else will be able to avoid having similar troubles in the future.

This issue is more specific to people who are using remote servers for their web apps.
I had the same problem. Xdebug ignores breakpoints really helped me however i have given solution more specific to netbeans, but the essence is the same, which ever IDE you are using. Just map your local project path with your remote server path.
My environment is WINDOWS 7 and website is hosted on UBUNTU VM. I am using NETBEANS from Windows 7 and has setup a remote project.
My xdebug logs
<- breakpoint_set -i 4 -t line -s enabled -f file:///C:/Users/ali/Documents/NetBeansProjects/test.com.au/cgen/src/Acme/TestBundle/Controller/CreateController.php -n 39
->
The real problem was the project path in netbeans [C:/Users/ali/Documents/NetBeansProjects/test.com.au] and the project path on the webserver. /home/ali/sites/test.com.au
Fix: In Netbeans click on your project > properties > Run Configuration > Advanced > Just put the appropriate server path and equivalent project path. It will work fine.

Same problem was solved by commenting xdebug.extended_info = 0. Also one may switch it to 1.

To get it to work again i changedxdebug.remote_host=127.0.0.1 to xdebug.remote_host=localhost in php.ini
below is my config for xdebuga
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_autostart = 1
xdebug.show_local_vars = 1
xdebug.profiler_enable = 1
output_buffering=off
xdebug.idekey=netbeans-xdebug

Related

How can I turn on the Kodi webserver from the command line?

My Kodi is running as root (for better or for worse). This means the user folder is:
/root/.kodi/userdata/guisettings.xml
A quick search for web-related junk:
cat guisettings.xml | grep web
yields
<webserver default="true">false</webserver>
<webserverpassword default="true"></webserverpassword>
<webserverport default="true">8080</webserverport>
<webserverusername default="true">kodi</webserverusername>
<webskin default="true">webinterface.default</webskin>
Looks good to me. I just have to turn on the webserver.
Steps Taken
systemctl stop kodi
perl -i -pe 's/<webserver default="true">false<\/webserver>/<webserver default="true">true<\/webserver>/' /root/.kodi/userdata/guisettings.xml # (I actually used vim)
systemctl start kodi
Guess what happens, the guisettings.xml gets overwritten each time I start Kodi. I also tried adding the following file: /root/.kodi/userdata/advancedsettings.xml with the following contents:
<advancedsettings>
<loglevel hide="attribute">3</loglevel>
<webserver default="true">true</webserver>
<webserverpassword default="true"></webserverpassword>
<webserverport default="true">8080</webserverport>
<webserverusername default="true">kodi</webserverusername>
<webskin default="true">webinterface.default</webskin>
</advancedsettings>
This also does not work.
Are you by any chance trying to enable the web server to allow using Kodi remote?
I encountered the same issue too, "guisettings.xml gets overwritten".
According to kodi.wiki, you need to configure 2 more XML elements.
To be complete, having the following in advancedsettings.xml should help:
<advancedsettings>
<services>
<esallinterfaces>true</esallinterfaces>
<webserver>true</webserver>
<zeroconf>true</zeroconf>
</services>
</advancedsettings>

EasyPHP Webserver - Dashboard - http://127.0.0.1:10000 No longer loading

I am running EasyPHP Webserver 14.1 on Win Server 2012.
When I first installed it the dashboard loaded fine.
Now that I have built up my PHPbb3 forum it no longer loads. The browser continuously states
Waiting for response from 172.0.0.1...
but nothing happens, it just keeps spinning trying to load.
Is there any way I can fix /restore / reinstall the dashboard without affecting any work I've done on PHPbb3?
If it helps after some searching on this forum I created a .bat file containing:
ews-dashboard.exe -S 127.0.0.1:10000 -c ews-dashboard.ini cmd /k
This opens a CMD window containing the following:
C:\Program Files (x86)\EasyPHP-Webserver-14.1b2\dashboard>ews-dashboard.exe -S 127.0.0.1:10000 -c ews-dashboard.ini
PHP 5.4.30 Development Server started at Tue Nov 14 14:33:33 2017
Listening on http://127.0.0.1:10000
Document root is C:\Program Files (x86)\EasyPHP-Webserver-14.1b2\dashboard
Press Ctrl-C to quit.
But this doesn't seem to change anything.
it will work if you change the current port.
start-ews.bat
ews-dashboard.exe -S 127.0.0.1:1000 -c ews-dashboard.ini cmd /k
ews-dashboard.ini
[ServiceEx]
ServiceExeFullPath = "D:/Program Files/EasyPHP-Webserver\dashboard\ews-dashboard.exe"
; program arguments to be sent to executable
options = "-S 127.0.0.1:1000"
; can program interact with desktop [true | false] (default: true)
desktop = false
; start type (valid values: Auto Manual Disabled) (default: auto)
Start=Auto
; start the service upon installation [true | false] (default: no)
StartNow=true

List of available software sites lost after Eclipse update

After clicking the Check Update, installing a few updates and clicking OK to restart Eclipse, the list of available software sites in the Install window is gone.
Is it possible to get it as it was?
If not, how can I rebuild it so that my plug-ins will be updated in the future?
I'm working with Eclipse 4.3.2 in Windows 7.
I ran into the same problem on a Win7-64bit after a set of automatic updates.
All settings for "Available Software Sites" were lost. My eclipse version after the data lost was luna 4.4.2. (don't now the version number before, I had installed eclipse-cpp-luna-SR1a-win32-x86_64_2014.zip).
I set this site to get the "/Help/Install new software...." Dialog work again:
Eclipse-Project-Repository - http://download.eclipse.org/eclipse/updates/4.4
To get the repository for another eclipse version look here.
Follow the link to your eclipse version and search there for the "Eclipse p2 Repository".
For those interested in restoring the update site, here is a way to do the job which may or may not work for you:
Locate the ${ECLIPSE_HOME}\p2\org.eclipse.equinox.p2.engine\profileRegistry\<profile>\.data\.settings\org.eclipse.equinox.p2.artifact.repository.prefs file. The <profile> depends on the installed Eclipse, for me it was epp.package.rcp.profile.
Find all keys ending by /uri=: they would contains the original URI. You could use grep: grep --color -Po '/uri=.+' org.eclipse.equinox.p2.artifact.repository.prefs (you may want to filter file:/ URI).
Remove the /uri and unescape the property to regain valid URI: sed is good for that. eg: sed -E -e 's#^/uri=##g' -e 's#\\##g'
Apply a sort --unique
Now, you would have this command line and result:
$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs | sed -E -e 's#^/uri=##g' -e 's#\\##g' | sort
https://spotbugs.github.io/eclipse/
http://download.eclipse.org/e4/snapshots/org.eclipse.e4.tools/latest/
http://download.eclipse.org/eclipse/updates/4.7
http://download.eclipse.org/eclipse/updates/4.7/R-4.7-201706120950
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.1-201709061700
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.1a-201710090410
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.2-201711300510
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.3-201803010715
http://download.eclipse.org/eclipse/updates/4.7/R-4.7.3a-201803300640
You are almost there!
If you look at the example above, you can see multiple duplicate URI for the same endpoint (/eclipse/updates/4.7) which is a P2 composite repository: you may add it to the sed command to remove these parts: -e 's#/(R-[^/]+|)20[0-9]{10}##g'.
That's better:
$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs | sed -E -e 's#^/uri=##g' -e 's#\\##g' -e 's#/(R-[^/]+|)20[0-9]{10}##g' | sort --unique
http://download.eclipse.org/e4/snapshots/org.eclipse.e4.tools/latest/
http://download.eclipse.org/eclipse/updates/4.7
http://download.eclipse.org/efxclipse/updates-released/3.0.0/site
http://download.eclipse.org/releases/oxygen
http://download.eclipse.org/technology/epp/packages/oxygen/
http://eclipse.pitest.org/release/
http://netceteragroup.github.io/quickrex/updatesite
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.8.0/N/0.8.0.201409231215/
http://ucdetector.sourceforge.net/update/
Now we will transform that into a XML file to be imported: in the Available Software Sites, you may export a bookmarks.xml file which contains this for one entry:
<?xml version="1.0" encoding="UTF-8"?>
<bookmarks>
<site url="http://download.eclipse.org/eclipse/updates/4.7" selected="true" name=""/>
</bookmarks>
As you would probably don't care about the name or selected (Eclipse may also update these using the Update site metadata), you may use builtin or sed again:
$ grep --color -Po '/uri=http.+' org.eclipse.equinox.p2.artifact.repository.prefs.old | \
sed -E -e 's#^/uri=##g' -e 's#\\##g' -e 's#/(R-[^/]+|)20[0-9]{10}##g' | \
sort --unique | \
while read url; do echo "<site url=\"${url}\" />"; done > bookmarks.xml
You now have a bookmarks.xml to edit: simply add the <?xml version="1.0" encoding="UTF-8"?> <bookmarks> and </bookmarks>, and import it in Available Software Suite.
All that remains is to enable all site by selecting them and clicking Enable. When done, try to update Eclipse as usual and that should do the job!
You may want to:
Remove any invalid entries or at least disable them
Save your bookmarks.xml into a repository or "somewhere".
Export the bookmarks.xml again, now with proper name.
Good luck!
And ... raise this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=502524
I ran into the same problem on a Win10-64bit after a set of automatic updates. All settings for "Available Software Sites" were lost.
Eclipse p2 Repository
To update your Eclipse installation to this development stream, you can use the software repository at
http://download.eclipse.org/eclipse/updates/4.5 .
To update your build to use this specific build, you can use the software repository at
http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500
Fixed in Neon
Good new is that the available update sites survive Eclipse update on Neon. But I still see this problem on Mars and older.
Fix for Mars and older releases
There is a simple change which fixed this problem for me on Mars-, it's adding the "-Djava.net.preferIPv4Stack=true" JVM param to Eclipse.ini file before running an update:
-Djava.net.preferIPv4Stack=true
Please note this is a VM argument, so it must go after the "-vmargs"
So why the available software sites were deleted on update?
Eclipse Update is done by ProvisioningJob which calls LoadMetadataRepositoryJob.runModal(), which in its turn calls MetadataRepositoryManager.loadRepository().
AbstractRepositoryManager.loadRepository() checks if a repository is valid by callingcheckNotFound(). If it's not found that the repo is not added. preferIPv4=true fixes it.
Had the same problem while updating from 4.19 (2021-03) to 4.20 (2021-06). What worked for me was:
Re-Opening the "Help" -> "Install New Software" after the list was lost, this refreshed some of the repositories that went missing.
Manually adding the repo URL at "Window" -> "Preferences" -> "Install/Update" -> "Available Software Sites" -> "Add..."
I wanted to update to the last version (at that time) so I added the following URL. Replace that URL with the URL of the version you wish to install or your current version:
"Help" -> "Check for updates" again, it should work.
I encountered this with Eclipse 4.16 (2020-06).
Inspired by #NoDataFound approach, I wrote a Perl script as an all-in-one-solution.
How it works:
Check each line of '/p2/org.eclipse.equinox.p2.engine/profileRegistry//.data/.settings/org.eclipse.equinox.p2.artifact.repository.prefs' for 'nickname', 'uri' or 'enabled' of a http[s] repo.
Store captured property name and value in a hash associated with the repo identifier.
my $propNameCapture = qr/(nickname(?==.*)|(?:uri|enabled)(?==.+))/;
my ($repo, $propName) = m{^repositories/(http.+?)/$propNameCapture};
next if !$repo || !$propName;
my ($propValue) = m{^repositories/http.+?/$propName=(.*)};
# Remove the backslash after http[s] if we have an uri.
$propValue =~ s/\\// if $propName eq 'uri';
# $repo is used merely to collect props belonging together.
$SiteFromRepo{$repo}->{$propName} = $propValue;
Create an array of site properties
for my $site (values %SiteFromRepo)
{
# There are many entries without a nickname.
# These are not from "Available Software Sites", so skip them.
next unless exists $site->{nickname};
print("nickname:\t$site->{nickname}\nuri:\t\t$site->{uri}\nenabled:\t$site->{enabled}\n\n");
push(#Sites, $site);
}
Write XML file
open($fh, '>:utf8', $OutFilePath) or die("Could not open file '$OutFilePath' for write, exiting.\n");
$fh->print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bookmarks>\n");
$fh->print(" <site url=\"$_->{uri}\" selected=\"$_->{enabled}\" name=\"$_->{nickname}\"/>\n") for #Sites;
$fh->print('</bookmarks>');
close($fh);
The complete script can be downloaded from my GitHub repo
Try to run Eclipse as administrator. That way the "check for updates" should work.

Where to find logs for a cloud-init user-data script?

I'm initializing spot instances running a derivative of the standard Ubuntu 13.04 AMI by pasting a shell script into the user-data field.
This works. The script runs. But it's difficult to debug because I can't figure out where the output of the script is being logged, if anywhere.
I've looked in /var/log/cloud-init.log, which seems to contain a bunch of stuff that would be relevant to debugging cloud-init, itself, but nothing about my script. I grepped in /var/log and found nothing.
Is there something special I have to do to turn logging on?
The default location for cloud init user data is already /var/log/cloud-init-output.log, in AWS, DigitalOcean and most other cloud providers. You don't need to set up any additional logging to see the output.
You could create a cloud-config file (with "#cloud-config" at the top) for your userdata, use runcmd to call the script, and then enable output logging like this:
output: {all: '| tee -a /var/log/cloud-init-output.log'}
so I tried to replicate your problem. Usually I work in Cloud Config and therefore I just created a simple test user-data script like this:
#!/bin/sh
echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt
echo "I am out of the output file...somewhere?"
yum search git # just for fun
ls
exit 0
Notice that, with CloudInit shell scripts, the user-data "will be executed at rc.local-like level during first boot. rc.local-like means 'very late in the boot sequence'"
After logging in into my instance (a Scientific Linux machine) I first went to /var/log/boot.log and there I found:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200! I am
out of the file. Log file somewhere? Loaded plugins: changelog,
kernel-module, priorities, protectbase, security,
: tsflags, versionlock 126 packages excluded due to repository priority protections 9 packages excluded due to repository
protections ^Mepel/pkgtags
| 581 kB 00:00
=============================== N/S Matched: git =============================== ^[[1mGit^[[0;10mPython.noarch : Python ^[[1mGit^[[0;10m Library c^[[1mgit^[[0;10m.x86_64 : A fast web
interface for ^[[1mgit^[[0;10m
...
... (more yum search output)
...
bin etc lib lost+found mnt proc sbin srv tmp var
boot dev home lib64 media opt root selinux sys usr
(other unrelated stuff)
So, as you can see, my script ran and was rightly logged.
Also, as expected, I had my forced log 'output.txt' in /root/output.txt with the content:
Hello World. The time is now Wed, 11 Sep 2013 10:21:37 +0200!
So...I am not really sure what is happening in you script.
Make sure you're exiting the script with
exit 0 #or some other code
If it still doesn't work, you should provide more info, like your script, your boot.log, your /etc/rc.local, and your cloudinit.log.
btw: what is your cloudinit version?

unable to open X server

I am trying to generate a screenshot of a firefox window in my terminal, but I keep getting an error:
root#host [~]# DISPLAY=:1 firefox http://www.cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox
[1] 30200
import: unable to open X server `:1' # import.c/ImportImageCommand/364.
Why is this happening? How can I fix it?
Maybe try DISPLAY=:0, for example?
It looks like you used changed to root in the terminal after starting it (or did you login to X as root?). If that's the case the display can't be opened because it's owned by another user and you can't just go and display stuff somebody else's display.
Exit the root session and it will probably work. If you want it to work from the root session take a look at 'man xhost'.
Can you tell us what are the result when you type
ls -la /tmp/ | grep X
and
ps | grep X
Also, I had some trouble with using the DISPLAY=:1 syntax, so instead I use:
firefox --display=:1 URL_OF_SITE
import -display :1 -window root etc...