From 4523ee2b141b74218c11c555a80bd38d1db7dcd5 Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Tue, 22 Oct 2019 18:04:14 -0400 Subject: [PATCH] gpu: nvgpu: unit: enable signal handler in single thread Until now, using single thread we disable the signal handler to make it easier to debug crashes. Since we are now using single threading in GVS, it is better to have the signal handler enabled by default. This patch introduces a "-d" argument to explicitly disable the signal handler and thus make local debugging easier. JIRA NVGPU-2975 Change-Id: I35b0fb71990b3fef575242c1bba398a3b0e6facf Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/2223662 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/include/unit/args.h | 1 + userspace/src/args.c | 10 +++++++--- userspace/src/exec.c | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) 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,