__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
     b L3
     .align 3
L3:
     cmpi g4,0
     bne L2
     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
     b L5
     .align 3
L2:
     ldconst LC0,g0
     callx _printf
L5:
     b LR1
LR1:
     #EPILOGUE#
     ldq 80(fp),g8
     ld 96(fp),g12
     ret
     #End Epilogue#
.globl _jbuf
.bss _jbuf,4096,2
 
 
 
begin:vcard 
n:Alimarine;Artem
tel;home:(+31) 40-2440633
tel;work:(+31) 40-2763078
x-mozilla-html:TRUE
adr:;;;;;;
version:2.1
email;internet:aalimari@best.ms.philips.com
fn:Artem Alimarine
end:vcard


More information about the Gcc-bugs mailing list