You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type signatures used in the fields of FunctionABI and SyscallABI are somewhat messy. This is a mega-issue dedicated to cleaning them up. These will likely involve some backwards-incompatible API changes.
Inconsistent use of IO versus OverrideSim in return types
The syscallArgumentRegisters and syscallNumberRegister functions return IO, but the syscallReturnRegisters function returns OverrideSim. This seems very inconsistent, given that all of these functions do very similar things. I propose that these functions either all return IO or all return OverrideSim.
Similarly, functionIntegerArguments and functionReturnAddr return IO, but functionIntegerReturnRegisters returns OverrideSim.
functionReturnAddr should return an Either, not a Maybe
Currently, the return type of functionReturnAddr is IO (Maybe (MemWord (ArchAddrWidth arch))), but this arguably doesn't capture the full range of ways that this function could fail. This is best explained by looking at one implementation of functionReturnAddr:
["Initial assumptions are unsatisfiable at "++show (PP.pretty (WP.plSourceLoc loc))]
-- This can genuinely happen if a function is invoked as a tail call, so
-- which the main reason why this returns a Maybe instead of panicking.
LeftAVC.MultipleModels->
pureNothing
-- I'm unclear if this case can ever happen under normal circumstances, but
-- we'll return Nothing here just to be on the safe side.
LeftAVC.SolverUnknown->
pureNothing
Right addrBV ->
pure$Just$fromIntegral$BVS.asUnsigned addrBV
Some of these cases return Nothing, while others panic. Moreover, it's conceivable that the panicking case could be reachable from user-written code.
Really, functionReturnAddr ought to return Either e (MemWord (ArchAddrWidth arch)), where e is some suitable enumeration type that covers all of the different possible failures.
syscallReturnRegisters takes a redundant CtxRepr argument
Currently, syscallReturnRegisters takes both a CtxRepr atps argument as well as a RegEntry sym (StructType atps) argument. The CtxRepr atps argument is redundant, however, as it can be recovered from the RegEntry. We should remove the CtxRepr atps argument.
The text was updated successfully, but these errors were encountered:
The type signatures used in the fields of
FunctionABI
andSyscallABI
are somewhat messy. This is a mega-issue dedicated to cleaning them up. These will likely involve some backwards-incompatible API changes.Inconsistent use of
IO
versusOverrideSim
in return typesThe
syscallArgumentRegisters
andsyscallNumberRegister
functions returnIO
, but thesyscallReturnRegisters
function returnsOverrideSim
. This seems very inconsistent, given that all of these functions do very similar things. I propose that these functions either all returnIO
or all returnOverrideSim
.Similarly,
functionIntegerArguments
andfunctionReturnAddr
returnIO
, butfunctionIntegerReturnRegisters
returnsOverrideSim
.functionReturnAddr
should return anEither
, not aMaybe
(Spun off from a discussion at #38 (comment))
Currently, the return type of
functionReturnAddr
isIO (Maybe (MemWord (ArchAddrWidth arch)))
, but this arguably doesn't capture the full range of ways that this function could fail. This is best explained by looking at one implementation offunctionReturnAddr
:stubs/stubs-common/src/Stubs/FunctionOverride/X86_64/Linux.hs
Lines 200 to 225 in 56851fc
Some of these cases return
Nothing
, while others panic. Moreover, it's conceivable that thepanic
king case could be reachable from user-written code.Really,
functionReturnAddr
ought to returnEither e (MemWord (ArchAddrWidth arch))
, wheree
is some suitable enumeration type that covers all of the different possible failures.syscallReturnRegisters
takes a redundantCtxRepr
argument(Spun off from a discussion at #38 (comment))
Currently,
syscallReturnRegisters
takes both aCtxRepr atps
argument as well as aRegEntry sym (StructType atps)
argument. TheCtxRepr atps
argument is redundant, however, as it can be recovered from theRegEntry
. We should remove theCtxRepr atps
argument.The text was updated successfully, but these errors were encountered: