d88-jwa@nada.kth.se (Jon Watte) (01/20/90)
I am currently writing a DA using THINKC 4.0 on a 5meg SE/30.
I am using the stuff that came with the disks, the "Stub" DA
that routes you back into the application, so you can debug
the thing.
Anyway, everything runs OK, I get my Open call (with n=0, see
manual) and the return address is on the stack. I then do my
opening stuff in a separate function, like:
int already_opened = 0;
WindowPtr theWindow;
GrafPtr realPort;
/* ... */
int
_main(<foo>, <bar>, int n)
{
GrafPtr savePort;
asm {
MOVE.L 0(A5), realPort
}
GetPort(&savePort);
if(already_opened) SetPort(theWindow);
switch(n) {
case 0: ret = do_open(<foo>, <bar>);
break;
case 1: /* ... */
}
SetPort(savePort);
return ret;
}
int
do_open(<foo>, <bar>)
{
/* Checking for machine type and the likes */
/* Finding of System Folder */
/* Opening or creation of file */
/* Opening of window */
/* Setting up of TextEdit */
already_opened = 1;
return noErr;
}
Somewhere on the road, the stack gets corrupted. After the return,
I get back to address 0x010000 (That's what the debugger tells me)
and after that I die of a severe heart failure... uh, address error.
I have checked and breakpointed in MacsBug. It seems OK in the
beginning, but looks _really_ weird at the end - sort of like someone
popped one byte, but SP is even...
What's the deal ? It seems like something fishy is going on behind
my back, now is it the DA stub, moving memory or the Tooth Fairy that
causes this ? Or even me ?
All help appreciated ! Mail me, and I'll post a summary.
h+@nada.kth.se
--
--- Stay alert ! - Trust no one ! - Keep your laser handy ! ---
h+@nada.kth.se == h+@proxxi.se == Jon Watte
longer .sig available on request