May 1st, 2009 | 2 Comments

Exceptions are a sometimes-frustrating part of debugging and developing. You can configure Visual Studio to deal differently with certain exceptions.

When debugging a program in Visual Studio, a number of situations may cause the debugger to enter break mode. When the debugger enters break mode, program execution is suspended, allowing you—the developer—the opportunity to examine and change the program variables. With Visual Studio 2005, you can even alter the program’s underlying source code when in break mode and have the program continue with the edited source.

A common way that break mode is entered is through breakpoints. Another way that break mode is regularly entered is when an exception is raised that is not handled by your application. Any exception that bubbles up out of your user code will cause the Visual Studio debugger to display information about the exception. While you will likely always want to be notified of an unhandled exception when debugging, you may want to break when an exception is thrown, regardless of whether or not it’s handled. Visual Studio can be easily customized to break immediately when a particular type of exception is thrown.

To customize Visual Studio’s behavior when encountering exceptions, go to Debug -> Exceptions or press Ctrl-Alt-E (Debug.Exceptions). This will display the Exceptions dialog.

Exception Dialog

Exception Dialog

The Exceptions dialog allows you to specify Visual Studio’s behavior when encountering an exception of a specific type. As discussed earlier, the default behavior is to continue when the exception is thrown and to break into the debugger if the exception is not handled. To modify these settings for a particular exception type, simply choose the exception type from the tree of exceptions and customize the radio buttons, indicating the debugger’s behavior.

Understand that changing the setting for a particular exception modifies the behavior for any of those derived exception types whose Use Parent Setting option is selected. By default, all derived exceptions have this Use Parent Setting checked, which means that, by default, changing the behavior of an exception will propagate those changes to its derived exceptions.

Written by Ajay Matharu

May 1st, 2009 at 11:27 pm

Apr 29th, 2009 | 3 Comments

Following are the steps to debug your PHP code using Zend Debugger on Windows machine via WAMP,

1. Download http://downloads.zend.com/pdt/server-debugger/ZendDebugger-5.2.12-cygwin_nt-i386.zip or check for new version at http://downloads.zend.com/pdt/server-debugger/

2. Locate ZendDebugger.so or ZendDebugger.dll file that is compiled for the
correct version of PHP (4.3.x, 4.4.x, 5.0.x, 5.1.x, 5.2.x) in the
appropriate directory.

Get debugger from folder called “5_2_x_comp” or you may receive some errors about a non-thread   safe debugger if you take it from “5_2_x_nts_comp”

3. Configure php.ini for output buffering when debugging

implicit_flush = On ; Default: Off
output_buffering
= Off ; Default: 4096

4. Add the following line to the php.ini file:
Linux and Mac OS X:     zend_extension=/full/path/to/ZendDebugger.so
Windows:                zend_extension_ts=/full/path/to/ZendDebugger.dll
Windows non-tread safe: zend_extension=/full/path/to/ZendDebugger.dll

(*) the windows non-thread safe is used only with Zend Core 2.0

Note:
if you don’t have a Zend section you may add this at the end of the fie.
correct the php path if it is not installed in c:\wamp\www and extension directory.

5. Add the following lines to the php.ini file:
zend_debugger.allow_hosts=<ip_addresses>
zend_debugger.expose_remotely=always

This willl allow connections from local host and from your local network to addresses which start        with 192.168.1.

6. Place dummy.php file in the document root directory.

7. Restart web(Apache/Wamp) server.

8. To activate the debugger please use following query string:
?start_debug=1&debug_port=10000&debug_fastfile=1&debug_host=192.168.1.59%2C127.0.0.1

Note:
above statement assumes that the debugger listens at 192.168.0.2 or 127.0.0.1 on port 10000.

Here are some of the screen shots from my debugger,

Breakpoint in Zend

Breakpoint in Zend

This is watch window in Zend which will show the values of the variables, you need to add the variable to the watch window to view its values.

Watch Window in Zend

Watch Window in Zend

This is the output window that shows the output generated by the code executed till now,

Output Window in Zend

Output Window in Zend

Hope this helps :-)

Written by Ajay Matharu

April 29th, 2009 at 10:31 am

Page 1 of 3123