From ce4319e7bdf6e3a1d0f934d969966b8757dcbd1d Mon Sep 17 00:00:00 2001 From: Brian Nigito Date: Wed, 2 Oct 2024 15:42:07 -0400 Subject: [PATCH] Add an environment variable to skip specialized OCaml exception processing Signed-off-by: Brian Nigito --- src/env_vars.ml | 11 ++++++++--- src/env_vars.mli | 1 + src/trace.ml | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/env_vars.ml b/src/env_vars.ml index c62cf9898..a18b2da4f 100644 --- a/src/env_vars.ml +++ b/src/env_vars.ml @@ -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 @@ -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") +;; diff --git a/src/env_vars.mli b/src/env_vars.mli index 67f6b915b..c68df4fdf 100644 --- a/src/env_vars.mli +++ b/src/env_vars.mli @@ -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 diff --git a/src/trace.ml b/src/trace.ml index fd406fa3c..da41842ea 100644 --- a/src/trace.ml +++ b/src/trace.ml @@ -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