Bug 1051128 - Allow filtering the IPC log by toplevel protocol name (r=bent)

This commit is contained in:
Bill McCloskey 2014-08-20 12:49:11 -07:00
parent 179cf461f2
commit 805cf2f72c
4 changed files with 23 additions and 7 deletions

View File

@ -37,7 +37,7 @@ union MaybeTransform {
};
sync protocol PLayerTransaction {
manager PRenderFrame or PCompositor;
manager PCompositor or PRenderFrame;
manages PLayer;
manages PCompositable;
manages PTexture;

View File

@ -251,6 +251,20 @@ LoggingEnabled()
#endif
}
inline bool
LoggingEnabledFor(const char *aTopLevelProtocol)
{
#if defined(DEBUG)
const char *filter = PR_GetEnv("MOZ_IPC_MESSAGE_LOG");
if (!filter) {
return false;
}
return strcmp(filter, "1") == 0 || strcmp(filter, aTopLevelProtocol) == 0;
#else
return false;
#endif
}
MOZ_NEVER_INLINE void
ProtocolErrorBreakpoint(const char* aMsg);

View File

@ -377,8 +377,9 @@ def _sideToTransportMode(side):
elif side == 'child': mode = 'CLIENT'
return ExprVar('mozilla::ipc::Transport::MODE_'+ mode)
def _ifLogging(stmts):
iflogging = StmtIf(ExprCall(ExprVar('mozilla::ipc::LoggingEnabled')))
def _ifLogging(topLevelProtocol, stmts):
iflogging = StmtIf(ExprCall(ExprVar('mozilla::ipc::LoggingEnabledFor'),
args=[ topLevelProtocol ]))
iflogging.addifstmts(stmts)
return iflogging
@ -5372,7 +5373,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
def logMessage(self, md, msgptr, pfx, actor=None, receiving=False):
actorname = _actorName(self.protocol.name, self.side)
return _ifLogging([ StmtExpr(ExprCall(
topLevel = self.protocol.decl.type.toplevel().name()
return _ifLogging(ExprLiteral.String(topLevel), [ StmtExpr(ExprCall(
ExprSelect(msgptr, '->', 'Log'),
args=[ ExprLiteral.String('['+ actorname +'] '+ pfx),
self.protocol.callOtherProcess(actor),

View File

@ -280,7 +280,7 @@ class ProtocolType(IPDLType):
self.sendSemantics = sendSemantics
self.spawns = set() # ProtocolType
self.opens = set() # ProtocolType
self.managers = set() # ProtocolType
self.managers = [] # ProtocolType
self.manages = [ ]
self.stateless = stateless
self.hasDelete = False
@ -294,7 +294,7 @@ class ProtocolType(IPDLType):
def addManager(self, mgrtype):
assert mgrtype.isIPDL() and mgrtype.isProtocol()
self.managers.add(mgrtype)
self.managers.append(mgrtype)
def addSpawn(self, ptype):
assert self.isToplevel() and ptype.isToplevel()
@ -305,7 +305,7 @@ class ProtocolType(IPDLType):
self.opens.add(ptype)
def managedBy(self, mgr):
self.managers = mgr
self.managers = list(mgr)
def toplevel(self):
if self.isToplevel():