| View previous topic :: View next topic |
| Author |
Message |
Oguz286

Joined: 30 Oct 2007 Posts: 35
|
Posted: Tue Dec 18, 2007 1:45 am Post subject: Bus error when using dynamic_cast |
|
|
Hello everyone,
I have some dynamic casts in my code which works perfectly on my pc, but when I run the same app on the PSP, it gives me a bus error. I use the casts to cast a base class into an inhereted class which makes my life easier to handle objects, but it seems the PSP doesn't like it.
| Code: |
Texture* tex = new StaticTexture();
StaticTexture* temp = dynamic_cast<StaticTexture*>(tex);
if(temp) {
// do stuff
}
|
Anyone got ideas? |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue Dec 18, 2007 1:55 am Post subject: |
|
|
| Use psplink or psp-addr2line or something to figure out where the bus error is. Possibly an alignment issue. |
|
| Back to top |
|
 |
Oguz286

Joined: 30 Oct 2007 Posts: 35
|
Posted: Tue Dec 18, 2007 5:22 am Post subject: |
|
|
I'm using psplink so that's why I know there is a bus error, but I have no idea how to figure out where exactly it's happening, but I know it's happening on the dynamic_cast line in my first post. I looked at the psp-addr2line tool but I don't know what to input into the tool.
| Code: |
Load/Start host0:/engine.prx UID: 0x045C577B Name: "OguEngine"
host0:/> Exception - Bus error (data)
Thread ID - 0x045B8407
Th Name - user_main
Module ID - 0x045C577B
Mod Name - "OguEngine"
EPC - 0x08AA6A10
Cause - 0x1000001C
BadVAddr - 0x740410C5
Status - 0x20088613
zr:0x00000000 at:0x2008FF00 v0:0x00000010 v1:0x08B5FA28
a0:0x00000000 a1:0x08AF7E60 a2:0x08AF7E8C a3:0x00000000
t0:0x00000000 t1:0x00000001 t2:0x08B3C3F0 t3:0x08B986A0
t4:0x08B3C3E8 t5:0x00001E04 t6:0x08A35D70 t7:0x20088600
s0:0x08BF2440 s1:0x09FBFD04 s2:0x00000001 s3:0x000000D8
s4:0x08AF7E60 s5:0x000000FF s6:0x00000001 s7:0x09FBFCE8
t8:0x00000000 t9:0x00000000 k0:0x09FBFF00 k1:0x00000000
gp:0x08B44AB0 sp:0x09FBFC28 fp:0x09FBFEA0 ra:0x089D04C0
0x08AA6A10: 0x8C830000 '....' - lw $v1, 0($a0)
|
I can't tell if it's a memory alignment issue, because I have no code that aligns variables.
I started the debugger on psplink with debug ./engine.prx but that's as far as I get. |
|
| Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Tue Dec 18, 2007 5:57 am Post subject: Re: Bus error when using dynamic_cast |
|
|
| Oguz286 wrote: | Hello everyone,
I have some dynamic casts in my code which works perfectly on my pc, but when I run the same app on the PSP, it gives me a bus error. I use the casts to cast a base class into an inhereted class which makes my life easier to handle objects, but it seems the PSP doesn't like it.
| Code: |
Texture* tex = new StaticTexture();
StaticTexture* temp = dynamic_cast<StaticTexture*>(tex);
if(temp) {
// do stuff
}
|
Anyone got ideas? |
yes i have a strong idea : the option -nortti gives you no dynamic_cast since this one relies on RTTI |
|
| Back to top |
|
 |
Oguz286

Joined: 30 Oct 2007 Posts: 35
|
Posted: Tue Dec 18, 2007 6:01 am Post subject: Re: Bus error when using dynamic_cast |
|
|
| hlide wrote: | | Oguz286 wrote: | Hello everyone,
I have some dynamic casts in my code which works perfectly on my pc, but when I run the same app on the PSP, it gives me a bus error. I use the casts to cast a base class into an inhereted class which makes my life easier to handle objects, but it seems the PSP doesn't like it.
| Code: |
Texture* tex = new StaticTexture();
StaticTexture* temp = dynamic_cast<StaticTexture*>(tex);
if(temp) {
// do stuff
}
|
Anyone got ideas? |
yes i have a strong idea : the option -nortti gives you no dynamic_cast since this one relies on RTTI |
Yes you are right, CpuWhiz just told me the same. It works now, thanks! |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Tue Dec 18, 2007 4:55 pm Post subject: |
|
|
For furture reference you should be able to do in pspsh:
| Quote: | calc $epc-$mod
!psp-addr2line -e engine.elf $? |
As long as you built with the -g switch and ensure you use the ELF not the PRX as that contains the debug info. |
|
| Back to top |
|
 |
|