mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1072906 - TraceLogger: Part 2: Improve the interface to setup the tracelogger, r=bbouvier
This commit is contained in:
parent
7d56eb8578
commit
bd55524b78
@ -313,6 +313,7 @@ if CONFIG['ENABLE_TRACE_LOGGING']:
|
||||
SOURCES += [
|
||||
'vm/TraceLogging.cpp',
|
||||
'vm/TraceLoggingGraph.cpp',
|
||||
'vm/TraceLoggingTypes.cpp',
|
||||
]
|
||||
|
||||
if not CONFIG['ENABLE_ION']:
|
||||
|
@ -3772,20 +3772,68 @@ Debugger::makeGlobalObjectReference(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
bool
|
||||
Debugger::enableTraceItem(JSContext *cx, unsigned argc, Value *vp)
|
||||
Debugger::setupTraceLogger(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
THIS_DEBUGGER(cx, argc, vp, "enableTraceItem", args, dbg);
|
||||
if (!args.requireAtLeast(cx, "Debugger.enableTraceItem", 1))
|
||||
THIS_DEBUGGER(cx, argc, vp, "setupTraceLogger", args, dbg);
|
||||
if (!args.requireAtLeast(cx, "Debugger.setupTraceLogger", 1))
|
||||
return false;
|
||||
|
||||
uint32_t id = args[0].toInt32();
|
||||
RootedObject obj(cx, ToObject(cx, args[0]));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (!TLTextIdIsToggable(id)) {
|
||||
args.rval().setBoolean(false);
|
||||
AutoIdVector ids(cx);
|
||||
if (!GetPropertyKeys(cx, obj, JSITER_OWNONLY, &ids))
|
||||
return false;
|
||||
|
||||
if (ids.length() == 0) {
|
||||
args.rval().setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
TraceLogEnableTextId(cx, id);
|
||||
Vector<uint32_t> textIds(cx);
|
||||
if (!textIds.reserve(ids.length()))
|
||||
return false;
|
||||
|
||||
Vector<bool> values(cx);
|
||||
if (!values.reserve(ids.length()))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < ids.length(); i++) {
|
||||
if (!JSID_IS_STRING(ids[i])) {
|
||||
args.rval().setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString *id = JSID_TO_STRING(ids[i]);
|
||||
JSLinearString *linear = id->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return false;
|
||||
|
||||
uint32_t textId = TLStringToTextId(linear);
|
||||
|
||||
if (!TLTextIdIsToggable(textId)) {
|
||||
args.rval().setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedValue v(cx);
|
||||
if (!JSObject::getGeneric(cx, obj, obj, ids[i], &v))
|
||||
return false;
|
||||
|
||||
textIds.append(textId);
|
||||
values.append(ToBoolean(v));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(ids.length() == textIds.length());
|
||||
MOZ_ASSERT(textIds.length() == values.length());
|
||||
|
||||
for (size_t i = 0; i < textIds.length(); i++) {
|
||||
if (values[i])
|
||||
TraceLogEnableTextId(cx, textIds[i]);
|
||||
else
|
||||
TraceLogDisableTextId(cx, textIds[i]);
|
||||
}
|
||||
|
||||
args.rval().setBoolean(true);
|
||||
return true;
|
||||
@ -3820,7 +3868,7 @@ const JSFunctionSpec Debugger::methods[] = {
|
||||
JS_FN("findObjects", Debugger::findObjects, 1, 0),
|
||||
JS_FN("findAllGlobals", Debugger::findAllGlobals, 0, 0),
|
||||
JS_FN("makeGlobalObjectReference", Debugger::makeGlobalObjectReference, 1, 0),
|
||||
JS_FN("enableTraceItem", Debugger::enableTraceItem, 1, 0),
|
||||
JS_FN("setupTraceLogger", Debugger::setupTraceLogger, 1, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
|
@ -394,7 +394,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
|
||||
static bool findObjects(JSContext *cx, unsigned argc, Value *vp);
|
||||
static bool findAllGlobals(JSContext *cx, unsigned argc, Value *vp);
|
||||
static bool makeGlobalObjectReference(JSContext *cx, unsigned argc, Value *vp);
|
||||
static bool enableTraceItem(JSContext *cx, unsigned argc, Value *vp);
|
||||
static bool setupTraceLogger(JSContext *cx, unsigned argc, Value *vp);
|
||||
static bool construct(JSContext *cx, unsigned argc, Value *vp);
|
||||
static const JSPropertySpec properties[];
|
||||
static const JSFunctionSpec methods[];
|
||||
|
20
js/src/vm/TraceLoggingTypes.cpp
Normal file
20
js/src/vm/TraceLoggingTypes.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "vm/TraceLoggingTypes.h"
|
||||
|
||||
class JSLinearString;
|
||||
|
||||
uint32_t
|
||||
TLStringToTextId(JSLinearString *str)
|
||||
{
|
||||
#define NAME(textId) if (js::StringEqualsAscii(str, #textId)) return TraceLogger_ ## textId;
|
||||
TRACELOGGER_TREE_ITEMS(NAME)
|
||||
TRACELOGGER_LOG_ITEMS(NAME)
|
||||
#undef NAME
|
||||
return TraceLogger_Error;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define TraceLoggingTypes_h
|
||||
|
||||
#include "jsalloc.h"
|
||||
#include "jsstr.h"
|
||||
|
||||
#define TRACELOGGER_TREE_ITEMS(_) \
|
||||
_(Baseline) \
|
||||
@ -88,6 +89,9 @@ TLTextIdString(TraceLoggerTextId id)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TLStringToTextId(JSLinearString *str);
|
||||
|
||||
inline bool
|
||||
TLTextIdIsToggable(uint32_t id)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user