From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA05435; Sun, 8 Sep 2002 00:31:35 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA05591 for ; Sun, 8 Sep 2002 00:31:34 +0200 (MET DST) Received: from c007.snv.cp.net (h011.c007.snv.cp.net [209.228.33.239]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g87MVX114253 for ; Sun, 8 Sep 2002 00:31:33 +0200 (MET DST) Received: (cpmta 21292 invoked from network); 7 Sep 2002 15:31:31 -0700 Received: from 65.187.194.217 (HELO localhost) by smtp.directvinternet.com (209.228.33.239) with SMTP; 7 Sep 2002 15:31:31 -0700 X-Sent: 7 Sep 2002 22:31:31 GMT Date: Sat, 7 Sep 2002 18:33:56 -0400 Mime-Version: 1.0 (Apple Message framework v482) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: [Caml-list] how to add a primitive to Pervasives? From: jehenrik To: caml-list@inria.fr Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.482) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I tried to hack with the sources to be able to turn on stack backtracing in the toplevel. I realize I'm breaking the "no consumer serviceable parts inside, breaking this seal will void warranty" sticker, but I'd be happy if someone could explain to me why my approach is not working. Rather than being completely sure if it would work, I decided to try to just write this function and add it to Pervasives: CAMLprim value start_backtrace_c() { init_backtrace(); return Val_unit; } Judging by the function sys_exit, there are four other places that the function apparently must be added to show up: % grep -c -r sys_exit * |grep -v :0 boot/ocamlc:2 boot/ocamllex:1 byterun/main.c:1 // no this one is special for sys_exit byterun/sys.c:1 byterun/sys.h:1 byterun/win32.c:1 // this too otherlibs/threads/pervasives.ml:2 stdlib/pervasives.ml:2 So I add them all, in the obvious ways: % grep -c -r start_backtrace * |grep -v :0 byterun/sys.c:1 byterun/sys.h:1 otherlibs/threads/pervasives.ml:2 stdlib/pervasives.ml:2 stdlib/pervasives.mli:1 During make, this causes various files like prim.c to be contain copies, and everything seems to work until linking ocamlc fails: boot/ocamlrun boot/ocamlc -I boot -o ocamlc utils/misc.cmo utils/tbl.cmo utils/config.cmo utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo parsing/linenum.cmo parsing/location.cmo parsing/longident.cmo parsing/syntaxerr.cmo parsing/parser.cmo parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo typing/ident.cmo typing/path.cmo typing/primitive.cmo typing/types.cmo typing/btype.cmo typing/subst.cmo typing/predef.cmo typing/datarepr.cmo typing/env.cmo typing/typedtree.cmo typing/ctype.cmo typing/printtyp.cmo typing/includeclass.cmo typing/mtype.cmo typing/includecore.cmo typing/includemod.cmo typing/parmatch.cmo typing/typetexp.cmo typing/typecore.cmo typing/typedecl.cmo typing/typeclass.cmo typing/typemod.cmo bytecomp/lambda.cmo bytecomp/printlambda.cmo bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo bytecomp/translobj.cmo bytecomp/translcore.cmo bytecomp/translclass.cmo bytecomp/translmod.cmo bytecomp/simplif.cmo bytecomp/runtimedef.cmo bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo bytecomp/bytesections.cmo bytecomp/dll.cmo bytecomp/symtable.cmo bytecomp/bytelibrarian.cmo bytecomp/bytelink.cmo driver/errors.cmo driver/compile.cmo driver/main_args.cmo driver/main.cmo Error while linking boot/stdlib.cma(Pervasives): The external function `start_backtrace_c' is not available I also tried something similar putting a directive and an external in toplevel/topdirs.ml, this time modeling after the external symbol get_current_environment. But I have the same problem, I don't understand how to cross over from the c symbol world to a caml environment.: boot/ocamlrun boot/ocamlc -I boot -linkall -o ocaml.tmp toplevel/toplevellib.cma toplevel/topmain.cmo Error while linking toplevel/toplevellib.cma(Topdirs): The external function `init_backtrace' is not available make: *** [ocaml] Error 2 Thanks again for tolerating my mucking around. Jeff Henrikson ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners