Use a global variable for the loop such as:
int global_var = 1;
void some_function()
{
while(global_var == 1);
}
When you attach and are in the debugger, use the debugger to set global_var to 0, then when you step through you will exit the loop.
Your code should only invoke this loop when it detects the "error condition" where you want something like a "breakpoint".