зеркало из https://github.com/mozilla/gecko-dev.git
Bug 600639, part 1: Allow overriding gOutFile and gErrFile in js shell, and add a -g option to sleep on startup so that a debugger can be attached. r=dmandelin
This commit is contained in:
Родитель
cbd39a3782
Коммит
78322bd9eb
|
@ -79,6 +79,7 @@
|
|||
#include "jsxml.h"
|
||||
#include "jsperf.h"
|
||||
|
||||
#include "prenv.h"
|
||||
#include "prmjtime.h"
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
|
@ -559,7 +560,7 @@ static int
|
|||
usage(void)
|
||||
{
|
||||
fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
|
||||
fprintf(gErrFile, "usage: js [-zKPswWxCijmd] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] "
|
||||
fprintf(gErrFile, "usage: js [-zKPswWxCijmd] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] [-g sleep-seconds-on-startup]"
|
||||
#ifdef JS_GC_ZEAL
|
||||
"[-Z gczeal] "
|
||||
#endif
|
||||
|
@ -660,6 +661,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
|||
#ifdef MOZ_TRACEVIS
|
||||
case 'T':
|
||||
#endif
|
||||
case 'g':
|
||||
++i;
|
||||
break;
|
||||
default:;
|
||||
|
@ -859,6 +861,13 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
|||
StartTraceVis(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
case 'g':
|
||||
if (++i == argc)
|
||||
return usage();
|
||||
|
||||
PR_Sleep(PR_SecondsToInterval(atoi(argv[i])));
|
||||
break;
|
||||
|
||||
default:
|
||||
return usage();
|
||||
}
|
||||
|
@ -5322,6 +5331,17 @@ shell(JSContext *cx, int argc, char **argv, char **envp)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
MaybeOverrideOutFileFromEnv(const char* const envVar,
|
||||
FILE* defaultOut,
|
||||
FILE** outFile)
|
||||
{
|
||||
const char* outPath = PR_GetEnv(envVar);
|
||||
if (!outPath || !*outPath || !(*outFile = fopen(outPath, "w"))) {
|
||||
*outFile = defaultOut;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv, char **envp)
|
||||
{
|
||||
|
@ -5370,8 +5390,8 @@ main(int argc, char **argv, char **envp)
|
|||
setbuf(stderr,0);
|
||||
#endif
|
||||
|
||||
gErrFile = stderr;
|
||||
gOutFile = stdout;
|
||||
MaybeOverrideOutFileFromEnv("JS_STDERR", stderr, &gErrFile);
|
||||
MaybeOverrideOutFileFromEnv("JS_STDOUT", stdout, &gOutFile);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
|
Загрузка…
Ссылка в новой задаче