maziac / DeZog

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

c.lis file never being used, always auto disasm.asm #17

Closed mnunesvsc closed 4 years ago

mnunesvsc commented 4 years ago

Anytime i try to debug a code, compiled on z88dk, and running, the disassemble not use the c.lis generated, some early versions it worked, but not anymore

image

follows my launch options, early versions, if i change asm: option

it worked, and no change in files or sources do the slight difference.

i put the complete launch, but the one with the issue is;

DeZog raiz

{ // Verwendet IntelliSense zum Ermitteln möglicher Attribute. // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [

    {
        "type": "dezog",
        "request": "launch",
        "name": "DeZog raiz",
        "remoteType": "zrcp",
        "zrcp": {
            "hostname": "localhost",
            "port": 12000
        },
        "zsim": {
            "machine": "48k"
        },
        "serial": {
            "baudrate": 230400,
            "port": "/dev/tty.usbserial"
        },
        // "topOfStack": "stack_top",
        "listFiles": [
            {
                "sources": "efd.c.lis",
                "useFiles": true,
                "asm": "z88dk",
                "srcDirs": [],
                "path": "efd.c.lis",
            }
        ],
        "disassemblerArgs": {
            "esxdosRst": true
        },
        "load": "efd.tap",
        "skipInterrupt": true
    },

    {
        "type": "dezog",
        "request": "launch",
        "name": "Speccy Tron",
        "remoteType": "zrcp",
        "zrcp": {
            "hostname": "localhost",
            "port": 12000
        },            
        "listFiles": [
            {
                "path": "speccytron.c.lis",
                "sources": "speccytron.c.lis",
                "useFiles": true,
                "asm": "z88dk",
                "mainFile": "speccytron.c",
                "srcDirs": [],
                "addOffset": 32768
            }
        ],
        "startAutomatically": false,
        "skipInterrupt": true,
        "commandsAfterLaunch": [
            //"-sprites",
            //"-patterns"
        ],
        "disassemblerArgs": {
            "esxdosRst": true
        },
        "rootFolder": "${workspaceFolder}",
        "load": "speccytron5.tap",
        // "load": "4.Z80",
        "smallValuesMaximum": 512,
        "tmpDir": ".tmp"
   },
   {
    "type": "dezog",
    "request": "launch",
    "name": "efd",
    "remoteType": "zrcp",
    "zrcp": {
        "hostname": "localhost",
        "port": 12000
    },            
    "listFiles": [
        {
            "path": "efd.c.lis",
            // "sources": "efd.c",
            "useFiles": true,
            "asm": "z80asm",
            // "listfiles": "efd.c.lis, dbalib.c.lis",
            "mainFile": "efd.c.lis",
            // "srcDirs": [],
            "addOffset": 25124
        }
    ],
    "startAutomatically": false,
    "skipInterrupt": true,
    "commandsAfterLaunch": [
        //"-sprites",
        //"-patterns"
    ],
    "disassemblerArgs": {
        "esxdosRst": true
    },
    "rootFolder": "${workspaceFolder}",
    "load": "efd.tap",
    "smallValuesMaximum": 512,
    "tmpDir": ".tmp"
}
]

}

maziac commented 4 years ago

Could you attach your project here, so I can reproduce.

maziac commented 4 years ago

I looked at your launch.json. Maybe that helps already.

"sources" is not used at all anymore by DeZog. I have now seen that it is still included in the configuration snippet, so I will remove it there.

In the raiz configuration you didn't put in any "mainFile". I guess this is the reason why you cannot do source-level debugging.

In the Speccy Trom configuration I have seen that you put in "mainFile": "speccytron.c" This is a c-file I guess. So I don't think that it can work. DeZog expect asm sources here. If it really works please let me know, this was unintended (but would be really great).

mnunesvsc commented 4 years ago

Wow, thanks for the answers, i did was told, but not loading, but i got a different error, please not pay attention to the others launch options, "Raiz" is the only used

image

mnunesvsc commented 4 years ago

sorry the picture not go complete

image

maziac commented 4 years ago

If that didn't help then please provide me with the project or some minimal test program. (I did test my z88dk test project and that was working).

mnunesvsc commented 4 years ago

Luckyly speccy is small :) if in need of anything more tell me

