Jump to content

debugging isuues


jimfog

Recommended Posts

I use netbeans with xdebug and the behavior of the debugger at some point is becomes weird,, I cannot explain it. Here is what what happens: I press the step into button(at the debugger toolbar), or some of the other buttons and then the debugger "stops". When I mean stops, ALL the buttons on the toolbar(except the STOP button) becomeinactive. What might be causing that? I did not use any breakpoints. Here is the code where I am trying to use the debugger:

    require_once 'userauth_admin.php';	  		   $username=$_POST['username'];		   $passwd=$_POST['password'];   if(!filled_out($POST)){echo 'hi ';}	  

I hope I was clear.

Link to comment
Share on other sites

This happens on fatal errors. The moment that NetBeans starts doing that is the moment the fatal error has occurred. To find out the exact error, you'd have to either run the page without XDebug, seeing the message and/or enable error logging and look at the logs after the run.I'm not entirely sure if this behaviour counts as a NetBeans bug or an XDebug bug.Anyway, in some scenarios, it's easy to guess the fatal error even without seeing any messages. Calling an unidentified function is a fatal error, so if NetBeans hangs like that at

if(!filled_out($POST))

Then chances are that filled_out() is not a defined function (maybe you missed requiring the file its in?). Similarly, being unable to locate and execute a required file is a fatal error, so if the hang is instead at

require_once 'userauth_admin.php';

then 'userauth_admin.php' is missing/mistyped, or PHP doesn't have enough permissions to access it.

Link to comment
Share on other sites

Ι managed to find where the error was. I was requiring(require_once) a nonexistent file(had forgotten creating it). IF this counts as an Xdebug bug than I do not like the fact that the debbuger gives no indication at all there there is a fatal error. You are saying also that in order to find the exact error I must run the page without xDebug-I am assuming you mean, to run the script in Netbeans, because, when the page loads in the browser, I do not think XDebug has any effect on it-XDebug works only with in the "constraints" of the IDE. Yes it is easy sometimes to find error without message-as this is what I did in this case. And lastly, you are saying that I could see a message when a fatal error, how I can code that?By error logging I suppose you mean PHP error logs. Do these logs record all fatal errors?

Link to comment
Share on other sites

Yeah, sorry. I meant without NetBeans' "debug" feature (which in turn uses XDebug's debugging capability; hence I can't tell if this is NetBeans' fault or XDebug debugger's fault).

And lastly, you are saying that I could see a message when a fatal error, how I can code that?
You set "display_errors" to "On" in php.ini, or use ini_set() within the file for the same setting (though, obviously, the fatal error in question would have to happen no earlier than that point in the code).
By error logging I suppose you mean PHP error logs. Do these logs record all fatal errors?
If you enable it in php.ini, all errors defined by the "error_reporting" php.ini directive will be written into that log. This includes parsing errors and fatal errors.
Link to comment
Share on other sites

In php ini I found the following: ; display_errors=0; Default Value: Off; Development Value: On; Production Value: Off Which of the above I must uncomment? I will un comment display errors, as you suggest.

Edited by jimfog
Link to comment
Share on other sites

display_error=1 it works like boolean 1 means on , 0 means off.

Link to comment
Share on other sites

In php.ini I found 2 display_error entries. I set them both to 1. Nonetheless no error message appears.So, I have 2 questions:1. Do I need to make other adjustments in php.ini-related to the display of errors.2.Is it certain that PHP outputs error when a non-existent file is "required"?

Link to comment
Share on other sites

You only need one. The other commented ones are just usage examples. Set it like

display_errors = On

just in case.Another thing may be influencing things is the error_reporting directive, which determines which errors are reported. Find it, and change it to

error_reporting = E_ALL

(I would've said "E_ALL | E_STRICT", but PHP 5.4 includes E_STRICT in E_ALL)

Link to comment
Share on other sites

it should have one entry for each particular directive. there is one "display_error", incase there is more than one uncoommented same directive you can make them commented. 1) make sure error_reporting level is E_ALL level to see every possible errors2) yes it throw a fatal error if file does not exist when you use "require" and warning when you use "include"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...