Commit Graph

59 Commits (master)

Author SHA1 Message Date
David Allsopp 692bd73123 OCAMLRUNPARAM=b=2 => load debuginfo
Load the debug information during runtime startup if OCAMLRUNPARAM=b=2.
This guards against the specific case of running out of fds, since the
debug information can't then be loaded.
2018-12-11 10:17:04 +01:00
David Allsopp 43b28fac00 Improve error messages when loading backtrace info
Before, any errors when loading bytecode backtrace information were
fatal and the error message was potentially misleading.
2018-12-11 08:54:49 +01:00
Stephen Dolan 523fba919b
Extend Printexc API for raw backtrace entries (#9663) 2020-07-13 11:13:12 +01:00
Guillaume Munch-Maccagnoni abe982165b Fix data race in at_exit and Printexc.register_printer with systhreads 2020-05-16 22:57:34 +02:00
Stephen Dolan 0040c5d783 Print function names (derived from Lambda.scoped_location) in backtraces
Function names now appear in backtraces and are available via Printexc.
2020-04-27 12:58:53 +01:00
Raphael Sousa Santos c9d7cc7da4 Add Printexc.default_uncaught_exception_handler (issue #9248)
Printexc.uncaught_exception_handler ceases to be an option ref and becomes
a ref to the handler function initialized to
Printexc.default_uncaught_exception_handler.
2020-01-26 12:00:27 +01:00
Andrew Litteken d4ef2eecea Custom Exception Handlers at toplevel (#8594)
fixes #7156 

Two new functions exposed:

```ocaml
val to_string_default: exn -> string
(** [Printexc.to_string_default e] returns a string representation of the
    exception [e], ignoring all registered exception printers.
    @since 4.09
*)

val use_printers: exn -> string option
(** [Printexc.use_printers e] returns [None] if there are no registered
    printers and [Some s] with else as the resulting string otherwise.
    @since 4.09
*)
```
2019-04-14 15:38:27 +02:00
yallop ee1c2a4d7e Add paths for built-in types (#1876)
* Add an Extension_constructor submodule to Obj.

Deprecate top-level functions extension_constructor / extension_name /
extension_id.

* Add 'true' and 'false' to the definition of Bool.t

* Add aliases for the built-in 'list' and 'array' types.

* Add an alias for 'exn' to Printexc.

* Changes entry: built-in type aliases

* Add a Unit module.

* Add paths for built-in exceptions.
2018-11-08 16:08:17 +01:00
Jérémie Dimino 9124ab82d1
Deprecate Pervasives (#1605)
- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.

- remove special case for Stdlib.Pervasives in printtyp.ml
2018-08-27 12:42:14 +01:00
Sébastien Hinderer d3e73595e5 Merge the asmrun and byterun directories into the runtime directory 2018-06-28 17:50:33 +02:00
François Bobot 50e9b96564 Recover "Merge pull request #378 from bobot/feature/reraise_raw_backtrace_primitive"
This reverts commit f1b63d4a57.
It is the second time #378 tried to be recovered (e6c779ada8).
2017-02-14 09:21:45 -05:00
Damien Doligez 0b4fbc2b30 fix whitespace, long lines, headers 2016-08-01 16:06:59 +02:00
Gabriel Scherer f1b63d4a57 Revert "Merge pull request #378 from bobot/feature/reraise_raw_backtrace_primitive"
This reverts commit 5adf895aac, reversing
changes made to 38c3db40c7.

The reason for the revert is a continuous integration failure on 32bit
arm machines. I don't have the time (or capabilities) to investigate
it right now, and we need functional continuous testing for other
upcoming merges, so the safest choice is to revert -- and hopefully
merge back after the issue is fixed.
2016-07-27 11:30:26 -04:00
François Bobot 757f512831 Simplify the definition of Printexc.get_backtrace 2016-07-17 22:37:03 +02:00
François Bobot 10f5095a15 Add `%reraise_raw_backtrace` primitive
It reraises an exception just after copying the given backtrace to the
  backtrace buffer. The C primitive `caml_restore_raw_backtrace` only does
  the copying part, the compiler adds the reraise.
2016-07-17 22:37:03 +02:00
Frédéric Bour 28dc832030 Make backtraces aware of inlining (#247) 2016-05-25 14:00:37 +01:00
Damien Doligez 520fb2df50 Merge tag 4.03.0 into trunk. 2016-04-28 16:13:21 +02:00
Alain Frisch 8557a86477 Also enable more warnings in stdlib/ and fix them. 2016-03-15 22:47:26 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Gabriel Scherer 755b19650b Reformulation of the user-facing slot-access API
- The internal [backtrace_slot] type is not exposed anymore, instead
  accessors function return orthogonal information
  (is_raise, location). This is both more extensible and more
  user-friendly.

- The [raw_backtrace_slot] is exposed separately as a low-level type
  that most users should never use. The unsafety of marshalling is
  documented. Instead of defining
  [raw_backtrace = raw_backtrace_slot array], I kept [raw_backtrace]
  an abstract type with [length] and [get] functions for
  random-access. This should allow us to change the implementation in
  the future to be more robust wrt. marshalling (boxing the trace in
  a Custom block, or even possibly the raw slots at access time).

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14784 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-10 19:20:00 +00:00
Gabriel Scherer cc6b2ca107 expose Printexc.format_backtrace_slot to facilitate testing
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14781 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-10 19:19:55 +00:00
Gabriel Scherer 1fdea57c4c Printexc: OCaml-friendly access to individual backtrace slots
(Patch by Jacques-Henri Jourdan)

There are several changes:

- `raw_backtrace` is no longer an abstract type, but rather an
  `raw_backtrace_slot array`, where `raw_backtrace_slot` is a new
  abstract type. `raw_backtrace_slot` elements are hashable and
  comparable. At runtime, values of this type contain either
  a bytecode pointer or a frame_descr pointer. In order to prevent the
  GC from walking through this pointer, the low-order bit is set to
  1 when stored in the array.

- The old `loc_info` type is know public, renamed into `backtrace_slot`:

      type backtrace_slot =
        | Known_location of bool   (* is_raise *)
                          * string (* filename *)
                          * int    (* line number *)
                          * int    (* start char *)
                          * int    (* end char *)
        | Unknown_location of bool (*is_raise*)

- new primitive :

    val convert_raw_backtrace_slot: raw_backtrace_slot -> backtrace_slot

  Rather than returning an option, it raises Failure when it is not
  possible to get the debugging information. It seems more idiomatic,
  especially because the exceptional case cannot appear only for a part
  of the executable.

- the caml_convert_raw_backtrace primitive is removed; it is more
  difficult to implement in the C side because of the new exception
  interface described above.

- In the bytecode runtime, the events are no longer deserialized once
  for each conversion, but once and for all at the first conversion,
  and stored in a global array (*outside* the OCaml heap), sorted by
  program counter value. I believe this information should not take
  much memory in practice (it uses the same order of magnitude memory
  as the bytecode executable). It also makes location lookup much more
  efficient, as a dichomoty is used instead of linear search as
  previously.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14776 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-10 19:19:47 +00:00
Jérémie Dimino d3ec5feb26 PR#5941: add Printexc.set_uncaught_exception_handler
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14643 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-18 15:36:08 +00:00
Alain Frisch 7bb3e64160 Do not introduce Obj.raw_tag.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/raise_variants@14270 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-11-06 10:57:20 +00:00
Alain Frisch 5ef2ee909f Support for exception values allocated in the static area (e.g. out of bound exception in native code).
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/raise_variants@14242 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-10-23 15:17:05 +00:00
Alain Frisch be3c4d6882 Add two functions to get the exception slot id and name from an exception value.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/raise_variants@14240 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-10-23 14:35:43 +00:00
Alain Frisch 0f6f367ad4 Change the representation of exception slots: instead of being represented as 'string ref', they are now blocks
of size 2, with tag = Object_tag, the first field being the pointer to the string, and second one being a unique id, generated
from the same sequence as for object values.  Special case for predefined exceptions, represented with a negative id.

The unique id generator is moved from camlinternalOO to the C runtime system.

Also fix some bugs.



git-svn-id: http://caml.inria.fr/svn/ocaml/branches/raise_variants@14239 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-10-23 14:28:31 +00:00
Alain Frisch 7334bb026a #5899: expose Printexc.get_callstack. (Cherry-picked 13884, 13885 from trunk.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13886 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-07-11 12:37:10 +00:00
Gabriel Scherer 725da3dcc9 user-exposed abstract type for raw backtraces in Printexc.ml (original patch from Jacques-Henri Jourdan)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13394 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-03-11 19:04:12 +00:00
Damien Doligez c63f9e0957 fix a few problems with whitespace and over-long lines
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13393 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-03-09 22:38:52 +00:00
Alain Frisch ba00d09386 Revert bad commit.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13268 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-01-23 08:41:02 +00:00
Alain Frisch 20a4b99758 #5902: adapt standard ppx driver to support extra arguments.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13267 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-01-23 08:37:01 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Alain Frisch 1cc8f999d8 Document that a dummy declaration is here to avoid a warning.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12505 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-29 12:37:01 +00:00
Alain Frisch a0a14c08fa Enable and fix more warnings.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12498 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-29 11:47:28 +00:00
Xavier Clerc cb7818e6de PR#5344: some predifined exceptions need special printing
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11187 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-09-08 08:34:43 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Alain Frisch e178c1ab62 Fix #5003: document the fact that expressions raised by exception printers are just ignored; custom printers are tried before hard-coded ones.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10272 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-04-19 12:25:46 +00:00
Damien Doligez 04b1656222 clean up spaces and tabs
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9547 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-01-22 12:48:24 +00:00
Damien Doligez bdc0fadee2 merge changes from release/3.11.1 to release/3.11.2
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9540 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-01-20 16:26:46 +00:00
Xavier Leroy 640b24249d Ability to print and capture exception backtraces (see stdlib module Printexc)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8839 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-03-14 13:47:24 +00:00
Damien Doligez 776a8d59b7 suppression support MacOS9
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6074 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-01-16 15:24:03 +00:00
Damien Doligez 306f79785d points-virgules mal places
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5386 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-01-21 12:57:33 +00:00
Damien Doligez ed3123ee87 changement des locations, premiere tranche
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5224 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-11-01 17:06:47 +00:00
Pierre Weis 6df4c2b6de Introducing (and using) string and string format coercions.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5211 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-10-31 10:00:02 +00:00
Pierre Weis a829d1d7d6 Using formats %S and %C.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4959 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-06-27 09:27:14 +00:00
Xavier Leroy 7501784c80 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-12-07 13:41:02 +00:00
Xavier Leroy cc0f32b054 Changement de la licence
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-11-17 18:59:06 +00:00
Xavier Leroy 67971438ee Noms symboliques pour les tags speciaux
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2107 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1998-10-01 12:34:32 +00:00
Damien Doligez 9704b7a5f5 Ajout de Printexc.to_string.
Suppression de Printexc.print_exn qui est redondant.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1589 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-06-12 15:29:01 +00:00