Hi,
VisualGDB does not interact with the debugged devices directly, and instead uses various vendor-supplied tools like OpenOCD.
If STM32CubeIDE does it automatically, it likely has some special OpenOCD command in the script, or a command-line tool that it runs before or after debugging. You would need to find that out and make sure you can get it working with command-line tools alone.
Based on your findings, we can then help you configure VisualGDB to launch these tools automatically. If it’s a stand-alone tool, you can add it to VisualGDB Project Properties -> Debug Customization -> Pre/Debug steps. If it’s an OpenOCD script command, you can configure it via advanced settings on the Debug Settings page.