NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Debugging included files


Joined: 28 Sep 2013
Posts: 84
Location: Pantin, IDF, France
Reply with quote
Hello,

I would like to know what is the proper way to debug PHP (CLI or Web) code whose consists mostly in included files (included at several levels of depth by a main script accessing classes and function inside them).

Actually it works, but it seems that no breakpoints can be set until some functions have been called inside the included file.
The only fact to have executed the include statement (I actually use “require_once” most of the time) doesn't seem to be enough.

This makes very tricky to set a breakpoint in some deeply included (maybe 3 ou 4 levels of inclusion) function in which I have a debugging problem to solve, in order to reach this point quickly after having started the script.
In order to do that it is sometimes easier to set a DebugBreak() where I want to stop (instead of setting several breakpoints near included files transitions), but this not very elegant.

Is there something that I can do for actually be able to set breakpoints as soon as the file has been included?

Regards,

Gingko
View user's profileFind all posts by GingkoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Breakpoints work fine in included files regardless of their level of inclusion, regardless the other function is called or not. As soon as the line with breakpoint is executed, it will trigger and break in the IDE.
The only thing you have to keep in mid is you have to start debugging in the IDE or break into IDE through DebugBreak() or use any other way to start *debug* session with the IDE. Otherwise the IDE is not aware of the script you want to debug, therefore no breakpoints will be set, therefore no breakpoints will trigger.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 28 Sep 2013
Posts: 84
Location: Pantin, IDF, France
Reply with quote
dmitri wrote:
Breakpoints work fine in included files regardless of their level of inclusion, regardless the other function is called or not. As soon as the line with breakpoint is executed, it will trigger and break in the IDE.
The only thing you have to keep in mid is you have to start debugging in the IDE or break into IDE through DebugBreak() or use any other way to start *debug* session with the IDE. Otherwise the IDE is not aware of the script you want to debug, therefore no breakpoints will be set, therefore no breakpoints will trigger.
Ok, this is what I am doing, but as I told in my message above, some scripts appears to be not parsed until effectively executed (that is, I consider them parsed when I can see dots in the column on the left).

But I am thinking to one thing.

May it be a problem if the name of some included scripts are the result of an expression?

Like this? :
Code:
// In a previously included script:
define('SUFFIX', '_test');
// or
define('SUFFIX', '_production');

// In the script included by the previous one :
require_once('SomeIncludedScript'.SUFFIX.'.inc.php');
Gingko
View user's profileFind all posts by GingkoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Sorry I lost the point. What problem are you trying to solve?
Scripts are not parsed until you load them. Right. So what?
You set a breakpoint. When corresponding file is loaded it is parsed by PHP. When corresponding line is executed, breakpoint will trigger.
Blue dots -- should they appear or not, do not prevent you from setting the breakpoints. They only show where real breaks may appear.
If you set a breakpoint and it does not trigger, it may be resulted from either of the following conditions:
- execution didn't reach your line -- either file was not loaded at all or corresponding function wasn't called
- debug session didn't start -- because you didn't supply DBGSESSID (neither directly nor through the IDE)
- script byte codes were cached by opcode cache. Wizard always suggests to turn it off, so I assume that's not the case because you always follow recommendations, don't you?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Debugging included files
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic