开发者

Automatically step by step debugging in Visual Studio?

开发者 https://www.devze.com 2023-01-07 07:56 出处:网络
I was getting tired of hitting the F10 every step to debug the programs. Are there any program can automate the visual studio to run each deb开发者_如何转开发ugging step in a consistent frequency? say

I was getting tired of hitting the F10 every step to debug the programs. Are there any program can automate the visual studio to run each deb开发者_如何转开发ugging step in a consistent frequency? say, 3 seconds for each step?

Regards, Sam


You can easily do that with a simple script in Autohotkey.

Download it from here: http://www.autohotkey.com/

  1. Install Autohotkey.

  2. Run it.

  3. Find the green "H" icon in the task bar (bottom right).

  4. Right click the icon and select Edit script.

  5. And copy paste this script below.

^!y::
InputBox, input1, How many F10 strokes you want?, , , 250, 100
InputBox, input2, How many seconds between each F10 stroke?, , , 250, 100

if ErrorLevel <> 0
{
  MsgBox, CANCEL was pressed.
}
else
{
  loop, %input1%
  {
      Sleep, (input2 * 1000)
      Send {F10}
  }
  MsgBox, "Your F10 script has Ended"
}
return
  1. Then reload (again by right clicking the green "H" icon in task bar).

  2. Press Control+Alt+y to try out the above script.


Sitting there repeatedly hitting F10 can be annoying, but you probably just need to make more use of the inbuilt debugging features.

  • set a breakpoint at a targetted location and hit F5 to run the program, it will stop when it hits the breakpoint
  • use F11 to step in to a function
  • use Shift-F11 to step out of a function
  • use the breakpoints window (Debug->Windows->Breakpoints) to get a complete list of all the bp's and you can easily enable/disable any of them (or set any of their other options)
  • use the Exceptions window (Debug->Exceptions) to select exceptions that you want to break on when they are first thrown
  • familiarize yourself with the options available to breakpoints (right-click on the bp itself to get these)

    • hit count: specify how many times code should go past the breakpoint before it stops

    • condition: super useful (i use it all the time), you can use almost any expression in there, including checking the value of inscope variables

    • when hit: you can run a macro when the breakpoint is hit

    • filter: to restrict which running thread can break on that breakpoint

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号