internal int il_offset_to_line_number (int il_offset, out string src_file, out byte[] src_hash) { if (debug_info == null) debug_info = vm.conn.Method_GetDebugInfo (id); // FIXME: Optimize this src_file = null; src_hash = null; for (int i = debug_info.il_offsets.Length - 1; i >= 0; --i) { if (debug_info.il_offsets [i] <= il_offset) { src_file = debug_info.source_files [i].source_file; src_hash = debug_info.source_files [i].hash; return debug_info.line_numbers [i]; } } return -1; }
internal int il_offset_to_line_number (int il_offset) { if (debug_info == null) debug_info = vm.conn.Method_GetDebugInfo (id); // FIXME: Optimize this for (int i = debug_info.il_offsets.Length - 1; i >= 0; --i) { if (debug_info.il_offsets [i] <= il_offset) return debug_info.line_numbers [i]; } return -1; }
internal DebugInfo Method_GetDebugInfo (long id) { var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_DEBUG_INFO, new PacketWriter ().WriteId (id)); DebugInfo info = new DebugInfo (); info.max_il_offset = res.ReadInt (); info.filename = res.ReadString (); int n_il_offsets = res.ReadInt (); info.il_offsets = new int [n_il_offsets]; info.line_numbers = new int [n_il_offsets]; for (int i = 0; i < n_il_offsets; ++i) { info.il_offsets [i] = res.ReadInt (); info.line_numbers [i] = res.ReadInt (); } return info; }
internal DebugInfo Method_GetDebugInfo(long id) { var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_DEBUG_INFO, new PacketWriter ().WriteId (id)); DebugInfo info = new DebugInfo (); info.max_il_offset = res.ReadInt (); SourceInfo[] sources = null; if (Version.AtLeast (2, 13)) { int n = res.ReadInt (); sources = new SourceInfo [n]; for (int i = 0; i < n; ++i) { sources [i].source_file = res.ReadString (); if (Version.AtLeast (2, 14)) { sources [i].hash = new byte [16]; for (int j = 0; j < 16; ++j) sources [i].hash [j] = (byte)res.ReadByte (); } } } else { sources = new SourceInfo [1]; sources [0].source_file = res.ReadString (); } int n_il_offsets = res.ReadInt (); info.il_offsets = new int [n_il_offsets]; info.line_numbers = new int [n_il_offsets]; info.source_files = new SourceInfo [n_il_offsets]; info.column_numbers = new int [n_il_offsets]; info.end_line_numbers = new int [n_il_offsets]; info.end_column_numbers = new int [n_il_offsets]; for (int i = 0; i < n_il_offsets; ++i) { info.il_offsets [i] = res.ReadInt (); info.line_numbers [i] = res.ReadInt (); if (Version.AtLeast (2, 12)) { int idx = res.ReadInt (); info.source_files [i] = idx >= 0 ? sources [idx] : default (SourceInfo); } else { info.source_files [i] = sources [0]; } if (Version.AtLeast (2, 19)) info.column_numbers [i] = res.ReadInt (); else info.column_numbers [i] = 0; if (Version.AtLeast (2, 32)) { info.end_line_numbers [i] = res.ReadInt (); info.end_column_numbers [i] = res.ReadInt (); } else { info.end_column_numbers [i] = -1; info.end_column_numbers [i] = -1; } } return info; }
internal DebugInfo Method_GetDebugInfo (long id) { var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_DEBUG_INFO, new PacketWriter ().WriteId (id)); DebugInfo info = new DebugInfo (); info.max_il_offset = res.ReadInt (); string[] filenames = null; if (Version.AtLeast (2, 12)) { int n = res.ReadInt (); filenames = new string [n]; for (int i = 0; i < n; ++i) filenames [i] = res.ReadString (); } else { filenames = new string [1]; filenames [0] = res.ReadString (); } int n_il_offsets = res.ReadInt (); info.il_offsets = new int [n_il_offsets]; info.line_numbers = new int [n_il_offsets]; info.source_files = new string [n_il_offsets]; for (int i = 0; i < n_il_offsets; ++i) { info.il_offsets [i] = res.ReadInt (); info.line_numbers [i] = res.ReadInt (); if (Version.AtLeast (2, 12)) { int idx = res.ReadInt (); info.source_files [i] = idx >= 0 ? filenames [idx] : null; } else { info.source_files [i] = filenames [0]; } } return info; }