speccytron.zip

mnunesvsc commented 4 years ago

by the way this is reporting too, this error, some parameter on start

image

maziac commented 4 years ago

Hi, I got it working somehow: Bildschirmfoto 2020-04-05 um 18 28 39

You need to change your listFiles section such:

"listFiles": [
                {
                    "path": "efd.c.lis",
                    "useFiles": false,
                    "asm": "z88dk",
                    //"mainFile": "efd.c.lis",
                    "addOffset": 25124,
                    "srcDirs": []                }
            ],

Explanation: You don't have asm source files only an assembler list file therefore you have to choose "useFiles": false. This means: your list file only, no assembler source files. Furthermore remove "mainFile". This is normally the main assembler source file. You have none so nothing should be specified here. Then: It is working, i.e. it uses your list file and shows it, i.e. you can step. But the lines do not match what you see in the "Disassembly" view. This probably means that your offset ("addOffset") is wrong. Maybe you need to experiment with other values here. Or maybe the tap file didn't exactly match the included list file.

You are currently using a tap file as output. That is fine. But it requires zesarux to go through the ZX ROM and "load" the file. If you have the chance to use the SNA or NEX file format this would not be required, i.e. the loading works more smooth.

Further note: I didn't see the "Illegal operation" or ZEsarUX errors. But I'm working on macOS. If it persists for you please report.

maziac commented 4 years ago

Aah, I forgot: It's normal that you start with a disassembly at 0000h. This is because of that tap loading. You would need to put a breakpoint somewhere in your list file and run from 0000h.

mnunesvsc commented 4 years ago

Did the instructions, and if on debbug i do an step, it goes to the file, but as long i hit go and pause he got back to disasm, i generated the .sna and changed the launch, sending again

image

image

speccytron.zip

mnunesvsc commented 4 years ago

I have success in setting a breakpoint in file and the debbug stoped right, but if i dig into, he cannot find the lib ( dbalib.c.lis ) and show me a fuzzy code ( not the one in .c.lis ) and return.

pointg that because it is the routine i need to know why is not workig :)

sorry for the trouble.

image

image

the code is the same, of the previously comment.

mnunesvsc commented 4 years ago

more info, if i change the asm from;

z80asm

to

z88dk

it cannot set the breakpoints, nor show the main c.lis file, only works for me with z80asm, and it is the only option in sugestion.

image

image

hope this could help

maziac commented 4 years ago

The z80asm option is for Savannah's z80asm. For z88dk use "z88dk". Unfortunately z88dk used the same name for its assembler.

I think I need some more time to sort this out. It has something to do with the "addOffset". Do you know what the ORG for your source code is, e.g. where the _loadlevel is supposed to be?

The list files of z88dk are not very easy to read as all sections start at 0000h although they are located at some real addresses.

mnunesvsc commented 4 years ago

Thankyou for the help, unfortunally i do not possess the knowledge of the inards of the z88dk, but the only thing out of the code, c.lis is the pragma i used hope this help somehow

// definitions

pragma output STACKPTR = 53248 // place stack at $d000 at startup

pragma output REGISTER_SP = 0xd000 // place stack at $d000 at startup

pragma output CLIB_MALLOC_HEAP_SIZE = 3000 // create a 3000-byte heap in BSS section

pragma output CLIB_EXIT_STACK_SIZE = 0 // no atexit() functions

pragma output CLIB_STDIO_HEAP_SIZE = 0 // no memory for files

pragma output CLIB_FOPEN_MAX = -1 // do not create open files list

// COMPILE TIME CRT CONFIGURATION

pragma output CRT_ORG_CODE = 25124 // org of compile

// #pragma output CRT_ORG_CODE = 32768 // org 32768

pragma output CRT_ENABLE_CLOSE = 0 // don't bother closing files on exit

pragma output CRT_ENABLE_EIDI = 0x1 // disable interrupts at start

// #pragma output CRT_ON_EXIT = 0x30002 // return to basic on exit

pragma output CLIB_MALLOC_HEAP_SIZE = 0 // no malloc heap

pragma output CLIB_STDIO_HEAP_SIZE = 0 // no stdio heap (no files)

pragma output CLIB_FOPEN_MAX = -1 // no FILE* list

