在 Visual Studio 调试器中使用断点Use breakpoints in the Visual Studio debugger

在开发人员的工具箱中,断点是最重要的调试技术之一。Breakpoints are one of the most important debugging techniques in your developer's toolbox. 你可以在希望暂停调试器执行的任何位置设置断点。You set breakpoints wherever you want to pause debugger execution. 例如,你可能想要查看代码变量的状态,或查看某个断点处的调用堆栈。For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint. 如果你正在尝试解决使用断点时出现的警告或问题,请参阅 Visual Studio 调试器中的断点排除故障If you are trying to resolve a warning or issue while using breakpoints, see Troubleshoot breakpoints in the Visual Studio debugger.

备注

如果知道要解决的任务或问题,但想要了解应使用哪种断点,请参见查找调试任务If you know the task or problem you're trying to solve, but you need to know what kind of breakpoint to use, see Find your debugging task.

在源代码中设置断点Set breakpoints in source code

可以在任意可执行代码行上设置断点。You can set a breakpoint on any line of executable code. 例如,在下面的 C# 代码中,可以在变量声明、for 循环或 for 循环内的任何代码上设置断点。For example, in the following C# code, you could set a breakpoint on the variable declaration, the for loop, or any code inside the for loop. 不能在命名空间、类声明或方法签名上设置断点。You can't set a breakpoint on the namespace or class declarations, or on the method signature.

若要在源代码中设置断点,请单击代码行最左边的边距。To set a breakpoint in source code, click in the far left margin next to a line of code. 你还可以选择行并按“F9”,选择“调试” > “切换断点”,或者右键单击并选择“断点” > “插入断点” 。You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. 断点显示为左边距中的一个红点。The breakpoint appears as a red dot in the left margin.

