Debugging homebrew in 2020

All your homebrew software needs & discussion
Post Reply
User avatar
capzlk
Posts: 79
Joined: Tue Sep 15, 2015 9:18 pm

Debugging homebrew in 2020

Post by capzlk » Tue Feb 25, 2020 8:37 am

I've been doing some development for my little cube again lately, but i'm running more and more into the fact that i need to do debugging to be able to progress.
In my PSO AR code making days back in ~2005 i used to use GCNRD over the BBA and was able to step through code with it. Now i've noticed swiss has WiiRD support. Does this work in a similar fashion? I couldn't find much info on how to use it with the gamecube. I've also seen some mentions of using gdb but somehow information is sparse.

What kind of set up are people using to debug homebrew these days? Surely there are more efficient ways to achieve this these days? USBGecko probably but those aren't for sale anymore, so where should new development start?
User avatar
emu_kidid
Site Admin
Posts: 4927
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Debugging homebrew in 2020

Post by emu_kidid » Tue Feb 25, 2020 9:24 pm

When I need that kind of debugging I use a USB Gecko and gdb (load the elf to have symbols obviously). There's a stub for the BBA too I believe but I've never used that myself. It works fine albeit slowly and there's no support for memory breakpoints afaik. It's pretty crude and IDE integration would be much nicer instead (I'm sure there's generic platform agnostic IDE's with gdb support out there).

Mostly these days I just run my elf through gdb and assess stack traces with it.
Image
Homebruv
Posts: 3
Joined: Tue Feb 08, 2022 12:48 pm

Re: Debugging homebrew in 2020

Post by Homebruv » Sat Feb 12, 2022 2:08 pm

Not sure if this thread is dead, but I use the stub in combination with the BBA on my GC. I never got a USB Gecko (I doubt there're still for sale), so I don't have much choice.
The official release of GDB stops supporting the GC stub after GDB 7.7.1, but I found a fix so I'm currently using GDB 11.2. It works well enough for homebrew debugging I think.
shazz
Posts: 1
Joined: Thu Mar 31, 2022 3:27 pm

Re: Debugging homebrew in 2020

Post by shazz » Thu Mar 31, 2022 3:34 pm

If I can wake up this thread, how does it work? Is there a network bootloader available for the GC to transfer/execute/debug code remotely (similar to Ps2link) ?

Thanks !
Homebruv
Posts: 3
Joined: Tue Feb 08, 2022 12:48 pm

Re: Debugging homebrew in 2020

Post by Homebruv » Sun Jun 05, 2022 7:12 pm

I'm not familiar with Ps2link, so I can't say anything about that. So there's a couple things you need: First, you need a GC with a BBA hooked up to a router (check the IP address that is assigned to the GC and see if you can ping it from your laptop/pc). Now, if you have the code examples for the GC, there's one example called 'gdbstub'. This example shows you how to use the debug library that comes with the gamecube C libraries. The way it works is basically:
1) The debug init function needs to be called somewhere at the beginning of your program (but preferably after the system init of the GC itself)
2) Now you can add 'breakpoints' in your program by adding '_break()', which is basically a blocking call to the debug library.
3) When your program hits the first breakpoint, you can call GDB (on your pc terminal) and connect remotely to the IP address of the BBA. I would recommend building GDB
from source with flags for PPC so it can read debuggable compiled code.
4) After a successful connection, you can step through the program remotely using GDB on your PC.

A couple considerations though: if you choose to debug over the BBA, you can't use the networking capabilities for anything else. Also, since you're debugging remotely, you can't read variables directly like you can in modern debuggers. Lastly, restarting a program is also not possible AFAIK.

So all in all it's pretty limited in what you can do, so unless you need to directly interface with hardware I would recommend debugging on the emulator first. Hope this helps!
User avatar
capzlk
Posts: 79
Joined: Tue Sep 15, 2015 9:18 pm

Re: Debugging homebrew in 2020

Post by capzlk » Wed Mar 27, 2024 2:22 pm

sorry for not getting back earlier. my time with gamecube dev is very inconsistent. I've noticed webhdx sometimes seems to make usb-c shuriken hardware in small batches and have asked him if/when another batch will show up. I'll also try the bba method but since i am trying to develop some DNS and internet connectivity features, i'm doubtful that these two things can be combined.

nevertheless, i'll give it a go! will report back when i can :)
thanks for the info so far
Post Reply