Skip to content

Commit b7747c9

Browse files
authored
Merge pull request #1619 from goblint/issue-1616
Print innermost backtrace mark for uncaught exception even with backtrace printing off
2 parents d2f6584 + f7184c0 commit b7747c9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/util/backtrace/goblint_backtrace.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,19 @@ let print_marktrace oc e =
7676
Printf.fprintf oc "Marked with %s\n" (mark_to_string m)
7777
) ms
7878

79+
let print_innermost_mark oc e =
80+
match find_marks e with
81+
| m :: _ -> Printf.fprintf oc "Marked with %s\n" (mark_to_string m)
82+
| [] -> ()
83+
7984
let () =
8085
Printexc.set_uncaught_exception_handler (fun e bt ->
8186
(* Copied & modified from Printexc.default_uncaught_exception_handler. *)
8287
Printf.eprintf "Fatal error: exception %s\n" (Printexc.to_string e); (* nosemgrep: print-not-logging *)
8388
if Printexc.backtrace_status () then
84-
print_marktrace stderr e;
89+
print_marktrace stderr e
90+
else
91+
print_innermost_mark stderr e;
8592
Printexc.print_raw_backtrace stderr bt;
8693
flush stderr
8794
)

src/util/backtrace/goblint_backtrace.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,10 @@ val print_marktrace: out_channel -> exn -> unit
3232
3333
Used by default for uncaught exceptions. *)
3434

35+
val print_innermost_mark: out_channel -> exn -> unit
36+
(** Print innermost mark of an exception.
37+
38+
Used by default for uncaught exceptions. *)
39+
3540
val find_marks: exn -> mark list
3641
(** Find all marks of an exception. *)

0 commit comments

Comments
 (0)