maziac / DeZog

Visual Studio Code Debugger for Z80/ZX Spectrum.
MIT License
212 stars 35 forks source link

Debugging with ZEsarUX does not work on DeZog 0.12.0 #9

Closed kborowinski closed 4 years ago

kborowinski commented 4 years ago

Describe the bug Remote debugging does not work at all with ZEsarUX and DeZog 0.12.0. It works as expected on DeZog 0.11.0. As per instruction in 0.12.0 release I've added "remoteType": "zrcp" to launch.json

To Reproduce Start ZEsarUX Launch debugging from VSC Nothing happens i.e. no error, no output in debug console

dezog

Version etc. (please complete the following information):

Additional context Please attach your launch.json file.

"version": "0.2.0",
"configurations": [
    {
        "type": "dezog",
        "request": "launch",
        "name": "ZEsarUX",
        "zhostname": "localhost",
        "remoteType": "zrcp",
        "zport": 10000,
        "listFiles": [
            {
                "path": "zxnext.list",
                "useFiles": true,
                "asm": "sjasmplus",
                "mainFile": "zxnext.asm"
            }
        ],
        "startAutomatically": false,
        "skipInterrupt": true,
        "commandsAfterLaunch": [
            //"-sprites",
            //"-patterns"
        ],
        "disassemblerArgs": {
            "esxdosRst": true
        },
        "rootFolder": "${workspaceFolder}",
        "topOfStack": "stackTop",
        //"load": "../../EMULATORS/ZESARUX/zxnext.sna",
        "load": "../../EMULATORS/ZESARUX/zxnext.nex",
        "smallValuesMaximum": 513,
        "tmpDir": ".tmp",
        "preLaunchTask": "zesarux"
    }
maziac commented 4 years ago

Please try the new version: https://github.com/maziac/DeZog/releases/tag/0.12.2

(Could you maybe also try the new internal Z80 simulator, "remoteType": "zxsim")

kborowinski commented 4 years ago

Yep, the remote debugging with ZEsarUX works again on 0.12.2!

I did try the "zxsim" debugging. The simulator starts, runs the z80 code for a bit but then stops executing the code (the debugging is still running and there is no error). When you pause the debugging then disassembly show some random location im memory (first ROM page address space) with nops:

zxsim

maziac commented 4 years ago

Fine to hear.

Is this a ZX Next program? The simulator (currently) does not support Z80N instructions or ZX Next registers.

kborowinski commented 4 years ago

Nope it's not. I've made sure to run regular Z80 version.

maziac commented 4 years ago

Can you share the code (or part of it) with me?

kborowinski commented 4 years ago

Try to debug following code using "zxsim":

;SjASMPlus

    ORG $8000
    di
    ld (restoreStack+1),sp
    ld sp,$7fff
    ei
    xor a
1   ld hl,$4000
    ld de,$4001
    ld bc,$1800
    ld (hl),a
    ldir
    ld bc,$2ff
    ld (hl),$38
    ldir
    dec a
    jr nz,1B
    di
restoreStack:
    ld sp,0
    ei
    ret
maziac commented 4 years ago

OK. Although it is a little slow this works fine for me. What is the problem? zxsim

kborowinski commented 4 years ago

That's strange. It does not work on mine computer. There you have full assembly listing. Maybe it has something to do with SNA snapshot? When I change DEVICE type to ZXPSECTRUM48 it does not work at all.

;SjASMPlus

    DEVICE ZXSPECTRUM128

    ORG $8000
main:
    di
    ld (restoreStack+1),sp
    ld sp,$7fff
    ei
    xor a
1   ld hl,$4000
    ld de,$4001
    ld bc,$1800
    ld (hl),a
    ldir
    ld bc,$2ff
    ld (hl),$38
    ldir
    dec a
    jr nz,1B
    di
restoreStack:
    ld sp,0
    ei
    ret

    SAVESNA "../../emulators/unreal/qsave1.sna", main

DEVICE ZXSPECTRUM128:

dezog_zxsim_1

DEVICE ZXSPECTRUM48:

dezog_zxsim_2

maziac commented 4 years ago

Thanks to your full listing I could reproduce the problem and fix it here: https://github.com/maziac/DeZog/releases/tag/0.12.3

The problem was that the IM register was not taken from the SNA file but set to 2 always. The interrupt kicked in during LDIR and was going nowhere.

maziac commented 4 years ago

Could you please verify that it is working for you, so I can close this issue.

kborowinski commented 4 years ago

Yes, it's working now. Thanks!