对于大多数语言(包括 C#),会自动突出显示断点和当前执行的行。For most languages including C#, breakpoint and current execution lines are automatically highlighted. 对于 C++ 代码,可以通过选择“工具”(或“调试”)>“选项” > “调试” > “突出显示断点和当前语句的整个源行(仅限 C++)” 。For C++ code, you can turn on highlighting of breakpoint and current lines by selecting Tools (or Debug) > Options > Debugging > Highlight entire source line for breakpoints and current statement (C++ only).

设置断点Set a breakpoint

调试时,在执行断点所在行上的代码之前,执行会在断点处暂停。When you debug, execution pauses at the breakpoint, before the code on that line is executed. 断点符号显示黄色箭头。The breakpoint symbol shows a yellow arrow.

在以下示例中的断点处,testInt 的值仍然为 1。At the breakpoint in the following example, the value of testInt is still 1. 也就是说,从变量初始化(设置为值 1)以来,该值没有更改,因为尚未执行黄色的语句。So, the value hasn't changed since the variable was initialized (set to a value of 1) because the statement in yellow hasn't yet executed.

断点执行已停止Breakpoint execution stopped

当调试器在断点处停止时,可以查看应用程序的当前状态,包括变量值调用堆栈When the debugger stops at the breakpoint, you can look at the current state of the app, including variable values and the call stack.

下面是关于使用断点的一些常规说明。Here are a few general instructions for working with breakpoints.

  • 断点是一个开关。The breakpoint is a toggle. 你可以单击它,按 F9,或使用“调试” > “切换断点”来删除或重新插入该断点 。You can click it, press F9, or use Debug > Toggle Breakpoint to delete or reinsert it.

  • 若要禁用断点而不删除它,请将鼠标悬停在其上或右键单击它,然后选择“禁用断点” 。To disable a breakpoint without deleting it, hover over or right-click it, and select Disable breakpoint. 禁用的断点在左边距或“断点”窗口中显示为空心圆点 。Disabled breakpoints appear as empty dots in the left margin or the Breakpoints window. 若要重新启用断点,请将鼠标悬停在断点上或右键单击它,然后选择“启用断点” 。To re-enable a breakpoint, hover over or right-click it, and select Enable breakpoint.

  • 设置条件和操作,添加和编辑标签,或通过右键单击断点并选择适当的命令导出断点,或将鼠标悬停在断点上并选择“设置”图标 。Set conditions and actions, add and edit labels, or export a breakpoint by right-clicking it and selecting the appropriate command, or hovering over it and selecting the Settings icon.

断点操作和跟踪点Breakpoint actions and tracepoints

“跟踪点”是将消息打印到“输出”窗口的断点 。A tracepoint is a breakpoint that prints a message to the Output window. 跟踪点的作用像这种编程语言中的一个临时跟踪语句,且不会暂停代码的执行。A tracepoint can act like a temporary trace statement in the programming language and does not pause the execution of code. 通过在“断点设置”窗口中设置特殊操作,可以创建跟踪点 。You create a tracepoint by setting a special action in the Breakpoint Settings window. 有关详细说明,请参阅在 Visual Studio 调试器中使用跟踪点For detailed instructions, see Use tracepoints in the Visual Studio debugger.

断点条件Breakpoint conditions

可以通过设置条件来控制在何时何处执行断点。You can control when and where a breakpoint executes by setting conditions. 条件可以是调试器能够识别的任何有效表达式。The condition can be any valid expression that the debugger recognizes. 有关有效表达式的详细信息,请参见调试器中的表达式For more information about valid expressions, see Expressions in the debugger.

设置断点条件:To set a breakpoint condition:

  1. 右键单击该断点符号并选择“条件” 。Right-click the breakpoint symbol and select Conditions. 或者将鼠标悬停在断点符号上,选择“设置”图标,然后在“断点设置”窗口中选择“条件” 。Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.

    还可以在“断点”窗口中设置条件,方法是右键单击断点并选择“设置”,然后选择“条件” 。You can also set conditions in the Breakpoints window by right-clicking a breakpoint and selecting Settings, and then selecting Conditions.

    断点设置Breakpoint settings

  2. 在下拉列表中,选择“条件表达式”、“命中计数”或“筛选器”,并相应地设置其值 。In the dropdown, select Conditional Expression, Hit Count, or Filter, and set the value accordingly.

  3. 选择“关闭”或按 Ctrl+Enter 关闭“断点设置”窗口 。Select Close or press Ctrl+Enter to close the Breakpoint Settings window. 或者,从“断点”窗口中,选择“确定”以关闭对话框 。Or, from the Breakpoints window, select OK to close the dialog.

设置了条件的断点在源代码和“断点”窗口中带有 + 符号 。Breakpoints with conditions set appear with a + symbol in the source code and Breakpoints windows.

创建条件表达式Create a conditional expression

选择“条件表达式”时,可以在两个条件之间进行选择: “为 true”或“更改时” 。When you select Conditional Expression, you can choose between two conditions: Is true or When changed. 要在满足表达式时中断,请选择“为 true”;要在表达式的值更改时中断,请选择“更改时” 。Choose Is true to break when the expression is satisfied, or When changed to break when the value of the expression has changed.

在下面的示例中,仅当 testInt 的值为“4”时才会命中断点 :In the following example, the breakpoint is hit only when the value of testInt is 4:

断点条件为 trueBreakpoint condition is true

在下面的示例中,仅当 testInt 的值更改时才会命中断点:In the following example, the breakpoint is hit only when the value of testInt changes:

断点更改时Breakpoint When changed

如果使用无效语法设置断点条件,则会显示警告消息。If you set a breakpoint condition with invalid syntax, a warning message appears. 如果在指定断点条件时使用的语法有效但语义无效,则在第一次命中断点将出现警告消息。If you specify a breakpoint condition with valid syntax but invalid semantics, a warning message appears the first time the breakpoint is hit. 在这两种情况下,调试器都会在遇到无效断点时中断。In either case, the debugger breaks when it hits the invalid breakpoint. 仅在条件有效且计算结果为 false时才会跳过断点。The breakpoint is skipped only if the condition is valid and evaluates to false.

备注

不同编程语言的“更改时”字段的行为不同 。The behavior of the When changed field is different for different programming languages.

  • 对于本机代码,调试器不会将条件的第一次计算当作一次更改,所以第一次计算时不会命中断点。For native code, the debugger doesn't consider the first evaluation of the condition to be a change, so doesn't hit the breakpoint on the first evaluation.
  • 对于托管代码,当选择了“更改时”,调试器将在之后的第一次计算时命中断点 。For managed code, the debugger hits the breakpoint on the first evaluation after When changed is selected.

在条件表达式中使用对象 ID(仅限 C# 和 F#)Use Object IDs in conditional expressions (C# and F# only)

有时,你想要观察特定对象的行为。There are times when you want to observe the behavior of a specific object. 例如,你可能想要找出对象多次插入到集合中的原因。For example, you might want to find out why an object was inserted into a collection more than once. 在 C# 和 F# 中,可以创建引用类型的特定实例的对象 ID,并在断点条件下使用它们。In C# and F#, you can create object IDs for specific instances of reference types, and use them in breakpoint conditions. 对象 ID 由公共语言运行时 (CLR) 调试服务生成并与该对象关联。The object ID is generated by the common language runtime (CLR) debugging services and associated with the object.

创建对象 ID:To create an Object ID:

  1. 在创建对象后的代码中设置断点。Set a breakpoint in the code some place after the object has been created.

  2. 开始调试,当执行在断点处暂停时,选择“调试” > “窗口” > “局部变量”或按 Alt+4 打开“局部变量”窗口 。Start debugging, and when execution pauses at the breakpoint, select Debug > Windows > Locals or Alt+4 to open the Locals window.

    在“局部变量”窗口中找到特定的对象实例,右键单击它,然后选择“生成对象 ID” 。Find the specific object instance in the Locals window, right-click it, and select Make Object ID.

    应该会在“局部变量” $ 窗口中看到 $ 窗口中设置断点来中断调用函数返回到的指令或行处的执行。You should see a $ plus a number in the Locals window. 这就是对象 ID。This is the object ID.

  3. 在想要开展调查时添加一个新断点,例如将对象添加到集合中时。Add a new breakpoint at the point you want to investigate; for example, when the object is to be added to the collection. 右键单击该断点并选择“条件” 。Right-click the breakpoint and select Conditions.

  4. 在“条件表达式”字段中使用对象 ID 。Use the Object ID in the Conditional Expression field. 例如,如果变量 item 是要添加到集合中的对象,则选择“为 true”,并键入“item == $<n>”,其中 <n> 是对象 ID 号 。For example, if the variable item is the object to be added to the collection, select Is true and type item == $<n>, where <n> is the object ID number.

    会在将该对象添加到集合中时中断执行。Execution will break at the point when that object is to be added to the collection.

    若要删除对象 ID,请右键单击“局部变量”窗口中的变量,然后选择“删除对象 ID” 。To delete the Object ID, right-click the variable in the Locals window and select Delete Object ID.

备注

对象 ID 创建弱引用,且不会阻止对象被垃圾回收。Object IDs create weak references, and do not prevent the object from being garbage collected. 它们仅对当前调试会话有效。They are valid only for the current debugging session.

设置命中次数条件Set a hit count condition

如果怀疑代码中的循环在一定数量的迭代后开始产生错误行为,则可以设置断点以在该次数的命中后停止执行,而不必反复按 F5 以到达该迭代 。If you suspect that a loop in your code starts misbehaving after a certain number of iterations, you can set a breakpoint to stop execution after that number of hits, rather than having to repeatedly press F5 to reach that iteration.

在“断点设置”窗口的“条件”下,选择“命中计数”,然后指定迭代次数 。Under Conditions in the Breakpoint Settings window, select Hit Count, and then specify the number of iterations. 在下面的示例中,将断点设置为每隔一次迭代命中一次:In the following example, the breakpoint is set to hit on every other iteration:

断点命中次数Breakpoint hit count

设置筛选条件Set a filter condition

可以将断点限制为仅在指定设备上或在指定进程和线程中触发。You can restrict a breakpoint to fire only on specified devices, or in specified processes and threads.

在“断点设置”窗口的“条件”下,选择“筛选器”,然后输入以下一个或多个表达式 :Under Conditions in the Breakpoint Settings window, select Filter, and then enter one or more of the following expressions:

  • MachineName = "name"MachineName = "name"
  • ProcessId = valueProcessId = value
  • ProcessName = "name"ProcessName = "name"
  • ThreadId = valueThreadId = value
  • ThreadName = "name"ThreadName = "name"

将字符串值放在双引号内。Enclose string values in double quotes. 可以使用 & (AND)、 || (OR)、 ! (NOT) 和括号合并子句。You can combine clauses using & (AND), || (OR), ! (NOT), and parentheses.

设置函数断点Set function breakpoints

可以在调用函数时中断执行。You can break execution when a function is called. 例如,当你知道函数名但不知道其位置时,这很有用。This is useful, for example, when you know the function name but not its location. 如果多个函数(例如重载函数或不同项目中的函数)具有相同的名称,而你想要将其全部中断,这也很有用。It is also useful if you have functions with the same name and you want to break on them all (such as overloaded functions or functions in different projects).

设置函数断点:To set a function breakpoint:

  1. 选择“调试” > “新建断点” > “函数断点”,或按 Alt+F9 > Ctrl+B 。Select Debug > New Breakpoint > Function Breakpoint, or press Alt+F9 > Ctrl+B.

    也可以在“断点”窗口中选择“新建” > “函数断点” 。You can also select New > Function Breakpoint in the Breakpoints window.

  2. 在“新建函数断点”对话框中,在“函数名称”框中输入函数名称 。In the New Function Breakpoint dialog, enter the function name in the Function Name box.

    缩小函数规格:To narrow the function specification:

    • 使用完全限定的函数名。Use the fully qualified function name.

      示例:Namespace1.ClassX.MethodA()Example: Namespace1.ClassX.MethodA()

    • 添加重载函数的参数类型。Add the parameter types of an overloaded function.

      示例:MethodA(int, string)Example: MethodA(int, string)

    • 使用“!”符号指定模块。Use the '!' symbol to specify the module.

      示例:App1.dll!MethodAExample: App1.dll!MethodA

    • 使用本机 C++ 中的上下文运算符。Use the context operator in native C++.

      {function, , [module]} [+<line offset from start of method>]

      示例:{MethodA, , App1.dll}+2Example: {MethodA, , App1.dll}+2

  3. 在“语言”下拉列表中,选择函数的语言 。In the Language dropdown, choose the language of the function.

  4. 选择“确定” 。Select OK.

使用内存地址设置函数断点(仅限本机 C++)Set a function breakpoint using a memory address (native C++ only)

你还可以使用对象的地址在类的特定实例调用的方法上设置函数断点。You can use the address of an object to set a function breakpoint on a method called by a specific instance of a class. 例如,给定一个类型为 my_class 的可寻址对象,可以在实例调用的 my_method 方法上设置函数断点。For example, given an addressable object of type my_class, you can set a function breakpoint on the my_method method that instance calls.

  1. 在实例化类的实例后的位置设置断点。Set a breakpoint somewhere after the instance of the class is instantiated.

  2. 找到实例的地址(例如 0xcccccccc)。Find the address of the instance (for example, 0xcccccccc).

  3. 选择“调试” > “新建断点” > “函数断点”,或按 Alt+F9 > Ctrl+B 。Select Debug > New Breakpoint > Function Breakpoint, or press Alt+F9 > Ctrl+B.

  4. 将下列内容添加到“函数名”框中,并选择“C++”语言 。Add the following to the Function Name box, and select C++ language.

    ((my_class *) 0xcccccccc)->my_method
    

设置数据断点(.NET Core 3.0 或更高版本)Set data breakpoints (.NET Core 3.0 or higher)

当特定对象的属性更改时,数据断点中断执行。Data breakpoints break execution when a specific object's property changes.

设置数据断点To set a data breakpoint

  1. 在 .NET Core 项目中,启动调试,并等待到达断点。In a .NET Core project, start debugging, and wait until a breakpoint is reached.

  2. 在“自动”、“监视”或“局部变量”窗口中,右键单击一个属性并在上下文菜单中选择“当值更改时中断” 。In the Autos, Watch, or Locals window, right-click a property and select Break when value changes in the context menu.

    托管数据断点Managed Data Breakpoint

.NET Core 中的数据断点不适用于:Data breakpoints in .NET Core won't work for:

  • 无法在工具提示、“局部变量”、“自动”或“监视”窗口中展开的属性Properties that are not expandable in the tooltip, Locals, Autos, or Watch window
  • 静态变量Static variables
  • 具有 DebuggerTypeProxy 属性的类Classes with the DebuggerTypeProxy Attribute
  • 结构内的字段Fields inside of structs

设置数据断点(仅限本机 C++)Set data breakpoints (native C++ only)

数据断点在存储在指定内存地址中的值更改时中断执行。Data breakpoints break execution when a value stored at a specified memory address changes. 如果只读取但不更改该值,则执行不会中断。If the value is read but not changed, execution doesn't break.

设置数据断点:To set a data breakpoint:

  1. 在 C++ 项目中,启动调试,并等待到达断点。In a C++ project, start debugging, and wait until a breakpoint is reached. 在“调试”菜单上,选择“新建断点” > “数据断点” On the Debug menu, choose New Breakpoint > Data Breakpoint

    还可以在“断点”窗口中选择“新建” > “数据断点”,或者右键单击“自动”、“监视”或“局部变量”窗口中的某个项,然后在上下文菜单中选择“当值更改时中断” 。You can also select New > Data Breakpoint in the Breakpoints window or right-click an item in the Autos, Watch, or Locals window and select Break when value changes in the context menu.

  2. 在“地址”框中,键入内存地址或计算结果为内存地址的表达式 。In the Address box, type a memory address, or an expression that evaluates to a memory address. 例如,键入 &avar 以在变量 avar 的内容更改时执行中断操作。For example, type &avar to break when the contents of the variable avar changes.

  3. “字节计数” 下拉菜单中,选择你想要调试程序监视的字节数。In the Byte Count dropdown, select the number of bytes you want the debugger to watch. 例如,如果选择 4,则调试程序将监视从 &avar 开始的四个字节,并在其中任何字节的值发生更改时执行中断操作。For example, if you select 4, the debugger will watch the four bytes starting at &avar and break if any of those bytes change value.

数据断点在下列情况下无效:Data breakpoints don't work under the following conditions:

  • 将未经调试的进程写入内存位置。A process that is not being debugged writes to the memory location.
  • 在两个或多个进程间共享内存位置。The memory location is shared between two or more processes.
  • 内存位置在内核内更新。The memory location is updated within the kernel. 例如,如果内存传递给 32 位 Windows ReadFile 函数,则内存将从内核模式进行更新,因此调试器不会在更新时中断。For example, if memory is passed to the 32-bit Windows ReadFile function, the memory will be updated from kernel mode, so the debugger won't break on the update.
  • 其中,监视表达式在 32 位硬件上大于 4 字节,在 64 位硬件上大于 8 字节。Where the watch expression is larger than 4 bytes on 32-bit hardware and 8 bytes on 64-bit hardware. 这是 x86 体系结构的一个限制。This is a limitation of the x86 architecture.

备注

  • 数据断点取决于特定的内存地址。Data breakpoints depend on specific memory addresses. 变量的地址随调试会话而更改,因此将在每个调试会话结束时自动禁用数据断点。The address of a variable changes from one debugging session to the next, so data breakpoints are automatically disabled at the end of each debugging session.

  • 如果在局部变量上设置数据断点,则断点在函数结束时仍处于启用状态,但内存地址不再适用,因此断点的行为不可预测。If you set a data breakpoint on a local variable, the breakpoint remains enabled when the function ends, but the memory address is no longer applicable, so the behavior of the breakpoint is unpredictable. 如果在局部变量上设置了数据断点,则应在函数结束前删除或禁用该断点。If you set a data breakpoint on a local variable, you should delete or disable the breakpoint before the function ends.

在“断点”窗口中管理断点Manage breakpoints in the Breakpoints window

可以使用“断点”窗口查看和管理解决方案中的所有断点 。You can use the Breakpoints window to see and manage all the breakpoints in your solution. 在大型解决方案中,或者在断点非常重要的复杂调试方案中,这一集中位置尤为有用。This centralized location is especially helpful in a large solution, or for complex debugging scenarios where breakpoints are critical.

在“断点”窗口中,可以搜索、排列、筛选、启用/禁用或删除断点 。In the Breakpoints window, you can search, sort, filter, enable/disable, or delete breakpoints. 还可以设置条件和操作,或添加新的函数或数据断点。You can also set conditions and actions, or add a new function or data breakpoint.

若要打开“断点”窗口,请选择“调试” > “窗口” > “断点”,或按 Alt+F9 或 Ctrl+Alt + B。To open the Breakpoints window, select Debug > Windows > Breakpoints, or press Alt+F9 or Ctrl+Alt+B.

“断点”窗口Breakpoints window

若要选择要在“断点”窗口中显示的列,请选择“显示列” 。To select the columns to display in the Breakpoints window, select Show Columns. 选择列标题以按该列对断点列表进行排序。Select a column header to sort the breakpoints list by that column.

断点标签Breakpoint labels

可以使用标签对“断点”窗口中的断点列表进行排序和筛选 。You can use labels to sort and filter the list of breakpoints in the Breakpoints window.

  1. 若要向断点添加标签,请在源代码或“断点”窗口中右键单击断点,然后选择“编辑标签” 。To add a label to a breakpoint, right-click the breakpoint in the source code or the Breakpoints window, and then select Edit labels. 添加新标签或选择现有标签,然后选择“确定” 。Add a new label or choose an existing one, and then select OK.
  2. 通过选择“标签”、“条件”或其他列标题,在“断点”窗口中对断点列表进行排序 。Sort the breakpoint list in the Breakpoints window by selecting the Labels, Conditions, or other column headers. 可以通过选择工具栏中的“显示列”来选择要显示的列 。You can select the columns to display by selecting Show Columns in the toolbar.

导入和导出断点Export and import breakpoints

若要保存或共享断点的状态和位置,可以导出或导入断点。To save or share the state and location of your breakpoints, you can export or import them.

  • 若要将单个断点导出到 XML 文件,请在源代码或“断点”窗口中右键单击该断点,然后选择“导出”或“导出已选内容” 。To export a single breakpoint to an XML file, right-click the breakpoint in the source code or Breakpoints window, and select Export or Export selected. 选择导出位置,然后选择“保存” 。Select an export location, and then select Save. 默认位置是解决方案文件夹。The default location is the solution folder.
  • 若要导出多个断点,请在“断点”窗口中选择断点旁边的框,或在“搜索”字段中输入搜索条件 。To export several breakpoints, in the Breakpoints window, select the boxes next to the breakpoints, or enter search criteria in the Search field. 选择“导出与当前搜索条件匹配的所有断点”图标,然后保存文件 。Select the Export all breakpoints matching the current search criteria icon, and save the file.
  • 若要导出所有断点,请取消选中所有框并将“搜索”字段留空 。To export all breakpoints, deselect all boxes and leave the Search field blank. 选择“导出与当前搜索条件匹配的所有断点”图标,然后保存文件 。Select the Export all breakpoints matching the current search criteria icon, and save the file.
  • 若要导入断点,请在“断点”窗口中选择“从文件导入断点”图标,导航到 XML 文件位置,然后选择“打开” 。To import breakpoints, in the Breakpoints window, select the Import breakpoints from a file icon, navigate to the XML file location, and select Open.

从调试器窗口设置断点Set breakpoints from debugger windows

还可以从“调用堆栈”和“反汇编”调试器窗口设置断点 。You can also set breakpoints from the Call Stack and Disassembly debugger windows.

在“调用堆栈”窗口中设置断点Set a breakpoint in the Call Stack window

若要在调用函数返回的指令或行处中断,可以在“调用堆栈”窗口中设置断点 。To break at the instruction or line that a calling function returns to, you can set a breakpoint in the Call Stack window.

在调用堆栈窗口中设置断点:To set a breakpoint in the Call Stack window:

  1. 若要打开“调用堆栈”窗口,必须在调试期间暂停 。To open the Call Stack window, you must be paused during debugging. 选择“调试” > “窗口” > “调用堆栈”,或按 Ctrl+Alt+C 。Select Debug > Windows > Call Stack, or press Ctrl+Alt+C.

  2. 在“调用堆栈”窗口中,右键单击调用函数并选择“断点” > “插入断点”,或按 F9 。In the Call Stack window, right-click the calling function and select Breakpoint > Insert Breakpoint, or press F9.

    断点符号显示在调用堆栈左边距中的函数调用名称旁。A breakpoint symbol appears next to the function call name in the left margin of the call stack.

调用堆栈断点在“断点”窗口中显示为一个地址,其内存位置对应于函数中的下一个可执行指令 。The call stack breakpoint appears in the Breakpoints window as an address, with a memory location that corresponds to the next executable instruction in the function.

调试器在指令处中断。The debugger breaks at the instruction.

有关调用堆栈的详细信息,请参阅如何:使用“调用堆栈”窗口For more information about the call stack, see How to: Use the Call Stack window.

要在代码执行期间以可视化方式跟踪断点,请参阅调试时映射调用堆栈上的方法To visually trace breakpoints during code execution, see Map methods on the call stack while debugging.

在“反汇编”窗口中设置断点Set a breakpoint in the Disassembly window

  1. 若要打开“反汇编”窗口,必须在调试期间暂停 。To open the Disassembly window, you must be paused during debugging. 选择“调试” > “窗口” > “反汇编”,或按 Alt+8 。Select Debug > Windows > Disassembly, or press Alt+8.

  2. 在“反汇编”窗口中,单击要中断的指令的左边距 。In the Disassembly window, click in the left margin of the instruction you want to break at. 你还可以选择它并按 F9,或者右键单击并选择“断点” > “插入断点” 。You can also select it and press F9, or right-click and select Breakpoint > Insert Breakpoint.

请参阅See also