DOSBox can be configured to include a debugger. The feature is not enabled in the official binary but the enhanced derivative projects probably have it (DOSBox-X definitely does):
- https://www.vogons.org/viewtopic.php?t=3944
- https://github.com/joncampbell123/dosbox-x/wiki/DOSBox%E2%80...
DOSBox-x on FreeBSD at least has is disabled by default, but it can be enabled when building from ports (make config).
https://github.com/joncampbell123/dosbox-x/blob/master/READM...