__builtin_longjmp problem
Artem Alimarine
aalimari@best.ms.philips.com
Tue Aug 31 22:45:00 GMT 1999
Hello,
I use gcc-2.95 on Cygwin for i960-unknown-coff. The exception handling
does not work. As far as I could find it is due
to __builtin_setjmp/longjmp. The following code hangs on VxWorks 5.1:
#include <stdio.h>
int jbuf[1024];
void hello() {
ÃÂ ÃÂ ÃÂ if(__builtin_setjmp(jbuf) == 0) {
ÃÂ __builtin_longjmp(jbuf, 1);
ÃÂ ÃÂ ÃÂ } else {
ÃÂ printf("jumped\n");
ÃÂ ÃÂ ÃÂ }
}
In the assembler I can see that the code for longjmp is wrong (the whole
output is attached at the end):
code generated for __bulitin_setjmp (seems OK for me):
ÃÂ ÃÂ ÃÂ ldconst _jbuf,g4
ÃÂ ÃÂ ÃÂ st fp,(g4)
ÃÂ ÃÂ ÃÂ ldconst L17,g5
ÃÂ ÃÂ ÃÂ st g5,4(g4)
ÃÂ ÃÂ ÃÂ st sp,8(g4)
ÃÂ ÃÂ ÃÂ mov 0,g4
ÃÂ
code generated for __buitin_longjmp(seems wrong):
ÃÂ ÃÂ ÃÂ ldconst _jbuf,g4
ÃÂ ÃÂ ÃÂ flushreg
ÃÂ ÃÂ ÃÂ mov 1,fp
ÃÂ ÃÂ ÃÂ lda -64(fp),pfp
ÃÂ ÃÂ ÃÂ ld (g4),g5
ÃÂ ÃÂ ÃÂ st g5,-56(fp)
ÃÂ ÃÂ ÃÂ ld 8(g4),g4
ÃÂ ÃÂ ÃÂ st g4,-60(fp)
ÃÂ ÃÂ ÃÂ ret
How do I fix this?
Is that possible to make compiler to generate calls to aÃÂ setjmp/longjmp
from the library
for exception handling?
I've seen a macro DONT_USE_BUITIN_SETJMP in the source code. How do
I turn it on for
buiding gcc?
Best regards
Artem
ÃÂ
assembler output:
ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ .file "hello.cpp"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
ÃÂ ÃÂ ÃÂ ÃÂ .align 3
LC0:
ÃÂ ÃÂ ÃÂ ÃÂ .ascii "jumped\12\0"
ÃÂ ÃÂ ÃÂ ÃÂ .align 4
ÃÂ ÃÂ ÃÂ ÃÂ .globl _hello__Fv
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ Function 'hello__Fv'
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ Registers used: g0 g4 g5 g8* g9*
g10* g11* g12* g14 fp pfp
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ ÃÂ ÃÂ ÃÂ sp r3* r4* r5*
r6* r7* r8* r9* r10* r11* r12* r13* r14* r15* cc
_hello__Fv:
ÃÂ ÃÂ ÃÂ ÃÂ lda 36(sp),sp
ÃÂ ÃÂ ÃÂ ÃÂ stq g8,80(fp)
ÃÂ ÃÂ ÃÂ ÃÂ st g12,96(fp)
ÃÂ ÃÂ ÃÂ ÃÂ #Prologue stats:
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ Total Frame Size: 36 bytes
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ Local Variable Size: 16 bytes
ÃÂ ÃÂ ÃÂ ÃÂ #ÃÂ Register Save Size: 5 regs, 20
bytes
ÃÂ ÃÂ ÃÂ ÃÂ #End Prologue#
ÃÂ ÃÂ ÃÂ ÃÂ st g14,64(fp)
ÃÂ ÃÂ ÃÂ ÃÂ ldconst _jbuf,g4
ÃÂ ÃÂ ÃÂ ÃÂ st fp,(g4)
ÃÂ ÃÂ ÃÂ ÃÂ ldconst L4,g5
ÃÂ ÃÂ ÃÂ ÃÂ st g5,4(g4)
ÃÂ ÃÂ ÃÂ ÃÂ st sp,8(g4)
ÃÂ ÃÂ ÃÂ ÃÂ mov 0,g4
ÃÂ ÃÂ ÃÂ ÃÂ b L3
ÃÂ ÃÂ ÃÂ ÃÂ .align 3
L4:
ÃÂ ÃÂ ÃÂ ÃÂ ld 64(fp),g5
ÃÂ ÃÂ ÃÂ ÃÂ mov g5,g14
ÃÂ ÃÂ ÃÂ ÃÂ lda 1,g4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