On 2009-01-18 07:39:51, Christoph Mallon wrote: > > Are more C functions involved? E.g. is the function pointer passed to > qsort(), which lives in libc, which is not compiled with -fexceptions. > Look at the stack trace when the exception occurs. In gdb you can use the > command "catch throw" (sic) to break when an exception gets thrown. > Conversely you can break at the catcher with "catch catch" (if it gets this > far).
Unfortunately not. That was the first thing I looked at. Here's the complete test: /* c_function.c */ #include <stdio.h> void c_function (void (*func)(int x)) { printf ("-- %s enter\n", __func__); func (23); printf ("-- %s exit\n", __func__); } -- ada_main.adb with interfaces.c; with ada.text_io; procedure ada_main is package c renames interfaces.c; test_error : exception; procedure ext_function (x : in c.int) is begin ada.text_io.put_line ("-- ext_function " & c.int'image (x)); raise test_error; end ext_function; procedure c_function (process : access procedure (x : in c.int)); pragma import (c, c_function, "c_function"); begin ada.text_io.put_line ("-- ada_main entry"); c_function (ext_function'access); exception when test_error => ada.text_io.put_line ("-- ada_main caught test_error"); end ada_main; Compilation: gcc43 -o c_function.o -c c_function.c -fPIC -fexceptions -g -W -Werror -Wall -std=c99 -pedantic-errors -Wno-unused-parameter gcc43 -shared -Wl,-soname,c_function.so -o c_function.so c_function.o -lc gcc43 -o ada_main.o -c ada_main.adb -g -fstack-check -gnatwaleFG -gnatVa -gnato -gnata gnatbind ada_main.ali gnatlink -o main-dynamic ada_main.ali c_function.so gnatbind ada_main.ali gnatlink -o main-static ada_main.ali c_function.o $ LD_LIBRARY_PATH=. ldd c_function.so c_function.so: libc.so.6 => /lib/libc.so.6 (0x2807d000) libgcc_s.so.1 => /usr/local/lib/gcc-4.2.3/libgcc_s.so.1 (0x28170000) Test: $ ./main-static -- ada_main entry -- c_function enter -- ext_function 23 -- ada_main caught test_error $ LD_LIBRARY_PATH=. ./main-dynamic -- ada_main entry -- c_function enter -- ext_function 23 raised ADA_MAIN.TEST_ERROR : ada_main.adb:15 $ LD_LIBRARY_PATH=. gdb68 ./main-dynamic (gdb) catch exception Catchpoint 1: all Ada exceptions (gdb) b __gnat_os_exit Breakpoint 2 at 0x805851b: file adaint.c, line 2116. (gdb) r Catchpoint 1, ADA_MAIN.TEST_ERROR at 0x08049cda in ada_main.ext_function (x=23) at ada_main.adb:15 15 raise test_error; (gdb) bt #0 <__gnat_debug_raise_exception> (e=0x8061168) at s-except.adb:48 #1 0x0804b620 in <__gnat_raise_nodefer_with_msg> (e=0x8061168) at a-except.adb:830 #2 0x0804b698 in <__gnat_raise_exception> (e=0x8061168, message=0x8061168) at a-except.adb:870 #3 0x08049cda in ada_main.ext_function (x=23) at ada_main.adb:15 #4 0x280927ae in c_function (func=0x8049bf8 <ada_main.ext_function>) at c_function.c:9 #5 0x08049b5c in ada_main () at ada_main.adb:24 (gdb) c Breakpoint 2, __gnat_os_exit (status=1) at adaint.c:2116 (gdb) bt #0 __gnat_os_exit (status=1) at adaint.c:2116 #1 0x0805a41e in __gnat_unhandled_terminate () at raise.c:78 #2 0x0805a1f1 in <__gnat_last_chance_handler> (exce...@0x8071000) at a-elchha.adb:138 #3 0x0804ae14 in ada.exceptions.exception_traces.unhandled_exception_terminate () at a-exextr.adb:175 #4 0x0804aad2 in ada.exceptions.exception_propagation.cleanupunwind_handler (uw_version=1, uw_phases=10, uw_eclass=5138137877735301376, uw_exception=0xa, uw_context=3217024852, uw_argument=0, <uw_exceptionF>=134587758) at a-exexpr.adb:369 #5 0x0805c282 in _Unwind_ForcedUnwind_Phase2 (exc=0x806f000, context=0xbfbfe754) at ../.././..//gcc-4.3.2/libgcc/../gcc/unwind.inc:168 #6 0x0805c4d6 in _Unwind_Resume (exc=0x806f000) at ../.././..//gcc-4.3.2/libgcc/../gcc/unwind.inc:237 #7 0x08049cfa in ada_main.ext_function (x=23) at ada_main.adb:16 #8 0x280927ae in c_function (func=0x8049bf8 <ada_main.ext_function>) at c_function.c:9 #9 0x08049b5c in ada_main () at ada_main.adb:24 _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"