caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
@ 2004-01-05 19:27 Aleksey Nogin
  2004-01-05 20:18 ` Damien Doligez
  0 siblings, 1 reply; 11+ messages in thread
From: Aleksey Nogin @ 2004-01-05 19:27 UTC (permalink / raw)
  To: Caml List

I noticed that in 3.07 the backtrace (OCAMLRUNPARAM=b) has empty file 
names for the files was compiled with a camlp4 preprocessor. Since in 
our project most of the files are camlp4-processed, this makes the 
backtraces completely unusable :-(

Is there some workaround for this (short of staying with 3.06)?

P.S. I filed PR #2022 on this one - 
http://caml.inria.fr/bin/caml-bugs/incoming?id=2022

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Jorgensen 70, tel: (626) 395-2907

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-05 19:27 [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name? Aleksey Nogin
@ 2004-01-05 20:18 ` Damien Doligez
  2004-01-07  5:47   ` Aleksey Nogin
  2004-01-08  8:17   ` Stefano Zacchiroli
  0 siblings, 2 replies; 11+ messages in thread
From: Damien Doligez @ 2004-01-05 20:18 UTC (permalink / raw)
  To: Aleksey Nogin; +Cc: Caml List

On Monday, January 5, 2004, at 08:27 PM, Aleksey Nogin wrote:

> I noticed that in 3.07 the backtrace (OCAMLRUNPARAM=b) has empty file 
> names for the files was compiled with a camlp4 preprocessor. Since in 
> our project most of the files are camlp4-processed, this makes the 
> backtraces completely unusable :-(
>
> Is there some workaround for this (short of staying with 3.06)?

You can try this patch, developed by Artem Prysyznuk.  We haven't
incorporated it because we are doing extensive changes to camlp4
to deal correctly with new-style locations.  Please let me know
whether it works for you.

-- Damien

---------- begin patch file

diff -ru ocaml-3.07/camlp4/camlp4/argl.ml 
ocaml-3.07.tema/camlp4/camlp4/argl.ml
--- ocaml-3.07/camlp4/camlp4/argl.ml	2003-07-10 15:28:14.000000000 +0300
+++ ocaml-3.07.tema/camlp4/camlp4/argl.ml	2003-11-06 17:43:28.000000000 
+0200
@@ -397,11 +397,12 @@
            exit 2
          } ];
      try
