Пример #1
0
 private static IEnumerable <DisasmInstruction> DecodeSourceAnnotatedDisassemblyInstructions(DebuggedProcess process, TupleValue[] items)
 {
     foreach (var item in items)
     {
         uint           line       = item.FindUint("line");
         string         file       = process.GetMappedFileFromTuple(item);
         ValueListValue asm_items  = item.Find <ValueListValue>("line_asm_insn");
         uint           lineOffset = 0;
         foreach (var asm_item in asm_items.Content)
         {
             DisasmInstruction disassemblyData = new DisasmInstruction();
             disassemblyData.Addr          = asm_item.FindAddr("address");
             disassemblyData.AddressString = asm_item.FindString("address");
             disassemblyData.Symbol        = asm_item.TryFindString("func-name");
             disassemblyData.Offset        = asm_item.Contains("offset") ? asm_item.FindUint("offset") : 0;
             disassemblyData.Opcode        = asm_item.FindString("inst");
             disassemblyData.CodeBytes     = asm_item.TryFindString("opcodes");
             disassemblyData.Line          = line;
             disassemblyData.File          = file;
             if (lineOffset == 0)
             {
                 lineOffset = disassemblyData.Offset;    // offset to start of current line
             }
             disassemblyData.OffsetInLine = disassemblyData.Offset - lineOffset;
             yield return(disassemblyData);
         }
     }
 }
Пример #2
0
        public static MITextPosition TryParse(DebuggedProcess process, TupleValue miTuple)
        {
            string filename = process.GetMappedFileFromTuple(miTuple);

            if (!string.IsNullOrEmpty(filename))
            {
                filename = DebuggedProcess.UnixPathToWindowsPath(filename);
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            uint?line = miTuple.TryFindUint("line");

            if (!line.HasValue || line.Value == 0)
            {
                return(null);
            }

            uint lineValue = line.Value;

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION startPosition = new Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION();
            startPosition.dwLine   = lineValue - 1;
            startPosition.dwColumn = 0;

            uint?startColumn = miTuple.TryFindUint("col");

            if (startColumn > 0)
            {
                startPosition.dwColumn = startColumn.Value - 1;
            }

            Microsoft.VisualStudio.Debugger.Interop.TEXT_POSITION endPosition = startPosition;
            uint?endLine = miTuple.TryFindUint("end-line");

            if (endLine > 0)
            {
                endPosition.dwLine = endLine.Value - 1;

                uint?endCol = miTuple.TryFindUint("end-col");
                if (endCol > 0)
                {
                    endPosition.dwColumn = endCol.Value - 1;
                }
            }

            return(new MITextPosition(filename, startPosition, endPosition));
        }