Break Time!

Barry Pretsell's picture

Going through every line of code is not the most efficient way to debug, sooner than than later you'll want to start debugging at a particular line in a file or function, eventually with practice you'll be wanting to start debugging when certain criteria has been met.

Load the file you want to debug, if it is not already loaded in Komodo.

Komodo debugger load file - watch

Once loaded You will notice we can see a nice navigation window on the left, and below this Komodo displays the currently selected function's comments. This is useful for navigating the Drupal code. Here is a custom module I wrote, in the navigator window.
Komodo debugger code browser

The easiest way to add a breakpoint is to click on the grey area to the left of the text editor window. This will create a red breakpoint. Click it again and it becomes a red circle filled white to denote the break point is still there but the debugger will not break at that line. Click it once more to delete it, and once more again to reinstate the breakpoint.
Komodo debugger add a break point

Control-mouseclick or click and hold over a breakpoint in the breakpoint tab page will bring up a menu which alls us to set more properties for the breakpoint. Select Properties
Komodo debugger modify a break point

Having selected Properties the following dialog window will appear. Now we can make our break point a conditional breakpoint so that we only break whenever our condition is true.
Komodo debugger modifying the break point

Here we have set a condition to only break if the $op is ever equal to the value 'load'. Of course we could have just set a break point within the case 'load' to achieve the same thing.
Click OK and now you will see the conditional setting display in the Breakpoints tabpage.
Komodo debugger add a conditional break point - after

Once you get the hang of the breakpoints you will be able to control exactly when you break.

Comments

Running to breakpoint

How can I just run to a break point without having to step through/over everything to get there? For instance, if I want to stop at a point where hook_install() is called for my module, how can I get there without having to run through everything before that point?

Barry Pretsell's picture

breakpoints

To stop at a particular function, create a breakpoint on the first line of your hook_install function definition. When you run in debug mode the debugger should only stop when it reaches the breakpoint. If you are running index.php with parameters then you may need to use continue which will allow the debugger to continue until either another breakpoint is encountered or the program terminates.

I hope this helps.

Barry