Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print innermost backtrace mark for uncaught exception even with backtrace printing off #1619

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/util/backtrace/goblint_backtrace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ let print_marktrace oc e =
Printf.fprintf oc "Marked with %s\n" (mark_to_string m)
) ms

let print_innermost_mark oc e =
match find_marks e with
| m :: _ -> Printf.fprintf oc "Marked with %s\n" (mark_to_string m)
| [] -> ()

let () =
Printexc.set_uncaught_exception_handler (fun e bt ->
(* Copied & modified from Printexc.default_uncaught_exception_handler. *)
Printf.eprintf "Fatal error: exception %s\n" (Printexc.to_string e); (* nosemgrep: print-not-logging *)
if Printexc.backtrace_status () then
print_marktrace stderr e;
print_marktrace stderr e
else
print_innermost_mark stderr e;
Printexc.print_raw_backtrace stderr bt;
flush stderr
)
5 changes: 5 additions & 0 deletions src/util/backtrace/goblint_backtrace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ val print_marktrace: out_channel -> exn -> unit

Used by default for uncaught exceptions. *)

val print_innermost_mark: out_channel -> exn -> unit
(** Print innermost mark of an exception.

Used by default for uncaught exceptions. *)

val find_marks: exn -> mark list
(** Find all marks of an exception. *)
Loading