Beispiel #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);
         }
     }
 }
Beispiel #2
0
 private static DisasmInstruction[] DecodeDisassemblyInstructions(TupleValue[] items)
 {
     DisasmInstruction[] instructions = new DisasmInstruction[items.Length];
     for (int i = 0; i < items.Length; i++)
     {
         DisasmInstruction inst = new DisasmInstruction();
         inst.Addr          = items[i].FindAddr("address");
         inst.AddressString = items[i].FindString("address");
         inst.Symbol        = items[i].TryFindString("func-name");
         inst.Offset        = items[i].Contains("offset") ? items[i].FindUint("offset") : 0;
         inst.Opcode        = items[i].FindString("inst");
         inst.Line          = 0;
         inst.File          = null;
         instructions[i]    = inst;
     }
     return(instructions);
 }
Beispiel #3
0
        // https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Data-Manipulation.html#GDB_002fMI-Data-Manipulation
        // NB: the spec is wrong, offset and func-name are optional
        private static DisasmInstruction[] DecodeDisassemblyInstructions(TupleValue[] items)
        {
            var instructions = new DisasmInstruction[items.Length];

            for (int i = 0; i < items.Length; i++)
            {
                var inst = new DisasmInstruction();
                inst.Addr          = items[i].FindAddr("address");
                inst.AddressString = items[i].FindString("address");
                int offset = items[i].Contains("offset") ? items[i].FindInt("offset") : 0;
                if (offset > 0) // negative offset seen after throw
                {
                    inst.Offset = (uint)offset;
                    inst.Symbol = items[i].TryFindString("func-name");
                }
                inst.Opcode     = items[i].FindString("inst");
                inst.CodeBytes  = items[i].TryFindString("opcodes");
                inst.Line       = 0;
                inst.File       = null;
                instructions[i] = inst;
            }
            return(instructions);
        }
Beispiel #4
0
 public DisassemblyBlock(DisasmInstruction[] ins)
 {
     Touch = ++s_touchCount;
     _instructions = ins;
 }
Beispiel #5
0
 private static IEnumerable<DisasmInstruction> DecodeSourceAnnotatedDisassemblyInstructions(TupleValue[] items)
 {
     foreach (var item in items)
     {
         uint line = item.FindUint("line");
         string file = item.FindString("file");
         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.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;
         }
     }
 }
Beispiel #6
0
 private static DisasmInstruction[] DecodeDisassemblyInstructions(TupleValue[] items)
 {
     DisasmInstruction[] instructions = new DisasmInstruction[items.Length];
     for (int i = 0; i < items.Length; i++)
     {
         DisasmInstruction inst = new DisasmInstruction();
         inst.Addr = items[i].FindAddr("address");
         inst.AddressString = items[i].FindString("address");
         inst.Symbol = items[i].TryFindString("func-name");
         inst.Offset = items[i].Contains("offset") ? items[i].FindUint("offset") : 0;
         inst.Opcode = items[i].FindString("inst");
         inst.Line = 0;
         inst.File = null;
         instructions[i] = inst;
     }
     return instructions;
 }
Beispiel #7
0
 private async Task<DisasmInstruction[]> VerifyDisassembly(DisasmInstruction[] instructions, ulong startAddress, ulong targetAddress)
 {
     int count = 0;
     while (instructions[instructions.Length - 1].Addr != targetAddress && count < _process.MaxInstructionSize)
     {
         instructions = null;    // throw away the previous instructions
         count++;
         startAddress--;         // back up one byte
         instructions = await Disassemble(_process, startAddress, targetAddress + 1); // try again
     }
     return instructions;
 }