Esempio n. 1
0
        public void TryAddStackTrace(string info = null, bool doTrace = true)
        {
            if (!ShouldCollect)
            {
                return;
            }

            Current.TryMarkSimulating();

            var trace = doTrace ? MpUtil.FastStackTrace(4) : new MethodBase[0];

            Current.traces.Add(new TraceInfo()
            {
                trace = trace, info = info
            });
            current.traceHashes.Add(trace.Hash() ^ (info?.GetHashCode() ?? 0));
        }
Esempio n. 2
0
        /// <summary>
        /// Logs the current stack so that in the event of a desync we have some stack traces.
        /// </summary>
        /// <param name="info">Any additional message to be logged with the stack</param>
        /// <param name="doTrace">Set to false to not actually log a stack, only the message</param>
        public void TryAddStackTraceForDesyncLog(string info = null, bool doTrace = true)
        {
            if (!ShouldCollect)
            {
                return;
            }

            CurrentOpinion.TryMarkSimulating();

            //Get the current stack trace
            var trace = doTrace ? MpUtil.FastStackTrace(4) : new MethodBase[0];

            //Add it to the list
            CurrentOpinion.desyncStackTraces.Add(new StackTraceLogItem {
                stackTrace = trace, additionalInfo = info
            });

            //Calculate its hash and add it, for comparison with other opinions.
            currentOpinion.desyncStackTraceHashes.Add(trace.Hash() ^ (info?.GetHashCode() ?? 0));
        }