From 5766e987ac8177bca54a901920f9527e9ed5b526 Mon Sep 17 00:00:00 2001 From: Bojun Seo Date: Mon, 13 Mar 2023 17:29:29 +0900 Subject: [PATCH] heaptrace: Add ignore feature interface This patch adds ignore feature interface only Sometimes user wants to remove some reports not necessary to be traced Ignore feature will filter user defined symbols, functions and files This feature resembles suppressions feature in llvm-project Signed-off-by: Bojun Seo --- src/heaptrace.cc | 9 +++++++++ src/heaptrace.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/heaptrace.cc b/src/heaptrace.cc index 24f3e1e..c696e4d 100644 --- a/src/heaptrace.cc +++ b/src/heaptrace.cc @@ -26,6 +26,7 @@ enum options { OPT_sort, OPT_flamegraph, OPT_outfile, + OPT_ignore, }; static struct argp_option heaptrace_options[] = { @@ -34,6 +35,7 @@ static struct argp_option heaptrace_options[] = { { "sort", 's', "KEYs", 0, "Sort backtraces based on KEYs (size or count)" }, { "flame-graph", OPT_flamegraph, nullptr, 0, "Print heap trace info in flamegraph format" }, { "outfile", OPT_outfile, "FILE", 0, "Save log messages to this file" }, + { "ignore", OPT_ignore, "FILE", 0, "Apply ignore rules from this file" }, { nullptr } }; @@ -62,6 +64,10 @@ static error_t parse_option(int key, char *arg, struct argp_state *state) opts->outfile = arg; break; + case OPT_ignore: + opts->ignore = arg; + break; + case ARGP_KEY_ARG: if (state->arg_num) return ARGP_ERR_UNKNOWN; @@ -136,6 +142,9 @@ static void setup_child_environ(struct opts *opts, int argc, char *argv[]) if (opts->outfile) setenv("HEAPTRACE_OUTFILE", opts->outfile, 1); + + if (opts->ignore) + setenv("HEAPTRACE_IGNORE", opts->ignore, 1); } int main(int argc, char *argv[]) diff --git a/src/heaptrace.h b/src/heaptrace.h index ab60bf0..2d62692 100644 --- a/src/heaptrace.h +++ b/src/heaptrace.h @@ -42,6 +42,7 @@ struct opts { const char *sort_keys; bool flamegraph; char *outfile; + char *ignore; }; extern opts opts;