Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005044OCamlOCaml generalpublic2010-05-04 16:022014-05-25 20:24
Assigned To 
PlatformOSOS Version
Product Version 
Target Version4.02.0+devFixed in Version 
Summary0005044: Emacs doesn't recognize the backtrace error location format
DescriptionBacktrace error locations are not printed in the standard format recognized by emacs. The backtrace format is the following :

  Raised at file "", line 191, characters 24-64
  Called from file "", line 69, characters 12-15

The compiler usually produces an error message formatted like this :

  File "", line 147, characters 2-9:
TagsNo tags attached.
Attached Files

- Relationships
related to 0004628closed emacs mode: allow the use of next error with stack traces 
related to 0005070assigneddoligez Error location output not supported by emacs 

-  Notes
dbuenzli (reporter)
2010-05-04 17:46

Which version are you using ?

This should be fixed in 3.11 see [^]

bluestorm (reporter)
2010-05-05 12:16

You are right, it is fixed under 3.11. Thanks for your patch, and sorry for not searching mantis before reporting.

It's strange that we can't access the character positions of the error message. I don't understand the precise use of the error regexps internal to the Caml mode, but I had a look at emacs compilation-error-regexp-alist documentation, and I came with the following fix, wich works fine in my .emacs :

  (defun caml-change-error-alist-for-backtraces ()
    "Hook to change the compilation-error-regexp-alist variable, to
     search the ocaml backtraces for error locations"
      (setq compilation-error-regexp-alist-alist
  "^ *\\(?:Raised at\\|Called from\\) file \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1,\
   lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
  \\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:?\\)?\\)"
                2 (3 . 4) (5 . 6)))
      (setq compilation-error-regexp-alist
            (append compilation-error-regexp-alist '(caml-backtrace)))))
  (add-hook 'caml-mode-hook 'caml-change-error-alist-for-backtraces)

(The regexp is mainly an adaptation of the 'caml' regexp preset in emacs compile.el)

I also have the following, to spot error positions in assert failures (Assert_failure("", 1, 11)) :

  (defun caml-change-error-alist-for-assert-failure ()
    "Hook to change the compilation-error-regexp-alist variable, to
     search the assert failure messages for error locations"
      (setq compilation-error-regexp-alist-alist
                "Assert_failure(\"\\([^,\" \n\t<>]+\\)\", \\([0-9]+\\), \\([0-9]+\\))"
                1 2 3))
      (setq compilation-error-regexp-alist
            (append compilation-error-regexp-alist '(caml-assert-failure)))))
  (add-hook 'caml-mode-hook 'caml-change-error-alist-for-assert-failure)

Would it be possible to integrate something similar in caml.el ?
doligez (administrator)
2013-07-10 19:51

In 4.01.0+dev, the backtrace works fine, including the character positions.

I'm turning this into a feature wish to make it work also for assert failures.

- Issue History
Date Modified Username Field Change
2010-05-04 16:02 bluestorm New Issue
2010-05-04 17:46 dbuenzli Note Added: 0005446
2010-05-05 12:16 bluestorm Note Added: 0005447
2011-06-01 22:52 doligez Relationship added related to 0004628
2011-06-01 22:52 doligez Status new => acknowledged
2012-02-14 10:16 gasche Relationship added related to 0005070
2012-09-06 16:43 doligez Target Version => 4.00.1+dev
2012-09-18 13:09 doligez Target Version 4.00.1+dev => 4.00.2+dev
2013-07-10 19:51 doligez Note Added: 0009749
2013-07-10 19:51 doligez Severity tweak => feature
2013-07-10 19:51 doligez Target Version 4.00.2+dev => 4.02.0+dev
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2014-05-25 20:24 doligez Target Version 4.01.1+dev => 4.02.0+dev

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker