caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] line number for assert
@ 2001-09-11  9:39 Vesa Karvonen
  2001-09-11  9:51 ` David Mentre
  0 siblings, 1 reply; 8+ messages in thread
From: Vesa Karvonen @ 2001-09-11  9:39 UTC (permalink / raw)
  To: caml-list

Hi,

The assert primitive of Ocaml 3.02 (windows version) seems to print the source
file location as an offset from the beginning of the file rather than as a
line number and column.

Is there a particular reason for this?

The reason why I'm asking this is that it makes it much more difficult to find
the right assertion on most editors.

Is there a simple way to overcome this limitation?

I was thinking of the possibility of preprocessing the source code with some
simple preprocessor and using a home brewn assertion procedure, but I'd like
to hear about simpler solutions.

Regards,
  Vesa Karvonen


-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11  9:39 [Caml-list] line number for assert Vesa Karvonen
@ 2001-09-11  9:51 ` David Mentre
  2001-09-11 10:06   ` Markus Mottl
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Mentre @ 2001-09-11  9:51 UTC (permalink / raw)
  To: Vesa Karvonen; +Cc: caml-list

"Vesa Karvonen" <vesa.karvonen@housemarque.fi> writes:

> The assert primitive of Ocaml 3.02 (windows version) seems to print the source
> file location as an offset from the beginning of the file rather than as a
> line number and column.
> 
> Is there a particular reason for this?

Yes. Internally, the compiler knows only about character position. The
line number is computed (in fact the source file is reparsed) only when
an error message is printed:
  http://caml.inria.fr/archives/200011/msg00032.html

> The reason why I'm asking this is that it makes it much more difficult to find
> the right assertion on most editors.

Except with emacs. :)

> Is there a simple way to overcome this limitation?

As far as I know, no. However you should look at mailing list
archive. This topic has been discussed numerous times.

Best regards,
d.
-- 
 David.Mentre@inria.fr
 Opinions expressed here are only mine.
-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11  9:51 ` David Mentre
@ 2001-09-11 10:06   ` Markus Mottl
  2001-09-13  0:14     ` SooHyoung Oh
  2001-09-11 10:53   ` Sven
  2001-09-11 14:41   ` Vesa Karvonen
  2 siblings, 1 reply; 8+ messages in thread
From: Markus Mottl @ 2001-09-11 10:06 UTC (permalink / raw)
  To: David Mentre; +Cc: Vesa Karvonen, caml-list

On Tue, 11 Sep 2001, David Mentre wrote:
> > The reason why I'm asking this is that it makes it much more difficult to find
> > the right assertion on most editors.
> 
> Except with emacs. :)

And except with Vim. :)

Best regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11  9:51 ` David Mentre
  2001-09-11 10:06   ` Markus Mottl
@ 2001-09-11 10:53   ` Sven
  2001-09-11 13:49     ` Christian Lindig
  2001-09-11 14:41   ` Vesa Karvonen
  2 siblings, 1 reply; 8+ messages in thread
From: Sven @ 2001-09-11 10:53 UTC (permalink / raw)
  To: David Mentre; +Cc: Vesa Karvonen, caml-list

On Tue, Sep 11, 2001 at 11:51:50AM +0200, David Mentre wrote:
> "Vesa Karvonen" <vesa.karvonen@housemarque.fi> writes:
> 
> > The assert primitive of Ocaml 3.02 (windows version) seems to print the source
> > file location as an offset from the beginning of the file rather than as a
> > line number and column.
> > 
> > Is there a particular reason for this?
> 
> Yes. Internally, the compiler knows only about character position. The
> line number is computed (in fact the source file is reparsed) only when
> an error message is printed:
>   http://caml.inria.fr/archives/200011/msg00032.html
> 
> > The reason why I'm asking this is that it makes it much more difficult to find
> > the right assertion on most editors.
> 
> Except with emacs. :)
> 
> > Is there a simple way to overcome this limitation?
> 
> As far as I know, no. However you should look at mailing list
> archive. This topic has been discussed numerous times.

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.

Friendly,

Sven Luther
-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11 10:53   ` Sven
@ 2001-09-11 13:49     ` Christian Lindig
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Lindig @ 2001-09-11 13:49 UTC (permalink / raw)
  To: Caml Mailing List

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11  9:51 ` David Mentre
  2001-09-11 10:06   ` Markus Mottl
  2001-09-11 10:53   ` Sven
@ 2001-09-11 14:41   ` Vesa Karvonen
  2 siblings, 0 replies; 8+ messages in thread
From: Vesa Karvonen @ 2001-09-11 14:41 UTC (permalink / raw)
  To: caml-list

From: "David Menthe" <David.Mentre@inria.fr>
> "Vesa Karvonen" <vesa.karvonen@housemarque.fi> writes:
> > The reason why I'm asking this is that it makes it much more difficult to
find
> > the right assertion on most editors.
>
> Except with emacs. :)

Well, I guess we'll be using emacs on Ocaml projects, so I think that solves
the problem for us. However, I still think that the assertion should output a
line number (and column), because it is much more informative to human
readers.

Regards,
  Vesa Karvonen


-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-11 10:06   ` Markus Mottl
@ 2001-09-13  0:14     ` SooHyoung Oh
  2001-09-13  8:46       ` Markus Mottl
  0 siblings, 1 reply; 8+ messages in thread
From: SooHyoung Oh @ 2001-09-13  0:14 UTC (permalink / raw)
  To: Markus Mottl; +Cc: caml-list


Could you explain how to use "vim" for assert?

---
SooHyoung Oh
----- Original Message -----
From: "Markus Mottl" <markus@mail4.ai.univie.ac.at>
To: "David Mentre" <David.Mentre@inria.fr>
Cc: "Vesa Karvonen" <vesa.karvonen@housemarque.fi>; <caml-list@inria.fr>
Sent: Tuesday, September 11, 2001 7:06 PM
Subject: Re: [Caml-list] line number for assert


> On Tue, 11 Sep 2001, David Mentre wrote:
> > > The reason why I'm asking this is that it makes it much more difficult
to find
> > > the right assertion on most editors.
> >
> > Except with emacs. :)
>
> And except with Vim. :)
>
> Best regards,
> Markus Mottl
>
> --
> Markus Mottl                                             markus@oefai.at
> Austrian Research Institute
> for Artificial Intelligence                  http://www.oefai.at/~markus
> -------------------
> 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

-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] line number for assert
  2001-09-13  0:14     ` SooHyoung Oh
@ 2001-09-13  8:46       ` Markus Mottl
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Mottl @ 2001-09-13  8:46 UTC (permalink / raw)
  To: SooHyoung Oh; +Cc: caml-list

On Thu, 13 Sep 2001, SooHyoung Oh wrote:
> Could you explain how to use "vim" for assert?

Sure: just take a look at the char number you want to jump to and say,
for example, ":go 1234" to jump to char 1234.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-09-13  8:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-11  9:39 [Caml-list] line number for assert Vesa Karvonen
2001-09-11  9:51 ` David Mentre
2001-09-11 10:06   ` Markus Mottl
2001-09-13  0:14     ` SooHyoung Oh
2001-09-13  8:46       ` Markus Mottl
2001-09-11 10:53   ` Sven
2001-09-11 13:49     ` Christian Lindig
2001-09-11 14:41   ` Vesa Karvonen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).