Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a unit test project based on UnitTest++. I usually put a breakpoint to the last line of the code so that the I can inspect the console when one of the tests fails:

  n = UnitTest::RunAllTests();
  if ( n != 0 )
  {
  // place breakpoint here    
    return n;
  }
  return n;

But I have to reinsert it each time I check-out the code anew from SVN. Is it possible to somewhat place the breakpoint by the compiler?:

      n = UnitTest::RunAllTests();
      if ( n != 0 )
      {
      // place breakpoint here    
#ifdef __MSVC__
        @!!!$$$??___BREAKPOINT;
#endif
        return n;
      }
      return n;
question from:https://stackoverflow.com/questions/2389270/visual-studio-can-be-a-breakpoint-called-from-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
196 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use the __debugbreak() intrinsic(requires the inclusion of <intrin.h>).

Using __debugbreak() is preferable to directly writing __asm { int 3 } since inline assembly is not permitted when compiling code for the x64 architecture.

And for the record, on Linux and Mac, with GCC, I'm using __builtin_trap().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...