summaryrefslogtreecommitdiffstats
path: root/src/audit-error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audit-error.c')
-rw-r--r--src/audit-error.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/audit-error.c b/src/audit-error.c
index f6286cd..7636f35 100644
--- a/src/audit-error.c
+++ b/src/audit-error.c
@@ -118,6 +118,34 @@ static int install_sigsegv(struct lt_config_shared *cfg)
static __thread unsigned long automated_sym_cnt = 0;
+
+/* TODO make type agnostics... now only AFTER type */
+static void update_start_info(struct lt_config_audit *cfg,
+ const char *symname, int is_entry)
+{
+ if (cfg->error_allowed)
+ return;
+
+ if (is_entry && cfg->error_start_after_entries) {
+ if (strcmp(symname, cfg->error_start_after_sym))
+ return;
+
+ cfg->error_start_after_current++;
+
+ if (cfg->error_start_after_current != cfg->error_start_after_entries)
+ return;
+
+ cfg->error_allowed = 1;
+ }
+}
+
+int lt_error_sym_entry(struct lt_config_audit *cfg,
+ const char *symname)
+{
+ update_start_info(cfg, symname, 1);
+ return 0;
+}
+
int lt_error_sym_exit(struct lt_config_audit *cfg,
const char *symname,
struct lt_symbol *sym,
@@ -137,6 +165,11 @@ int lt_error_sym_exit(struct lt_config_audit *cfg,
if (!sym || !sym->error)
return -1;
+ update_start_info(cfg, symname, 0);
+
+ if (!cfg->error_allowed)
+ return -1;
+
if (cfg_err->type == LT_ERROR_RUN_TYPE_AUTO) {
struct lt_error_sym *esym;
@@ -251,6 +284,29 @@ static void display_error_symbols(struct lt_config_audit *cfg,
PRINT_VERBOSE(cfg, 1, "END\n");
}
+
+static int init_start_info(struct lt_config_audit *cfg,
+ struct lt_error_config *cfg_err,
+ char *names)
+{
+ struct lt_error_start *start = &cfg_err->start;
+
+ if (start->type == LT_ERROR_START_TYPE_AFTER) {
+ if (start->after.name.index != -1)
+ cfg->error_start_after_sym = names + start->after.name.index;
+
+ cfg->error_start_after_entries = start->after.entries;
+ cfg->error_start_after_exits = start->after.exits;
+
+ PRINT_VERBOSE(cfg, 1, "START AFTER entries %ld, exits %ld, sym %s\n",
+ cfg->error_start_after_entries,
+ cfg->error_start_after_exits,
+ cfg->error_start_after_sym);
+ }
+
+ return 0;
+}
+
int lt_error_init(struct lt_config_audit *cfg)
{
struct lt_error_config *cfg_err = cfg->error_config;
@@ -286,6 +342,9 @@ int lt_error_init(struct lt_config_audit *cfg)
return -1;
}
+ if (init_start_info(cfg, cfg_err, names))
+ return -1;
+
lt_sh(cfg, error_sim) = 1;
return 0;
}