Problem with psp-gdb

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
BobJelly
Posts: 3
Joined: Tue Nov 20, 2007 10:50 am

Problem with psp-gdb

Post by BobJelly »

Hi everyone!

I just ported my engine code to PSP and I want to use gdb to be able to debug it. From what I understand, I have a really standard dev env. I've been able to reproduce the problem with the sprite sample from the sdk. I modified the makefile to compile it as a PRX since i've got a slim, and I added debug info (-g)... well to be able to debug :)

* I'm using cygwin under WinXP
* I obtained the latest pspdev from svn
* I built everything and got no error... except for remote joy. As mentionned in other threads, it does need linux/joystick.h but this package is not available under cygwin? I don't need remote joy so I don't really care :)
* I start usbhostfs_pc
* I start pspsh, then "debug sprite.prx"
* I then proceed to debug using GDB... Here's what I get :

Code: Select all

$ psp-gdb sprite.elf
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+&#58; GNU GPL version 3 or later <http&#58;//gnu.org/licenses/gpl.html>
This is free software&#58; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-cygwin --target=psp"...
&#40;gdb&#41; target remote&#58;10001
Remote debugging using &#58;10001
&#91;New Thread 0&#93;
_start &#40;args=0, argp=0x0&#41; at crt0_prx.c&#58;109
109             if &#40;&sce_newlib_nocreate_thread_in_start != NULL&#41; &#123;
&#40;gdb&#41; break main
Breakpoint 1 at 0x88042d0&#58; file sprite.c, line 71.
&#40;gdb&#41; c
Continuing.
&#91;New Thread 72894009&#93;
&#91;Switching to Thread 72894009&#93;

Breakpoint 1, main &#40;argc=Cannot access memory at address 0xbbbfe00
&#41; at sprite.c&#58;71
71              setupCallbacks&#40;&#41;;
&#40;gdb&#41; next
75              for &#40;i = 0; i < NUM_SLICES; ++i&#41;
&#40;gdb&#41; next
77                      for &#40;j = 0; j < NUM_ROWS; ++j&#41;
&#40;gdb&#41; next
79                              float s = i + 0.5f, t = j;
&#40;gdb&#41; next
82                              x = &#40;RING_SIZE + RING_RADIUS * cosf&#40;s * &#40;&#40;GU_PI*2&#41;/NUM_SLICES&#41;&#41;&#41; * cosf&#40;t * &#40;&#40;GU_PI*2&#41;/NUM_ROWS&#41;
&#41;;
&#40;gdb&#41;

As you can see, the problem is this:

Code: Select all

Breakpoint 1, main &#40;argc=Cannot access memory at address 0xbbbfe00
&#41; at sprite.c&#58;71
GDB is reporting a wrong address for argc, even if it's not really the case. My code runs ok outside of GDB.

Has anyone seen this ? The problem is that I would like to use Eclipse, but it chokes when gdb give this error.

Thanks for your help!
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Hmm a bug surfaces :) The problem is GDB implements a range restriction on what addresses it is willing to read to prevent GDB itself from crashing. Unfortunately now people have forced psplink to run with the large memory model on slims your stack frame is above the old 32MB limit and GDB refuses to read the memory.

Not sure if I feel like fixing it personally ;) You could change it yourself if you checkout a copy of psplinkusb from subversion and hard code it. You would need to change the file usbgdb/main.c then on lines 128 and 163 change the 0x0A000000 to 0x0C000000 and copy that new version of the usbgdb.prx on to your memory stick.

A "proper" fix would inspect the size of the memory regions ;)
BobJelly
Posts: 3
Joined: Tue Nov 20, 2007 10:50 am

Post by BobJelly »

Oh yeah, you were right! That was exactly the problem. Now I'm able to debug using Eclipse :)

Thanks for the quick response!

And thanks a LOT for this amazing tool that is PSPLINK... It makes everything so much easier !!
Post Reply