pragma output CLIB_OPEN_MAX = -1 // no fd table

// CREATE A BLOCK MEMORY ALLOCATOR WITH ONE QUEUE // #pragma output CLIB_BALLOC_TABLE_SIZE = 1

mnunesvsc commented 4 years ago

And the command line i use to compile the code, if i can be of any more help.

set PATH=C:\z88dk\bin;%PATH% set ZCCCFG=C:\z88dk\lib\config set TEMP=.temp set TMP=.temp

rem compile all
zcc +zx -vn --opt-code-speed -SO3 -clib=sdcc_iy -startup=31 --max-allocs-per-node2000 @efd.lst -m --list --c-code-in-asm -oefd -create-app -Cz"--sna"

maziac commented 4 years ago

What seems to work is the address offset 30520

            "listFiles": [
                {
                    "path": "efd.c.lis",
                    "useFiles": false,
                    "asm": "z88dk",
                    // "mainFile": "efd.c.lis",
                    "addOffset": 30520, //25281,
                    "srcDirs": []
                }

I have taken it from the lis and map file. The code section in the lis file starts with _loadlevel. The lis file includes only relative addresses so it starts with address 0000. The map file shows that this maps to $7738 which is 30520.

Start the debug session, you land in some disassembled code. Set a breakpoint at '_main' in your lis file. Do a 'run'. You will end up here in the lis file: Bildschirmfoto 2020-04-06 um 09 36 23

Although this seems to work for the code section there is a problem with the other labels. I.e. the data labels like _off_screen also start at relative address 0000. The offset is added to them as well. This results in _off_screen == _loadlevel which is not true if you look at the map file. I.e. you can't rely on the label resolution for your data.

I will need to think a bit if I can work around this (otherwise I need to drop official support for z88dk).

maziac commented 4 years ago

I have created a new release v1.1.1, please get it here: https://github.com/maziac/DeZog/releases/tag/v1.1.1

Please download and install via the vscode command palette (Press F1) and choose "Extensions: install from VSIX...".

The addresses now seem to work correctly but you need to add a new parameter. Use this:


            "listFiles": [
                {
                    "path": "efd.c.lis",
                    "asm": "z88dk",
                    "srcDirs": [],
                    "z88dkMapFile": "efd.map"
                }
            ],

I.e. the map file is added here. It allows to associate the labels with the line numbers in the lis file. The "addOffset" is gone. Don't use it together with "z88dkMapFile". It will not work.

As before: Start the debug session, you land in some disassembled code. Set a breakpoint at '_main' in your lis file. Do a 'run'.

Now you should be in your lis file instead of the disasm.asm.

mnunesvsc commented 4 years ago

Testing the release, if i use z88dk this happen.

image

if i use z80asm the c.lis is not loaded, even if i set a breakpoint.

image

P.S. Again the warning for the parameter; cpu-history ignorephalt yes => Error. Unknow parameter

speccytron.zip

maziac commented 4 years ago

As said, you need to remove "addOffset" completely. Please try again.

And: You don't need to tinker around with "z80asm". It is a different assembler.

mnunesvsc commented 4 years ago

does not even start, works only with z80asm, appear to be some file in fault, wanna see my machine with skype ?

mine´s : mnunesvsc

image

maziac commented 4 years ago

I don't think that Skype will help. I need to debug the problem. Could you once again zip your project.

mnunesvsc commented 4 years ago

I don't think that Skype will help. I need to debug the problem. Could you once again zip your project.

i did, on a post before, it is on a zip, + map, and lis

maziac commented 4 years ago

I could reproduce it now. You are missing the "srcDirs": [] from my post.

Please use exactly this "listFiles" properties. No additions, no left outs:

            "listFiles": [
                {
                    "path": "efd.c.lis",
                    "asm": "z88dk",
                    "srcDirs": [],
                    "z88dkMapFile": "efd.map"
                }
            ],
mnunesvsc commented 4 years ago

nope..

image

directly to disasm, do not even open the .clis file

image

mnunesvsc commented 4 years ago

can be any relation with that rootdir ? what appear to be is that he can not find the file

image

maziac commented 4 years ago

I prepared a new release https://github.com/maziac/DeZog/releases/tag/v1.1.2-pre1 to make sure that we are working with exactly the same version.

If that does not help then please send me your zipped project once again. There must be something different. Your old project is working fine for me now.

mnunesvsc commented 4 years ago

not work same behavior

image

speccytron.zip

maziac commented 4 years ago

The zip is missing the .vscode folder, i.e. the launch.json.

mnunesvsc commented 4 years ago

My bad, here goes

speccytron.zip

maziac commented 4 years ago

I could change it so that it works. Again: Don't use "z80asm". This property is used for Savannah's assembler listing syntax. It has nothing in common with z88dk-z80asm besides the name. For z88dk-z80asm use "z88dk".

That was in fact the only line that I changed. Here is an animated gif and I attached the changed project below.

speccytron

speccytron.zip

mnunesvsc commented 4 years ago

This is what happens to me

image

maziac commented 4 years ago

Interesting issue. I have now run into a similar problem: sometimes, when I set an breakpoint it is not set, i.e. it is "unverified". That means the Z80-address to file-line association has gone wrong. Have you really used the speccytron.zip that I attached. Especially rootFolder should be "${workspaceFolder}"?

I have prepared a new version 1.1.2-pre2 here which has additional debug output: https://github.com/maziac/DeZog/releases/tag/v1.1.2-pre2

Could you please install it, make sure all files are saved and start a debug session. Then at line 1498 (push ix) Bildschirmfoto 2020-04-08 um 08 26 48 set a breakpoint and make a screenshot of the DEBUG CONSOLE. You should get something similar to this: Bildschirmfoto 2020-04-08 um 08 28 38

mnunesvsc commented 4 years ago

The initial operation worked as predicted, BUT....

image

image

as the images shows no output on the screen, on the output tab

and as i pause, on the interface, they return to the disasm.asm

image

if i restart the code, and all the "stage" is maintened, the step over works on c.lis, but as i hit the continue and go back , returns on disasm, it is after the communication with the zesaur ( i thougth so )

image

hope this help

speccytron.zip

maziac commented 4 years ago

Actually this looks good.

- "as the images shows no output on the screen, on the output tab": This is because you are on the OUTPUT tab. Please change to the DEBUG CONSOLE to see the output I meant (the output when setting a breakpoint). But as I can see the breakpoints are verified now. I.e. working correctly. So the output would not help here. But please, as soon as you run into this problem again (a breakpoint cannot be set in your lis file) then check the DEBUG CONSOLE and send me a screenshot. I suspect that sometimes something is going wrong there.

- "and as i pause, on the interface, they return to the disasm.asm": This is correct behavior. It is simply because there is no source code provided for that memory area. In that case the internal disassembler jumps in and shows the disasm.asm code. Have a look at your efd.c.lis file and search e.g. for "_drawSpriteM". It is used by some calls but not defined in end.c.lis. Thus DeZog does not know about it. Luckily you can tell DeZog to use several list files like so:


            "listFiles": [
                {
                    "path": "efd.c.lis",
                    "asm": "z88dk",
                    "srcDirs": [],
                    "z88dkMapFile": "efd.map"
                },
                {
                    "path": "dbalib.c.lis",
                    "asm": "z88dk",
                    "srcDirs": [],
                    "z88dkMapFile": "efd.map"
                }
            ],

"_drawSpriteM" is included in "dbalib.c.lis" and now DeZog can find it. If you now do a break you probably land in known source code. Bildschirmfoto 2020-04-09 um 08 24 28 If you have more lis files you should add them probably as well.

mnunesvsc commented 4 years ago

WORKED like a charm, sorry for all the trouble

goes inside the other lib, AWESOME

image

image

thank you for the hard work and the excellent tool.

anything i can be of help, drop me a mail mnunesvsc@protonmail.com

maziac commented 4 years ago

That's nice to hear. And thanks for your support as well. This made the z88dk support a bit better.

And thanks for the offer. Any testing is always appreciated.

mnunesvsc commented 4 years ago

Thanks for the fast responses, and hard working, closing the issue

Blackbelt61 commented 4 years ago

Hi, I have followed this interesting and useful thread because I am trying to use DeZog with z88dk.

With the hints and explanations in this thread I have been able to prepare an environment for compiling and debugging my z88dk projects, but there is still a problem that I am not able to solve: even if I am including the .map and .lis files in my launch.json, I can see the code listing while I am debugging, but all the breakpoints are always unverified.

Here is the error I get in the Debug console:

Unverified breakpoint:{"verified":false,"line":996,"column":0,"source":{"name":"TestLists2.c.lis","path":"n:\DGT_LIB\Examples\TestLists2\Sources\TestLists2.c.lis","sourceReference":0}}

and attached you can find my project (the folder that has to be opened with VSC is "N:\DGT_LIB\Examples\TestLists2").

I am sure I am making something wrong, but I don't know what.

Thank you in advance for any help you can give here.

TestLists2.zip

maziac commented 4 years ago

Hi, I can have a look but your zip misses the .vscode folders, I think. Could you include them as well. Regards.

Blackbelt61 commented 4 years ago

Hi @maziac you are right, sorry.

Here is the .zip file again with the .vscode folder included. You can find it in N:\DGT_LIB\Examples\TestLists2

Thanks

TestLists2.zip

maziac commented 4 years ago

I tested it now but I don't think there is any problem with your setup. I was able to set breakpoints. Maybe you used the wrong file. Don't set the breakpoints in the TestLists2.lis file but e.g. in TestLists2.c.lis.

When I startup I end up here. That's some preamble code of your compiler. Bildschirmfoto 2020-05-31 um 23 37 06

Now goto TestLists2.c.lis and set a breakpoint e.g. beneath _main: Bildschirmfoto 2020-05-31 um 23 37 19 It should work.

Press start and you should break at _main.

Blackbelt61 commented 4 years ago

Well, this is exactly what I am doing. I start the debugging session and land in the compiler preamble:

Screen Shot 05-31-20 at 11 50 PM

Then I open the TestLists2.c.lis file and try to set a breakpoint, but it is always invalid:

Screen Shot 05-31-20 at 11 51 PM

TestLists2.lis file is completely different and doesn't contain the _main entrypoint, in fact I don't use it.

It is really strange that the same setup that doesn't work for me works like a charm on your computer.

I am using a portable version of VSC 1.45.0, but I don't think that it can be the problem.

maziac commented 4 years ago

Strange. The only thing I changed were the path slashes because I‘m on macos. Could you check if the paths are correct. You could also try changing all \\ to / in launch.json. I think vscode can deal with it.

Blackbelt61 commented 4 years ago

So, I have finally found a way. I have tried to change the path slashes as you suggested, but it didn't work. I have then removed some ${workspaceRoot} from tasks.json and launch.json and now my breakpoints are verified :-)

Here are the new working task.json and launch.json

vscode.zip

I don't know why I had to remove those ${workspaceRoot} to get the debugger work, but it works and that's enough for me ;-)

