Compartir a través de


Breakpoints.Add Method

Creates and enables a new breakpoint.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Function Add ( _
    Function As String, _
    File As String, _
    Line As Integer, _
    Column As Integer, _
    Condition As String, _
    ConditionType As dbgBreakpointConditionType, _
    Language As String, _
    Data As String, _
    DataCount As Integer, _
    Address As String, _
    HitCount As Integer, _
    HitCountType As dbgHitCountType _
) As Breakpoints
Breakpoints Add(
    string Function,
    string File,
    int Line,
    int Column,
    string Condition,
    dbgBreakpointConditionType ConditionType,
    string Language,
    string Data,
    int DataCount,
    string Address,
    int HitCount,
    dbgHitCountType HitCountType
)
Breakpoints^ Add(
    [InAttribute] String^ Function, 
    [InAttribute] String^ File, 
    [InAttribute] int Line, 
    [InAttribute] int Column, 
    [InAttribute] String^ Condition, 
    [InAttribute] dbgBreakpointConditionType ConditionType, 
    [InAttribute] String^ Language, 
    [InAttribute] String^ Data, 
    [InAttribute] int DataCount, 
    [InAttribute] String^ Address, 
    [InAttribute] int HitCount, 
    [InAttribute] dbgHitCountType HitCountType
)
abstract Add : 
        Function:string * 
        File:string * 
        Line:int * 
        Column:int * 
        Condition:string * 
        ConditionType:dbgBreakpointConditionType * 
        Language:string * 
        Data:string * 
        DataCount:int * 
        Address:string * 
        HitCount:int * 
        HitCountType:dbgHitCountType -> Breakpoints
function Add(
    Function : String, 
    File : String, 
    Line : int, 
    Column : int, 
    Condition : String, 
    ConditionType : dbgBreakpointConditionType, 
    Language : String, 
    Data : String, 
    DataCount : int, 
    Address : String, 
    HitCount : int, 
    HitCountType : dbgHitCountType
) : Breakpoints

Parameters

  • Function
    Type: System.String

    Optional. A function breakpoint. The name of the function on which the breakpoint is set.

  • File
    Type: System.String

    Optional. A file breakpoint. The name and optional path of the file in which the breakpoint is set.

  • Line
    Type: System.Int32

    Optional. A file breakpoint. The source-code line number, measured from the start of the function, at which the breakpoint is set. If this value is 1, the breakpoint is set at the start of the function.

  • Column
    Type: System.Int32

    Optional. A file breakpoint. The character at which the breakpoint is set. In most cases, you can leave this value set to 1, which sets the breakpoint at the start of the line.

  • Language
    Type: System.String

    Optional. The programming language in which the function is written.

  • Data
    Type: System.String

    Optional. A data breakpoint. If the breakpoint is set on a variable, you can specify the name of the variable. You can use the context operator to specify a variable outside the current scope.

  • DataCount
    Type: System.Int32

    Optional. A data breakpoint. If the breakpoint is set on a variable, and if the variable is an array or dereferenced pointer, this value specifies the number of elements to watch.

  • Address
    Type: System.String

    Optional. An address breakpoint. The memory address where the breakpoint is set, in decimal or hexadecimal format.

  • HitCount
    Type: System.Int32

    Optional. The Hit Count property for the breakpoint. If you specify no hit count, program execution breaks each time the breakpoint is hit. If you specify a hit count, program execution breaks only on the specified number of hits.

Return Value

Type: EnvDTE.Breakpoints
A Breakpoints collection.

Remarks

Creates and enables a new breakpoint and returns a Breakpoints collection.

All parameters for this method are optional; however you can specify only one of four location types, as described below.

To set a breakpoint in this location type

Use parameter(s)

Within a function.

Function

Within a file. Can optionally specify the line and column location within the file.

File, Line, and Column

Within data. Can optionally be set for variables and the number of variables to watch.

Data and DataCount

At a specific address.

Address

To any of these location types, you can optionally supply Condition and ConditionType to break only when a specified condition is true. You can optionally supply HitCount and HitCountType to break on the specified hit count.

Examples

The following example demonstrates how to use the Add method.

To test this method:

  1. Open the target project and run the add-in.
public static void Add(DTE dte)
{
    // Setup debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Add Method Test: ");
    owp.Activate();

    // dte is a reference to the DTE object passed to you by the
    // OnConnection method that you implement when you create an add-in.
    EnvDTE.Debugger debugger = (EnvDTE.Debugger)dte.Debugger;
    debugger.Breakpoints.Add("","Target001.cs", 13, 1, "", 
                             EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, 
                             "C#","", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);
    debugger.Breakpoints.Add("","Target001.cs", 15, 1, "", 
                             EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, 
                             "C#","", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);

    owp.OutputString("\nNumber of Breakpoints: " + debugger.Breakpoints.Count);
    owp.OutputString("\nEdition of the environment: " + 
                     debugger.Breakpoints.DTE.Edition);
    owp.OutputString("\nParent's Current Mode: " + 
                     debugger.Breakpoints.Parent.CurrentMode);
    owp.OutputString("\nFirst breakpoint is on line " + 
                     debugger.Breakpoints.Item(1).FileLine + ".");
    owp.OutputString("\nSecond breakpoint is on line " + 
                     debugger.Breakpoints.Item(2).FileLine + ".");
}
Shared Sub AddBreakpoint(ByRef dte As EnvDTE.DTE)
    dte.Debugger.StepInto(True)
    dte.Debugger.Breakpoints.Add("", "Target001.cs", 13, 1, "", _
                                 EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, _
                                 "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone)
    dte.Debugger.Breakpoints.Add("", "Target001.cs", 15, 1, "", _
                                 EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, _
                                 "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone)
End Sub

.NET Framework Security

See Also

Reference

Breakpoints Interface

EnvDTE Namespace