public JsonExecutionTrace(ExecutionTrace item) { this.Name = string.Format("{0}.{1}({2})", item.ClassName, item.MethodName, item.Tag); this.MinDuration = item.MinDuration; this.MaxDuration = item.MaxDuration; this.AvgDuration = item.AvgDuration; this.TotalDuration = Format(Math.Round((double)item.TotalDuration / 1000 /*secs*/ / 60 /*mins*/ / 60 /*hrs*/, 2)); this.Counter = item.Counter; this.LastCall = item.LastCall.ToString("yyy-MM-dd HH:mm"); }
/// <summary> /// Default contructor, initializes properties, etc. accordingly. /// </summary> public DebugConfiguration() { // Initialize our execution trace ExecutionTrace = new ExecutionTrace(); // Set our default tracing IsTracing = false; // Set our default for exception throwing on failed results. ThrowExceptionOnFailResult = true; }
/// <summary> /// Default contructor, initializes properties, etc. accordingly. /// </summary> public DebugConfiguration(BaseDB database = null) { // Set/initialize our database. Database = database ?? new BaseDB(); // Initialize our execution trace ExecutionTrace = new ExecutionTrace(); // Set our default tracing IsTracing = false; // Set our default for preimage tracing IsTracingPreimages = true; // Set our default for exception throwing on failed results. ThrowExceptionOnFailResult = true; }
// Exceptions public void RecordException(Exception exception, bool isContractExecuting, bool onlyIfNoPreviousErrors = false) { // Use optional tracing information to return with the error for callstack/execution information. if (IsTracing && !onlyIfNoPreviousErrors) { ExecutionTrace?.RecordException(exception, isContractExecuting); } // If we already have an exception, stop if (Error != null) { return; } // Set our error. Error = exception; }
// Tracing public void RecordExecutionStart(MeadowEVM evm) { // If we're not tracing, clear our execution trace. if (!IsTracing) { ExecutionTrace = null; } // If our depth is 0, we should start a new trace map and clear errors. if (evm.Message.Depth == 0) { // Start a new trace map if we're tracing. if (IsTracing) { ExecutionTrace = new ExecutionTrace(); } // Clear our error. Error = null; } }
internal static ExecutionTrace CoreExecutionTraceJsonExecutionTrace(Meadow.EVM.Debugging.Tracing.ExecutionTrace coreExecutionTrace) { // If the execution trace is null, we return null if (coreExecutionTrace == null) { return(null); } // Create our array of trace points ExecutionTracePoint[] tracepoints = new ExecutionTracePoint[coreExecutionTrace.Tracepoints.Count]; // Populate all tracepoint items. for (int i = 0; i < tracepoints.Length; i++) { // Obtain our trace point. var executionTracePoint = coreExecutionTrace.Tracepoints[i]; // Define our memory and stack Data[] executionMemory = null; Data[] executionStack = executionTracePoint.Stack.Select(s => new Data(s)).ToArray(); if (executionTracePoint.Memory != null) { int wordCount = (int)EVMDefinitions.GetWordCount(executionTracePoint.Memory.Length); Span <byte> memorySpan = executionTracePoint.Memory; executionMemory = new Data[wordCount]; for (int x = 0; x < executionMemory.Length; x++) { executionMemory[x] = new Data(memorySpan.Slice(x * EVMDefinitions.WORD_SIZE, EVMDefinitions.WORD_SIZE)); } } // Obtain our memory tracepoints[i] = new ExecutionTracePoint() { CallData = executionTracePoint.CallData, Code = executionTracePoint.Code, ContractAddress = executionTracePoint.ContractAddress == null ? (Address?)null : new Address(executionTracePoint.ContractAddress.ToByteArray()), ContractDeployed = executionTracePoint.ContractDeployed, Opcode = executionTracePoint.Opcode, GasRemaining = (UInt256)executionTracePoint.GasRemaining, GasCost = (UInt256)executionTracePoint.GasCost, PC = executionTracePoint.PC, Depth = executionTracePoint.Depth, Stack = executionStack, Memory = executionMemory, Storage = executionTracePoint.Storage }; } // Create our array of exceptions ExecutionTraceException[] exceptions = new ExecutionTraceException[coreExecutionTrace.Exceptions.Count]; // Populate all exception items for (int i = 0; i < exceptions.Length; i++) { // Set our item. exceptions[i] = new ExecutionTraceException() { TraceIndex = coreExecutionTrace.Exceptions[i].TraceIndex, Message = coreExecutionTrace.Exceptions[i].Exception.Message }; } // Obtain our execution trace analysis. ExecutionTrace executionTrace = new ExecutionTrace() { Tracepoints = tracepoints, Exceptions = exceptions }; // Return our execution trace. return(executionTrace); }
/// <summary> /// Initializes the storage manager with the provided execution trace. /// </summary> /// <param name="executionTrace">The execution trace to initialize and track storage across.</param> public StorageManager(ExecutionTrace executionTrace) { // Set our properties ExecutionTrace = executionTrace; }