Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

int i = 2; // what do you use as a throwaway line when you just need something to breakpoint on?

Tags:

debugging

Whenever I want a breakpoint someplace where there isnt anything to break on just (inside a loop, &c), I tend to automatically drop down a:

int i = 2;

I'm curious what others use.

like image 744
rektide Avatar asked Mar 13 '09 02:03

rektide


2 Answers

Visual Studio lets you break on a brace.

like image 139
Andrew Hare Avatar answered Oct 24 '22 19:10

Andrew Hare


In the .NET Framework (using C# here):

System.Diagnostics.Debugger.Break();

To avoid typing this every time just create a new code snippet for your preferred language:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>sddb</Title>
      <Shortcut>sddb</Shortcut>
      <Description>
        Code snippet for System.Diagnostics.Debugger.Break()
      </Description>
      <Author>Peter McG</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp">
        <![CDATA[System.Diagnostics.Debugger.Break();$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
like image 25
Peter McG Avatar answered Oct 24 '22 19:10

Peter McG