@@ -3,6 +3,7 @@ use crate::prelude::*;
33use core:: fmt;
44use events:: EventError ;
55use serde:: { Deserialize , Serialize } ;
6+ use wasmtime_environ:: EntityIndex ;
67// Use component events internally even without feature flags enabled
78// so that [`RREvent`] has a well-defined serialization format, but export
89// it for other modules only when enabled
@@ -198,12 +199,14 @@ pub enum ReplayError {
198199 EmptyBuffer ,
199200 FailedValidation ,
200201 IncorrectEventVariant ,
201- InvalidOrdering ,
202+ InvalidEventPosition ,
202203 FailedRead ( IOError ) ,
203204 EventError ( Box < dyn EventError > ) ,
204- MissingComponentOrModule ,
205- MissingComponentOrModuleInstance ,
206- IncorrectCoreFuncIndex ,
205+ MissingComponent ( [ u8 ; 32 ] ) ,
206+ MissingModule ( [ u8 ; 32 ] ) ,
207+ MissingComponentInstance ( u32 ) ,
208+ MissingModuleInstance ( u32 ) ,
209+ InvalidCoreFuncIndex ( EntityIndex ) ,
207210}
208211
209212impl fmt:: Display for ReplayError {
@@ -213,10 +216,13 @@ impl fmt::Display for ReplayError {
213216 write ! ( f, "replay buffer is empty" )
214217 }
215218 Self :: FailedValidation => {
216- write ! ( f, "replay event validation failed" )
219+ write ! (
220+ f,
221+ "failed validation check during replay; see wasmtime log for error"
222+ )
217223 }
218224 Self :: IncorrectEventVariant => {
219- write ! ( f, "event method invoked on incorrect variant " )
225+ write ! ( f, "event type mismatch during replay " )
220226 }
221227 Self :: EventError ( e) => {
222228 write ! ( f, "{:?}" , e)
@@ -225,17 +231,37 @@ impl fmt::Display for ReplayError {
225231 write ! ( f, "{}" , e) ?;
226232 f. write_str ( "Note: Ensure sufficient `deserialization-buffer-size` in replay settings if you included `validation-metadata` during recording" )
227233 }
228- Self :: InvalidOrdering => {
234+ Self :: InvalidEventPosition => {
229235 write ! ( f, "event occured at an invalid position in the trace" )
230236 }
231- Self :: MissingComponentOrModule => {
232- write ! ( f, "missing component or module for replay" )
237+ Self :: MissingComponent ( checksum) => {
238+ write ! (
239+ f,
240+ "missing component binary with checksum 0x{} during replay" ,
241+ checksum
242+ . iter( )
243+ . map( |b| format!( "{:02x}" , b) )
244+ . collect:: <String >( )
245+ )
233246 }
234- Self :: MissingComponentOrModuleInstance => {
235- write ! ( f, "missing component or module instance for replay" )
247+ Self :: MissingModule ( checksum) => {
248+ write ! (
249+ f,
250+ "missing module binary with checksum {:02x?} during replay" ,
251+ checksum
252+ . iter( )
253+ . map( |b| format!( "{:02x}" , b) )
254+ . collect:: <String >( )
255+ )
236256 }
237- Self :: IncorrectCoreFuncIndex => {
238- write ! ( f, "incorrect core function index encountered during replay" )
257+ Self :: MissingComponentInstance ( id) => {
258+ write ! ( f, "missing component instance ID {:?} during replay" , id)
259+ }
260+ Self :: MissingModuleInstance ( id) => {
261+ write ! ( f, "missing module instance ID {:?} during replay" , id)
262+ }
263+ Self :: InvalidCoreFuncIndex ( index) => {
264+ write ! ( f, "replay core func ({:?}) during replay is invalid" , index)
239265 }
240266 }
241267 }
@@ -306,9 +332,6 @@ pub trait Replayer: Iterator<Item = Result<RREvent, ReplayError>> {
306332 /// Get the settings (embedded within the trace) during recording
307333 fn trace_settings ( & self ) -> & RecordSettings ;
308334
309- ///// Peek at the next event without consuming it
310- //fn peek(&mut self) -> Option<Result<&RREvent, ReplayError>>;
311-
312335 // Provided Methods
313336
314337 /// Get the next functional replay event (skips past all non-marker events)
@@ -458,8 +481,6 @@ pub struct ReplayBuffer {
458481 deser_buffer : Vec < u8 > ,
459482 /// Whether buffer has been completely read
460483 eof_encountered : bool ,
461- /// Peeked event for lookahead
462- peeked : Option < RREvent > ,
463484}
464485
465486impl Iterator for ReplayBuffer {
@@ -469,9 +490,6 @@ impl Iterator for ReplayBuffer {
469490 if self . eof_encountered {
470491 return None ;
471492 }
472- if self . peeked . is_some ( ) {
473- return self . peeked . take ( ) . map ( Ok ) ;
474- }
475493 let ret = ' event_loop: loop {
476494 let result = io:: from_replay_reader ( & mut self . reader , & mut self . deser_buffer ) ;
477495 match result {
@@ -499,17 +517,17 @@ impl Drop for ReplayBuffer {
499517 let mut remaining_events = 0 ;
500518 log:: info!( "Replay buffer is being dropped; checking for remaining replay events..." ) ;
501519 // Cannot use count() in iterator because IO error may loop indefinitely
502- while let Some ( event ) = self . next ( ) {
503- event . unwrap ( ) ;
520+ while let Some ( e ) = self . next ( ) {
521+ e . unwrap ( ) ;
504522 remaining_events += 1 ;
505523 }
506524 if remaining_events > 0 {
507525 log:: warn!(
508- "{} events were remaining in the replay buffer. This is likely the result of an erroneous/incomplete execution" ,
526+ "{} events were not used in the replay buffer. This is likely the result of an erroneous/incomplete execution" ,
509527 remaining_events
510528 ) ;
511529 } else {
512- log:: info !( "All replay events were successfully processed." ) ;
530+ log:: debug !( "All replay events were successfully processed." ) ;
513531 }
514532 }
515533}
@@ -546,7 +564,6 @@ impl Replayer for ReplayBuffer {
546564 trace_settings,
547565 deser_buffer,
548566 eof_encountered : false ,
549- peeked : None ,
550567 } )
551568 }
552569
@@ -559,14 +576,6 @@ impl Replayer for ReplayBuffer {
559576 fn trace_settings ( & self ) -> & RecordSettings {
560577 & self . trace_settings
561578 }
562-
563- //#[inline]
564- //fn peek(&mut self) -> Option<Result<&RREvent, ReplayError>> {
565- // if self.peeked.is_none() {
566- // self.peeked = self.next();
567- // }
568- // self.peeked.as_ref().map(|r| Ok(r))
569- //}
570579}
571580
572581#[ cfg( test) ]
0 commit comments