aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cparser/Cerrors.ml16
-rw-r--r--cparser/Cerrors.mli3
-rwxr-xr-xdriver/Driver.ml2
3 files changed, 21 insertions, 0 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml
index 612980f1..e7b21dbb 100644
--- a/cparser/Cerrors.ml
+++ b/cparser/Cerrors.ml
@@ -321,3 +321,19 @@ let warning_help = "Diagnostic options:\n\
let raise_on_errors () =
if !num_errors > 0 then
raise Abort
+
+let crash exn =
+ if Version.buildnr <> "" && Version.tag <> "" then begin
+ eprintf "%tThis is CompCert, Release:%s, Build:%s, Tag:%s%t\n"
+ bc Version.version Version.buildnr Version.tag rsc;
+ eprintf "Backtrace (please include this in your support request):\n%s"
+ (Printexc.get_backtrace ());
+ eprintf "%tUncaught exception:%s.\n\
+\ Please report this problem to our support.\n\
+\ Error occurred in Build: %s, Tag: %s.\n%t"
+ rc (Printexc.to_string exn) Version.buildnr Version.tag rsc;
+ exit 2
+ end else begin
+ Printexc.print_backtrace stderr;
+ exit 2
+ end
diff --git a/cparser/Cerrors.mli b/cparser/Cerrors.mli
index 8501cfa0..b2350db6 100644
--- a/cparser/Cerrors.mli
+++ b/cparser/Cerrors.mli
@@ -72,3 +72,6 @@ val warning_options : (Commandline.pattern * Commandline.action) list
(** List of all options for diagnostics *)
val raise_on_errors : unit -> unit
+
+val crash: exn -> unit
+(** Report the backtrace of the last exception and exit *)
diff --git a/driver/Driver.ml b/driver/Driver.ml
index e3b9ec52..8fc52e0c 100755
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -552,3 +552,5 @@ let _ =
if Cerrors.check_errors () then exit 2
with Sys_error msg ->
eprintf "I/O error: %s.\n" msg; exit 2
+ | e ->
+ Cerrors.crash e