Welcome! Log In Create A New Profile

Advanced

Wifi Debugging

Posted by cdmac 
Wifi Debugging
March 23, 2009 09:22PM
Hi all,

I'm not sure if this functionality is available yet (I wrote it before Christmas), but I've modified libogc to support debugging using gdb over a wifi connection. Here's a link to the patch which has been submitted to the sourceforge page. SourceForge.net patch. I can't seem to attach files to posts in these forums, so I can't give precompiled versions at this time.

To use:

DEBUG_Init(GDBSTUB_DEVICE_WIFI, 8000); // Port 8000 (use whatever you want)
_break();


The call to DEBUG_Init() will block until gdb on the host connects. If you can view printf()s, then the Wii will display its IP address for reference, and let you know if it worked. _break() can be placed wherever you want to hit the initial breakpoint.

I've been using it with the Insight GUI and it works great, except for the old-skool GUI! Hope you find this useful!

Thanks,
cdmac
Re: Wifi Debugging
March 23, 2009 10:48PM
Come over here and kiss me.
Re: Wifi Debugging
March 24, 2009 01:00PM
I could have sworn that someone did this before.
Re: Wifi Debugging
March 24, 2009 01:46PM
I couldn't believe that nobody had done it yet, but I spent some time searching for an existing solution. I read in forums how people were just using printf()s to debug, and using gcc tools to find out where crashes occurred.

The first thing I did was to write a remote TTY system, so you can view trace messages on a PC app instead of on the TV. Then I still yearned for a debugger so I started poking around inside libdb. I'm sure my modifications could use some improvement, but it works. libogc really needs some documentation, and at least a few comments in the code!

Thanks,
cdmac
Re: Wifi Debugging
March 24, 2009 07:00PM
I remember asking on #wiidev if someone had done this and I think someone said that someone else had, but I'm not sure if they ever got it to a release worthy state. Thanks for putting this out there, this is awesome.
Re: Wifi Debugging
April 01, 2009 12:08AM
Hi, first of all Thanks for doing this!!!

I have aplied the patch to the libogc on windows, after some modifications to the code, i compiled it.

Well, I have the libogc with the wifi gdb support, but when I put the "DEBUG_Init(GDBSTUB_DEVICE_WIFI, 8000);" line on my code and compile it I get a linker error:

Quote

> "make"
linking ... template.elf
template.o: In function `main':
e:/template/source/template.c:48: undefined reference to `DEBUG_Init'
collect2: ld returned 1 exit status
make[1]: *** [/e/template/template.elf] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:01

I have tried a lot of things but I can't get it working :S, I'll be grateful if you can help me :D

In the other hand, when I get it working how I connect the Wii to the gdb on the pc? and I will be able to send "printf" messages to the gdb?

Thanks in advance,

TiRaNog.



Edited 1 time(s). Last edit at 04/01/2009 02:13AM by TiRaNog.
Re: Wifi Debugging
April 01, 2009 12:47AM
Hey TiRaNog,
Undefined reference to DEBUG_Init means that the linker cannot find the code to link DEBUG_Init to your program. Try adding -ldb to the extra libraries portion of your makefile right before -logc.

As far as debugging your program:

Open gdb by running "powerpc-gekko-gdb yourprog.elf." When your program is running on the wii make your first gdb command "target remote your wii's ip:8000"

Your program will now break where you wrote _BREAK(); at in your code. From there use regular gdb commands to debug your code. As far as printf goes, printf writes to stdout and that should automatically show up on the gdb console but I don't see any of my printf statements showing up. I'll have to research that later...



Edited 1 time(s). Last edit at 04/01/2009 12:48AM by MrPeanut.
Re: Wifi Debugging
April 01, 2009 02:13AM
Quote
MrPeanut
Hey TiRaNog,
Undefined reference to DEBUG_Init means that the linker cannot find the code to link DEBUG_Init to your program. Try adding -ldb to the extra libraries portion of your makefile right before -logc.

As far as debugging your program:

Open gdb by running "powerpc-gekko-gdb yourprog.elf." When your program is running on the wii make your first gdb command "target remote your wii's ip:8000"

Your program will now break where you wrote _BREAK(); at in your code. From there use regular gdb commands to debug your code. As far as printf goes, printf writes to stdout and that should automatically show up on the gdb console but I don't see any of my printf statements showing up. I'll have to research that later...

Hi, many thanks MrPeanut ^.^ I have it working right now, but i can't see the "printfs" too.

My problem is that i'm using GRRLIB and it sems incompatible with the libogc text console (when I init it and then the GRRLIB it crashes), and the GRRLIB printf function is very crappy (I can't use the tipical "\n" or other commands and I'm not able to make a functional font with any converter), so I need some way to print debugging stuff.

By the way I'll test the gdb commands and make some testing code.

Another time, Thanks,

TiRaNog.
Re: Wifi Debugging
April 01, 2009 10:54AM
Hi TiRaNog,

I've written a windows tool to display trace messages from the Wii. It connects in the same way as with the debug patch. I'm currently working on integrating a GUI GDB frontend into the tool, but I can provide a standalone version for now if you'd like.

I also meant to look into using GDB to pass trace messages which would simplify things by only requiring one socket connection. I'll let you know how I get on with this.

By the way, I'm pretty sure I saw that someone else had written remote trace messages for the Wii in these forums. I haven't tried it as I'd already written my own by the time I saw the post.

Thanks,
cdmac
Re: Wifi Debugging
April 01, 2009 04:25PM
Hi cdmac,

I'll really be greateful if you provide me the stand alone version of your tool :D

I'm now making some test with the gdb and the insight GUI but I only get comunication errors and the program freezes.

Thanks,

TiRaNog.
Re: Wifi Debugging
April 02, 2009 02:20PM
Hi TiRaNog,

Could you send me a private message with your email address and I'll send the program to you. Anyone else who wants it can do the same.

Thanks,
cdmac
Re: Wifi Debugging
October 04, 2009 10:09PM
WHY DID THIS DIE OFF
It sounds awesome and needs to be in trunk, along with the tty implementation!
Re: Wifi Debugging
October 12, 2009 07:02PM
Quote
shuffle2
WHY DID THIS DIE OFF
It sounds awesome and needs to be in trunk, along with the tty implementation!

I thought sounded like a good idea too.
Re: Wifi Debugging
November 02, 2009 05:42PM
Quote
scanff
Quote
shuffle2
WHY DID THIS DIE OFF
It sounds awesome and needs to be in trunk, along with the tty implementation!

I thought sounded like a good idea too.

It is a great idea
Sorry, only registered users may post in this forum.

Click here to login