Skip to content

Commit

Permalink
Add an environment variable to skip specialized OCaml exception proce…
Browse files Browse the repository at this point in the history
…ssing

Signed-off-by: Brian Nigito <[email protected]>
  • Loading branch information
bnigito authored and Xyene committed Oct 3, 2024
1 parent 42b7c90 commit ce4319e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/env_vars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ open Async
files around. *)
let perfetto_dir = Unix.getenv "MAGIC_TRACE_PERFETTO_DIR"

(** Override which [perf] to use. If this isn't set, magic-trace will use whatever's first
in $PATH. *)
(* Override which [perf] to use. If this isn't set, magic-trace will use whatever's first
in $PATH. *)
let perf_path = Option.value ~default:"perf" (Unix.getenv "MAGIC_TRACE_PERF_PATH")

(* Whether [perf] should be considered privileged when running as not-root. Bypasses error
checks around kernel tracing when not root. *)
let perf_is_privileged = Option.is_some (Unix.getenv "MAGIC_TRACE_PERF_IS_PRIVILEGED")

(** Override whether kcore will be used (in the case that [perf] supports it at all). *)
(* Override whether kcore will be used (in the case that [perf] supports it at all). *)
let perf_no_kcore = Option.is_some (Unix.getenv "MAGIC_TRACE_PERF_NO_KCORE")

(* Turns on hidden command line options and attached "[inferred start time]" to functions
Expand All @@ -37,3 +37,8 @@ let no_dlfilter = Option.is_some (Unix.getenv "MAGIC_TRACE_NO_DLFILTER")
(* Demangle symbols in the fuzzy finder. This is currently slow on large binaries, so is
disabled by default. *)
let fzf_demangle_symbols = Option.is_some (Unix.getenv "MAGIC_TRACE_FZF_DEMANGLE_SYMBOLS")

(* Use old-style trace generation for exceptions in all cases. *)
let no_ocaml_exception_debug_info =
Option.is_some (Unix.getenv "MAGIC_TRACE_NO_OCAML_EXCEPTION_DEBUG_INFO")
;;
1 change: 1 addition & 0 deletions src/env_vars.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ val perf_no_kcore : bool
val perfetto_dir : string option
val no_dlfilter : bool
val fzf_demangle_symbols : bool
val no_ocaml_exception_debug_info : bool
6 changes: 5 additions & 1 deletion src/trace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ module Make_commands (Backend : Backend_intf.S) = struct
None
| Some _ as x -> x
in
let ocaml_exception_info = Option.bind elf ~f:Elf.ocaml_exception_info in
let ocaml_exception_info =
match Env_vars.no_ocaml_exception_debug_info with
| true -> None
| false -> Option.bind elf ~f:Elf.ocaml_exception_info
in
let%bind events, close_result =
get_events_and_close_result ~decode_events ~range_symbols
in
Expand Down

0 comments on commit ce4319e

Please sign in to comment.