Skip to content

Commit

Permalink
Bug 1345111 - Make the IPDL compiler error out when it finds sync-mes…
Browse files Browse the repository at this point in the history
…sages.ini entries without corresponding IPDL sync messages; r=billm

This ensures that our sync-messages.ini correctly reflects the existing set of
sync IPC messages we have.
  • Loading branch information
ehsan committed Mar 9, 2017
1 parent f6f7b64 commit 0946cb8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions ipc/ipdl/ipdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def normalizedFilename(f):
log(3, ' pretty printed code:')
ipdl.genipdl(ast, codedir)

ipdl.checkFixedSyncMessages(parser)

# Second pass: generate code
for f in files:
# Read from parser cache
Expand Down
5 changes: 3 additions & 2 deletions ipc/ipdl/ipdl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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/.

__all__ = [ 'gencxx', 'genipdl', 'parse', 'typecheck', 'writeifmodified', 'checkSyncMessage' ]
__all__ = [ 'gencxx', 'genipdl', 'parse', 'typecheck', 'writeifmodified',
'checkSyncMessage', 'checkFixedSyncMessages' ]

import os, sys
from cStringIO import StringIO
Expand All @@ -11,7 +12,7 @@
from ipdl.lower import LowerToCxx, msgenums
from ipdl.parser import Parser, ParseError
from ipdl.type import TypeCheck
from ipdl.checker import checkSyncMessage
from ipdl.checker import checkSyncMessage, checkFixedSyncMessages

from ipdl.cxx.cgen import CxxCodeGen

Expand Down
30 changes: 26 additions & 4 deletions ipc/ipdl/ipdl/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
from ipdl.ast import Visitor, ASYNC

class SyncMessageChecker(Visitor):
syncMsgList = []
seenProtocols = []
seenSyncMessages = []
def __init__(self, syncMsgList):
self.syncMsgList = syncMsgList
SyncMessageChecker.syncMsgList = syncMsgList
self.errors = []

def prettyMsgName(self, msg):
Expand All @@ -23,16 +26,24 @@ def errorAsyncMessageCanRemove(self, loc, msg):
(str(loc), msg))

def visitProtocol(self, p):
self.errors = []
self.currentProtocol = p.name
SyncMessageChecker.seenProtocols.append(p.name)
Visitor.visitProtocol(self, p)

def visitMessageDecl(self, md):
pn = self.prettyMsgName(md.name)
if md.sendSemantics is not ASYNC and pn not in self.syncMsgList:
self.errorUnknownSyncMessage(md.loc, pn)
if md.sendSemantics is ASYNC and pn in self.syncMsgList:
if md.sendSemantics is not ASYNC:
if pn not in SyncMessageChecker.syncMsgList:
self.errorUnknownSyncMessage(md.loc, pn)
SyncMessageChecker.seenSyncMessages.append(pn)
elif pn in SyncMessageChecker.syncMsgList:
self.errorAsyncMessageCanRemove(md.loc, pn)

@staticmethod
def getFixedSyncMessages():
return set(SyncMessageChecker.syncMsgList) - set(SyncMessageChecker.seenSyncMessages)

def checkSyncMessage(tu, syncMsgList, errout=sys.stderr):
checker = SyncMessageChecker(syncMsgList)
tu.accept(checker)
Expand All @@ -41,3 +52,14 @@ def checkSyncMessage(tu, syncMsgList, errout=sys.stderr):
print >>errout, error
return False
return True

def checkFixedSyncMessages(config, errout=sys.stderr):
fixed = SyncMessageChecker.getFixedSyncMessages()
for item in fixed:
protocol = item.split('::')[0]
# Ignore things like sync messages in test protocols we didn't compile.
# Also, ignore platform-specific IPC messages.
if protocol in SyncMessageChecker.seenProtocols and \
'platform' not in config.options(item):
print >>errout, 'Error: Sync IPC message %s not found, it appears to be fixed.\n' \
'Please remove it from sync-messages.ini.' % item
19 changes: 1 addition & 18 deletions ipc/ipdl/sync-messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ description =
description =
[PDocAccessible::GetWindowedPluginIAccessible]
description =
platform = win

# CPOWs
[PBrowser::RpcMessage]
Expand Down Expand Up @@ -537,8 +538,6 @@ description =
description =
[PPluginInstance::NPP_GetValue_NPPVpluginWantsAllNetworkStreams]
description =
[PPluginInstance::NPP_GetValue_NPPVpluginNeedsXEmbed]
description =
[PPluginInstance::NPP_GetValue_NPPVpluginScriptableNPObject]
description =
[PPluginInstance::NPP_SetValue_NPNVprivateModeBool]
Expand Down Expand Up @@ -619,8 +618,6 @@ description =
description =
[PPluginInstance::NPN_ConvertPoint]
description =
[PPluginInstance::NegotiatedCarbon]
description =
[PPluginInstance::GetCompositionString]
description =
[PPluginInstance::NPP_NewStream]
Expand All @@ -645,8 +642,6 @@ description =
description =
[PPluginModule::OptionalFunctionsSupported]
description =
[PPluginModule::PCrashReporter]
description =
[PPluginModule::ProcessSomeEvents]
description =
[PPluginModule::NPN_SetException]
Expand Down Expand Up @@ -759,8 +754,6 @@ description =
description =
[PContent::FindPlugins]
description =
[PContent::PCrashReporter]
description =
[PContent::NSSU2FTokenIsCompatibleVersion]
description =
[PContent::NSSU2FTokenIsRegistered]
Expand Down Expand Up @@ -801,8 +794,6 @@ description =
description =
[PContent::AllocateLayerTreeId]
description =
[PContent::GetGfxInfoFeatureStatus]
description =
[PContent::BeginDriverCrashGuard]
description =
[PContent::EndDriverCrashGuard]
Expand Down Expand Up @@ -913,12 +904,6 @@ description =
description =
[PCompositorBridge::PWebRenderBridge]
description =
[PCompositorWidget::EnterPresentLock]
description =
[PCompositorWidget::LeavePresentLock]
description =
[PCompositorWidget::ClearTransparentWindow]
description =
[PImageBridge::WillClose]
description =
[PImageBridge::NewCompositable]
Expand All @@ -939,8 +924,6 @@ description =
description =
[PLayerTransaction::RequestProperty]
description =
[PTexture::DestroySync]
description =
[PUiCompositorController::Pause]
description =
[PUiCompositorController::Resume]
Expand Down

0 comments on commit 0946cb8

Please sign in to comment.