public MonoClassObject(MonoClassType type, MonoClassInfo info, TargetLocation location) : base(type, location) { this.type = type; this.info = info; }
public override TargetClass ForceClassInitialization(Thread thread) { if (class_info != null) { return(class_info); } thread.ThreadServant.DoTargetAccess( delegate(TargetMemoryAccess target) { class_info = ResolveClass(target, false); return(class_info); }); if (class_info != null) { return(class_info); } TargetAddress image = file.MonoImage; TargetAddress klass = thread.CallMethod( file.MonoLanguage.MonoDebuggerInfo.LookupClass, image, 0, 0, Name); return((TargetClass)thread.ThreadServant.DoTargetAccess( delegate(TargetMemoryAccess target) { class_info = MonoClassInfo.ReadClassInfo( file.MonoLanguage, target, klass); return class_info; })); }
public override TargetMethodSignature GetSignature(Thread thread) { if (signature != null) { return(signature); } if (!ContainsGenericParameters) { return(new MonoMethodSignature(return_type, parameter_types)); } if (!thread.CurrentFrame.Language.IsManaged) { throw new TargetException(TargetError.InvalidContext); } TargetAddress addr = (TargetAddress)thread.ThreadServant.DoTargetAccess( delegate(TargetMemoryAccess target) { MonoClassInfo class_info = ResolveClass(target, true); return(class_info.GetMethodAddress(target, token)); }); MonoLanguageBackend mono = klass.File.MonoLanguage; TargetAddress sig = thread.CallMethod( mono.MonoDebuggerInfo.GetMethodSignature, addr, 0); signature = (MonoMethodSignature)thread.ThreadServant.DoTargetAccess( delegate(TargetMemoryAccess target) { return(mono.MetadataHelper.GetMethodSignature(mono, target, sig)); }); return(signature); }
void get_parent(TargetMemoryAccess target) { parent_klass = MetadataHelper.MonoClassGetParent(target, KlassAddress); if (parent_klass.IsNull) { return; } parent_info = ReadClassInfo(SymbolFile.MonoLanguage, target, parent_klass); }
internal override TargetClassType GetParentType(TargetMemoryAccess target) { ResolveClass(target, true); MonoClassInfo parent = class_info.GetParent(target); if (parent == null) { return(null); } return(parent.Type); }
public static MonoClassInfo ReadCoreType(MonoSymbolFile file, Cecil.TypeDefinition typedef, TargetMemoryAccess target, TargetAddress klass, out MonoClassType type) { MonoClassInfo info = new MonoClassInfo(file, typedef, target, klass); type = new MonoClassType(file, typedef, info); ((IMonoStructType)type).ClassInfo = info; info.struct_type = type; info.type = type; return(info); }
public MonoClassInfo ResolveClass(TargetMemoryAccess target, bool fail) { if (resolved) { return(class_info); } if (class_info == null) { if (class_ptr.IsNull) { return(null); } TargetAddress klass = target.ReadAddress(class_ptr); if (klass.IsNull) { return(null); } class_info = File.MonoLanguage.ReadClassInfo(target, klass); } if (class_info == null) { if (!fail) { return(null); } throw new TargetException(TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", Name); } if (class_info.HasParent) { MonoClassInfo parent_info = class_info.GetParent(target); parent_type = (IMonoStructType)parent_info.Type; parent_type.ClassInfo = parent_info; if (parent_type.ResolveClass(target, fail) == null) { return(null); } } resolved = true; return(class_info); }
protected bool DoResolve(TargetMemoryAccess target) { if (Parent != null) { if (!Parent.Resolve(target)) { return(false); } type = (TargetClassType)Parent.Type; } klass = (MonoClassInfo)type.GetClass(target); if (klass == null) { return(false); } fields = klass.GetFields(target); return(true); }
public MonoClassInfo ResolveClass(TargetMemoryAccess target, bool fail) { if (resolved) { return(class_info); } if (class_info == null) { int token = type.MetadataToken.ToInt32(); class_info = file.LookupClassInfo(target, token); } if (class_info == null) { if (!fail) { return(null); } throw new TargetException(TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", Name); } if (class_info.HasParent) { MonoClassInfo parent_info = class_info.GetParent(target); parent_type = (IMonoStructType)parent_info.Type; parent_type.ClassInfo = parent_info; if (parent_type.ResolveClass(target, fail) == null) { return(null); } } resolved = true; return(class_info); }
internal override int GetElementSize(TargetMemoryAccess target) { TargetType element_type; if (ElementType is MonoEnumType) { element_type = ((MonoEnumType)ElementType).ClassType; } else { element_type = ElementType; } IMonoStructType stype = element_type as IMonoStructType; if ((stype == null) || stype.Type.IsByRef) { return(base.GetElementSize(target)); } MonoClassInfo cinfo = stype.ResolveClass(target, true); return(cinfo.GetInstanceSize(target)); }
public override TargetClass ForceClassInitialization(Thread thread) { if (class_info != null) return class_info; thread.ThreadServant.DoTargetAccess ( delegate (TargetMemoryAccess target) { class_info = ResolveClass (target, false); return class_info; }); if (class_info != null) return class_info; TargetAddress image = file.MonoImage; TargetAddress klass = thread.CallMethod ( file.MonoLanguage.MonoDebuggerInfo.LookupClass, image, 0, 0, Name); return (TargetClass) thread.ThreadServant.DoTargetAccess ( delegate (TargetMemoryAccess target) { class_info = MonoClassInfo.ReadClassInfo ( file.MonoLanguage, target, klass); return class_info; }); }
public MonoClassType(MonoSymbolFile file, Cecil.TypeDefinition typedef, MonoClassInfo class_info) : this(file, typedef) { this.class_info = class_info; }
internal MonoClassInfo ReadClassInfo(MonoLanguageBackend mono, TargetMemoryAccess target) { if (info == null) info = mono.ReadClassInfo (target, KlassAddress); return info; }
public static MonoClassInfo ReadCoreType(MonoSymbolFile file, Cecil.TypeDefinition typedef, TargetMemoryAccess target, TargetAddress klass, out MonoClassType type) { MonoClassInfo info = new MonoClassInfo (file, typedef, target, klass); type = new MonoClassType (file, typedef, info); ((IMonoStructType) type).ClassInfo = info; info.struct_type = type; info.type = type; return info; }
void do_execute() { switch (stage) { case Stage.Uninitialized: { class_info = RTI.Function.ResolveClass (inferior, false); if (class_info != null) goto case Stage.ResolvedClass; MonoClassType klass = RTI.Function.DeclaringType as MonoClassType; if (klass == null) throw new TargetException (TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", RTI.Function.DeclaringType.Name); TargetAddress image = RTI.Function.SymbolFile.MonoImage; int token = klass.Token; Report.Debug (DebugFlags.SSE, "{0} rti resolving class {1}:{2:x}", sse, image, token); inferior.CallMethod ( sse.MonoDebuggerInfo.LookupClass, image.Address, 0, 0, RTI.Function.DeclaringType.Name, ID); break; } case Stage.ResolvedClass: if (!get_method_address ()) throw new TargetException (TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", RTI.Function.DeclaringType.Name); goto case Stage.HasMethodAddress; case Stage.HasMethodAddress: if (!get_virtual_method ()) return; goto case Stage.HasVirtualMethod; case Stage.HasVirtualMethod: { Report.Debug (DebugFlags.SSE, "{0} rti compiling method: {1}", sse, method); stage = Stage.CompilingMethod; inferior.CallMethod ( sse.MonoDebuggerInfo.CompileMethod, method.Address, 0, ID); return; } case Stage.CompiledMethod: { RTI.HasStarted = true; sse.insert_temporary_breakpoint (invoke); inferior.RuntimeInvoke ( sse.MonoDebuggerInfo.RuntimeInvoke, method, instance, RTI.ParamObjects, ID, RTI.Debug); stage = Stage.InvokedMethod; return; } default: throw new InternalError (); } }
void get_parent(TargetMemoryAccess target) { parent_klass = MetadataHelper.MonoClassGetParent (target, KlassAddress); if (parent_klass.IsNull) return; parent_info = ReadClassInfo (SymbolFile.MonoLanguage, target, parent_klass); }
public static MonoClassInfo ReadClassInfo(MonoLanguageBackend mono, TargetMemoryAccess target, TargetAddress klass) { TargetAddress image = mono.MetadataHelper.MonoClassGetMonoImage (target, klass); MonoSymbolFile file = mono.GetImage (image); if (file == null) throw new InternalError (); int token = mono.MetadataHelper.MonoClassGetToken (target, klass); if ((token & 0xff000000) != 0x02000000) throw new InternalError (); Cecil.TypeDefinition typedef; typedef = (Cecil.TypeDefinition) file.ModuleDefinition.LookupByToken ( Cecil.Metadata.TokenType.TypeDef, token & 0x00ffffff); if (typedef == null) throw new InternalError (); MonoClassInfo info = new MonoClassInfo (file, typedef, target, klass); if ((file == mono.BuiltinTypes.Corlib) && (typedef.FullName == "System.Decimal")) { MonoFundamentalType ftype = mono.BuiltinTypes.DecimalType; if (ftype.ClassType == null) { MonoClassType ctype = new MonoClassType (file, typedef, info); ((IMonoStructType) ctype).ClassInfo = info; ftype.SetClass (ctype); } info.struct_type = (IMonoStructType) ftype.ClassType; info.type = ftype; } else if (info.IsGenericClass) { info.struct_type = (IMonoStructType) file.MonoLanguage.ReadGenericClass ( target, info.GenericClass, false); info.type = info.struct_type.Type; } else { info.type = file.LookupMonoType (typedef); if (info.type is TargetClassType) info.struct_type = (IMonoStructType) info.type; else info.struct_type = (IMonoStructType) info.type.ClassType; } info.struct_type.ClassInfo = info; return info; }
public static MonoClassInfo ReadClassInfo(MonoLanguageBackend mono, TargetMemoryAccess target, TargetAddress klass) { TargetAddress image = mono.MetadataHelper.MonoClassGetMonoImage(target, klass); MonoSymbolFile file = mono.GetImage(image); if (file == null) { throw new InternalError(); } int token = mono.MetadataHelper.MonoClassGetToken(target, klass); if ((token & 0xff000000) != 0x02000000) { throw new InternalError(); } Cecil.TypeDefinition typedef; typedef = (Cecil.TypeDefinition)file.ModuleDefinition.LookupToken( new Cecil.MetadataToken(Cecil.TokenType.TypeDef, token & 0x00ffffff)); if (typedef == null) { throw new InternalError(); } MonoClassInfo info = new MonoClassInfo(file, typedef, target, klass); if ((file == mono.BuiltinTypes.Corlib) && (typedef.FullName == "System.Decimal")) { MonoFundamentalType ftype = mono.BuiltinTypes.DecimalType; if (ftype.ClassType == null) { MonoClassType ctype = new MonoClassType(file, typedef, info); ((IMonoStructType)ctype).ClassInfo = info; ftype.SetClass(ctype); } info.struct_type = (IMonoStructType)ftype.ClassType; info.type = ftype; } else if (info.IsGenericClass) { info.struct_type = (IMonoStructType) file.MonoLanguage.ReadGenericClass( target, info.GenericClass, false); info.type = info.struct_type.Type; } else { info.type = file.LookupMonoType(typedef); if (info.type is TargetClassType) { info.struct_type = (IMonoStructType)info.type; } else { info.struct_type = (IMonoStructType)info.type.ClassType; } } info.struct_type.ClassInfo = info; return(info); }
public MonoGenericInstanceObject(MonoGenericInstanceType type, MonoClassInfo info, TargetLocation location) : base(type, location) { this.type = type; }
protected bool DoResolve(TargetMemoryAccess target) { if (Parent != null) { if (!Parent.Resolve (target)) return false; type = (TargetClassType) Parent.Type; } klass = (MonoClassInfo) type.GetClass (target); if (klass == null) return false; fields = klass.GetFields (target); return true; }
public MonoClassInfo ResolveClass(TargetMemoryAccess target, bool fail) { if (resolved) return class_info; if (class_info == null) { int token = type.MetadataToken.ToInt32 (); class_info = file.LookupClassInfo (target, token); } if (class_info == null) { if (!fail) return null; throw new TargetException (TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", Name); } if (class_info.HasParent) { MonoClassInfo parent_info = class_info.GetParent (target); parent_type = (IMonoStructType) parent_info.Type; parent_type.ClassInfo = parent_info; if (parent_type.ResolveClass (target, fail) == null) return null; } resolved = true; return class_info; }
public MonoClassInfo ResolveClass(TargetMemoryAccess target, bool fail) { if (resolved) return class_info; if (class_info == null) { if (class_ptr.IsNull) return null; TargetAddress klass = target.ReadAddress (class_ptr); if (klass.IsNull) return null; class_info = File.MonoLanguage.ReadClassInfo (target, klass); } if (class_info == null) { if (!fail) return null; throw new TargetException (TargetError.ClassNotInitialized, "Class `{0}' not initialized yet.", Name); } if (class_info.HasParent) { MonoClassInfo parent_info = class_info.GetParent (target); parent_type = (IMonoStructType) parent_info.Type; parent_type.ClassInfo = parent_info; if (parent_type.ResolveClass (target, fail) == null) return null; } resolved = true; return class_info; }
protected override EventResult CallbackCompleted(long data1, long data2, out TargetEventArgs args) { if (RTI.AbortRequested) { CompletedRTI (); RTI.Result.InvocationAborted = true; RestoreStack (); args = null; return EventResult.CompletedCallback; } switch (stage) { case Stage.Uninitialized: { TargetAddress klass = new TargetAddress (inferior.AddressDomain, data1); Report.Debug (DebugFlags.SSE, "{0} rti resolved class: {1}", sse, klass); class_info = language.ReadClassInfo (inferior, klass); ((IMonoStructType) RTI.Function.DeclaringType).ClassInfo = class_info; ((IMonoStructType) RTI.Function.DeclaringType).ResolveClass (inferior, false); stage = Stage.ResolvedClass; do_execute (); args = null; return EventResult.Running; } case Stage.BoxingInstance: { TargetAddress boxed = new TargetAddress (inferior.AddressDomain, data1); Report.Debug (DebugFlags.SSE, "{0} rti boxed object: {1}", sse, boxed); TargetLocation new_loc = new AbsoluteTargetLocation (boxed); TargetClassType parent_type = instance.Type.GetParentType (inferior); instance = (TargetClassObject) parent_type.GetObject (inferior, new_loc); stage = Stage.HasMethodAddress; do_execute (); args = null; return EventResult.Running; } case Stage.GettingVirtualMethod: { method = new TargetAddress (inferior.AddressDomain, data1); Report.Debug (DebugFlags.SSE, "{0} rti got virtual method: {1}", sse, method); TargetAddress klass = inferior.ReadAddress (method + 8); TargetType class_type = language.ReadMonoClass (inferior, klass); if (class_type == null) { RTI.Result.ExceptionMessage = String.Format ( "Unable to get virtual method `{0}'.", RTI.Function.FullName); RTI.Result.InvocationCompleted = true; RestoreStack (); args = null; return EventResult.CompletedCallback; } if (!class_type.IsByRef) { TargetLocation new_loc = instance.Location.GetLocationAtOffset ( 2 * inferior.TargetMemoryInfo.TargetAddressSize); instance = (TargetClassObject) class_type.GetObject ( inferior, new_loc); } Report.Debug (DebugFlags.SSE, "{0} rti got virtual method #1: {1} {2}", sse, class_type, instance); stage = Stage.HasVirtualMethod; do_execute (); args = null; return EventResult.Running; } case Stage.CompilingMethod: { invoke = new TargetAddress (inferior.AddressDomain, data1); Report.Debug (DebugFlags.SSE, "{0} rti compiled method: {1}", sse, invoke); stage = Stage.CompiledMethod; do_execute (); args = null; return EventResult.Running; } case Stage.InvokedMethod: { RTI.Completed (data1, data2); RestoreStack (); args = null; return EventResult.CompletedCallback; } default: throw new InternalError (); } }