Qt Creator Dreamcast Development Environment: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 52: Line 52:
If everything is correct, you should see the following entries populated automatically:
If everything is correct, you should see the following entries populated automatically:
* '''Type''': GDB
* '''Type''': GDB
* ```ABIs```: sh-baremetal-generic-elf-32bit
* '''ABIs''': sh-baremetal-generic-elf-32bit
* ```Version```: The correct version number corresponding to the toolchain you chose
* '''Version''': The correct version number corresponding to the toolchain you chose

Revision as of 19:06, 25 May 2023

This is a guide to set up the Qt Creator IDE for source-level debugging on the Sega Dreamcast using the KallistiOS development environment and the GDB debugger. Choosing Qt Creator as your IDE has several strengths, such as being massively cross-platform, supporting a multitude of devices and toolchains (Windows, Mac, Linux, iOS, Android, WebAssembly, etc), and being extremely easy to add additional toolchains to.

However, the downside is that as of the writing of this tutorial (Qt Creator version 10.0.1), there are a few places where we are forced to do things that are slightly less than ideal or a bit hacky to maneuver around limitations in the configurability of the IDE. In my personal opinion, these are not actually a big deal, and your resulting environment is almost as easy to use as debugging locally; however, there are tutorials for other IDEs which can arguably have even better integration.

Prerequisites

To start with, this tutorial makes the following assumptions:

  1. You have already installed and set up your KallistiOS development environment.
  2. You have already downloaded and installed Qt Creator (version 10.0.1 was used for this tutorial).

Setting up GDB

Before we can begin configuring Qt Creator, we must install GDB, which is not installed by default with the KOS toolchain build scripts.

Building GDB

The first thing we need to do is additionally set up and install the GDB debugger for the Dreamcast's GCC SH toolchain. Open a bash shell or whatever terminal you use to compile KOS code with and navigate back to the `dc-chain` folder within KOS, which was previously used to install the toolchains:

cd /opt/toolchains/dc/kos/utils/dc-chain

Once there, check to see whether you have a `config.mk` file which was used to build your toolchain previously. If you do, you can proceed to the next step. If you don't, you need to copy one of the three sample configuration files as your new `config.mk` file, depending on which version of the toolchain you had set up previously. If you aren't sure, you can run `sh-gcc-elf --version` and check which version of the compiler you had chosen. Next run one of the following commands:

  • GCC 4.7.4:
cp config.mk.legacy.sample config.mk
  • GCC 9.3.0:
cp config.mk.stable.sample config.mk
  • GCC 13.1.0:
cp config.mk.testing.sample config.mk

Finally, we're ready to actually download and install it. You can do so by running the following command:

make gdb

You should see a bunch of scrolling text as the make scripts download, extract, and begin building GDB.

Verifying GDB

After awhile, GDB should be built and installed into your DC toolchain. You can verify this by checking to see whether you have the executable. It is located at:

/opt/toolchains/dc/sh-elf/bin/sh-elf-gdb 

Alternatively, if you're currently within a DC environment, simply checking to see if you can run:

sh-elf-gdb

If everything goes well, it should start up and leave you at a command prompt.

Verifying GDB Python Support

Note that Qt Creator requires that GDB be built with support for Python scripting extensions. This should be automatically detected and handled by the Makefiles which are checking to see whether Python is installed or not based on your path. You can verify that it was properly built with Python support by running the following command:

gdb --batch -ex 'python import sys; print(sys.version)'

Setting up Qt Creator

Now that we have GDB downloaded and installed, it's time to tell Qt Creator how to use our shiny new Dreamcast toolchain.

Setting up the Kit

First, select the "Preferences" option from the "Edit" file menu. A dialog window should open. Select first entry, "Kits" from the top of the navigator pane on the left.

Next select the right-most "Debuggers" tab from the main view. Depending upon what you installed with Qt Creator, you may or may not see some automatically detected debuggers that it has preconfigured for you.

Next click "Add" to add a new Debugger entry. Then fill out the following fields:

  • Name: Dreamcast GDB
  • Path: Browse to where your sh-elf-gdb binary wound up being installed. This is /opt/toolchains/dc/sh-elf/bin/sh-elf-gdb by default.

If everything is correct, you should see the following entries populated automatically:

  • Type: GDB
  • ABIs: sh-baremetal-generic-elf-32bit
  • Version: The correct version number corresponding to the toolchain you chose