// // This is a signal handler that does thread and task reporting. // static void SIGINT_handler(int sig) { signal(sig, SIG_IGN); if (blockreport) report_locked_threads(); if (do_taskReport) report_all_tasks(); chpl_exit_any(1); }
void chpl_error_preformatted(const char* message) { spinhaltIfAlreadyExiting(); fflush(stdout); fprintf(stderr, "%s\n", message); #ifdef CHPL_UNWIND_NOT_LAUNCHER chpl_stack_unwind(); #endif chpl_exit_any(1); }
static void SIGINT_handler(int sig) { signal(sig, SIG_IGN); if (blockreport) { report_locked_threads(); } if (taskreport) { fprintf(stderr, "Taskreport is currently unsupported by the qthreads tasking layer.\n"); // report_all_tasks(); } chpl_exit_any(1); }
void chpl_error_explicit(const char *message, int32_t lineno, const char *filename) { spinhaltIfAlreadyExiting(); fflush(stdout); if (lineno > 0) fprintf(stderr, "%s:%" PRId32 ": error: %s", filename, lineno, message); else if (filename) fprintf(stderr, "%s: error: %s", filename, message); else fprintf(stderr, "error: %s", message); fprintf(stderr, "\n"); #ifdef CHPL_UNWIND_NOT_LAUNCHER chpl_stack_unwind(); #endif chpl_exit_any(1); }
// // Check for and report deadlock, when a suspension deadline passes. // static void check_for_deadlock(void) { // Blockreport should be true here, because this can't be called // unless set_block_loc() returns true, and it can't do that unless // blockreport is true. So this is just a check for ongoing // internal consistency. assert(blockreport); if (get_thread_private_data()->lockRprt->prev_progress_cnt < progress_cnt) return; fflush(stdout); fprintf(stderr, "Program is deadlocked!\n"); report_locked_threads(); if (do_taskReport) report_all_tasks(); chpl_exit_any(1); }
static void SIGINT_handler(int sig) { signal(sig, SIG_IGN); if (blockreport) { #ifdef SUPPORT_BLOCKREPORT report_locked_threads(); #else fprintf(stderr, "Blockreport is currently unsupported by the qthreads " "tasking layer.\n"); #endif } if (taskreport) { #ifdef SUPPORT_TASKREPORT report_all_tasks(); #else fprintf(stderr, "Taskreport is currently unsupported by the qthreads tasking layer.\n"); #endif } chpl_exit_any(1); }
void chpl_internal_error(const char* message) { spinhaltIfAlreadyExiting(); fflush(stdout); fprintf(stderr, "internal error: %s\n", message); chpl_exit_any(2); }
void parseArgs(chpl_bool isLauncher, chpl_parseArgsMode_t mode, int* argc, char* argv[]) { int i; int printHelp = 0; int printAbout = 0; int origargc = *argc; int stop_parsing = 0; // // Handle the pre-parse for '-E' arguments separately. // if (mode == parse_dash_E) { assert(!isLauncher); parseDashEArgs(argc, argv); return; } for (i = 1; i < *argc; i++) { const char* filename = "<command-line arg>"; int lineno = i + (origargc - *argc); int argLength = 0; const char* currentArg = argv[i]; argLength = strlen(currentArg); if (mainHasArgs && (stop_parsing || argLength < 2)) { /* update the argv structure passed to a Chapel program, but don't parse * the arguments */ chpl_gen_main_arg.argv[chpl_gen_main_arg.argc] = argv[i]; chpl_gen_main_arg.argc++; continue; } /* if the Chapel main takes arguments, then "--" is a magic argument that * will prevent parsing of any additional arguments */ if (mainHasArgs && strcmp(currentArg, "--") == 0) { stop_parsing = 1; continue; } if (argLength < 2) { const char* message = chpl_glom_strings(3, "\"", currentArg, "\" is not a valid argument"); chpl_error(message, lineno, filename); } switch (currentArg[0]) { case '-': switch (currentArg[1]) { case '-': { const char* flag = currentArg + 2; if (strcmp(flag, "gdb") == 0) { gdbFlag = i; break; } if (strcmp(flag, "help") == 0) { printHelp = 1; chpl_gen_main_arg.argv[chpl_gen_main_arg.argc] = "--help"; chpl_gen_main_arg.argc++; break; } if (strcmp(flag, "about") == 0) { printAbout = 1; break; } if (strcmp(flag, "verbose") == 0) { verbosity=2; break; } if (strcmp(flag, "blockreport") == 0) { blockreport = 1; break; } if (strcmp(flag, "taskreport") == 0) { taskreport = 1; break; } if (strcmp(flag, "quiet") == 0) { verbosity = 0; break; } if (argLength < 3) { char* message = chpl_glom_strings(3, "\"", currentArg, "\" is not a valid argument"); chpl_error(message, lineno, filename); } i += handlePossibleConfigVar(argc, argv, i, lineno, filename); break; } case 'a': if (currentArg[2] == '\0') { printAbout = 1; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; case 'b': if (currentArg[2] == '\0') { blockreport = 1; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; case 'E': if (isLauncher) { i += handleNonstandardArg(argc, argv, i, lineno, filename); } else { // // We parse -E only in parse_dash_E mode, which is handled above. // if (currentArg[2] == '\0') { i++; } } break; case 'f': if (currentArg[2] == '\0') { i++; if (i >= *argc) { chpl_error("-f flag is missing <filename> argument", lineno, filename); } currentArg = argv[i]; parseConfigFile(currentArg, lineno, filename); } else { parseConfigFile(currentArg + 2, lineno, filename); } break; case 'h': if (currentArg[2] == '\0') { printHelp = 1; chpl_gen_main_arg.argv[chpl_gen_main_arg.argc] = "-h"; chpl_gen_main_arg.argc++; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; case 'n': if (currentArg[2] == 'l') { const char* numPtr; if (currentArg[3] == '\0') { i++; if (i >= *argc) { chpl_error("-nl flag is missing <numLocales> argument", lineno, filename); } currentArg = argv[i]; numPtr = currentArg; } else { numPtr = &(currentArg[3]); } initSetValue("numLocales", numPtr, "Built-in", lineno, filename); break; } i += handleNonstandardArg(argc, argv, i, lineno, filename); break; case 'q': if (currentArg[2] == '\0') { verbosity = 0; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; case 's': { if (argLength < 3) { char* message = chpl_glom_strings(3, "\"", currentArg, "\" is not a valid argument"); chpl_error(message, lineno, filename); } i += handlePossibleConfigVar(argc, argv, i, lineno, filename); break; } case 't': if (currentArg[2] == '\0') { taskreport = 1; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; case 'v': if (currentArg[2] == '\0') { verbosity = 2; } else { i += handleNonstandardArg(argc, argv, i, lineno, filename); } break; default: i += handleNonstandardArg(argc, argv, i, lineno, filename); break; } break; default: i += handleNonstandardArg(argc, argv, i, lineno, filename); break; } } if (printAbout) { chpl_program_about(); chpl_exit_any(0); } if (printHelp) { if (!mainHasArgs) { printHelpTable(); printConfigVarTable(); chpl_exit_any(0); } } }
void chpl_error(const char* message, int32_t lineno, c_string filename) { chpl_error_common(message, lineno, filename); fprintf(stderr, "\n"); chpl_exit_any(1); }