@@ -24,9 +24,10 @@ import System.Process (readProcessWithExitCode)
2424
2525import EVM (bytecode , replaceCodeOfSelf , loadContract , exec1 , vmOpIx )
2626import EVM.ABI
27+ import EVM.Dapp (DappInfo )
2728import EVM.Exec (exec , vmForEthrunCreation )
2829import EVM.Fetch qualified
29- import EVM.Format (hexText )
30+ import EVM.Format (hexText , showTraceTree )
3031import EVM.Types hiding (Env , Gas )
3132
3233import Echidna.Events (emptyEvents )
@@ -70,9 +71,12 @@ pattern Illegal :: VMResult Concrete s
7071pattern Illegal <- VMFailure (classifyError -> IllegalE )
7172
7273-- | Given an execution error, throw the appropriate exception.
73- vmExcept :: MonadThrow m => EvmError -> m ()
74- vmExcept e = throwM $
75- case VMFailure e of {Illegal -> IllegalExec e; _ -> UnknownFailure e}
74+ -- Also optionally takes a DappInfo and VM, which are used to show the stack trace.
75+ vmExcept :: MonadThrow m => Maybe (DappInfo , VM Concrete RealWorld ) -> EvmError -> m ()
76+ vmExcept traceInfo e =
77+ let trace = uncurry showTraceTree <$> traceInfo
78+ in throwM $
79+ case VMFailure e of {Illegal -> IllegalExec e; _ -> UnknownFailure e trace}
7680
7781execTxWith
7882 :: (MonadIO m , MonadState (VM Concrete RealWorld ) m , MonadReader Env m , MonadThrow m )
@@ -201,7 +205,10 @@ execTxWith executeTx tx = do
201205 # state % # callvalue .= callvalueBeforeVMReset
202206 # traces .= tracesBeforeVMReset
203207 # state % # codeContract .= codeContractBeforeVMReset
204- (VMFailure x, _) -> vmExcept x
208+ (VMFailure x, _) -> do
209+ dapp <- asks (. dapp)
210+ vm <- get
211+ vmExcept (Just (dapp, vm)) x
205212 (VMSuccess (ConcreteBuf bytecode'), SolCreate _) -> do
206213 -- Handle contract creation.
207214 # env % # contracts % at (LitAddr tx. dst) % _Just % # code .= InitCode mempty mempty
0 commit comments