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 (); } }
internal TargetObject CreateObject(TargetMemoryAccess target, TargetAddress address) { TargetLocation location = new AbsoluteTargetLocation (address); MonoObjectObject obj = (MonoObjectObject)builtin_types.ObjectType.GetObject ( target, location); if (obj == null) return null; TargetObject result; try { result = obj.GetDereferencedObject (target); if (result == null) result = obj; } catch { result = obj; } return result; }
TargetLocation GetLocation(StackFrame frame, TargetMemoryAccess memory, byte[] data) { TargetBinaryReader locreader = new TargetBinaryReader ( data, comp_unit.DwarfReader.TargetMemoryInfo); byte opcode = locreader.ReadByte (); bool is_regoffset; int reg, off; if ((opcode >= 0x50) && (opcode <= 0x6f)) { // DW_OP_reg reg = opcode - 0x50 + 3; off = 0; is_regoffset = false; } else if ((opcode >= 0x70) && (opcode <= 0x8f)) { // DW_OP_breg reg = opcode - 0x70 + 3; off = locreader.ReadSLeb128 (); is_regoffset = true; } else if (opcode == 0x90) { // DW_OP_regx reg = locreader.ReadLeb128 () + 3; off = 0; is_regoffset = false; } else if (opcode == 0x91) { // DW_OP_fbreg off = locreader.ReadSLeb128 (); if (frame_base != null) { TargetLocation rloc = new RelativeTargetLocation ( frame_base.GetLocation (frame, memory), off); if (is_byref) return new DereferencedTargetLocation (rloc); else return rloc; } else { is_regoffset = true; reg = 2; } } else if (opcode == 0x92) { // DW_OP_bregx reg = locreader.ReadLeb128 () + 3; off = locreader.ReadSLeb128 (); is_regoffset = true; } else if (opcode == 0x03) { // DW_OP_addr TargetAddress addr = new TargetAddress ( memory.AddressDomain, locreader.ReadAddress ()); TargetLocation aloc = new AbsoluteTargetLocation (addr); if (is_byref) return new DereferencedTargetLocation (aloc); else return aloc; } else { Console.WriteLine ("UNKNOWN OPCODE: {0:x}", opcode); return null; } reg = comp_unit.DwarfReader.bfd.Architecture.DwarfFrameRegisterMap [reg]; MonoVariableLocation loc = MonoVariableLocation.Create ( memory, is_regoffset, frame.Registers [reg], off, is_byref); if (!locreader.IsEof) { Console.WriteLine ("LOCREADER NOT AT EOF!"); return null; } return loc; }