From 647562c2d234c4bf88fd853d50835d132d6a2e05 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Sat, 21 May 2016 04:07:56 -0400 Subject: [PATCH] Bug 1262937 - part 7 - factor out union type deserialization errors; r=jld --- ipc/glue/ProtocolUtils.cpp | 7 +++++++ ipc/glue/ProtocolUtils.h | 3 +++ ipc/ipdl/ipdl/lower.py | 12 ++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 2c6b85b87268..74addce27e82 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -511,5 +511,12 @@ MismatchedActorTypeError(const char* aActorDescription) ProtocolErrorBreakpoint(message.get()); } +void +UnionTypeReadError(const char* aUnionName) +{ + nsPrintfCString message("error deserializing type of union %s", aUnionName); + NS_RUNTIMEABORT(message.get()); +} + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index ee6010d31f24..f2ef58024942 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -339,6 +339,9 @@ ActorLookupError(const char* aActorDescription); MOZ_NEVER_INLINE void MismatchedActorTypeError(const char* aActorDescription); +MOZ_NEVER_INLINE void +UnionTypeReadError(const char* aUnionName); + struct PrivateIPDLInterface {}; nsresult diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index fc2b62b77509..02fc612ea7f0 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -403,6 +403,11 @@ def _logicError(msg): return StmtExpr( ExprCall(ExprVar('mozilla::ipc::LogicError'), args=[ ExprLiteral.String(msg) ])) +def _unionTypeReadError(unionname): + return StmtExpr( + ExprCall(ExprVar('mozilla::ipc::UnionTypeReadError'), + args=[ ExprLiteral.String(unionname) ])) + def _killProcess(pid): return ExprCall( ExprVar('base::KillProcess'), @@ -462,6 +467,9 @@ def errfnRecv(msg, errcode=_Result.ValuError): def errfnRead(msg): return [ _fatalError(msg), StmtReturn.FALSE ] +def errfnUnionType(unionname): + return [ _unionTypeReadError(unionname), StmtReturn.FALSE ] + def _destroyMethod(): return ExprVar('ActorDestroy') @@ -4632,8 +4640,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): uniontdef, StmtDecl(Decl(Type.INT, typevar.name)), self.checkedRead( - None, ExprAddrOf(typevar), msgvar, itervar, errfnRead, - '\'' + typevar.name + '\' (' + Type.INT.name + ') of union \'' + uniontype.name() + '\''), + None, ExprAddrOf(typevar), msgvar, itervar, errfnUnionType, + [ uniontype.name() ]), Whitespace.NL, readswitch, ])