GP32 Gp32 "translation Exception"


slaanesh

Certified Guru
Joined
Nov 9, 2005
Messages
1,995
Age
54
Location
Melbourne, Australia
Website
www.slaanesh.net
I'm porting across a C++ application (Stella) to the GP32. All was going well except I'm getting a "translation" exception (according to the BIOS monitor).
It seems to be happening inside the C++ std lib, specifically near libstdc++.a(string-inst.o).

Here's the code, the highlighted code is where it's bombing. It seems innocent to me.

Any suggestions?

Code:
  GpPrintf("Added prop %d", mySize);
  // Add new property to the array
 myProperties[mySize].key = key;          <---- Translation exception here on this line.
  GpPrintf("Added prop key");
  myProperties[mySize].value = value;
  GpPrintf("Added prop value");

Other information.
I'm using DevKitArm r26, SDL++.
The myProperties array is being constructed from a "new" operator. This is the first value n the array.
I've tried using Mr. Mirko's gp_new_old.cxx (see next code snippet), but it makes no difference.


Code:
using namespace std;

//
// The four functions overload glocal
// new & delete operators..
//

void* operator new( size_t size ) throw(std::bad_alloc) {
	//GpPrintf("malloc %d", size);
	return ::_sbrk(size);
}

void* operator new[]( size_t size ) throw(std::bad_alloc) {
	//GpPrintf("malloc %d", size);
	return ::_sbrk(size);
}

void operator delete( void* todel ) throw() {
	//::gm_free(todel);
}

void operator delete[]( void* todel ) throw() {
	//::gm_free(todel);
}

EDIT: I've just run it again and now it's saying "Alignment exception" at the same point.
Which makes more sense to me as I had no idea what a translation exception was or how to fix it.

As for alignment issues, for me this is a bit easier to deal with in "C" as I am unfamiliar with C++.

Are there any recommended compiler options to make sure things are aligned?

I am already using a customized "new" and "new[]" operator which should be returning aligned memory from a pre-malloced heap.

What about statically declared objects and structures? Could these be a problem?
 
I thought a translation exception was an attempt to convert an invalid virtual memory address to a physical one. Eg. a Null pointer. It may make sense to print out the address stored in myProperties, or perhaps even &myProperties[mySize] to make sure they are valid and have not been corrupted.
 
Back
Top