Thank you for your help!

Should you need mine for some test, please ask and I will be happy to help.

maziac commented 4 years ago

Good to know that it works now. As it worked for me it seems that these are different in windows and mac.

Have fun with DeZog.

Blackbelt61 commented 1 year ago

Hi @maziac ,

I have updated all the z88dk and vscode/dezog environment after some (long) time but it seems that the long gone problem with the c.lis files from z88dk has raised again.

In fact I am receiving this error

'dezogif v2.1.0' initialized. Unverified breakpoint: {"verified":false,"line":7,"column":0,"source":{"name":"Test.c","path":"d:/TEST_C/Test.c","sourceReference":0}} Additional info: Address not found for d:/TEST_C/Test.c

on a very simple C program that you can find in the attached zip file

TEST_C.zip

I am using the latest z88dk version (2.2)

Thank you in advance for any help you could give here.

maziac commented 1 year ago

The TEST_C.zip does not contain the .vscode folder. Could you please add.

Blackbelt61 commented 1 year ago

Sorry about it.

Here is the TEST_C.zip file again, with the .vscode folder.

TEST_C.zip

maziac commented 1 year ago

Can I use your code (TEST_C.zip) as a test case inside DeZog? It is just a small code snippet but can you put it under MIT license.

Blackbelt61 commented 1 year ago

Of course! You can use the TEST_C.zip for whatever you want! I am not sure I can add any MIT license on the Test.c file: it is just an "Hello World" example...