BartmanAbyss / vscode-amiga-debug

One-stop Visual Studio Code Extension to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 12.2 with the bundled WinUAE/FS-UAE.
GNU General Public License v3.0
315 stars 39 forks source link

Add ability to define filesystem when launching UAE debugging #7

Closed tehKaiN closed 4 years ago

tehKaiN commented 4 years ago

Now since my library and games are building correctly, I still need one thing to be completely happy - ability to load files. Right now I see that there is a dh0 directory in extension's directory, which I assume is used to run the executable.

Would it be possible for extension to dynamically bind executable's original directory as UAE's main DH, so that when launching executable via debug task it'd be able to find files via relative paths?

tehKaiN commented 4 years ago

I did some quick research and it seems that it's quite possible to add harddrive config via commandline param:

http://eab.abime.net/showthread.php?t=63719

Pretty please? It's probably the last thing I'll need ;)

BartmanAbyss commented 4 years ago

The problem is, that "runme.exe" is hard-coded into WinUAE to detect the launch of the program for the debugger. I'm not sure how to do this any other way. Re. Mounting other harddrives: You are free to change the configuration in WinUAE, just make sure to save it as "default", and it will be used every time the debugger is started. Does this work for you?

tehKaiN commented 4 years ago

Yeah, but I have like 3 games which I'm actively working on and having to rename executable / rebind folder each time in uae config is a bit tedious.

I'm not a node.js guy but I've managed to do a bit of changes in amigaDebug.js locally. I've added:

            const objdumpPath = path.join(binPath, "opt/bin/m68k-amiga-elf-objdump.exe");
            const dh0Path = path.join(binPath, "dh0/"); // <-- this is new
            const ssPath = path.join(dh0Path, "s/startup-sequence"); //<-- this is new

At the end of UAE config prep:

            // filesystem for launched exe
            let runmePathSplit = (args.program + ".exe").split('/');
            let runmeDir = runmePathSplit.slice(0, -1).join('\\');
            config['filesystem2'] = 'rw,dh1:dh1:' + runmeDir + ',-128';

Instead of copying to runme.exe:

            try {
                let baseName = runmePathSplit.slice(-1)[0];
                fs.writeFileSync(ssPath, 'cd dh1:\n:' + baseName);
            }
            catch (err) {
                this.sendErrorResponse(response, 103, `Failed to rewrite startup sequence at ${ssPath}. ${err.toString()}`);
                return;
            }

EDIT: I've revised code above with additional progress. There are still 2 problems:

tehKaiN commented 4 years ago

I've implemented basic cd functionality here: https://github.com/AmigaPorts/amiga-cd - it does the job for that startup sequence.

So the only piece of puzzle remaining is to pass executable name to winuae which triggers debugging. I'm not familiar with uae codebase. Do you have any idea on where to start digging to have it passed as param or via config option?

BartmanAbyss commented 4 years ago

unfortunately the WinUAE param parsing code is very complex. It took me ages... I have only implemented a new option for config['debugging_features'] = 'gdbserver'; Maybe search for these terms?

BartmanAbyss commented 4 years ago

merged. at least doesn't seem to break anything. next time, please test beforehand.

tehKaiN commented 4 years ago

I can confirm that this works like a charm. I'll clean up my local changes and start a pull request!