Debugger 接口

定义

Debugger对象用于询问和操作调试器和正在调试的程序的状态。

public interface class Debugger
public interface class Debugger
__interface Debugger
[System.Runtime.InteropServices.Guid("338FB9A0-BAE5-11D2-8AD1-00C04F79E479")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface Debugger
[<System.Runtime.InteropServices.Guid("338FB9A0-BAE5-11D2-8AD1-00C04F79E479")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type Debugger = interface
Public Interface Debugger
派生
属性

示例

下面的示例演示如何使用调试器对象。

Imports EnvDTE  
Imports System.Diagnostics  

Public Module Module1  
    ' This function returns true if the debugger is actively debugging.  

    Function IsDebugging() As Boolean  
        Dim debugger As EnvDTE.Debugger  
        debugger = DTE.Debugger  

        If (debugger Is Nothing) Then  
            MsgBox("Debugger doesn't exist! Fatal error.")  
            IsDebugging = false  
        Else  
            IsDebugging = (debugger.CurrentMode <> dbgDebugMode.dbgDesignMode)  
        End If  
    End Function  
End Module  
// The following small C++ program can be run from the command line.  
// It detects whether an instance of Visual Studio is currently   
// running,and if so, prints a message stating whether its debugger  
// is actively debugging.  

#include <stdio.h>  
#import "dte.olb" raw_interfaces_only named_guids  

using namespace EnvDTE;  

int main(void)  
{  
    int nRet = 0;  

    CoInitialize(NULL);  

    IUnknownPtr pUnk;  
    GetActiveObject(CLSID_DTE, NULL, &pUnk);  

    if (pUnk == NULL) {  
        printf ("No instance of Visual Studio is running.\n");  
    }  
    else {  
        _DTEPtr pDTE = pUnk;  
        if (pDTE) {  
            DebuggerPtr pDebugger;  
            if (SUCCEEDED(pDTE->get_Debugger(&pDebugger)) && pDebugger != NULL){  
                dbgDebugMode mode;  
                if (SUCCEEDED(pDebugger->get_CurrentMode(&mode))) {  
                    if (mode != dbgDesignMode) {  
                        printf("Debugger is active.\n");  
                        nRet = 1;  
                    }  
                    else {  
                        printf("Debugger is not active.\n");  
                    }  
                }  
            }  
        }  
    }  

    CoUninitialize();  

    return nRet;  
}  

注解

可以通过 DTE 对象通过对象的属性来获取调试器 Debugger ,如以下示例中所示。 一个调试器对象可用于开发环境的每个实例。

属性

AllBreakpointsLastHit

获取最后同时命中的绑定断点的集合。

BreakpointLastHit

获取最后命中的断点。

Breakpoints

获取断点的集合。

CurrentMode

获取集成开发环境 (IDE) 上下文中调试器的当前模式。

CurrentProcess

设置或获取活动进程。

CurrentProgram

设置或获取活动程序。

CurrentStackFrame

设置或获取当前堆栈帧。

CurrentThread

设置或获取正在调试的当前线程。

DebuggedProcesses

获取当前正在调试的进程的列表。

DTE

获取顶级扩展性对象。

HexDisplayMode

获取或设置是以十六进制还是以十进制格式输出表达式。

HexInputMode

获取或设置是以十六进制还是以十进制格式计算表达式。

Languages

获取调试器所支持的语言的列表。

LastBreakReason

获取程序中断的最终原因。 如果程序正在运行,它将返回 DBG_REASON_NONE

LocalProcesses

获取该计算机上当前正在运行的进程列表。

Parent

获取 Debugger 对象的直接父对象。

方法

Break(Boolean)

使给定进程暂停执行以便可以分析其当前状态。

DetachAll()

从所有附加程序中分离。

ExecuteStatement(String, Int32, Boolean)

执行指定的语句。 如果 TreatAsExpression 标志为 true ,则将字符串解释为表达式,并将输出发送到命令窗口。

GetExpression(String, Boolean, Int32)

根据当前堆栈帧计算表达式。 如果可以分析但无法计算表达式,则将返回不包含有效值的对象。

Go(Boolean)

从当前语句开始执行程序。

RunToCursor(Boolean)

执行程序直至源文件光标的当前位置。

SetNextStatement()

根据当前源文件中的光标位置设置要执行的下一个指令。

StepInto(Boolean)

如果可能,单步执行下一个函数调用。

StepOut(Boolean)

跳出当前函数。

StepOver(Boolean)

转到下一个函数调用。

Stop(Boolean)

停止调试、终止或与所有附加进程分离。

TerminateAll()

终止所有进程。

适用于