views:

196

answers:

3

VS 2005

For example,

My employees gave me a project with about X try-*catch* statements.

X > 100 .. 300

I need to test a project. Is there a way to mark each (every) beginning of catch as a breakpoint ? I don't want to do it manually. Maybe there is some settings that fit to me ?

A: 

Short answer is no. But you might be able to make some an aspect-oriented plugin to your project that captures the catch crosspoint, then you just have to put one breakpoint at in your aspect

Flexo
+2  A: 

Go to Debug -> Exceptions. In this dialog you can enable first chance debugging of exceptions - when an exception is thrown, the debugger will automatically break at the throwing code before the "catch" code is executed, allowing you to debug it.

(Note: This won't get the debugger to break whenever you execute a try block, only if the exception is actually thrown)

Jason Williams
A: 

I am not aware of a possibility that allows setting breakpoints in code by some pattern. The closest you can come to is Debug/New breakpoint/Break at Function where you can specify the file and line number. If you can get this automated and working down a list generated by a grep search, you might find a way. Here is something from the IDE samples that might get you started:

' Sets a pending breakpoint at the function named "main".  It marks the 
' breakpoint as one set by automation.
Sub AddBreakpointToMain()
    Dim bp As EnvDTE.Breakpoint
    Dim bps As EnvDTE.Breakpoints

    bps = DTE.Debugger.Breakpoints.Add("main")
    For Each bp In bps
        bp.Tag = "SetByMacro"
    Next
End Sub

However, why do you want to set those breakpoints anyway? If it's in order to catch exceptions as they are thrown, you can make the debugger break automatically whenever the happens under Tools/Exceptions.

sbi