How to prevent setting of C_DEBUGEN bit on ARM Cortex M4

What would be the correct way to prevent the setting of the C_DEBUGEN bit in the DHCSR register when connecting to an ARM Cortex-M4 device via OpenOCD and ST-Link V2 in SWD Mode? If I understood that correctly OpenOCD seems to set some debugging bits in that register. The bit also gets set automatically if I try to read the flash? I’m using the target file of the STM32f1x and tried modifying it a little bit, but if I read the DHCSR register directly after starting the server the C_DEBUGEN bit is already set. The controller is a GD32F3.