I maintain a little diff patch for MAME and MESS that I call emubrk. This is an opcode ($11FC) that will cause the debugger to pop up when it is encountered in the instruction stream. Attached you’ll find the patches for this useful little bit of functionality. If you find the patches no longer work, please email me and I’ll fix them up.
Erik Gavriluk has since taken the mantle for this and incorporated these features into his for of MAME.