30 lines · c
1#ifdef _MSC_VER2#include <intrin.h>3#define BREAKPOINT_INTRINSIC() __debugbreak()4#else5#define BREAKPOINT_INTRINSIC() __asm__ __volatile__ ("int3")6#endif7 8int9bar(int const *foo)10{11 int count = 0, i = 0;12 for (; i < 10; ++i)13 {14 count += 1;15 BREAKPOINT_INTRINSIC();16 count += 1;17 }18 return *foo;19}20 21int22main(int argc, char **argv)23{24 int foo = 42;25 bar(&foo);26 return 0;27}28 29 30