aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cerrors.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2017-01-17 09:49:04 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2017-01-17 09:49:04 +0100
commit43db836ea4fb19036a19f78e1f988f75a42b910c (patch)
treea653f92b566735e85386715165a783afbfb54839 /cparser/Cerrors.ml
parent747ad5bd8c364684256fc7dd306cd475401fe1b0 (diff)
downloadcompcert-43db836ea4fb19036a19f78e1f988f75a42b910c.tar.gz
compcert-43db836ea4fb19036a19f78e1f988f75a42b910c.zip
Added backtrace handler.
If CompCert crashes because of an uncaught exception the exception is caught toplevel and the backtrace is printed plus an additional message to include the backtrace in a support request, if buildnr and tag are available. Bug 20681.
Diffstat (limited to 'cparser/Cerrors.ml')
-rw-r--r--cparser/Cerrors.ml16
1 files changed, 16 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