Skip to content

Commit

Permalink
Make sure backtraces are propagated
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Apr 30, 2024
1 parent 1fccc8d commit cc33267
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion spectec/src/backend-interpreter/runner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,11 @@ let parse_file name parser_ file =
try
parser_ file
with e ->
let bt = Printexc.get_raw_backtrace () in
print_endline ("- Failed to parse " ^ name ^ "\n");
log ("- Failed to parse %s\n") name;
num_parse_fail := !num_parse_fail + 1;
raise e
Printexc.raise_with_backtrace e bt


(** Runner **)
Expand Down
3 changes: 2 additions & 1 deletion spectec/src/il/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,9 @@ try
equiv_typ env t2 t e.at;
sub_typ env t1 t2 e.at
with exn ->
let bt = Printexc.get_raw_backtrace () in
Printf.eprintf "[valid_exp] %s\n%!" (Debug.il_exp e);
raise exn
Printexc.raise_with_backtrace exn bt


and valid_expmix env mixop e (mixop', t) at =
Expand Down
3 changes: 2 additions & 1 deletion spectec/src/util/debug_log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ let log_at (type a) label at (arg_f : unit -> string) (res_f : a -> string) (f :
Printf.eprintf "[%s%s] %s\n%!" label ats arg;
match f () with
| exception exn ->
let bt = Printexc.get_raw_backtrace () in
Printf.eprintf "[%s%s] %s => raise %s\n%!" label ats arg (Printexc.to_string exn);
raise exn
Printexc.raise_with_backtrace exn bt
| x ->
let res = res_f x in
if res <> "" then Printf.eprintf "[%s%s] %s => %s\n%!" label ats arg res;
Expand Down

0 comments on commit cc33267

Please sign in to comment.