A good way to test your code is psplink it tells you where and why your app crashes(usually)
don't worry psplink is part of the toolchain, still if you don't have it you can pull a compiled version from minpsp (use the oe version)
put psplink oe on your psp and compile your app as a prx
1. connect your psp to your computer(you might need the drivers
PSP Type B Driver install - ENG)
2. start usbhostfs_pc from your project directory(from command prompt)
3. start pspsh from your project directory(from command prompt)
4. start psplink from your psp (you will see it connected in usbhostfs_pc and pspsh)
5. from pspsh type in the name of your app (ex musicapp.
prx) and press enter to run
if you get an exception it'll tell you what type of exception, the address where it happened and what instruction caused it.
To find out where in the source code the error occurred type
calc $epc-$mod
and use the result in psp-addr2line like
psp-addr2line -fCe musicapp.
elf result