From f95eb1e5eda52a97070d4505810dad97e45918cd Mon Sep 17 00:00:00 2001 From: Andrew Beggs Date: Tue, 1 Oct 2024 17:50:30 +0100 Subject: [PATCH] Refactor opt_gencore to imply allow_coredump --- src/fiat/drhook/drhook.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/fiat/drhook/drhook.c b/src/fiat/drhook/drhook.c index 8359886..843667d 100644 --- a/src/fiat/drhook/drhook.c +++ b/src/fiat/drhook/drhook.c @@ -2239,24 +2239,6 @@ process_options() OPTPRINT(fp,"%s %s [%s@%s:%d] ATP_IGNORE_SIGTERM=%d\n",pfx,TIMESTR(tid),FFL,atp_ignore_sigterm); } - env = getenv("DR_HOOK_ALLOW_COREDUMP"); - if (env) { - ienv = atoi(env); - allow_coredump = (ienv == -1 || ienv == myproc) ? ienv : 0; - } - OPTPRINT(fp,"%s %s [%s@%s:%d] DR_HOOK_ALLOW_COREDUMP=%d\n",pfx,TIMESTR(tid),FFL,allow_coredump); -#if 0 - // Postponed until DrHook actully has caught the signal - if (allow_coredump) { - unsigned long long int hardlimit = 0; - int rc = set_corefile_to_hard_limit(&hardlimit,1); - if (rc == 0) { - OPTPRINT(fp,"%s %s [%s@%s:%d] Hardlimit for core file is now %llu (0x%llx)\n", - pfx,TIMESTR(tid),FFL,hardlimit,hardlimit); - } - } -#endif - env = getenv("DR_HOOK_PROFILE"); if (env) { char *s = calloc_drhook(strlen(env) + 15, sizeof(*s)); @@ -2494,6 +2476,25 @@ process_options() OPTPRINT(fp,"%s %s [%s@%s:%d] DR_HOOK_GENCORE_SIGNAL=%d\n",pfx,TIMESTR(tid),FFL,opt_gencore_signal); } + env = getenv("DR_HOOK_ALLOW_COREDUMP"); + if (env) { + ienv = atoi(env); + allow_coredump = (ienv == -1 || ienv == myproc) ? ienv : 0; + } + + /* opt_gencore implies allow_coredump */ + allow_coredump |= opt_gencore; + OPTPRINT(fp,"%s %s [%s@%s:%d] DR_HOOK_ALLOW_COREDUMP=%d\n",pfx,TIMESTR(tid),FFL,allow_coredump); + + if (allow_coredump) { + unsigned long long int hardlimit = 0; + int rc = set_corefile_to_hard_limit(&hardlimit,1); + if (rc == 0) { + OPTPRINT(fp,"%s %s [%s@%s:%d] Hardlimit for core file is now %llu (0x%llx)\n", + pfx,TIMESTR(tid),FFL,hardlimit,hardlimit); + } + } + newline = 0; env = getenv("DR_HOOK_OPT"); if (env) {