Cocotb scripts are executed by a python interpreter embedded in a native library which is dynamically loaded by a simulator at test runtime. Happily you don’t need to understand much about all of that to use Cocotb, but the indirection does mean a bit of scaffolding is necessary to enable visual debugging of scripts in PyCharm.
Complete Cocotb docs can be found here.
Unfortunately the steps below do require Remote Debug Server which is only available with the Professional (non-free) edition of PyCharm.
Create a Remote Debug Server Configuration. More details here.
Include and configure pydevd in your Cocotb python file
import pydevd pydevd.settrace('localhost', port=9090, stdoutToServer=True, stderrToServer=True)
Run the Remote Debug Server
Run the verification script Makefile specifying the path to pydevd.
Step through debugging in PyCharm.