Debugging and WFI/WFE

At least in CortexM, WFI (and probably WFE) gets in the way of debugging and there seem to be two options:

1- Avoiding it by using pm_block() 2-Configuring DBGMCU_CR

Problem is all this must be disabled for production, so the question is:

What is The Right Way to switch on and off this and other debug issues at compilation time?

TIA