public RuntimeInvokeResult RuntimeInvoke(Thread thread, TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags) { IInterruptionHandler interruption = InterruptionHandler ?? Interpreter; if (interruption.CheckInterruption()) { throw new EvaluationTimeoutException(); } RuntimeInvokeResult result = thread.RuntimeInvoke( function, object_argument, param_objects, flags); WaitHandle[] handles = new WaitHandle [2]; handles [0] = interruption.InterruptionEvent; handles [1] = result.CompletedEvent; int ret = WaitHandle.WaitAny(handles); if (ret == 0) { result.Abort(); throw new EvaluationTimeoutException(); } return(result); }
public override void RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result) { throw new InvalidOperationException(); }
public DynamicSourceLocation(TargetFunctionType function, int line, int column) { this.function = function; this.file = null; this.module = function.Module; this.line = line; this.column = column; }
protected FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, int line, int column) : base (bpt) { this.function = function; this.line = line; this.column = column; this.Index = MonoLanguageBackend.GetUniqueID (); }
internal StackFrame(Thread thread, FrameType type, TargetAddress address, TargetAddress stack_ptr, TargetAddress frame_address, Registers registers, TargetFunctionType function, SourceLocation location) : this(thread, type, address, stack_ptr, frame_address, registers) { this.function = function; this.language = function.DeclaringType.Language; this.name = new Symbol(function.FullName, address, 0); this.location = location; }
public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags) { lock (this) { check_alive(); RuntimeInvokeResult result = new RuntimeInvokeResult(this); servant.RuntimeInvoke( function, object_argument, param_objects, flags, result); return(result); } }
public SourceLocation(TargetFunctionType function) : this(new DynamicSourceLocation(function, -1, -1)) { Module = function.Module.Name; Method = function.FullName; Name = function.FullName; MethodSource source = function.GetSourceCode(); if (source != null) { FileName = source.SourceFile.FileName; } }
public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, bool is_virtual, bool debug) { RuntimeInvokeFlags flags = RuntimeInvokeFlags.None; if (is_virtual) { flags |= RuntimeInvokeFlags.VirtualMethod; } if (debug) { flags |= RuntimeInvokeFlags.BreakOnEntry; } return(RuntimeInvoke(function, object_argument, param_objects, flags)); }
public DynamicSourceLocation(MethodSource source, SourceFile file, int line, int column) { if (source.IsManaged) { this.function = source.Function; this.module = function.Module; } else { this.module = source.Module; this.source = source; } this.file = file; this.line = line; this.column = column; }
private bool TryCallback(ThreadServant thread, TargetMemoryAccess memory, ref StackFrame frame, bool exact_match) { try { if (frame == null) { return(false); } Inferior.CallbackFrame callback = thread.GetCallbackFrame( frame.StackPointer, exact_match); if (callback == null) { return(false); } frame = thread.Architecture.CreateFrame( thread.Client, FrameType.Normal, memory, callback.Registers); FrameType callback_type; string frame_name = "<method called from mdb>"; if (callback.IsRuntimeInvokeFrame) { callback_type = FrameType.RuntimeInvoke; TargetFunctionType func = thread.GetRuntimeInvokedFunction(callback.ID); if (func != null) { frame_name = String.Format("<Invocation of: {0}>", func.FullName); } } else { callback_type = FrameType.Callback; } AddFrame(new StackFrame( thread.Client, callback_type, callback.CallAddress, callback.StackPointer, TargetAddress.Null, callback.Registers, thread.NativeLanguage, new Symbol(frame_name, callback.CallAddress, 0))); return(true); } catch (TargetException) { return(false); } }
internal BreakpointHandle ResolveBreakpoint(Breakpoint breakpoint) { if (!module.IsLoaded) { return(null); } if ((function == null) && (source == null)) { if (file != null) { source = file.FindMethod(line); } else { throw new TargetException(TargetError.LocationInvalid); } if ((source != null) && source.IsManaged) { function = source.Function; } } if (function != null) { return(function.GetBreakpointHandle(breakpoint, line, column)); } if ((source == null) || source.IsManaged) { throw new TargetException(TargetError.LocationInvalid); } TargetAddress address = GetAddress(); if (!address.IsNull) { return(new AddressBreakpointHandle(breakpoint, address)); } return(null); }
protected string FormatMethod(string prefix, TargetMethodInfo method, bool is_static, bool is_ctor, Hashtable hash) { StringBuilder sb = new StringBuilder(); sb.Append(prefix); if (is_ctor) { if (is_static) { sb.Append(" .cctor "); } else { sb.Append(" .ctor "); } } else if (is_static) { sb.Append(" static "); } else { sb.Append(" "); } TargetFunctionType ftype = method.Type; if (!is_ctor) { if (ftype.HasReturnValue) { sb.Append(ftype.ReturnType != null ? ftype.ReturnType.Name : "<unknown type>"); } else { sb.Append("void"); } sb.Append(" "); sb.Append(method.Name); sb.Append(" "); } sb.Append("("); bool first = true; foreach (TargetType ptype in ftype.ParameterTypes) { if (first) { first = false; } else { sb.Append(", "); } sb.Append(ptype != null ? ptype.Name : "<unknown type>"); } sb.Append(");\n"); return(sb.ToString()); }
public abstract void RuntimeInvoke(TargetFunctionType function, TargetStructObject object_argument, TargetObject[] param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result);
public static EvaluationResult MonoObjectToString(Thread thread, TargetStructObject obj, EvaluationFlags flags, int timeout, out string result) { result = null; if (!obj.Type.Language.IsManaged) { return(EvaluationResult.MethodNotFound); } again: TargetStructType ctype = obj.Type; if ((ctype.Name == "System.Object") || (ctype.Name == "System.ValueType")) { return(EvaluationResult.MethodNotFound); } TargetClass klass = ctype.GetClass(thread); if (klass == null) { return(EvaluationResult.NotInitialized); } TargetMethodInfo[] methods = klass.GetMethods(thread); if (methods == null) { return(EvaluationResult.MethodNotFound); } foreach (TargetMethodInfo minfo in methods) { if (minfo.Name != "ToString") { continue; } TargetFunctionType ftype = minfo.Type; if (ftype.ParameterTypes.Length != 0) { continue; } if (ftype.ReturnType != ftype.Language.StringType) { continue; } RuntimeInvokeResult rti; try { RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod; if ((flags & EvaluationFlags.NestedBreakStates) != 0) { rti_flags |= RuntimeInvokeFlags.NestedBreakStates; } rti = thread.RuntimeInvoke( ftype, obj, new TargetObject [0], rti_flags); if (!rti.CompletedEvent.WaitOne(timeout, false)) { rti.Abort(); return(EvaluationResult.Timeout); } if ((rti.TargetException != null) && (rti.TargetException.Type == TargetError.ClassNotInitialized)) { result = null; return(EvaluationResult.NotInitialized); } if (rti.Result is Exception) { result = ((Exception)rti.Result).Message; return(EvaluationResult.UnknownError); } if (rti.ExceptionMessage != null) { result = rti.ExceptionMessage; return(EvaluationResult.Exception); } else if (rti.ReturnObject == null) { rti.Abort(); return(EvaluationResult.UnknownError); } } catch (TargetException ex) { result = ex.ToString(); return(EvaluationResult.UnknownError); } TargetObject retval = (TargetObject)rti.ReturnObject; result = (string)((TargetFundamentalObject)retval).GetObject(thread); return(EvaluationResult.Ok); } if (obj.Type.HasParent) { obj = obj.GetParentObject(thread) as TargetClassObject; if (obj != null) { goto again; } } return(EvaluationResult.MethodNotFound); }
public NativeFunctionPointer(Language language, TargetFunctionType func) : base(language, TargetObjectKind.Pointer, func.Name, language.TargetInfo.TargetAddressSize) { this.Type = func; }