Breakpoint

Why Trust Techopedia

What Does Breakpoint Mean?

A breakpoint, in the context of C#, is an intentional stop marked in the code of an application where execution pauses for debugging. This allows the programmer to inspect the internal state of the application at that point.

Advertisements

A breakpoint helps to speed up the debugging process in a large program by allowing the execution to continue up to a desired point before debugging begins. This is more efficient than stepping through the code on a line-by-line basis.

Conditions associated with a breakpoint represent an expression that determines whether the breakpoint is to be hit or skipped. When filters that specify process or thread are attached to the breakpoint, it is easier to debug parallel applications spread across multiple processors.

Techopedia Explains Breakpoint

Whenever a breakpoint is hit, the application and the debugger are said to be in "break" mode, during which the following actions can be executed:

  • Inspect the values of local variables set in the current block of code in a separate local window.
  • Terminate the execution of a single or multiple application.
  • Step through the code line by line. If there is no source code underlying the execution statements, it leads to debugging in the disassembly window.
  • Make adjustments to the program result by viewing and modifying the values of variables.
  • Move the execution point so as to resume the application execution from that point.
  • Change the code using the “Edit and Continue” feature, and resume the execution with applied changes without having to stop and restart the debugging session.

The key features of breakpoints include:

  • A breakpoint can be set and used while building an application using debug information.
  • A breakpoint can be set on the line of source code or on a function, with the ability to enable/ disable, edit and delete it.
  • A breakpoint can also be set at a memory address in the disassembly window and on a function using the call stack window.
  • Multiple breakpoints can be set on a line containing multiple executable statements.
  • A breakpoint can be set for all functions with the same name (both overloaded methods and functions occurring in multiple projects) in a single step.
  • Breakpoints are displayed in the source code and disassembly window using red symbols called glyphs in the left margin. The breakpoint tip displayed while resting the mouse on a glyph indicates information such as its associated condition, hit count (used for tracking the number of times a breakpoint is hit), filter, error condition, etc.

The .NET framework provides an option to insert a breakpoint programmatically by calling the System.Diagnostics.Debugger.Break method, which causes the application to break when run under the debugger. However, it is suggested that this be used in "Debug" mode only (by using compiler directive, #if DEBUG).

A breakpoint should not be set on system components that form part of a program with mixed-mode, native and managed code because it can break the common language runtime and cause the debugger to stop responding. Also, breakpoints on lines of source code after line number 64,000 will not be hit.

Advertisements

Related Terms

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.