diff --git a/userspace/include/unit/args.h b/userspace/include/unit/args.h index c933b7434..5a90af1ed 100644 --- a/userspace/include/unit/args.h +++ b/userspace/include/unit/args.h @@ -47,6 +47,7 @@ struct unit_fw_args { bool nvtest; bool is_qnx; unsigned int test_lvl; + bool debug; const char *binary_name; const char *unit_name; diff --git a/userspace/src/args.c b/userspace/src/args.c index 2ec6aaf20..d9e126fe6 100644 --- a/userspace/src/args.c +++ b/userspace/src/args.c @@ -36,15 +36,14 @@ static struct option core_opts[] = { { "no-color", 0, NULL, 'C' }, { "nvtest", 0, NULL, 'n' }, { "is-qnx", 0, NULL, 'Q' }, - { "unit-load-path", 1, NULL, 'L' }, { "num-threads", 1, NULL, 'j' }, { "test-level", 1, NULL, 't' }, - + { "debug", 0, NULL, 'd' }, { NULL, 0, NULL, 0 } }; -static const char *core_opts_str = "hvqCnQL:j:t:"; +static const char *core_opts_str = "hvqCnQL:j:t:d"; void core_print_help(struct unit_fw *fw) { @@ -73,6 +72,8 @@ void core_print_help(struct unit_fw *fw) " Number of threads to use while running all tests.\n", " -t, --test-level \n", " Test plan level. 0=L0, 1=L1. default: 1\n", +" -d, --debug Disable signal handling to facilitate debug of", +" crashes.\n", "\n", "Note: mandatory arguments to long arguments are mandatory for short\n", "arguments as well.\n", @@ -162,6 +163,9 @@ int core_parse_args(struct unit_fw *fw, int argc, char **argv) return -1; } break; + case 'd': + args->debug = true; + break; case '?': args->help = true; return -1; diff --git a/userspace/src/exec.c b/userspace/src/exec.c index ded1301ee..edc02df8a 100644 --- a/userspace/src/exec.c +++ b/userspace/src/exec.c @@ -191,10 +191,11 @@ int core_exec(struct unit_fw *fw) sem_init(&unit_thread_semaphore, 0, fw->args->thread_count); /* - * If running single threaded, keep the default SIGSEGV handler to make - * interactive debugging easier, otherwise install the custom one. + * By default, use a custom signal hanlder to catch faults such as + * SIGSEGV. This can be disabled with the -d argument to make it + * easier to investigate with a debugger. */ - if (fw->args->thread_count > 1) { + if (!fw->args->debug) { err = install_thread_error_handler(); if (err != 0) { core_msg_color(fw, C_RED,