Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] line number for assert
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Lindig <lindig@e...>
Subject: Re: [Caml-list] line number for assert
On Tue, Sep 11, 2001 at 12:53:25PM +0200, Sven wrote:
> What about a little tool to be added to the ocaml distribution, which parses a
> file, and convert the char number to line number + column. I guess, from what
> is already done by the toplevel, that this would be trivial to implement, as
> all the code for it is already written.

I have written a little tool that takes a stack trace on stdin,
annotates it with line numbers, and writes the annotated stack trace to
stdout. It also honors #line directives in the source file and thus can
deal with ocamlyacc and the OCaml preprocessor sources (I guess). Here
it is called with a list of directories to search for sources on the
command line. Errors in files that it fails to find the source code for
come out un-annotated. If I had included /usr/local/lib/ocaml in the
list of directories on the command line, the locations in the library
files would have been found, too.

    tools $ ./ocamlerror ../src ../lua < trace.txt 
    Fatal error: uncaught exception Assert_failure("cfg3.ml", 17778, 17790) (cfg3.nw: 1475, column 7)
    Raised at unknown location
    Called from module Set, character 8365
    Called from module Set, character 8360
    Called from module Set, character 8360
    Called from module Set, character 8360
    Called from module Cfg3, character 31510 (cfg3.nw: 580, column 126)
    Called from module Astasm, character 4745 (astasm.nw: 244, column 33)
    Called from module List, character 1783
    Called from module List, character 1783
    Called from module Ast3ir, character 30374 (ast3ir.nw: 1168, column 222)
    Called from module Luavalue, character 10485 (luavalue.nw: 390, column 7)
    Called from module Luainterp, character 3637 (luainterp.nw: 185, column 23)
    Called from module Luainterp, character 13688 (luainterp.nw: 466, column 22)
    Called from module Luainterp, character 14603 (luainterp.nw: 495, column 23)
    Re-raised at module Luainterp, character 14629 (luainterp.nw: 495, column 49)
    Called from module Luainterp, character 3637 (luainterp.nw: 185, column 23)
    Called from module Luabaselib, character 683 (luabaselib.nw: 83, column 16)
    Called from module Luainterp, character 14603 (luainterp.nw: 495, column 23)
    Re-raised at module Luainterp, character 14629 (luainterp.nw: 495, column 49)
    Called from module Main2, character 3219 (main2.nw: 156, column 42)
    Called from module List, character 1783
    Called from module Main2, character 4056 (main2.nw: 175, column 24)
    Called from module Main2, character 4324 (main2.nw: 190, column 9)


The tool is part of a larger project and not polished for publication.
It comes with a shell script to build it, a man page and a BSD style
license. 

http://www.eecs.harvard.edu/~lindig/software/download/ocamlerror.tar.gz

Would this be useful for the next release? I could do some polishing if
people think so.

-- Christian

-- 
Christian Lindig          Harvard University - DEAS
lindig@eecs.harvard.edu   33 Oxford St, MD 242, Cambridge MA 02138
phone: +1 (617) 496-7157  http://www.eecs.harvard.edu/~lindig/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr