зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1139834 - TraceLogger: refactor to add fail function, r=bbouvier
This commit is contained in:
Родитель
1df9e925e2
Коммит
1a22e29af0
|
@ -208,27 +208,29 @@ TraceLoggerThread::enable()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TraceLoggerThread::fail(JSContext *cx, const char *error)
|
||||||
|
{
|
||||||
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL, error);
|
||||||
|
failed = true;
|
||||||
|
enabled = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TraceLoggerThread::enable(JSContext *cx)
|
TraceLoggerThread::enable(JSContext *cx)
|
||||||
{
|
{
|
||||||
if (!enable()) {
|
if (!enable())
|
||||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL,
|
return fail(cx, "internal error");
|
||||||
"internal error");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enabled == 1) {
|
if (enabled == 1) {
|
||||||
// Get the top Activation to log the top script/pc (No inlined frames).
|
// Get the top Activation to log the top script/pc (No inlined frames).
|
||||||
ActivationIterator iter(cx->runtime());
|
ActivationIterator iter(cx->runtime());
|
||||||
Activation *act = iter.activation();
|
Activation *act = iter.activation();
|
||||||
|
|
||||||
if (!act) {
|
if (!act)
|
||||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL,
|
return fail(cx, "internal error");
|
||||||
"internal error");
|
|
||||||
failed = true;
|
|
||||||
enabled = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSScript *script = nullptr;
|
JSScript *script = nullptr;
|
||||||
int32_t engine = 0;
|
int32_t engine = 0;
|
||||||
|
@ -255,13 +257,8 @@ TraceLoggerThread::enable(JSContext *cx)
|
||||||
|
|
||||||
script = fp->script();
|
script = fp->script();
|
||||||
engine = TraceLogger_Interpreter;
|
engine = TraceLogger_Interpreter;
|
||||||
if (script->compartment() != cx->compartment()) {
|
if (script->compartment() != cx->compartment())
|
||||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL,
|
return fail(cx, "compartment mismatch");
|
||||||
"compartment mismatch");
|
|
||||||
failed = true;
|
|
||||||
enabled = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceLoggerEvent event(this, TraceLogger_Scripts, script);
|
TraceLoggerEvent event(this, TraceLogger_Scripts, script);
|
||||||
|
|
|
@ -195,6 +195,10 @@ class TraceLoggerThread
|
||||||
bool enable(JSContext *cx);
|
bool enable(JSContext *cx);
|
||||||
bool disable();
|
bool disable();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool fail(JSContext *cx, const char *error);
|
||||||
|
|
||||||
|
public:
|
||||||
// Given the previous iteration and lastEntryId, return an array of events
|
// Given the previous iteration and lastEntryId, return an array of events
|
||||||
// (there could be lost events). At the same time update the iteration and
|
// (there could be lost events). At the same time update the iteration and
|
||||||
// lastEntry and gives back how many events there are.
|
// lastEntry and gives back how many events there are.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче