I'm using XDebug to generate profile repport. The profile are generated, but I'm unable to create a complete call graph using kcachegraph.
The XDebug config is:
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /var/www/xdebug/
xdebug.profiler_output_name = cachegrind.out.%t-%s
xdebug.profiler_enable_trigger=1
When I open the repport in kcachegrind, it seems to works, except that somt call seem in double, with one of the two having a location: (unknown).
Note that index.php only have 1 line of actual code, that is a require to the front controller. No autoloading at this stage of the execution, so I really can't figure out why I have 2 require::frontcontroller.php.
Here's a screenshot of 3 windows that might help you:
http://img46.imageshack.us/img46/2226/kcachegrind123.png
Any clue on what could be the problem ?
Thanks
Finally that's an XDebug problem with the profile.
It looks like Kcachegrind have changed their format, but XDebug have not been updated yet as per bug #639.
This is now fixed for 2.1.1 and HEAD.
Related
Chrome preview does not render the response properly, since yesterday when I upgraded the work machine from Win 8 to Win 10. Please see the screenshots:
As you can see, only one line of the object is rendered, when I tried it with a simple array, same thing happened, it only rendered the word "array" and "0";
I'm using Chrome 72.0.3626.96, WampServer64 with PHP 7.2.14 and those are my Xdebug settings in php.ini:
zend_extension="c:/wamp64/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
xdebug.default_enable=1
html_errors = On
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9123
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024
It worked literally a day ago before I got Windows 10. Chrome bug or am I doing something wrong?
I found the issue and it is quite bizarre. It looks like the latest version of Chrome (72.0.3626.119 for me) has problems rendering the preview when the response text has a hash character (#) in the output. It will happily render everything until it encounters the hash character. This is most definitely a bug in Chrome.
I discovered this by first noticing that the preview stops at <font color='#888a85'>=></font>. I hardcoded this in the document and removed characters until I concluded that the hash character was causing the problem.
Here is a demo of the bug. When you run this snippet in the latest version of Chrome and with Inspector open, you should see the request pop up in the network tab. When you click on the request and go to the preview tab, the third paragraph is cut off since there is a # right before it.
<p>Para1</p>
<p>Para2</p>
#
<p>Para3</p>
I was unable to find an open bug report regarding this so I took the liberty of reporting it here: https://bugs.chromium.org/p/chromium/issues/detail?id=936284
It looks like this issue has already been reported (link) and fixed in the dev version of Chrome but hasn't been updated in the stable version yet.
In the meantime, if you really need to have var_dump work in Chrome, you can do this as a workaround (buffer the output and replace instances of #):
ob_start();
var_dump($var);
echo str_replace('#','',$ob_get_clean());
... or you can just turn off HTML errors:
ini_set('html_errors', false);
I've installed PHPStorm (8) and trying to debug WordPress theme using xDebug. I tried chrome browser extension and some other settings in the PHP Storm settings.
I've searched a lot but still unable to attach the page to the debugger. What I want is to run the code line by line and check variables etc.
Can someone tell me what exactly is required so the debugging works?
I've following structure:
WAMP is at: c:\wamp
Project is: d:\projects\test
alias is: http://localhost/test/
When I opened the project in PHP Storm. It identified it as WordPress project. But it never attaches the browser to debugger.
Edit
Here is the related xDebug code in php.ini
zend_extension = "c:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
[xdebug]
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.remote_port = 9000
I also tried true instead of 1. Also tried without providing any port.
There seem to be a lot of ways to set up debugging. There are browser plugins, and bookmark commands, and all sorts of elaborate setups.
For the most part, I always want debugging enabled while I'm developing. If that's true for you, you might consider adding this to your php.ini file:
xdebug.remote_autostart = 1
In addition, a key part to my setup is that I have to click the button in the toolbar for "Start Listening for PHP Debug Connections", and keep this enabled while I work. This is also in the menus under "Run".
Have you tried zero-configuration guide for PhpStorm debugger?
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
I'm using this solution and it works fine.
Don't forget to add breakpoints and I recommend to create the bookmarklets to activate/deactivate debugger cookies in browser (https://www.jetbrains.com/phpstorm/marklets/).
I've started working on a large PHP project that was built using Zend Framework 2. In trying to understand the code, I set up xdebug for both debugging within Eclipse and to output tracing of function calls. The problem is, I can't find certain methods in the trace file that I am almost 100% sure are being called. So I set a breakpoint within one of those methods in Eclipse, and sure enough, when I reload the page in the browser, execution halts at that breakpoint, so I know that method is being called. However, I can't find that method being called anywhere within the trace file that was just generated for that page load. Can anyone help explain this discrepancy?
Here is my xdebug (using v2.2.3) config from php.ini:
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=7800
xdebug.remote_host = "127.0.0.1"
xdebug.collect_params = 3
xdebug.trace_format = 0
xdebug.auto_trace = On
I am working on a project that uses CodeIgniter. I use Netbeans as my IDE and I have Xdebug installed. I am using XAMPP for local development.
What Works: Xdebug is working fine for normal PHP code.
Problem: However, I am facing problems debugging my CodeIgniter project. Debugger stops on a redirect()
Problem Details: Start debugging project in netbeans. Debugger starts and we see homepage. On homepage, there is a link that corresponds to a method in homepage controller. Debugger reaches the method in controller to which the link points to. In this method there is a redirect. At the point of redirect debugger STOPS.
Relevant Code Snippet(s):
URL That is clicked (This is part of the header menu)
Click Me
routes.php - Reroute for prettier url.
$route['somefunc'] = "foo/somefunc";
And in my Foo Controller (foo.php):
class Foo extends CI_Controller {
public function somefunc()
{
redirect('/bar/otherfunc'); // DEBUGGER REACHES TILL HERE THEN STOPS WORKING
}
}
As said above in the comment in function somefunc(), Xdebug stops working at the place where the redirect happens.
Additionally, the following information might be of some use:
config.php
$config['uri_protocol'] = 'AUTO'; // I have also tried PATH_INFO, QUERY_STRING, REQUEST_URI & ORIG_PATH_INFO.
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = TRUE; // Have tried FALSE too.
$config['index_page'] = ''; // Tried index.php too.
xdebug settings in php.ini
zend_extension ="path\to\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
NOTE - I have already tried playing around with different suggestions that I have seen here as well as through google but to no avail. Can somebody please point me in the right direction?
Found a solution. Perhaps this might help someone else who has been struggling with this. Apparantly to allow smooth debugging, you need to include the option:
xdebug.remote_autostart=1
in your php.ini. These settings work for me now:
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
The last line is the option I found on (Xdebug Official Documentation). The relevant part of the documentation is mentioned below:
xdebug.remote_autostart
Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Remote Debugging). When this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client, even if the GET/POST/COOKIE variable was not present.
I found the same problem, and fixed it by upgrading my version of xdebug.
There appears to have been a bug in the version I was using (xdebug 2.1.3), but it all works fine on xdebug 2.2.3.
Use this tool for custom installation instructions for your environment.
http://xdebug.org/wizard.php
Be aware that netbeans doenst work with $_SERVER['PATH_INFO'] and url like http://127.0.0.1/site/test.php/v1/v2/parametertoputonphpathinfo/v3, there is a bug of Mon Sep 09, 2013 8:54 am on netbeans board telling about it without response until now 2014:
http://forums.netbeans.org/topic56645.html
It make impossible debug frameworks using that sinatra way to routing requests.
Rewriting my simple Sinatra router to have a $_GET mode to debug and a better hook code.
I'm trying to get xdebug working on my Mac. I'm using OS 10.6 with the built-in versions of Apache (2.2.1) and PHP (5.3.8). I followed the "tailored installation instructions" on the xdebug website, which basically consisted of these steps:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Restart the webserver.
From what I understand, that should be it. I know most people use xdebug with an IDE like PHPEclipse, but it doesn't sound like that's necessary just to get debugging output on the page. And a lot of old instructions involve installing MAMP, but it looks like that's no longer necessary.
Signs xdebug is working: When I run php -m and phpinfo() I get the expected information on xdebug. In scripts I'm able to call functions like xdebug_is_enabled() (returns 1) and xdebug_get_function_stack() (returns the stack).
Ways xdebug is not working: The main reason I installed xdebug was to get a stack trace when there's an error, and that's not happening. According to this documentation page, I should get a stack trace as long as display_errors is set to On in php.ini, (which it is). I've tried code that should evoke a warning (e.g., echo(hello)) as well as code that produces a fatal error (e.g., $x->awesomefunction() when $x isn't an object). Neither one produces any xdebug output, and the fatal error just causes the page to die silently. The test code given in the documentation I linked to also produces nothing.
UPDATE: It turns out that if I run a script with a fatal error from the terminal, I do get a stack trace from xdebug. However, it's still not showing up when I run the script from a browser
Also, regular error reporting is now broken: Previously, I'd get error output by including the commands:
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
Now, putting those lines in my script doesn't produce any error reporting either. (in the browser. It does cause errors to be shown when I run the script from the terminal.)
So, what's wrong here? Did I leave something out of the xcode installation? Do I have a setting hanging around somewhere else on my system, suppressing errors? I've tried everything I can think of, but I'd be happy to test any ideas you have.
If it is working on console and not on browser, it's probably a xdebug configuration issue.
I'm not a Mac user, but on Ubuntu there are 2 different php.ini files, one for console and one for apache. If that's the case for Mac also, you can check if xdebug is enabled and properly set up in both php.ini files.
Also you can check the xdebug settings mentioned in the guide.
After several more hours of thrashing, I discovered that one of my test files actually was including another file that set display_errors to 0. The other test file was straight off of the xdebug site, but I think that at the time I was using it I'd introduced some other config error that prevented it from working properly. I'm truly embarrassed! Let this be today's object lesson in the importance of systematic, repeatable tests during debugging. On the bright side, xdebug is now working like a peach.
To summarize, the series of steps that worked was:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Add to php.ini: display_errors = On
Restart the webserver.