private static CallStackEntry GenerateCallStackEntry(MondProgram program, int address) { var debugInfo = program.DebugInfo; if (debugInfo == null) return new CallStackEntry(address, program.GetHashCode().ToString("X8"), address.ToString("X8"), 0, -1); var fileName = program.DebugInfo.FileName; string function = null; var lineNumber = 0; var columnNumber = -1; var func = program.DebugInfo.FindFunction(address); if (func.HasValue) function = program.Strings[func.Value.Name]; var position = program.DebugInfo.FindPosition(address); if (position.HasValue) { lineNumber = position.Value.LineNumber; columnNumber = position.Value.ColumnNumber; } if (fileName == null) fileName = program.GetHashCode().ToString("X8"); if (function == null) function = address.ToString("X8"); return new CallStackEntry(address, fileName, function, lineNumber, columnNumber); }
public ProgramInfo(MondProgram program) { _breakpoints = new List <int>(16); Program = program; DebugInfo = program.DebugInfo; FileName = DebugInfo?.FileName ?? Program.GetHashCode().ToString("X8"); }
private static CallStackEntry GenerateCallStackEntry(MondProgram program, int address) { var debugInfo = program.DebugInfo; if (debugInfo == null) { return(new CallStackEntry( program, address, program.GetHashCode().ToString("X8"), address.ToString("X8"), 0, -1)); } var fileName = program.DebugInfo.FileName; string function = null; var lineNumber = 0; var columnNumber = -1; var func = program.DebugInfo.FindFunction(address); if (func.HasValue) { function = program.Strings[func.Value.Name]; } var position = program.DebugInfo.FindPosition(address); if (position.HasValue) { lineNumber = position.Value.LineNumber; columnNumber = position.Value.ColumnNumber; } if (fileName == null) { fileName = program.GetHashCode().ToString("X8"); } if (function == null) { function = address.ToString("X8"); } return(new CallStackEntry( program, address, fileName, function, lineNumber, columnNumber)); }
private static string GetAddressDebugInfo(MondProgram program, int address) { if (program.DebugInfo != null) { var func = program.DebugInfo.FindFunction(address); var position = program.DebugInfo.FindPosition(address); if (func.HasValue && position.HasValue) { var prefix = ""; var funcName = program.Strings[func.Value.Name]; var fileName = program.DebugInfo.FileName ?? program.GetHashCode().ToString("X8"); if (!string.IsNullOrEmpty(funcName)) prefix = string.Format("at {0} ", funcName); return string.Format("{0}in {1}: line {2}:{3}", prefix, fileName, position.Value.LineNumber, position.Value.ColumnNumber); } } return address.ToString("X8"); }