Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
March 21, 2010, 11:24:56 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Join our IRC channel: ##psp-programming on freenode
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: Is there a way to have a exception handler with a call stack ?  (Read 2540 times)
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« on: March 01, 2008, 04:27:09 PM »

Hi,

I hear people taking about a exception handler with a call stack is there a way to do this ?
I tried to implement the exception example in my code, but as soon as I added it my project don’t start, after a message it drops back to the XMB.

Currently I have a reasonable assert handler (+ log file) that will show a message and quit to the XMB , but I have no call stack and in the case my project crashes it’s hard to find the bug.

I don’t use any external libs/sources outside the ones supplied by Sony or Gcc.

Thx in advance

PS: I know that I can make my project cross platform (basically it is) to find global/simple bugs, but there are always platform specific issues

« Last Edit: March 01, 2008, 04:52:42 PM by Cash » Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!


Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #1 on: March 01, 2008, 04:44:27 PM »

Also I like to know how to get my stack pointer so I can see the max/current stack usage, I added a safety guard of 8Kb to my stack and each frame I check if I override the stack without the safety guard, if so I show a message and drop back to the XMB.
« Last Edit: March 01, 2008, 04:54:24 PM by Cash » Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +83/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« Reply #2 on: March 01, 2008, 05:40:37 PM »

Use psplink for finding exceptions, and I know this is going to sound stupid but it's a lot easier not to make bugs in the first place than to track them.
For the psp you should write an error logger before anything else and code defensively to detect errors even if they're unlikely to happen.
Always check for null pointers, invalid function parameters, failed file reads/writes, failed allocations, etc.
Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #3 on: March 02, 2008, 05:15:22 AM »

Hi Flatmush,

> Use psplink for finding exceptions
I will investigate this

> and I know this is going to sound stupid but it's a lot easier not to make bugs in the first place than to track them.
Good practice, I will try to remember this simple rule Wink

> For the psp you should write an error logger before anything else and code defensively to detect errors even if they're unlikely to happen.
I already added an assert handler, log file and a function to check if I override my stack.

> Always check for null pointers, invalid function parameters, failed file reads/writes, failed allocations, etc.
In my project asserts are fatal so
assert(false);
will popup a message box and jump back to the XMB, the same is true for failed allocations
char* ptr = new char[24*1024*1024];
char* ptr = malloc(24*1024*1024);
both will write the requested allocation to my log file, close the log file and jump back to the XMB

Thx.
Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sakya
Jr. Member
**

Karma: +4/-1
Offline Offline

Posts: 60
3375.35 points

View Inventory
Send Money to sakya

View Profile WWW
« Reply #4 on: March 02, 2008, 06:28:42 AM »

Hi! Smile

You can try to have a look at this prx Smile
http://www.sakya.it/downloads/exceptionHandler.rar

Ciaooo
Sakya
Logged
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #5 on: March 02, 2008, 08:12:35 AM »

Hi sakya,

I created the exception.prx, EBOOT.PBP and PARAM.SFO, copied all files to G:\PSP\GAME\TEST (where G: is the mounted USB device of my PSP memory stick) and run the 'Exception Handler Test' it shows the following error message box

... snap ...

The game could not be started
(80020148)

O Back

... snap ...

Do I need to copy it to an other location on my memory stick ?
Is my system software to new or to old (3.71 M33-2) ?

Thx in advance
Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sakya
Jr. Member
**

Karma: +4/-1
Offline Offline

Posts: 60
3375.35 points

View Inventory
Send Money to sakya

View Profile WWW
« Reply #6 on: March 02, 2008, 12:38:20 PM »

Hi! Smile
copied all files to G:\PSP\GAME\TEST (where G: is the mounted USB device of my PSP memory stick) and run the 'Exception Handler Test' it shows the following error message box
The test app is for kernel 3.x, maybe you have set kernel 1.50 in the recovery menu.
Try to copy exception.prx and EBOOT.PBP to PSP/GAME371/test

Ciaooo
Sakya
« Last Edit: March 02, 2008, 12:41:30 PM by sakya » Logged
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #7 on: March 02, 2008, 01:12:24 PM »

Hi Sakya,

I tried to copy it to PSP/GAME371/test, but it still give the same result
I looked at the recovery menu, but didn't find any settings pointing to 1.50

Game folder homebrew -> 3.71

Thx anyway

PS: if I lookup the error message in pspkerror.h it says 80020148 = SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE
« Last Edit: March 02, 2008, 01:28:46 PM by Cash » Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sakya
Jr. Member
**

Karma: +4/-1
Offline Offline

Posts: 60
3375.35 points

View Inventory
Send Money to sakya

View Profile WWW
« Reply #8 on: March 03, 2008, 08:28:02 AM »

Hi! Smile
if I lookup the error message in pspkerror.h it says 80020148 = SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE
Sorry, I don't know why (except thinking about some sdk problem).
This version works for me under CF 3.71M33:
http://www.MegaShare.com/370457

