Commit ed9c04a6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Take command line arguments from environment, and add argument to disable tracebacks

Not sure if this is really a good feature for users, but taking
command line arguments from an environment variable is definitely
helpful for testing things like virtualenv which spawns a number (~10)
of subprocess.
parent fc34300a
......@@ -513,6 +513,15 @@ BoxedTraceback* getTraceback() {
return new BoxedTraceback();
}
if (!ENABLE_TRACEBACKS) {
static bool printed_warning = false;
if (!printed_warning) {
printed_warning = true;
fprintf(stderr, "Warning: can't get traceback since ENABLE_TRACEBACKS=0\n");
}
return new BoxedTraceback();
}
Timer _t("getTraceback", 1000);
std::vector<const LineInfo*> entries;
......
......@@ -41,6 +41,7 @@ bool ENABLE_INTERPRETER = true;
bool ENABLE_PYPA_PARSER = true;
bool USE_REGALLOC_BASIC = true;
bool PAUSE_AT_ABORT = false;
bool ENABLE_TRACEBACKS = true;
int OSR_THRESHOLD_INTERPRETER = 500;
int REOPT_THRESHOLD_INTERPRETER = 200;
......
......@@ -38,7 +38,7 @@ extern int SPECULATION_THRESHOLD;
extern int MAX_OBJECT_CACHE_ENTRIES;
extern bool SHOW_DISASM, FORCE_INTERPRETER, FORCE_OPTIMIZE, PROFILE, DUMPJIT, TRAP, USE_STRIPPED_STDLIB,
CONTINUE_AFTER_FATAL, ENABLE_INTERPRETER, ENABLE_PYPA_PARSER, USE_REGALLOC_BASIC, PAUSE_AT_ABORT;
CONTINUE_AFTER_FATAL, ENABLE_INTERPRETER, ENABLE_PYPA_PARSER, USE_REGALLOC_BASIC, PAUSE_AT_ABORT, ENABLE_TRACEBACKS;
extern bool ENABLE_ICS, ENABLE_ICGENERICS, ENABLE_ICGETITEMS, ENABLE_ICSETITEMS, ENABLE_ICDELITEMS, ENABLE_ICBINEXPS,
ENABLE_ICNONZEROS, ENABLE_ICCALLSITES, ENABLE_ICSETATTRS, ENABLE_ICGETATTRS, ENALBE_ICDELATTRS, ENABLE_ICGETGLOBALS,
......
......@@ -87,6 +87,57 @@ static bool handle_toplevel_exn(const ExcInfo& e, int* retcode) {
return false;
}
static bool force_repl = false;
static bool unbuffered = false;
int handleArg(char code) {
if (code == 'O')
FORCE_OPTIMIZE = true;
else if (code == 't')
TRAP = true;
else if (code == 'q')
GLOBAL_VERBOSITY = 0;
else if (code == 'v')
GLOBAL_VERBOSITY++;
else if (code == 'd')
SHOW_DISASM = true;
else if (code == 'I')
FORCE_INTERPRETER = true;
else if (code == 'i')
force_repl = true;
else if (code == 'n') {
ENABLE_INTERPRETER = false;
} else if (code == 'p') {
PROFILE = true;
} else if (code == 'j') {
DUMPJIT = true;
} else if (code == 's') {
Stats::setEnabled(true);
} else if (code == 'S') {
Py_NoSiteFlag = 1;
} else if (code == 'u') {
unbuffered = true;
} else if (code == 'r') {
USE_STRIPPED_STDLIB = true;
} else if (code == 'b') {
USE_REGALLOC_BASIC = false;
} else if (code == 'x') {
ENABLE_PYPA_PARSER = false;
} else if (code == 'E') {
Py_IgnoreEnvironmentFlag = 1;
} else if (code == 'P') {
PAUSE_AT_ABORT = true;
} else if (code == 'F') {
CONTINUE_AFTER_FATAL = true;
} else if (code == 'T') {
ENABLE_TRACEBACKS = false;
} else {
fprintf(stderr, "Unknown option: -%c\n", code);
return 2;
}
return 0;
}
static int main(int argc, char** argv) {
Timer _t("for jit startup");
// llvm::sys::PrintStackTraceOnErrorSignal();
......@@ -94,69 +145,37 @@ static int main(int argc, char** argv) {
llvm::llvm_shutdown_obj Y;
int code;
bool force_repl = false;
bool unbuffered = false;
const char* command = NULL;
char* env_args = getenv("PYSTON_RUN_ARGS");
if (env_args) {
while (*env_args) {
int r = handleArg(*env_args);
if (r)
return r;
env_args++;
}
}
// Suppress getopt errors so we can throw them ourselves
opterr = 0;
while ((code = getopt(argc, argv, "+:OqdIibpjtrsSvnxEc:FuP")) != -1) {
if (code == 'O')
FORCE_OPTIMIZE = true;
else if (code == 't')
TRAP = true;
else if (code == 'q')
GLOBAL_VERBOSITY = 0;
else if (code == 'v')
GLOBAL_VERBOSITY++;
else if (code == 'd')
SHOW_DISASM = true;
else if (code == 'I')
FORCE_INTERPRETER = true;
else if (code == 'i')
force_repl = true;
else if (code == 'n') {
ENABLE_INTERPRETER = false;
} else if (code == 'p') {
PROFILE = true;
} else if (code == 'j') {
DUMPJIT = true;
} else if (code == 's') {
Stats::setEnabled(true);
} else if (code == 'S') {
Py_NoSiteFlag = 1;
} else if (code == 'u') {
unbuffered = true;
} else if (code == 'r') {
USE_STRIPPED_STDLIB = true;
} else if (code == 'b') {
USE_REGALLOC_BASIC = false;
} else if (code == 'x') {
ENABLE_PYPA_PARSER = false;
} else if (code == 'E') {
Py_IgnoreEnvironmentFlag = 1;
} else if (code == 'P') {
PAUSE_AT_ABORT = true;
} else if (code == 'F') {
CONTINUE_AFTER_FATAL = true;
} else if (code == 'c') {
while ((code = getopt(argc, argv, "+:OqdIibpjtrsSvnxEc:FuPT")) != -1) {
if (code == 'c') {
assert(optarg);
command = optarg;
// no more option parsing; the rest of our arguments go into sys.argv.
break;
} else if (code == ':') {
fprintf(stderr, "Argument expected for the -%c option\n", optopt);
return 2;
} else if (code == '?') {
fprintf(stderr, "Unknown option: -%c\n", optopt);
return 2;
} else {
if (code == ':') {
fprintf(stderr, "Argument expected for the -%c option\n", optopt);
return 2;
}
if (code == '?') {
fprintf(stderr, "Unknown option: -%c\n", optopt);
return 2;
}
fprintf(stderr, "Unknown getopt() error. '%c' '%c'\n", code, optopt);
abort();
int r = handleArg(code);
if (r)
return r;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment