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() { ...@@ -513,6 +513,15 @@ BoxedTraceback* getTraceback() {
return new BoxedTraceback(); 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); Timer _t("getTraceback", 1000);
std::vector<const LineInfo*> entries; std::vector<const LineInfo*> entries;
......
...@@ -41,6 +41,7 @@ bool ENABLE_INTERPRETER = true; ...@@ -41,6 +41,7 @@ bool ENABLE_INTERPRETER = true;
bool ENABLE_PYPA_PARSER = true; bool ENABLE_PYPA_PARSER = true;
bool USE_REGALLOC_BASIC = true; bool USE_REGALLOC_BASIC = true;
bool PAUSE_AT_ABORT = false; bool PAUSE_AT_ABORT = false;
bool ENABLE_TRACEBACKS = true;
int OSR_THRESHOLD_INTERPRETER = 500; int OSR_THRESHOLD_INTERPRETER = 500;
int REOPT_THRESHOLD_INTERPRETER = 200; int REOPT_THRESHOLD_INTERPRETER = 200;
......
...@@ -38,7 +38,7 @@ extern int SPECULATION_THRESHOLD; ...@@ -38,7 +38,7 @@ extern int SPECULATION_THRESHOLD;
extern int MAX_OBJECT_CACHE_ENTRIES; extern int MAX_OBJECT_CACHE_ENTRIES;
extern bool SHOW_DISASM, FORCE_INTERPRETER, FORCE_OPTIMIZE, PROFILE, DUMPJIT, TRAP, USE_STRIPPED_STDLIB, 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, 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, ENABLE_ICNONZEROS, ENABLE_ICCALLSITES, ENABLE_ICSETATTRS, ENABLE_ICGETATTRS, ENALBE_ICDELATTRS, ENABLE_ICGETGLOBALS,
......
...@@ -87,20 +87,10 @@ static bool handle_toplevel_exn(const ExcInfo& e, int* retcode) { ...@@ -87,20 +87,10 @@ static bool handle_toplevel_exn(const ExcInfo& e, int* retcode) {
return false; return false;
} }
static int main(int argc, char** argv) { static bool force_repl = false;
Timer _t("for jit startup"); static bool unbuffered = false;
// llvm::sys::PrintStackTraceOnErrorSignal();
// llvm::PrettyStackTraceProgram X(argc, argv);
llvm::llvm_shutdown_obj Y;
int code; int handleArg(char code) {
bool force_repl = false;
bool unbuffered = false;
const char* command = NULL;
// Suppress getopt errors so we can throw them ourselves
opterr = 0;
while ((code = getopt(argc, argv, "+:OqdIibpjtrsSvnxEc:FuP")) != -1) {
if (code == 'O') if (code == 'O')
FORCE_OPTIMIZE = true; FORCE_OPTIMIZE = true;
else if (code == 't') else if (code == 't')
...@@ -139,24 +129,53 @@ static int main(int argc, char** argv) { ...@@ -139,24 +129,53 @@ static int main(int argc, char** argv) {
PAUSE_AT_ABORT = true; PAUSE_AT_ABORT = true;
} else if (code == 'F') { } else if (code == 'F') {
CONTINUE_AFTER_FATAL = true; CONTINUE_AFTER_FATAL = true;
} else if (code == 'c') { } 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();
// llvm::PrettyStackTraceProgram X(argc, argv);
llvm::llvm_shutdown_obj Y;
int code;
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:FuPT")) != -1) {
if (code == 'c') {
assert(optarg); assert(optarg);
command = optarg; command = optarg;
// no more option parsing; the rest of our arguments go into sys.argv. // no more option parsing; the rest of our arguments go into sys.argv.
break; break;
} else { } else if (code == ':') {
if (code == ':') {
fprintf(stderr, "Argument expected for the -%c option\n", optopt); fprintf(stderr, "Argument expected for the -%c option\n", optopt);
return 2; return 2;
} } else if (code == '?') {
if (code == '?') {
fprintf(stderr, "Unknown option: -%c\n", optopt); fprintf(stderr, "Unknown option: -%c\n", optopt);
return 2; return 2;
} } else {
int r = handleArg(code);
fprintf(stderr, "Unknown getopt() error. '%c' '%c'\n", code, optopt); if (r)
abort(); 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