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
320 stars 40 forks source link
amiga cpp debugger fs-uae gcc gdb vscode vscode-extension winuae

Binutils, GDB, and GCC elf2hunk

amiga-debug Visual Studio Code Extension

One-stop Visual Studio Code Extention to compile, debug and profile Amiga C/C++ programs compiled by the bundled gcc 13.2 with the bundled WinUAE/FS-UAE and GDB.

Overview

This fully self-contained extension will help you to quickly develop demos, intros, games, etc. for the Amiga 500, 1200, 4000. It supports C and C++, however no standard library is available. It comes with advanced productivity features like debug overlay, frame profiler, graphics debugger and size profiler.

Debugger Frame Profiler Size Profiler Graphics Debugger

Video

Here's a video showing off all the new features of v1.1, including the frame profiler and graphics debugger: https://www.youtube.com/watch?v=gQ4tKisnr7Y

Quick-start

  1. Install the extension from the Visual Studio Code Marketplace
  2. (recommended) install the Microsoft C/C++ extension from the Extensions tab under Recommended
  3. Create a new empty project folder with File > Open Folder...
  4. From the command palette Ctrl+Shift+P select Amiga: Init Project
  5. (optional, but recommended)
    • either: open settings Ctrl+, and under Extensions > Amiga C/C++ Compile, Debug & Profile point Rom-paths: A500 to your Kickstart 1.3 ROM
    • or: open .vscode/launch.json and point "kickstart" to your Kickstart 1.3 ROM
  6. Hit F5 to build and run a minimal sample project
  7. If you prefer C++ instead of C, just rename main.c to main.cpp

Features

How-to-use

Supported Amiga Models

Credits

Already used in these productions

Acknowledgements

This extension contains binaries of:

Caveats

Contributing

For development, just install the latest node.js LTS, create a new directory, clone the repository git clone https://github.com/BartmanAbyss/vscode-amiga-debug.git, then install the dependencies with npm install. To build, open the directory in VS Code and hit F5. You can then test the extension without building a .vsix. To build a .vsix, npm install -g vsce (once), and then vsce package. For better testing, install the Mocha Test Explorer extension. The tests should then show up in your Testing tab.

Development (Windows)

Here are the command-lines used to compile the external tools (We're building with MinGW on WSL on Windows 10/11 to c:\amiga-mingw\opt). Replace the 16 in make -j16 with your number of CPU cores

Ubuntu 22.4 LTS from Microsoft Store

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
wsl --install -d ubuntu

MinGW on WSL2 (Ubuntu 22.04)

sudo apt install build-essential flex bison expect dejagnu texinfo mingw-w64
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
# statically link pthread (for GDB) - see https://stackoverflow.com/a/72903594
sudo mv /usr/x86_64-w64-mingw32/lib/libwinpthread.dll.a /usr/x86_64-w64-mingw32/lib/libwinpthread.dll.a.bak
sudo mv /usr/x86_64-w64-mingw32/lib/libpthread.dll.a /usr/x86_64-w64-mingw32/lib/libpthread.dll.a.bak

Binutils+GDB

git clone https://github.com/BartmanAbyss/binutils-gdb.git
cd binutils-gdb
bash ./contrib/download_prerequisites
cd ..
mkdir build-binutils-gdb
cd build-binutils-gdb
LDFLAGS="-static -static-libgcc -static-libstdc++" ../binutils-gdb/configure --prefix=/mnt/c/amiga-mingw/opt --target=m68k-amiga-elf --disable-werror -enable-static --disable-shared --disable-interprocess-agent --disable-libcc --host=x86_64-w64-mingw32
make -j16
make install

GCC

wget https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.xz
tar -xf gcc-13.2.0.tar.xz
cd gcc-13.2.0
patch -p1 < ../gcc-barto.patch
bash ./contrib/download_prerequisites
cd ..
mkdir -p build-gcc-13.2.0
cd build-gcc-13.2.0
LDFLAGS="-static -static-libgcc -static-libstdc++" ../gcc-13.2.0/configure \
  --disable-clocale \
  --disable-gcov \
  --disable-libada \
  --disable-libgomp \
  --disable-libsanitizer \
  --disable-libssp \
  --disable-libvtv \
  --disable-multilib \
  --disable-threads \
  --disable-nls \
  --enable-languages=c,c++ \
  --enable-lto \
  --enable-static \
  --prefix=/mnt/c/amiga-mingw/opt \
  --target=m68k-amiga-elf \
  --with-cpu=68000 \
  --host=x86_64-w64-mingw32
make all-gcc -j16
# at this point, you're getting an error about not finding gcc-cross. This is okay.
sed 's/selftest # srcextra/# selftest srcextra/' gcc/Makefile >gcc/Makefile.tmp
mv gcc/Makefile.tmp gcc/Makefile
gcc/gcc-cross.exe -dumpspecs >gcc/specs
# continue the build
make all-gcc -j16
make install-gcc

elf2hunk

https://github.com/BartmanAbyss/elf2hunk

Cleaning up unnecessary files and stripping EXE files of debug information to reduce size

rm -r /mnt/c/amiga-mingw/opt/include
rm -r /mnt/c/amiga-mingw/opt/share
find /mnt/c/amiga-mingw/opt -name *.exe | xargs strip

Development (Linux/MacOS)

Internal Development

Debugging

preact-devtools

git clone https://github.com/preactjs/preact-devtools.git
npm install
npm run build:inline
<copy dist/inline/* to preact-devtools>

Updating node_modules

npm install -g npm-check
npm-check -u

WinUAE builds with Visual Studio 2022.

Create new GCC patch

diff -ruN gcc-13.2.0 gcc-13.2.0-barto > gcc-barto.patch

Known Issues/TODOs

Documentation

Profiler

Savestate Debugger

Assembly

Objdump

WinUAE

Debugger

Kickstart

Gfx Debugger