internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory, ref TargetAddress lmf_address) { TargetAddress lmf = lmf_address; TargetBinaryReader reader = memory.ReadMemory(lmf, 36).GetReader(); lmf_address = reader.ReadTargetAddress(); // prev reader.Position = 16; TargetAddress ebx = reader.ReadTargetAddress(); TargetAddress edi = reader.ReadTargetAddress(); TargetAddress esi = reader.ReadTargetAddress(); TargetAddress ebp = reader.ReadTargetAddress(); TargetAddress eip = reader.ReadTargetAddress(); Registers regs = new Registers(this); regs [(int)X86_Register.RBX].SetValue(lmf + 16, ebx); regs [(int)X86_Register.RDI].SetValue(lmf + 20, edi); regs [(int)X86_Register.RSI].SetValue(lmf + 24, esi); regs [(int)X86_Register.RBP].SetValue(lmf + 28, ebp); regs [(int)X86_Register.RIP].SetValue(lmf + 32, eip); TargetAddress new_ebp = memory.ReadAddress(ebp); regs [(int)X86_Register.RBP].SetValue(ebp, new_ebp); TargetAddress new_esp = ebp + 8; regs [(int)X86_Register.RSP].SetValue(ebp, new_esp); return(CreateFrame(thread.Client, FrameType.LMF, memory, eip, new_esp, new_ebp, regs)); }
public MonoMethodSignature GetMethodSignature(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetAddress signature) { int count = memory.ReadInteger(signature + 4) & 0x0000ffff; int offset = memory.TargetAddressSize == 8 ? 16 : 12; TargetAddress ret = memory.ReadAddress(signature + offset); TargetType ret_type = mono.ReadType(memory, ret); if (count == 0) { return(new MonoMethodSignature(ret_type, new TargetType [0])); } offset += memory.TargetAddressSize; TargetReader reader = new TargetReader( memory.ReadMemory(signature + offset, count * memory.TargetAddressSize)); TargetType[] param_types = new TargetType [count]; for (int i = 0; i < count; i++) { param_types [i] = mono.ReadType(memory, reader.ReadAddress()); } return(new MonoMethodSignature(ret_type, param_types)); }
internal void MonoArrayTypeGetBounds(TargetMemoryAccess memory, TargetAddress data) { // // FIXME: Only check whether the low bounds are all zero // int num_sizes = memory.ReadByte(data + memory.TargetAddressSize + 1); if (num_sizes != 0) { throw new InternalError(); } int num_lobounds = memory.ReadByte(data + memory.TargetAddressSize + 2); if (num_lobounds == 0) { return; } TargetAddress array = memory.ReadAddress(data + 3 * memory.TargetAddressSize); TargetBinaryReader bounds = memory.ReadMemory(array, num_lobounds * 4).GetReader(); for (int i = 0; i < num_lobounds; i++) { int bound = bounds.ReadInt32(); if (bound != 0) { throw new InternalError(); } } }
public GenericParamInfo GetGenericParameter(TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader( memory.ReadMemory(address, 4 * addr_size + 4)); TargetAddress container = reader.ReadAddress(); TargetAddress klass = reader.ReadAddress(); TargetAddress name_addr = reader.ReadAddress(); reader.BinaryReader.ReadInt16(); /* flags */ int pos = reader.BinaryReader.ReadInt16(); string name; if (!name_addr.IsNull) { name = memory.ReadString(name_addr); } else { name = String.Format("!{0}", pos); } return(new GenericParamInfo(container, klass, name, pos)); }
protected override void DoGetArrayBounds(TargetMemoryAccess target) { TargetBinaryReader reader = Location.ReadMemory(target, type.Size).GetReader(); reader.Position = 3 * reader.TargetMemoryInfo.TargetAddressSize; int length = reader.ReadInt32(); if (Rank == 1) { bounds = TargetArrayBounds.MakeSimpleArray(length); return; } reader.Position = 2 * reader.TargetMemoryInfo.TargetAddressSize; TargetAddress bounds_address = new TargetAddress( target.AddressDomain, reader.ReadAddress()); TargetBinaryReader breader = target.ReadMemory( bounds_address, 8 * Rank).GetReader(); int[] lower = new int [Rank]; int[] upper = new int [Rank]; for (int i = 0; i < Rank; i++) { int b_length = breader.ReadInt32(); int b_lower = breader.ReadInt32(); lower [i] = b_lower; upper [i] = b_lower + b_length - 1; } bounds = TargetArrayBounds.MakeMultiArray(lower, upper); }
StackFrame try_unwind_sigreturn(StackFrame frame, TargetMemoryAccess memory) { byte[] data = memory.ReadMemory(frame.TargetAddress, 9).Contents; /* * Check for signal return trampolines: * * mov __NR_rt_sigreturn, %eax * syscall */ if ((data [0] != 0x48) || (data [1] != 0xc7) || (data [2] != 0xc0) || (data [3] != 0x0f) || (data [4] != 0x00) || (data [5] != 0x00) || (data [6] != 0x00) || (data [7] != 0x0f) || (data [8] != 0x05)) { return(null); } TargetAddress stack = frame.StackPointer; /* See `struct sigcontext' in <asm/sigcontext.h> */ int[] regoffsets = { (int)X86_Register.R8, (int)X86_Register.R9, (int)X86_Register.R10, (int)X86_Register.R11, (int)X86_Register.R12, (int)X86_Register.R13, (int)X86_Register.R14, (int)X86_Register.R15, (int)X86_Register.RDI, (int)X86_Register.RSI, (int)X86_Register.RBP, (int)X86_Register.RBX, (int)X86_Register.RDX, (int)X86_Register.RAX, (int)X86_Register.RCX, (int)X86_Register.RSP, (int)X86_Register.RIP, (int)X86_Register.EFLAGS }; Registers regs = CopyRegisters(frame.Registers); int offset = 0x28; /* The stack contains the `struct ucontext' from <asm/ucontext.h>; the * `struct sigcontext' starts at offset 0x28 in it. */ foreach (int regoffset in regoffsets) { TargetAddress new_value = memory.ReadAddress(stack + offset); regs [regoffset].SetValue(new_value); offset += 8; } TargetAddress rip = new TargetAddress( memory.AddressDomain, regs [(int)X86_Register.RIP].GetValue()); TargetAddress rsp = new TargetAddress( memory.AddressDomain, regs [(int)X86_Register.RSP].GetValue()); TargetAddress rbp = new TargetAddress( memory.AddressDomain, regs [(int)X86_Register.RBP].GetValue()); Symbol name = new Symbol("<signal handler>", rip, 0); return(new StackFrame( frame.Thread, FrameType.Signal, rip, rsp, rbp, regs, frame.Thread.NativeLanguage, name)); }
public AppDomainInfo GetAppDomainInfo(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader (memory.ReadMemory (address, 12 * addr_size)); return new AppDomainInfo (mono, memory, reader); }
public AppDomainInfo GetAppDomainInfo(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader(memory.ReadMemory(address, 12 * addr_size)); return(new AppDomainInfo(mono, memory, reader)); }
// // The following API is new in `terrania'. // public GenericClassInfo GetGenericClass(TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader(memory.ReadMemory(address, 5 * addr_size)); TargetAddress container = reader.ReadAddress(); TargetAddress class_inst = reader.ReadAddress(); reader.ReadAddress(); /* method_inst */ reader.ReadAddress(); TargetAddress cached_class = reader.ReadAddress(); int inst_id = memory.ReadInteger(class_inst); int inst_data = memory.ReadInteger(class_inst + 4); TargetAddress inst_argv; if (MonoDebuggerInfo.MajorVersion == 80) { inst_argv = memory.ReadAddress(class_inst + 8); } else { inst_argv = class_inst + 8; } int type_argc = inst_data & 0x3fffff; TargetReader argv_reader = new TargetReader( memory.ReadMemory(inst_argv, type_argc * addr_size)); TargetAddress[] type_args = new TargetAddress [type_argc]; for (int i = 0; i < type_argc; i++) { type_args [i] = argv_reader.ReadAddress(); } TargetAddress cached_class_ptr = address + 4 * addr_size; return(new GenericClassInfo(container, type_args, cached_class_ptr, cached_class)); }
public static MonoDebuggerInfo Create(TargetMemoryAccess memory, TargetAddress info) { TargetBinaryReader header = memory.ReadMemory(info, 24).GetReader(); long magic = header.ReadInt64(); if (magic != DynamicMagic) { Report.Error("`MONO_DEBUGGER__debugger_info' at {0} has unknown magic {1:x}.", info, magic); return(null); } int version = header.ReadInt32(); if (version < MinDynamicVersion) { Report.Error("`MONO_DEBUGGER__debugger_info' has version {0}, " + "but expected at least {1}.", version, MonoDebuggerInfo.MinDynamicVersion); return(null); } if (version > MaxDynamicVersion) { Report.Error("`MONO_DEBUGGER__debugger_info' has version {0}, " + "but expected at most {1}.", version, MonoDebuggerInfo.MaxDynamicVersion); return(null); } header.ReadInt32(); // minor version header.ReadInt32(); int size = header.ReadInt32(); TargetReader reader = new TargetReader(memory.ReadMemory(info, size)); return(new MonoDebuggerInfo(memory, reader)); }
internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory, ref TargetAddress lmf_address) { TargetAddress lmf = lmf_address; TargetBinaryReader reader = memory.ReadMemory(lmf_address, 88).GetReader(); lmf_address = reader.ReadTargetAddress(); // prev reader.ReadTargetAddress(); reader.ReadTargetAddress(); // method TargetAddress rip = reader.ReadTargetAddress(); if (lmf_address.IsNull) { return(null); } TargetAddress rbx = reader.ReadTargetAddress(); TargetAddress rbp = reader.ReadTargetAddress(); TargetAddress rsp = reader.ReadTargetAddress(); TargetAddress r12 = reader.ReadTargetAddress(); TargetAddress r13 = reader.ReadTargetAddress(); TargetAddress r14 = reader.ReadTargetAddress(); TargetAddress r15 = reader.ReadTargetAddress(); Registers regs = new Registers(this); if ((lmf_address.Address & 1) == 0) { rip = memory.ReadAddress(rsp - 8); regs [(int)X86_Register.RIP].SetValue(rsp - 8, rip); regs [(int)X86_Register.RBP].SetValue(lmf + 40, rbp); } else { TargetAddress new_rbp = memory.ReadAddress(rbp); regs [(int)X86_Register.RIP].SetValue(lmf + 24, rip); regs [(int)X86_Register.RBP].SetValue(rbp, new_rbp); rbp = new_rbp; lmf_address--; } regs [(int)X86_Register.RBX].SetValue(lmf + 32, rbx); regs [(int)X86_Register.RSP].SetValue(lmf + 48, rsp); regs [(int)X86_Register.R12].SetValue(lmf + 56, r12); regs [(int)X86_Register.R13].SetValue(lmf + 64, r13); regs [(int)X86_Register.R14].SetValue(lmf + 72, r14); regs [(int)X86_Register.R15].SetValue(lmf + 80, r15); return(CreateFrame(thread.Client, FrameType.LMF, memory, rip, rsp, rbp, regs)); }
protected override bool GetMonoTrampoline(TargetMemoryAccess memory, TargetAddress call_target, out TargetAddress trampoline) { TargetBinaryReader reader = memory.ReadMemory(call_target, 10).GetReader(); byte opcode = reader.ReadByte(); if (opcode == 0x6a) { reader.Position++; } else if (opcode == 0x68) { reader.Position += 4; } else { trampoline = TargetAddress.Null; return(false); } opcode = reader.ReadByte(); if (opcode != 0xe9) { trampoline = TargetAddress.Null; return(false); } TargetAddress call = call_target + reader.ReadInt32() + reader.Position; if (!Opcodes.Process.MonoLanguage.IsTrampolineAddress(call)) { trampoline = TargetAddress.Null; return(false); } trampoline = call_target; return(true); }
protected void DoDecodeInstruction(TargetMemoryAccess memory, TargetAddress address) { TargetReader reader = new TargetReader( memory.ReadMemory(address, MaxInstructionLength)); while (CheckPrefix(reader)) { reader.Offset++; } byte opcode = reader.ReadByte(); if (opcode == 0x0f) { TwoByteOpcode(reader); } else { OneByteOpcode(reader, opcode); } if (InstructionType != Type.Unknown) { insn_size = (int)reader.Offset; has_insn_size = true; } else { insn_size = Opcodes.Disassembler.GetInstructionSize(memory, address); has_insn_size = true; } if (has_insn_size) { code = new byte [insn_size]; Array.Copy(reader.Contents, 0, code, 0, insn_size); } }
public MetadataInfo(TargetMemoryAccess memory, TargetAddress address) { int size = memory.ReadInteger(address); TargetBinaryReader reader = memory.ReadMemory(address, size).GetReader(); reader.ReadInt32(); MonoDefaultsSize = reader.ReadInt32(); MonoDefaultsAddress = new TargetAddress( memory.AddressDomain, reader.ReadAddress()); TypeSize = reader.ReadInt32(); ArrayTypeSize = reader.ReadInt32(); KlassSize = reader.ReadInt32(); ThreadSize = reader.ReadInt32(); ThreadTidOffset = reader.ReadInt32(); ThreadStackPtrOffset = reader.ReadInt32(); ThreadEndStackOffset = reader.ReadInt32(); KlassImageOffset = reader.ReadInt32(); KlassInstanceSizeOffset = reader.ReadInt32(); KlassParentOffset = reader.ReadInt32(); KlassTokenOffset = reader.ReadInt32(); KlassFieldOffset = reader.ReadInt32(); KlassMethodsOffset = reader.ReadInt32(); KlassMethodCountOffset = reader.ReadInt32(); KlassThisArgOffset = reader.ReadInt32(); KlassByValArgOffset = reader.ReadInt32(); KlassGenericClassOffset = reader.ReadInt32(); KlassGenericContainerOffset = reader.ReadInt32(); KlassVTableOffset = reader.ReadInt32(); FieldInfoSize = reader.ReadInt32(); FieldInfoTypeOffset = reader.ReadInt32(); FieldInfoOffsetOffset = reader.ReadInt32(); KlassFieldCountOffset = KlassMethodCountOffset - 8; MonoDefaultsCorlibOffset = reader.ReadInt32(); MonoDefaultsObjectOffset = reader.ReadInt32(); MonoDefaultsByteOffset = reader.ReadInt32(); MonoDefaultsVoidOffset = reader.ReadInt32(); MonoDefaultsBooleanOffset = reader.ReadInt32(); MonoDefaultsSByteOffset = reader.ReadInt32(); MonoDefaultsInt16Offset = reader.ReadInt32(); MonoDefaultsUInt16Offset = reader.ReadInt32(); MonoDefaultsInt32Offset = reader.ReadInt32(); MonoDefaultsUInt32Offset = reader.ReadInt32(); MonoDefaultsIntOffset = reader.ReadInt32(); MonoDefaultsUIntOffset = reader.ReadInt32(); MonoDefaultsInt64Offset = reader.ReadInt32(); MonoDefaultsUInt64Offset = reader.ReadInt32(); MonoDefaultsSingleOffset = reader.ReadInt32(); MonoDefaultsDoubleOffset = reader.ReadInt32(); MonoDefaultsCharOffset = reader.ReadInt32(); MonoDefaultsStringOffset = reader.ReadInt32(); MonoDefaultsEnumOffset = reader.ReadInt32(); MonoDefaultsArrayOffset = reader.ReadInt32(); MonoDefaultsDelegateOffset = reader.ReadInt32(); MonoDefaultsExceptionOffset = reader.ReadInt32(); MonoMethodKlassOffset = reader.ReadInt32(); MonoMethodTokenOffset = reader.ReadInt32(); MonoMethodFlagsOffset = reader.ReadInt32(); MonoMethodInflatedOffset = reader.ReadInt32(); MonoVTableKlassOffset = reader.ReadInt32(); MonoVTableVTableOffset = reader.ReadInt32(); }
protected override void DoGetArrayBounds(TargetMemoryAccess target) { TargetBinaryReader reader = Location.ReadMemory (target, type.Size).GetReader (); reader.Position = 3 * reader.TargetMemoryInfo.TargetAddressSize; int length = reader.ReadInt32 (); if (Rank == 1) { bounds = TargetArrayBounds.MakeSimpleArray (length); return; } reader.Position = 2 * reader.TargetMemoryInfo.TargetAddressSize; TargetAddress bounds_address = new TargetAddress ( target.AddressDomain, reader.ReadAddress ()); TargetBinaryReader breader = target.ReadMemory ( bounds_address, 8 * Rank).GetReader (); int[] lower = new int [Rank]; int[] upper = new int [Rank]; for (int i = 0; i < Rank; i++) { int b_length = breader.ReadInt32 (); int b_lower = breader.ReadInt32 (); lower [i] = b_lower; upper [i] = b_lower + b_length - 1; } bounds = TargetArrayBounds.MakeMultiArray (lower, upper); }
internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory, ref TargetAddress lmf_address) { TargetAddress lmf = lmf_address; TargetBinaryReader reader = memory.ReadMemory (lmf, 36).GetReader (); lmf_address = reader.ReadTargetAddress (); // prev reader.Position = 16; TargetAddress ebx = reader.ReadTargetAddress (); TargetAddress edi = reader.ReadTargetAddress (); TargetAddress esi = reader.ReadTargetAddress (); TargetAddress ebp = reader.ReadTargetAddress (); TargetAddress eip = reader.ReadTargetAddress (); Registers regs = new Registers (this); regs [(int) X86_Register.RBX].SetValue (lmf + 16, ebx); regs [(int) X86_Register.RDI].SetValue (lmf + 20, edi); regs [(int) X86_Register.RSI].SetValue (lmf + 24, esi); regs [(int) X86_Register.RBP].SetValue (lmf + 28, ebp); regs [(int) X86_Register.RIP].SetValue (lmf + 32, eip); TargetAddress new_ebp = memory.ReadAddress (ebp); regs [(int) X86_Register.RBP].SetValue (ebp, new_ebp); TargetAddress new_esp = ebp + 8; regs [(int) X86_Register.RSP].SetValue (ebp, new_esp); return CreateFrame (thread.Client, FrameType.LMF, memory, eip, new_esp, new_ebp, regs); }
internal override StackFrame GetLMF(ThreadServant thread, TargetMemoryAccess memory, ref TargetAddress lmf_address) { TargetAddress lmf = lmf_address; TargetBinaryReader reader = memory.ReadMemory (lmf_address, 88).GetReader (); lmf_address = reader.ReadTargetAddress (); // prev reader.ReadTargetAddress (); reader.ReadTargetAddress (); // method TargetAddress rip = reader.ReadTargetAddress (); if (lmf_address.IsNull) return null; TargetAddress rbx = reader.ReadTargetAddress (); TargetAddress rbp = reader.ReadTargetAddress (); TargetAddress rsp = reader.ReadTargetAddress (); TargetAddress r12 = reader.ReadTargetAddress (); TargetAddress r13 = reader.ReadTargetAddress (); TargetAddress r14 = reader.ReadTargetAddress (); TargetAddress r15 = reader.ReadTargetAddress (); Registers regs = new Registers (this); if ((lmf_address.Address & 1) == 0) { rip = memory.ReadAddress (rsp - 8); regs [(int) X86_Register.RIP].SetValue (rsp - 8, rip); regs [(int) X86_Register.RBP].SetValue (lmf + 40, rbp); } else { TargetAddress new_rbp = memory.ReadAddress (rbp); regs [(int) X86_Register.RIP].SetValue (lmf + 24, rip); regs [(int) X86_Register.RBP].SetValue (rbp, new_rbp); rbp = new_rbp; lmf_address--; } regs [(int) X86_Register.RBX].SetValue (lmf + 32, rbx); regs [(int) X86_Register.RSP].SetValue (lmf + 48, rsp); regs [(int) X86_Register.R12].SetValue (lmf + 56, r12); regs [(int) X86_Register.R13].SetValue (lmf + 64, r13); regs [(int) X86_Register.R14].SetValue (lmf + 72, r14); regs [(int) X86_Register.R15].SetValue (lmf + 80, r15); return CreateFrame (thread.Client, FrameType.LMF, memory, rip, rsp, rbp, regs); }
StackFrame try_unwind_sigreturn(StackFrame frame, TargetMemoryAccess memory) { byte[] data = memory.ReadMemory (frame.TargetAddress, 9).Contents; /* * Check for signal return trampolines: * * mov __NR_rt_sigreturn, %eax * syscall */ if ((data [0] != 0x48) || (data [1] != 0xc7) || (data [2] != 0xc0) || (data [3] != 0x0f) || (data [4] != 0x00) || (data [5] != 0x00) || (data [6] != 0x00) || (data [7] != 0x0f) || (data [8] != 0x05)) return null; TargetAddress stack = frame.StackPointer; /* See `struct sigcontext' in <asm/sigcontext.h> */ int[] regoffsets = { (int) X86_Register.R8, (int) X86_Register.R9, (int) X86_Register.R10, (int) X86_Register.R11, (int) X86_Register.R12, (int) X86_Register.R13, (int) X86_Register.R14, (int) X86_Register.R15, (int) X86_Register.RDI, (int) X86_Register.RSI, (int) X86_Register.RBP, (int) X86_Register.RBX, (int) X86_Register.RDX, (int) X86_Register.RAX, (int) X86_Register.RCX, (int) X86_Register.RSP, (int) X86_Register.RIP, (int) X86_Register.EFLAGS }; Registers regs = CopyRegisters (frame.Registers); int offset = 0x28; /* The stack contains the `struct ucontext' from <asm/ucontext.h>; the * `struct sigcontext' starts at offset 0x28 in it. */ foreach (int regoffset in regoffsets) { TargetAddress new_value = memory.ReadAddress (stack + offset); regs [regoffset].SetValue (new_value); offset += 8; } TargetAddress rip = new TargetAddress ( memory.AddressDomain, regs [(int) X86_Register.RIP].GetValue ()); TargetAddress rsp = new TargetAddress ( memory.AddressDomain, regs [(int) X86_Register.RSP].GetValue ()); TargetAddress rbp = new TargetAddress ( memory.AddressDomain, regs [(int) X86_Register.RBP].GetValue ()); Symbol name = new Symbol ("<signal handler>", rip, 0); return new StackFrame ( frame.Thread, FrameType.Signal, rip, rsp, rbp, regs, frame.Thread.NativeLanguage, name); }
public MonoMethodSignature GetMethodSignature(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetAddress signature) { int count = memory.ReadInteger (signature + 4) & 0x0000ffff; int offset = memory.TargetAddressSize == 8 ? 16 : 12; TargetAddress ret = memory.ReadAddress (signature + offset); TargetType ret_type = mono.ReadType (memory, ret); if (count == 0) return new MonoMethodSignature (ret_type, new TargetType [0]); offset += memory.TargetAddressSize; TargetReader reader = new TargetReader ( memory.ReadMemory (signature + offset, count * memory.TargetAddressSize)); TargetType[] param_types = new TargetType [count]; for (int i = 0; i < count; i++) param_types [i] = mono.ReadType (memory, reader.ReadAddress ()); return new MonoMethodSignature (ret_type, param_types); }
internal virtual TargetBlob ReadMemory(TargetMemoryAccess target, int size) { return target.ReadMemory (GetAddress (target), size); }
// This method reads the MonoDebuggerSymbolTable structure // (struct definition is in mono-debug-debugger.h) void do_read_symbol_table(TargetMemoryAccess memory) { TargetAddress symtab_address = memory.ReadAddress (info.SymbolTable); if (symtab_address.IsNull) throw new SymbolTableException ("Symbol table is null."); TargetReader header = new TargetReader ( memory.ReadMemory (symtab_address, info.SymbolTableSize)); long magic = header.BinaryReader.ReadInt64 (); if (magic != MonoDebuggerInfo.DynamicMagic) throw new SymbolTableException ( "Debugger symbol table has unknown magic {0:x}.", magic); int version = header.ReadInteger (); if (version < MonoDebuggerInfo.MinDynamicVersion) throw new SymbolTableException ( "Debugger symbol table has version {0}, but " + "expected at least {1}.", version, MonoDebuggerInfo.MinDynamicVersion); if (version > MonoDebuggerInfo.MaxDynamicVersion) throw new SymbolTableException ( "Debugger symbol table has version {0}, but " + "expected at most {1}.", version, MonoDebuggerInfo.MaxDynamicVersion); int total_size = header.ReadInteger (); if (total_size != info.SymbolTableSize) throw new SymbolTableException ( "Debugger symbol table has size {0}, but " + "expected {1}.", total_size, info.SymbolTableSize); TargetAddress corlib_address = header.ReadAddress (); TargetAddress global_data_table_ptr = header.ReadAddress (); TargetAddress data_table_list = header.ReadAddress (); TargetAddress symfile_by_index = header.ReadAddress (); if (corlib_address.IsNull) throw new SymbolTableException ("Corlib address is null."); corlib = load_symfile (memory, corlib_address); if (corlib == null) throw new SymbolTableException ("Cannot read corlib!"); TargetAddress ptr = symfile_by_index; while (!ptr.IsNull) { TargetAddress next_ptr = memory.ReadAddress (ptr); TargetAddress address = memory.ReadAddress ( ptr + memory.TargetMemoryInfo.TargetAddressSize); ptr = next_ptr; load_symfile (memory, address); } ptr = data_table_list; while (!ptr.IsNull) { TargetAddress next_ptr = memory.ReadAddress (ptr); TargetAddress address = memory.ReadAddress ( ptr + memory.TargetMemoryInfo.TargetAddressSize); ptr = next_ptr; add_data_table (memory, address); } global_data_table = new GlobalDataTable (this, global_data_table_ptr); }
Method read_range_entry(TargetMemoryAccess target, TargetAddress address) { int size = target.ReadInteger (address); TargetReader reader = new TargetReader (target.ReadMemory (address, size)); byte[] contents = reader.BinaryReader.PeekBuffer (size); reader.BinaryReader.ReadInt32 (); int file_idx = reader.BinaryReader.ReadInt32 (); MonoSymbolFile file = (MonoSymbolFile) symfile_by_index [file_idx]; return file.ReadRangeEntry (target, reader, contents); }
void add_data_table(TargetMemoryAccess memory, TargetAddress ptr) { int table_size = 8 + 2 * memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader (memory.ReadMemory (ptr, table_size)); int domain = reader.ReadInteger (); reader.Offset += 4; DomainDataTable table = (DomainDataTable) data_tables [domain]; if (table == null) { TargetAddress first_chunk = reader.ReadAddress (); table = new DomainDataTable (this, domain, ptr, first_chunk); data_tables.Add (domain, table); } }
void create_appdomain(TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader ( memory.ReadMemory (address, 8 + 3 * addr_size)); int id = reader.BinaryReader.ReadInt32 (); int shadow_path_len = reader.BinaryReader.ReadInt32 (); TargetAddress shadow_path_addr = reader.ReadAddress (); string shadow_path = null; if (!shadow_path_addr.IsNull) { byte[] buffer = memory.ReadBuffer (shadow_path_addr, shadow_path_len); char[] cbuffer = new char [buffer.Length]; for (int i = 0; i < buffer.Length; i++) cbuffer [i] = (char) buffer [i]; shadow_path = new String (cbuffer); } TargetAddress domain = reader.ReadAddress (); TargetAddress setup = reader.ReadAddress (); MetadataHelper.AppDomainInfo info = MetadataHelper.GetAppDomainInfo (this, memory, setup); info.ShadowCopyPath = shadow_path; appdomain_info.Add (id, info); }
protected override bool GetMonoTrampoline(TargetMemoryAccess memory, TargetAddress call_target, out TargetAddress trampoline) { TargetBinaryReader reader = memory.ReadMemory (call_target, 14).GetReader (); byte opcode = reader.ReadByte (); if (opcode != 0xe8) { trampoline = TargetAddress.Null; return false; } TargetAddress call = call_target + reader.ReadInt32 () + 5; if (!Opcodes.Process.MonoLanguage.IsTrampolineAddress (call)) { trampoline = TargetAddress.Null; return false; } trampoline = call_target; return true; }
public GenericParamInfo GetGenericParameter(TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader ( memory.ReadMemory (address, 4 * addr_size + 4)); TargetAddress container = reader.ReadAddress (); TargetAddress klass = reader.ReadAddress (); TargetAddress name_addr = reader.ReadAddress (); reader.BinaryReader.ReadInt16 (); /* flags */ int pos = reader.BinaryReader.ReadInt16 (); string name; if (!name_addr.IsNull) name = memory.ReadString (name_addr); else name = String.Format ("!{0}", pos); return new GenericParamInfo (container, klass, name, pos); }
protected void DoDecodeInstruction(TargetMemoryAccess memory, TargetAddress address) { TargetReader reader = new TargetReader ( memory.ReadMemory (address, MaxInstructionLength)); while (CheckPrefix (reader)) reader.Offset++; byte opcode = reader.ReadByte (); if (opcode == 0x0f) TwoByteOpcode (reader); else OneByteOpcode (reader, opcode); if (InstructionType != Type.Unknown) { insn_size = (int) reader.Offset; has_insn_size = true; } else { insn_size = Opcodes.Disassembler.GetInstructionSize (memory, address); has_insn_size = true; } if (has_insn_size) { code = new byte [insn_size]; Array.Copy (reader.Contents, 0, code, 0, insn_size); } }
public MetadataInfo(TargetMemoryAccess memory, TargetAddress address) { int size = memory.ReadInteger (address); TargetBinaryReader reader = memory.ReadMemory (address, size).GetReader (); reader.ReadInt32 (); MonoDefaultsSize = reader.ReadInt32 (); MonoDefaultsAddress = new TargetAddress ( memory.AddressDomain, reader.ReadAddress ()); TypeSize = reader.ReadInt32 (); ArrayTypeSize = reader.ReadInt32 (); KlassSize = reader.ReadInt32 (); ThreadSize = reader.ReadInt32 (); ThreadTidOffset = reader.ReadInt32 (); ThreadStackPtrOffset = reader.ReadInt32 (); ThreadEndStackOffset = reader.ReadInt32 (); KlassImageOffset = reader.ReadInt32 (); KlassInstanceSizeOffset = reader.ReadInt32 (); KlassParentOffset = reader.ReadInt32 (); KlassTokenOffset = reader.ReadInt32 (); KlassFieldOffset = reader.ReadInt32 (); KlassMethodsOffset = reader.ReadInt32 (); KlassMethodCountOffset = reader.ReadInt32 (); KlassThisArgOffset = reader.ReadInt32 (); KlassByValArgOffset = reader.ReadInt32 (); KlassGenericClassOffset = reader.ReadInt32 (); KlassGenericContainerOffset = reader.ReadInt32 (); KlassVTableOffset = reader.ReadInt32 (); FieldInfoSize = reader.ReadInt32 (); FieldInfoTypeOffset = reader.ReadInt32 (); FieldInfoOffsetOffset = reader.ReadInt32 (); KlassFieldCountOffset = KlassMethodCountOffset - 8; MonoDefaultsCorlibOffset = reader.ReadInt32 (); MonoDefaultsObjectOffset = reader.ReadInt32 (); MonoDefaultsByteOffset = reader.ReadInt32 (); MonoDefaultsVoidOffset = reader.ReadInt32 (); MonoDefaultsBooleanOffset = reader.ReadInt32 (); MonoDefaultsSByteOffset = reader.ReadInt32 (); MonoDefaultsInt16Offset = reader.ReadInt32 (); MonoDefaultsUInt16Offset = reader.ReadInt32 (); MonoDefaultsInt32Offset = reader.ReadInt32 (); MonoDefaultsUInt32Offset = reader.ReadInt32 (); MonoDefaultsIntOffset = reader.ReadInt32 (); MonoDefaultsUIntOffset = reader.ReadInt32 (); MonoDefaultsInt64Offset = reader.ReadInt32 (); MonoDefaultsUInt64Offset = reader.ReadInt32 (); MonoDefaultsSingleOffset = reader.ReadInt32 (); MonoDefaultsDoubleOffset = reader.ReadInt32 (); MonoDefaultsCharOffset = reader.ReadInt32 (); MonoDefaultsStringOffset = reader.ReadInt32 (); MonoDefaultsEnumOffset = reader.ReadInt32 (); MonoDefaultsArrayOffset = reader.ReadInt32 (); MonoDefaultsDelegateOffset = reader.ReadInt32 (); MonoDefaultsExceptionOffset = reader.ReadInt32 (); MonoMethodKlassOffset = reader.ReadInt32 (); MonoMethodTokenOffset = reader.ReadInt32 (); MonoMethodFlagsOffset = reader.ReadInt32 (); MonoMethodInflatedOffset = reader.ReadInt32 (); MonoVTableKlassOffset = reader.ReadInt32 (); MonoVTableVTableOffset = reader.ReadInt32 (); }
public void Read(TargetMemoryAccess memory) { int address_size = memory.TargetMemoryInfo.TargetAddressSize; int header_size = 16 + address_size; if (first_chunk.IsNull) { first_chunk = memory.ReadAddress (TableAddress + 8); current_chunk = first_chunk; } if (current_chunk.IsNull) return; again: TargetReader reader = new TargetReader ( memory.ReadMemory (current_chunk, header_size)); reader.ReadInteger (); /* size */ int allocated_size = reader.ReadInteger (); int current_offset = reader.ReadInteger (); reader.ReadInteger (); /* dummy */ TargetAddress next = reader.ReadAddress (); read_data_items (memory, current_chunk + header_size, last_offset, current_offset); last_offset = current_offset; if (!next.IsNull && (current_offset == allocated_size)) { current_chunk = next; last_offset = 0; goto again; } }
internal void MonoArrayTypeGetBounds(TargetMemoryAccess memory, TargetAddress data) { // // FIXME: Only check whether the low bounds are all zero // int num_sizes = memory.ReadByte (data + memory.TargetAddressSize + 1); if (num_sizes != 0) throw new InternalError (); int num_lobounds = memory.ReadByte (data + memory.TargetAddressSize + 2); if (num_lobounds == 0) return; TargetAddress array = memory.ReadAddress (data + 3 * memory.TargetAddressSize); TargetBinaryReader bounds = memory.ReadMemory (array, num_lobounds * 4).GetReader (); for (int i = 0; i < num_lobounds; i++) { int bound = bounds.ReadInt32 (); if (bound != 0) throw new InternalError (); } }
void read_data_items(TargetMemoryAccess memory, TargetAddress address, int start, int end) { TargetReader reader = new TargetReader ( memory.ReadMemory (address + start, end - start)); Report.Debug (DebugFlags.JitSymtab, "READ DATA ITEMS: {0} {1} {2} - {3} {4}", address, start, end, reader.BinaryReader.Position, reader.Size); while (reader.BinaryReader.Position + 4 < reader.Size) { int item_size = reader.BinaryReader.ReadInt32 (); if (item_size == 0) break; DataItemType item_type = (DataItemType) reader.BinaryReader.ReadInt32 (); long pos = reader.BinaryReader.Position; ReadDataItem (memory, item_type, reader); reader.BinaryReader.Position = pos + item_size; } }
// // The following API is new in `terrania'. // public GenericClassInfo GetGenericClass(TargetMemoryAccess memory, TargetAddress address) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; TargetReader reader = new TargetReader (memory.ReadMemory (address, 5 * addr_size)); TargetAddress container = reader.ReadAddress (); TargetAddress class_inst = reader.ReadAddress (); reader.ReadAddress (); /* method_inst */ reader.ReadAddress (); TargetAddress cached_class = reader.ReadAddress (); int inst_id = memory.ReadInteger (class_inst); int inst_data = memory.ReadInteger (class_inst + 4); TargetAddress inst_argv; if (MonoDebuggerInfo.MajorVersion == 80) inst_argv = memory.ReadAddress (class_inst + 8); else inst_argv = class_inst + 8; int type_argc = inst_data & 0x3fffff; TargetReader argv_reader = new TargetReader ( memory.ReadMemory (inst_argv, type_argc * addr_size)); TargetAddress[] type_args = new TargetAddress [type_argc]; for (int i = 0; i < type_argc; i++) type_args [i] = argv_reader.ReadAddress (); TargetAddress cached_class_ptr = address + 4 * addr_size; return new GenericClassInfo (container, type_args, cached_class_ptr, cached_class); }
internal virtual TargetBlob ReadMemory(TargetMemoryAccess target, int size) { return(target.ReadMemory(GetAddress(target), size)); }