-      if Pcaml.input_file.val <> "" then
+      if Pcaml.input_file.val <> "" then do {
+        Ast2pt.glob_fname.val := Pcaml.input_file.val;
          match file_kind.val with
          [ Intf -> process_intf ()
          | Impl -> process_impl () ]
-      else ()
+      } else ()
      with exc ->
        do {
          Format.set_formatter_out_channel stderr;
diff -ru ocaml-3.07/camlp4/camlp4/ast2pt.mli 
ocaml-3.07.tema/camlp4/camlp4/ast2pt.mli
--- ocaml-3.07/camlp4/camlp4/ast2pt.mli	2002-07-19 17:53:44.000000000 
+0300
+++ ocaml-3.07.tema/camlp4/camlp4/ast2pt.mli	2003-11-06 
17:43:28.000000000 +0200
@@ -12,6 +12,7 @@

  (* $Id: ast2pt.mli,v 1.3 2002/07/19 14:53:44 mauny Exp $ *)

+value glob_fname : ref string;
  value fast : ref bool;
  value no_constructors_arity : ref bool;
  value mkloc : (int * int) -> Location.t;

---------- end patch file

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-05 20:18 ` Damien Doligez
@ 2004-01-07  5:47   ` Aleksey Nogin
  2004-01-07 12:50     ` Damien Doligez
  2004-01-08  8:17   ` Stefano Zacchiroli
  1 sibling, 1 reply; 11+ messages in thread
From: Aleksey Nogin @ 2004-01-07  5:47 UTC (permalink / raw)
  To: Damien Doligez; +Cc: Caml List

On 05.01.2004 12:18, Damien Doligez wrote:

> You can try this patch, developed by Artem Prysyznuk.  We haven't
> incorporated it because we are doing extensive changes to camlp4
> to deal correctly with new-style locations.  Please let me know
> whether it works for you.

It works, but produces results that are slightly (but insignificantly) 
different from the ones that I get without camlp4. For example:

with camlp4:

> Raised by primitive operation at file "unify_mm.ml", line 1, character 20504
> Re-raised at file "unify_mm.ml", line 1, character 22067
> Called from file "unify_mm.ml", line 1, character 27263
...

Without:

> Fatal error: exception Out_of_memory
> Raised by primitive operation at file "unify_mm.ml", line 560, character 63
> Re-raised at file "unify_mm.ml", line 595, character 11
> Called from file "unify_mm.ml", line 707, character 76
...

Character 20504 in the file is indeed "line 560, character 63", but 
"character 22067" is not the same as "line 595, character 11".

the code in question is:

          ...
       else begin
          if ...

and non-camlp4 "line 595, character 11" one points to the space between 
"else" and "begin", while camlp4's "character 22067" points to the space 
right before the "if".

P.S. Why would an exception (supposedly raised inside the "true" branch 
of an if) be re-raised at the end of the "if" branch?

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Jorgensen 70, tel: (626) 395-2907

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-07  5:47   ` Aleksey Nogin
@ 2004-01-07 12:50     ` Damien Doligez
  2004-01-08  1:29       ` Aleksey Nogin
  0 siblings, 1 reply; 11+ messages in thread
From: Damien Doligez @ 2004-01-07 12:50 UTC (permalink / raw)
  To: Caml List

On Wednesday, January 7, 2004, at 06:47 AM, Aleksey Nogin wrote:

> Character 20504 in the file is indeed "line 560, character 63", but 
> "character 22067" is not the same as "line 595, character 11".
>
> the code in question is:
>
>          ...
>       else begin
>          if ...
>
> and non-camlp4 "line 595, character 11" one points to the space 
> between "else" and "begin", while camlp4's "character 22067" points to 
> the space right before the "if".

In both cases, it's not the space right before, but the first character
of.  Because we used zero-based character numbers (the first character 
of
the line is character 0).

If you're interested in the reasons for the difference, here is the
story:

begin...end is like a pair of parentheses.  It is used by the parser
to disambiguate the expression, but it doesn't appear explicitely
in the abstract syntax tree.  Hence we have to choose, when we parse
"begin 1 + 2 end" whether the location of the expression is only
the inner expression "1 + 2" or the whole thing.

Originally, it was the inner expression, because it's the natural
way of writing the parser.  I changed it for cosmetic reasons related
to type display (option -dtypes and caml-types.el).  I changed it
in the yacc-based parser but not (yet) in the camlp4 parsers, hence
the discrepancy.

> P.S. Why would an exception (supposedly raised inside the "true" 
> branch of an if) be re-raised at the end of the "if" branch?

I don't know.  Maybe because the "inside" is a call to a primitive, and
the "if branch" is the smallest OCaml expression that contains it ?

-- Damien

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-07 12:50     ` Damien Doligez
@ 2004-01-08  1:29       ` Aleksey Nogin
  0 siblings, 0 replies; 11+ messages in thread
From: Aleksey Nogin @ 2004-01-08  1:29 UTC (permalink / raw)
  To: Damien Doligez; +Cc: Caml List

On 07.01.2004 04:50, Damien Doligez wrote:

> begin...end is like a pair of parentheses. [...]  I changed it
> in the yacc-based parser but not (yet) in the camlp4 parsers, hence
> the discrepancy.

Yes, that's what I figured, thanks!

>> P.S. Why would an exception (supposedly raised inside the "true" 
>> branch of an if) be re-raised at the end of the "if" branch?
> 
> 
> I don't know.  Maybe because the "inside" is a call to a primitive, and
> the "if branch" is the smallest OCaml expression that contains it ?

No, all the expressions were nested pretty deeply. But there were some 
"try ... with Not_found -> ..." nested there, so I am guessing one of 
them was causing the exception to be caught and re-raised...

Anyway, once I cleaned the code a bit, the weirdness went away. Now the 
only remaining weirdness that I see is that the innermost frame is 
missing from backtrace when the exception was raised from C - PR #2030; 
this one however is common to both 3.06 and 3.07+13 CVS.

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Jorgensen 70, tel: (626) 395-2907

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-05 20:18 ` Damien Doligez
  2004-01-07  5:47   ` Aleksey Nogin
@ 2004-01-08  8:17   ` Stefano Zacchiroli
  2004-01-08  9:49     ` Damien Doligez
  1 sibling, 1 reply; 11+ messages in thread
From: Stefano Zacchiroli @ 2004-01-08  8:17 UTC (permalink / raw)
  To: Caml List

On Mon, Jan 05, 2004 at 09:18:31PM +0100, Damien Doligez wrote:
> You can try this patch, developed by Artem Prysyznuk.  We haven't
> incorporated it because we are doing extensive changes to camlp4
> to deal correctly with new-style locations.  Please let me know
> whether it works for you.

Do this patch change also the output format of -dtypes option when used
in combination with camlp4? Actually while using camlp4, the .annot file
generated uses offsets that are all referred to the beginning of file;
while not using camlp4 offsets are referred to the beginning of each
line.

I'm asking because I've written vim support for .annot files, but
actually it works only with non camlp4 generated .annot files ...

Cheers.

-- 
^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$
^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$
^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$
^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-08  8:17   ` Stefano Zacchiroli
@ 2004-01-08  9:49     ` Damien Doligez
  2004-01-08 15:38       ` skaller
  2004-01-09  8:41       ` Stefano Zacchiroli
  0 siblings, 2 replies; 11+ messages in thread
From: Damien Doligez @ 2004-01-08  9:49 UTC (permalink / raw)
  To: Caml List

On Thursday, January 8, 2004, at 09:17 AM, Stefano Zacchiroli wrote:

> Do this patch change also the output format of -dtypes option when used
> in combination with camlp4?

Yes.  It changes the annotations in the parse tree, which are used
for the debugger, the -dtypes option, error messages, backtrace, etc.

>  Actually while using camlp4, the .annot file
> generated uses offsets that are all referred to the beginning of file;
> while not using camlp4 offsets are referred to the beginning of each
> line.

The missing file name can be considered a bug.  Otherwise, there are
two possible formats: the old format (line 1, offset from the
beginning of the file) and the new format (line, character).  We are
working to get rid of the old format before the next release of
O'Caml.

> I'm asking because I've written vim support for .annot files, but
> actually it works only with non camlp4 generated .annot files ...

If possible, you shouldn't count on the line number to be exact.
Start at the beginning of the line, and go forward the given number
of characters.  Most of the time, you won't encounter any line break,
but that's not strongly guaranteed.

-- Damien

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-08  9:49     ` Damien Doligez
@ 2004-01-08 15:38       ` skaller
  2004-01-09 10:46         ` Damien Doligez
  2004-01-09  8:41       ` Stefano Zacchiroli
  1 sibling, 1 reply; 11+ messages in thread
From: skaller @ 2004-01-08 15:38 UTC (permalink / raw)
  To: Damien Doligez; +Cc: Caml List

On Thu, 2004-01-08 at 20:49, Damien Doligez wrote:

> The missing file name can be considered a bug.  Otherwise, there are
> two possible formats: the old format (line 1, offset from the
> beginning of the file) and the new format (line, character).  We are
> working to get rid of the old format before the next release of
> O'Caml.

Are you also teaching it to respect the original source
file name? Ocamlyacc/lex doen't seem to allow for that either.

-- 
John Max Skaller, mailto:skaller@tpg.com.au
snail:25/85c Wigram Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850. Checkout Felix: http://felix.sf.net




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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-08  9:49     ` Damien Doligez
  2004-01-08 15:38       ` skaller
@ 2004-01-09  8:41       ` Stefano Zacchiroli
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Zacchiroli @ 2004-01-09  8:41 UTC (permalink / raw)
  To: Caml List

On Thu, Jan 08, 2004 at 10:49:17AM +0100, Damien Doligez wrote:
> The missing file name can be considered a bug.  Otherwise, there are
> two possible formats: the old format (line 1, offset from the
> beginning of the file) and the new format (line, character).  We are
> working to get rid of the old format before the next release of

Is the new format already used in some cases by the 3.07 compiler?

Cheers.

-- 
^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$
^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$
^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$
^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-08 15:38       ` skaller
@ 2004-01-09 10:46         ` Damien Doligez
  2004-01-10 11:15           ` skaller
  0 siblings, 1 reply; 11+ messages in thread
From: Damien Doligez @ 2004-01-09 10:46 UTC (permalink / raw)
  To: Caml List

On Thursday, January 8, 2004, at 04:38 PM, skaller wrote:

> Are you also teaching it to respect the original source
> file name?

If you mean to heed the cpp-like "# <line> <file>" annotations
then yes, that is planned.

>  Ocamlyacc/lex doen't seem to allow for that either.

I'm not sure I understand this remark.  ocamlyacc and ocamllex
do insert these annotations in the code they generate.


On Friday, January 9, 2004, at 09:41 AM, Stefano Zacchiroli wrote:

> Is the new format already used in some cases by the 3.07 compiler?

The 3.07 compiler itself uses the new format.  Only camlp4 and
ocamldebug are still on the old format.

-- Damien

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


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

* Re: [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name?
  2004-01-09 10:46         ` Damien Doligez
@ 2004-01-10 11:15           ` skaller
  0 siblings, 0 replies; 11+ messages in thread
From: skaller @ 2004-01-10 11:15 UTC (permalink / raw)
  To: Damien Doligez; +Cc: Caml List

On Fri, 2004-01-09 at 21:46, Damien Doligez wrote:
> On Thursday, January 8, 2004, at 04:38 PM, skaller wrote:
> 
> > Are you also teaching it to respect the original source
> > file name?
> 
> If you mean to heed the cpp-like "# <line> <file>" annotations

Yes, that's what I mean.

> then yes, that is planned.

Good, thanks!

> >  Ocamlyacc/lex doen't seem to allow for that either.
> 
> I'm not sure I understand this remark.  ocamlyacc and ocamllex
> do insert these annotations in the code they generate.

Yeah, but they do not *read* annotations inserted by
the program that generated the .mll and .mly files
as far as I know?

BTW: is there any plan to fix the parser so it uses an abstract
token source, rather than a lexbuf? 

This seems a good use for classes, but the parser requests for
source information (as well as tokens) must somehow be made into 
user plugable function calls.

My parsers are all completely separated from the lexer.
I encode locations in each token. Using a lexbuf to do that
is impossible: I have to process #include like directives
which of course create a stack of lexbufs. Thus there is no
possibility a single real lexbuf permanently attached to
the parser makes any sense for me .. 

Lexing is expensive .. storing the location in each
lexbuf variable even if you're not recursing down include
files would be quite expensive .. just so the parser
can report an error which may not exist.

-- 
John Max Skaller, mailto:skaller@tpg.com.au
snail:25/85c Wigram Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850. Checkout Felix: http://felix.sf.net




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


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

end of thread, other threads:[~2004-01-10 11:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-05 19:27 [Caml-list] 3.07: debug information on camlp4-processed files is missing the file name? Aleksey Nogin
2004-01-05 20:18 ` Damien Doligez
2004-01-07  5:47   ` Aleksey Nogin
2004-01-07 12:50     ` Damien Doligez
2004-01-08  1:29       ` Aleksey Nogin
2004-01-08  8:17   ` Stefano Zacchiroli
2004-01-08  9:49     ` Damien Doligez
2004-01-08 15:38       ` skaller
2004-01-09 10:46         ` Damien Doligez
2004-01-10 11:15           ` skaller
2004-01-09  8:41       ` Stefano Zacchiroli

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