I wish to debug memory access on POSE, and wrote a program to test the
functionality.  I am using:

the newest (3.0a6) version of emulator,
fresh ROM (Palm OS 3.5-en-ezdbg.rom),
SDK 3.5 + new debugger plugin for CW, since this month.

Debug settings on emulator are all on, but it seems not to be catching my
errors in some cases.  Following is a short code segment, for demonstration:

//-----------------------------------------------------------------------
static Boolean MainFormSelectEvent(UInt16 ctl) {
        Boolean handled = false;
        MemHandle intHandle;
        UInt16* intPtr;
        switch (ctl){

                case MainCheckUnlockedChunkAccessButton:
                        intHandle = MemHandleNew(sizeof(UInt16));
                        intPtr = (UInt16*)MemHandleLock(intHandle);
                        MemHandleUnlock(intHandle);
                        *intPtr = 32;  // <- This is reported, as expected
                        break;         // (.. just read directly from unlocked chunk)

                case MainCheckFreeChunkAccessButton:
                        intPtr = (UInt16*)MemPtrNew(sizeof(UInt16));
                        MemPtrFree(intPtr);
                        *intPtr = 32;  // <- This is NOT reported at all!
                        break;

                case MainCheckStackOverFlowButton:
                        Recurse(0);    // <- This is reported, as expected
                        break;         // (.. getting close to overflowing ..)

                case MainCheckOffStackedReferenceButton:
                        intPtr = NULL;
                        OffStacker(&intPtr); // This points intPtr to a
                                             // local array in OffStacker
                        *intPtr = 43;  // <- This is NOT reported at all!
                        break;
                }
        return handled;
}

static void OffStacker(UInt16** t) {
        UInt16 localArray[5];
        *t = localArray;
}
static void Recurse(UInt16 i) {
        Recurse(i);
}
//-----------------------------------------------------------------------

Am I incorrect in assuming that the Emulator can assist me in checking for
errors such as the ones above that are not reported in my configuration.  If
there is additional configuration or installation to get this to work,
pointers would be appreciated.

ps. I did turn off the optimizer, and even tried putting some extra code in
the functions to thwart it, and it is most definitely executing the illegal
memory access.

Thanks,


Magnus Torfason


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to