Ciaooo
Sakya
Logged
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #9 on: March 03, 2008, 01:49:39 PM »

Hi Sakya,

This version works on my PSP, so I have to get a newer compiler / sdk to run the exception handler ;(

Currently I use the SDK from http://xorloser.com/PSPDevWin32.zip

Thx...
Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sakya
Jr. Member
**

Karma: +4/-1
Offline Offline

Posts: 60
3375.35 points

View Inventory
Send Money to sakya

View Profile WWW
« Reply #10 on: March 03, 2008, 11:05:33 PM »

Hi! Smile
so I have to get a newer compiler / sdk to run the exception handler ;(
Try this:
http://www.jetcube.eu/archives/2008/02/entry_71.html

Ciaooo
Sakya
Logged
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #11 on: March 04, 2008, 12:15:53 PM »

Hi Sakya,

Whit this compiler/sdk I can't even compile the exception.prx in your exception handler example ;(, below is the output, the test itself compiles whitout problems

But the good news is that I see that the SDK is newer then the one from xorloser, and I can still compile my own project.

So I will keep this one for a while..

Thx.

E:\Develop\PSP\exceptionHandler\prx>make
psp-gcc -IE:\Develop\PSP\pspsdk/psp/sdk/include/libc -I. -IE:\Develop\PSP\pspsdk/psp/sdk/include -Os -G0 -Wall  -nostartfiles -D_PSP_FW_VERSION=150   -c -o main.o main.c
psp-gcc -I. -IE:\Develop\PSP\pspsdk/psp/sdk/include -Os -G0 -Wall  -nostartfiles -I. -IE:\Develop\PSP\pspsdk/psp/sdk/include -Os -G0 -Wall  -nostartfiles  -o exception_asm.o exception_asm.s
exception_asm.s: Assembler messages:
exception_asm.s:101: Error: Macro used $at after ".set noat"
...
list of exception_asm.s:101: Error: Macro used $at after ".set noat"
...
exception_asm.s:140: Error: Macro used $at after ".set noat"
exception_asm.s:141: Error: illegal operands `mfc0 $v1,BadVAddr'
exception_asm.s:142: Error: Macro used $at after ".set noat"
exception_asm.s:143: Error: illegal operands `mfc0 $v1,Cause'
exception_asm.s:144: Error: Macro used $at after ".set noat"
exception_asm.s:145: Error: illegal operands `mfc0 $v1,EPC'
exception_asm.s:146: Error: Macro used $at after ".set noat"
exception_asm.s:147: Error: illegal operands `mfc0 $v1,Status'
exception_asm.s:148: Error: Macro used $at after ".set noat"
...
more exception_asm.s:101: Error: Macro used $at after ".set noat"
...
exception_asm.s:187: Error: Macro used $at after ".set noat"
exception_asm.s:189: Error: illegal operands `cfc1'
exception_asm.s:190: Error: Macro used $at after ".set noat"
exception_asm.s:191: Error: illegal operands `cfc1'
exception_asm.s:192: Error: Macro used $at after ".set noat"
exception_asm.s:193: Error: illegal operands `ctc1'
exception_asm.s:198: Error: Macro used $at after ".set noat"
exception_asm.s:213: Error: unrecognized opcode `import_start "ExceptionManagerForKernel",0x00010011'
exception_asm.s:214: Error: unrecognized opcode `import_func "ExceptionManagerForKernel",0x565C0B0E,sceKernelRegisterDefaultExceptionHandler371'
make: *** [exception_asm.o] Error 1
« Last Edit: March 04, 2008, 12:36:08 PM by Cash » Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
Noware
C/C++ Developer
Hero Member
*****

Karma: +41/-2
Offline Offline

Posts: 688
37476.53 points

View Inventory
Send Money to Noware

Avatar by: Jason Hise


View Profile
« Reply #12 on: March 08, 2008, 02:43:03 PM »

Hi Sakya (or anybody else),

One more thing:

is there a way to change the compiler error and warning log to the way Visual Studio does ?, now I'm unable to double click on a error or warning and go to the line where the error or warning is ;(

I'm only uning Visual Studio as a editor and capture the output

Thx in advance.
Logged

Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sakya
Jr. Member
**

Karma: +4/-1
Offline Offline

Posts: 60
3375.35 points

View Inventory
Send Money to sakya

View Profile WWW
« Reply #13 on: March 09, 2008, 01:43:17 AM »

Hi! :

Sorry, but I don't know how to solve your compilation problems.
Try to read this thread, maybe there's something interesting (and some updates)
http://forums.ps2dev.org/viewtopic.php?t=9812

Also for VS, I don't use it for psp development (just at work)....

Ciaooo
Sakya
Logged
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.21 seconds with 40 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com