<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">My emails keep getting truncated for some reason.. :(<br><br></div><br><hr id="stopSpelling">> From: jayk123@hotmail.com<br>> To: m3devel@elegosoft.com<br>> Subject: bad code on PPC_LINUX?<br>> Date: Thu, 10 Jan 2008 07:11:11 +0000<br>> <br>> <br>> Something is screwy I think.<br>> My gdb skills are um not good.<br>> <br>> On PPC_LINUX.<br>> <br>> /dev2/cm3/m3-sys/cm3/src/Utils.m3<br>> <br>> PROCEDURE WriteFile (file: TEXT; proc: Emitter; append := FALSE) =<br>> VAR wr: Wr.T;<br>> BEGIN<br>> IF (append)<br>> THEN wr := AppendWriter (file, fatal := TRUE);<br>> ELSE wr := OpenWriter (file, fatal := TRUE);<br>> END;<br>> TRY (* line 78 *)<br>> TRY<br>> proc (wr);<br>> EXCEPT<br>> | Wr.Failure (ec) =><br>> Msg.FatalError (ec, "write failed on ", file);<br>> | Thread.Alerted =><br>> Msg.FatalError (NIL, "interrupted while writing ", file);<br>> END;<br>> FINALLY<br>> CloseWriter (wr, file);<br>> END;<br>> END WriteFile;<br>> <br>> I get a SEGV on line 78.<br>> <br>> I'm willing to believe, sadly, that some of these huge offsets<br>> are the price of TRY and saving the register context on anything<br>> other than x86 (for registers that aren't even used by the function?),<br>> however it crashes just after the call and notice there the huge 32k offset.<br>> <br>> And really? A 720 byte frame for any function with a TRY on PowerPC?<br>> Really?<br>> I guess I should look at what PPC_DARWIN does.<br>> <br>> If someone can give me a quick run down on PowerPC ABI, thanks.<br>> I'll search the web. Or maybe check my Mac docs.<br>> register 0 is 0 or general purpose?<br>> Stack is register ?<br>> I know that return address is in the link register.<br>> bl is branch and link -- call -- jump and save pc in link register.<br>> <br>> The code is:<br>> (gdb) disassemble<br>> Dump of assembler code for function Utils__WriteFile:<br>> 0x10024fbc : stwu r1,-720(r1)<br>> 0x10024fc0 : mflr r0<br>> 0x10024fc4 : mfcr r12<br>> 0x10024fc8 : stfd f14,576(r1)<br>> 0x10024fcc : stfd f15,584(r1)<br>> 0x10024fd0 : stfd f16,592(r1)<br>> 0x10024fd4 : stfd f17,600(r1)<br>> 0x10024fd8 : stfd f18,608(r1)<br>> 0x10024fdc : stfd f19,616(r1)<br>> 0x10024fe0 : stfd f20,624(r1)<br>> 0x10024fe4 : stfd f21,632(r1)<br>> 0x10024fe8 : stfd f22,640(r1)<br>> 0x10024fec : stfd f23,648(r1)<br>> 0x10024ff0 : stfd f24,656(r1)<br>> 0x10024ff4 : stfd f25,664(r1)<br>> 0x10024ff8 : stfd f26,672(r1)<br>> 0x10024ffc : stfd f27,680(r1)<br>> 0x10025000 : stfd f28,688(r1)<br>> 0x10025004 : stfd f29,696(r1)<br>> 0x10025008 : stfd f30,704(r1)<br>> 0x1002500c : stfd f31,712(r1)<br>> 0x10025010 : stw r14,504(r1)<br>> 0x10025014 : stw r15,508(r1)<br>> 0x10025018 : stw r16,512(r1)<br>> 0x1002501c : stw r17,516(r1)<br>> 0x10025020 : stw r18,520(r1)<br>> 0x10025024 : stw r19,524(r1)<br>> 0x10025028 : stw r20,528(r1)<br>> 0x1002502c : stw r21,532(r1)<br>> ---Type to continue, or q to quit---<br>> 0x10025030 : stw r22,536(r1)<br>> 0x10025034 : stw r23,540(r1)<br>> 0x10025038 : stw r24,544(r1)<br>> 0x1002503c : stw r25,548(r1)<br>> 0x10025040 : stw r26,552(r1)<br>> 0x10025044 : stw r27,556(r1)<br>> 0x10025048 : stw r28,560(r1)<br>> 0x1002504c : stw r29,564(r1)<br>> 0x10025050 : stw r30,568(r1)<br>> 0x10025054 : stw r31,572(r1)<br>> 0x10025058 : stw r0,724(r1)<br>> 0x1002505c : stw r12,500(r1)<br>> 0x10025060 : mr r31,r1<br>> 0x10025064 : bl 0x10025068 <br>> 0x10025068 : mflr r30<br>> 0x1002506c : lwz r0,-176(r30)<br>> 0x10025070 : add r30,r0,r30<br>> 0x10025074 : stw r3,8(r31)<br>> 0x10025078 : stw r4,12(r31)<br>> 0x1002507c : mr r0,r5<br>> 0x10025080 : stb r0,16(r31)<br>> 0x10025084 : li r0,0<br>> 0x10025088 : stw r0,20(r31)<br>> 0x1002508c : lbz r0,16(r31)<br>> 0x10025090 : clrlwi r0,r0,24<br>> 0x10025094 : cmpwi r0,0<br>> 0x10025098 : beq- 0x100250b8 <br>> 0x1002509c : lwz r3,8(r31)<br>> 0x100250a0 : li r4,1<br>> 0x100250a4 : bl 0x100248a4 <br>> ---Type to continue, or q to quit---<br>> 0x100250a8 : stw r3,476(r31)<br>> 0x100250ac : lwz r9,476(r31)<br>> 0x100250b0 : stw r9,20(r31)<br>> 0x100250b4 : b 0x100250d0 <br>> 0x100250b8 : lwz r3,8(r31)<br>> 0x100250bc : li r4,1<br>> 0x100250c0 : bl 0x10024658 <br>> 0x100250c4 : stw r3,476(r31)<br>> 0x100250c8 : lwz r9,476(r31)<br>> 0x100250cc : stw r9,20(r31)<br>> <br>> ** here I believe ** <br>> <br>> 0x100250d0 : lwz r0,-32760(r30)<br>> 0x100250d4 : stw r0,32(r31)<br>> 0x100250d8 : addi r0,r31,8<br>> 0x100250dc : stw r0,36(r31)<br>> 0x100250e0 : li r0,3<br>> 0x100250e4 : stw r0,28(r31)<br>> 0x100250e8 : lwz r9,-32764(r30)<br>> 0x100250ec : lwz r0,0(r9)<br>> 0x100250f0 : stw r0,24(r31)<br>> 0x100250f4 : lwz r9,-32764(r30)<br>> 0x100250f8 : addi r0,r31,24<br>> 0x100250fc : stw r0,0(r9)<br>> 0x10025100 : lwz r9,-32768(r30)<br>> 0x10025104 : addi r0,r9,76<br>> 0x10025108 : stw r0,64(r31)<br>> 0x1002510c : li r0,0<br>> 0x10025110 : stw r0,60(r31)<br>> 0x10025114 : lwz r9,-32764(r30)<br>> 0x10025118 : lwz r0,0(r9)<br>> 0x1002511c : stw r0,56(r31)<br>> ---Type to continue, or q to quit---<br>> 0x10025120 : lwz r9,-32764(r30)<br>> 0x10025124 : addi r0,r31,56<br>> 0x10025128 : stw r0,0(r9)<br>> 0x1002512c : addi r9,r31,56<br>> 0x10025130 : addi r0,r9,48<br>> 0x10025134 : mr r3,r0<br>> 0x10025138 : bl 0x101bbf28 <br>> 0x1002513c : mr r0,r3<br>> 0x10025140 : cmpwi r0,0<br>> 0x10025144 : bne- 0x100251ac <br>> 0x10025148 : lwz r9,12(r31)<br>> 0x1002514c : stw r9,476(r31)<br>> 0x10025150 : lwz r9,476(r31)<br>> 0x10025154 : cmpwi r9,0<br>> 0x10025158 : beq- 0x10025188 <br>> 0x1002515c : lwz r9,476(r31)<br>> 0x10025160 : lwz r0,0(r9)<br>> 0x10025164 : li r9,-1<br>> 0x10025168 : cmpw r0,r9<br>> 0x1002516c : bne- 0x10025188 <br>> 0x10025170 : lwz r9,476(r31)<br>> 0x10025174 : lwz r9,8(r9)<br>> 0x10025178 : stw r9,480(r31)<br>> 0x1002517c : lwz r9,476(r31)<br>> 0x10025180 : lwz r9,4(r9)<br>> 0x10025184 : stw r9,476(r31)<br>> 0x10025188 : lwz r11,480(r31)<br>> 0x1002518c : lwz r3,20(r31)<br>> 0x10025190 : lwz r0,476(r31)<br>> 0x10025194 : mtlr r0<br>> ---Type to continue, or q to quit---<br>> 0x10025198 : blrl<br>> 0x1002519c : lwz r9,-32764(r30)<br>> 0x100251a0 : lwz r0,56(r31)<br>> 0x100251a4 : stw r0,0(r9)<br>> 0x100251a8 : b 0x10025210 <br>> 0x100251ac : lwz r9,68(r31)<br>> 0x100251b0 : lwz r9,0(r9)<br>> 0x100251b4 : lis r0,-15535<br>> 0x100251b8 : ori r0,r0,42454<br>> 0x100251bc : cmpw r9,r0<br>> 0x100251c0 : bne- 0x100251f0 <br>> 0x100251c4 : lwz r0,72(r31)<br>> 0x100251c8 : stw r0,472(r31)<br>> 0x100251cc : lwz r9,-32768(r30)<br>> 0x100251d0 : addi r0,r9,180<br>> 0x100251d4 : lwz r3,472(r31)<br>> 0x100251d8 : mr r4,r0<br>> 0x100251dc : lwz r5,8(r31)<br>> 0x100251e0 : li r6,0<br>> 0x100251e4 : li r7,0<br>> 0x100251e8 : bl 0x10023b4c <br>> 0x100251ec : b 0x10025210 <br>> 0x100251f0 : lwz r9,-32768(r30)<br>> 0x100251f4 : addi r0,r9,212<br>> 0x100251f8 : li r3,0<br>> 0x100251fc : mr r4,r0<br>> 0x10025200 : lwz r5,8(r31)<br>> 0x10025204 : li r6,0<br>> 0x10025208 : li r7,0<br>> 0x1002520c : bl 0x10023b4c <br>> ---Type to continue, or q to quit---<br>> 0x10025210 : lwz r9,-32764(r30)<br>> 0x10025214 : lwz r0,24(r31)<br>> 0x10025218 : stw r0,0(r9)<br>> 0x1002521c : addi r11,r31,8<br>> 0x10025220 : bl 0x10024f74 <br>> 0x10025224 : lwz r11,0(r1)<br>> 0x10025228 : lwz r0,4(r11)<br>> 0x1002522c : lwz r12,-220(r11)<br>> 0x10025230 : mtlr r0<br>> 0x10025234 : lwz r14,-216(r11)<br>> 0x10025238 : lwz r15,-212(r11)<br>> 0x1002523c : lwz r16,-208(r11)<br>> 0x10025240 : lwz r17,-204(r11)<br>> 0x10025244 : lwz r18,-200(r11)<br>> 0x10025248 : lwz r19,-196(r11)<br>> 0x1002524c : lwz r20,-192(r11)<br>> 0x10025250 : lwz r21,-188(r11)<br>> 0x10025254 : lwz r22,-184(r11)<br>> 0x10025258 : lwz r23,-180(r11)<br>> 0x1002525c : lwz r24,-176(r11)<br>> 0x10025260 : lwz r25,-172(r11)<br>> 0x10025264 : lwz r26,-168(r11)<br>> 0x10025268 : lwz r27,-164(r11)<br>> 0x1002526c : lwz r28,-160(r11)<br>> 0x10025270 : lwz r29,-156(r11)<br>> 0x10025274 : lwz r30,-152(r11)<br>> 0x10025278 : lwz r31,-148(r11)<br>> 0x1002527c : lfd f14,-144(r11)<br>> 0x10025280 : lfd f15,-136(r11)<br>> 0x10025284 : lfd f16,-128(r11)<br>> ---Type to continue, or q to quit---<br>> 0x10025288 : lfd f17,-120(r11)<br>> 0x1002528c : lfd f18,-112(r11)<br>> 0x10025290 : lfd f19,-104(r11)<br>> 0x10025294 : lfd f20,-96(r11)<br>> 0x10025298 : lfd f21,-88(r11)<br>> 0x1002529c : lfd f22,-80(r11)<br>> 0x100252a0 : lfd f23,-72(r11)<br>> 0x100252a4 : lfd f24,-64(r11)<br>> 0x100252a8 : lfd f25,-56(r11)<br>> 0x100252ac : lfd f26,-48(r11)<br>> 0x100252b0 : lfd f27,-40(r11)<br>> 0x100252b4 : lfd f28,-32(r11)<br>> 0x100252b8 : lfd f29,-24(r11)<br>> 0x100252bc : lfd f30,-16(r11)<br>> 0x100252c0 : lfd f31,-8(r11)<br>> 0x100252c4 : mtcrf 56,r12<br>> 0x100252c8 : mr r1,r11<br>> 0x100252cc : blr<br>> 0x100252d0 : .long 0x24ebb0<br>> End of assembler dump.<br>> <br>> <br>> (gdb) bt<br>> #0 Utils__WriteFile (M3_Bd56fi_file=0x10277ba0, M3_DmuccK_proc=0x7fb22210,<br>> M3_AicXUJ_append=0 '\0') at Utils.m3:78<br>> #1 0x10020a10 in Makefile__Build (M3_Bd56fi_src_dir=0x102720ec)<br>> at Makefile.m3:101<br>> #2 0x100292d4 in Main__DoIt () at Main.m3:71<br>> #3 0x10029834 in Main_M3 (M3_AcxOUs_mode=1) at Main.m3:193<br>> #4 0x10188f9c in RTLinker__RunMainBody (M3_DUuepq_m=0x10279b28)<br>> at RTLinker.m3:387<br>> #5 0x101880bc in RTLinker__AddUnitI (M3_DUuepq_m=0x10279b28) at RTLinker.m3:100<br>> #6 0x10188198 in RTLinker__AddUnit (M3_DUuepw_b=0x100297f8) at RTLinker.m3:110<br>> #7 0x100002ec in main (argc=1, argv=0x7fb22834, envp=0x7fb2283c) at _m3main.mc:4<br>> <br>> I haven't yet figured out how to get gdb to show me the details of the SEGV, like what address was referenced.<br>> <br>> I swear I think this was working better recently.<br>> <br>> Oh, I did change something. I will try to change it back.<br>> I added -fPIC.<br>> Dynamic linking was not working and I thought that might fix it.<br>> I'll definitely try without it now.<br>> <br>> Also, relevant aside -- what, if any, distributions/versions of Linux are people using on PowerPC?<br>> Specifically on PowerPC (to limit the religious explosion)<br>> I'm currently using Yellow Dog, I think 4.1, but only for Modula-3 purposes, not for anything else.<br>> <br>> ps: I'd like a SMALL forum of SMART programmers, to discuss GENERAL programming topics.<br>> This is it perhaps?<br>> <br>> - Jay<br>> _________________________________________________________________<br>> Watch “Cause Effect,” a show about real people making a real difference.<br>> http://im.live.com/Messenger/IM/MTV/?source=text_watchcause<br><br /><hr />Make distant family not so distant with Windows Vista® + Windows Live™. <a href='http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008' target='_new'>Start now!</a></body>
</html>