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); }
internal static string ReadString(MonoLanguageBackend mono, TargetMemoryAccess target, TargetAddress address) { if (address.IsNull) return null; TargetLocation location = new AbsoluteTargetLocation (address); MonoStringObject so = new MonoStringObject (mono.BuiltinTypes.StringType, location); return (string) so.DoGetObject (target); }
internal bool CheckException(MonoLanguageBackend mono, TargetMemoryAccess target, TargetAddress address) { TargetClassObject exc = mono.CreateObject (target, address) as TargetClassObject; if (exc == null) return false; // OOOPS if (exception == null) exception = mono.LookupType (Name); if (exception == null) return false; return IsSubclassOf (target, exc.Type, exception); }
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; }
void DoDispose() { if (!is_forked) { if (architecture != null) { architecture.Dispose (); architecture = null; } if (mono_language != null) { mono_language.Dispose(); mono_language = null; } if (native_language != null) { native_language.Dispose (); native_language = null; } if (os != null) { os.Dispose (); os = null; } if (symtab_manager != null) { symtab_manager.Dispose (); symtab_manager = null; } } if (breakpoint_manager != null) { breakpoint_manager.Dispose (); breakpoint_manager = null; } if (thread_db != null) { thread_db.Dispose (); thread_db = null; } if (thread_lock_mutex != null) { thread_lock_mutex.Dispose (); thread_lock_mutex = null; } exception_handlers = null; manager.RemoveProcess (this); }
internal MonoLanguageBackend CreateMonoLanguage(MonoDebuggerInfo info) { mono_language = new MonoLanguageBackend (this, info); return mono_language; }
internal bool InitializeAfterAttach(Inferior inferior) { initialize_notifications (inferior); inferior.WriteAddress (debugger_info.ThreadVTablePtr, debugger_info.ThreadVTable); inferior.WriteAddress (debugger_info.EventHandlerPtr, debugger_info.EventHandler); inferior.WriteInteger (debugger_info.UsingMonoDebugger, 1); csharp_language = inferior.Process.CreateMonoLanguage (debugger_info); csharp_language.InitializeAttach (inferior); return true; }
internal bool HandleChildEvent(SingleSteppingEngine engine, Inferior inferior, ref Inferior.ChildEvent cevent, out bool resume_target) { if (cevent.Type == Inferior.ChildEventType.CHILD_NOTIFICATION) { NotificationType type = (NotificationType) cevent.Argument; Report.Debug (DebugFlags.EventLoop, "{0} received notification {1}: {2}", engine, type, cevent); switch (type) { case NotificationType.AcquireGlobalThreadLock: Report.Debug (DebugFlags.Threads, "{0} received notification {1}", engine, type); engine.Process.AcquireGlobalThreadLock (engine); break; case NotificationType.ReleaseGlobalThreadLock: Report.Debug (DebugFlags.Threads, "{0} received notification {1}", engine, type); engine.Process.ReleaseGlobalThreadLock (engine); break; case NotificationType.ThreadCreated: { TargetAddress data = new TargetAddress ( inferior.AddressDomain, cevent.Data2); TargetAddress lmf = inferior.ReadAddress (data + 8); engine.SetManagedThreadData (lmf, data + 24); if (MonoDebuggerInfo.CheckRuntimeVersion (81, 3)) { int flags_offset = 56 + inferior.TargetAddressSize; ThreadFlags flags = (ThreadFlags) inferior.ReadInteger (data + flags_offset); check_thread_flags (engine, flags); } Report.Debug (DebugFlags.Threads, "{0} managed thread created: {1:x} {2} {3} - {4}", engine, cevent.Data1, data, lmf, engine.LMFAddress); break; } case NotificationType.ThreadCleanup: { TargetAddress data = new TargetAddress ( inferior.AddressDomain, cevent.Data1); Report.Debug (DebugFlags.Threads, "{0} managed thread cleanup: {1:x} {2}", engine, cevent.Data2, data); break; } case NotificationType.GcThreadCreated: { TargetAddress data = new TargetAddress ( inferior.AddressDomain, cevent.Data1); long tid = cevent.Data2; Report.Debug (DebugFlags.Threads, "{0} created gc thread: {1:x} {2}", engine, tid, data); engine = engine.Process.GetEngineByTID (inferior, tid); if (engine == null) throw new InternalError (); engine.OnManagedThreadCreated (data); break; } case NotificationType.GcThreadExited: Report.Debug (DebugFlags.Threads, "{0} gc thread exited", engine); engine.OnManagedThreadExited (); try { inferior.Continue (); } catch { // Ignore errors; for some reason, the thread may have died // already by the time get this notification. } resume_target = false; return true; case NotificationType.InitializeThreadManager: csharp_language = inferior.Process.CreateMonoLanguage ( debugger_info); if (engine.Process.IsAttached) csharp_language.InitializeAttach (inferior); else csharp_language.Initialize (inferior); break; case NotificationType.ReachedMain: { Inferior.StackFrame iframe = inferior.GetCurrentFrame (false); engine.SetMainReturnAddress (iframe.StackPointer); engine.Process.OnProcessReachedMainEvent (); resume_target = !engine.InitializeBreakpoints (); return true; } case NotificationType.WrapperMain: break; case NotificationType.MainExited: engine.SetMainReturnAddress (TargetAddress.Null); break; case NotificationType.UnhandledException: cevent = new Inferior.ChildEvent ( Inferior.ChildEventType.UNHANDLED_EXCEPTION, 0, cevent.Data1, cevent.Data2); resume_target = false; return false; case NotificationType.HandleException: cevent = new Inferior.ChildEvent ( Inferior.ChildEventType.HANDLE_EXCEPTION, 0, cevent.Data1, cevent.Data2); resume_target = false; return false; case NotificationType.ThrowException: cevent = new Inferior.ChildEvent ( Inferior.ChildEventType.THROW_EXCEPTION, 0, cevent.Data1, cevent.Data2); resume_target = false; return false; case NotificationType.FinalizeManagedCode: mono_debugger_server_finalize_mono_runtime (mono_runtime_info); mono_runtime_info = IntPtr.Zero; csharp_language = null; break; case NotificationType.OldTrampoline: case NotificationType.Trampoline: resume_target = false; return false; case NotificationType.ClassInitialized: break; case NotificationType.InterruptionRequest: inferior.WriteInteger (MonoDebuggerInfo.InterruptionRequest, 0); var callbacks = managed_callbacks; managed_callbacks = new Queue<ManagedCallbackData> (); resume_target = !engine.OnManagedCallback (callbacks); return true; default: { TargetAddress data = new TargetAddress ( inferior.AddressDomain, cevent.Data1); resume_target = csharp_language.Notification ( engine, inferior, type, data, cevent.Data2); return true; } } resume_target = true; return true; } if ((cevent.Type == Inferior.ChildEventType.CHILD_STOPPED) && (cevent.Argument == thread_abort_signal)) { resume_target = true; return true; } if ((cevent.Type == Inferior.ChildEventType.CHILD_STOPPED) && (cevent.Argument != 0) && ! engine.Process.Session.Config.StopOnManagedSignals) { if (inferior.IsManagedSignal ((int) cevent.Argument)) { resume_target = true; return true; } } resume_target = false; return false; }
public GlobalDataTable(MonoLanguageBackend mono, TargetAddress address) : base(address, TargetAddress.Null) { this.Mono = mono; delegate_impl_list = new ArrayList (); }
public DomainDataTable(MonoLanguageBackend mono, int domain, TargetAddress address, TargetAddress first_chunk) : base(address, first_chunk) { this.Mono = mono; this.Domain = domain; }
public OperationRuntimeInvokeHelper(SingleSteppingEngine sse, OperationRuntimeInvoke rti) : base(sse) { this.RTI = rti; this.instance = RTI.Instance; this.method = TargetAddress.Null; this.stage = Stage.Uninitialized; language = sse.process.MonoLanguage; }
internal MonoGenericParameterType(MonoLanguageBackend mono, string name) : base(mono) { this.name = name; }
internal MonoClassInfo ReadClassInfo(MonoLanguageBackend mono, TargetMemoryAccess target) { if (info == null) info = mono.ReadClassInfo (target, KlassAddress); return info; }
internal MonoSymbolFile(MonoLanguageBackend language, Process process, TargetMemoryAccess memory, TargetAddress address) { this.MonoLanguage = language; this.TargetMemoryInfo = memory.TargetMemoryInfo; this.Architecture = process.Architecture; this.process = process; ThreadManager = process.ThreadManager; int address_size = TargetMemoryInfo.TargetAddressSize; int int_size = TargetMemoryInfo.TargetIntegerSize; ranges = ArrayList.Synchronized (new ArrayList ()); range_hash = Hashtable.Synchronized (new Hashtable ()); type_hash = Hashtable.Synchronized (new Hashtable ()); class_entry_by_token = Hashtable.Synchronized (new Hashtable ()); Index = memory.ReadInteger (address); address += int_size; TargetAddress image_file_addr = memory.ReadAddress (address); address += address_size; ImageFile = memory.ReadString (image_file_addr); MonoImage = memory.ReadAddress (address); address += address_size; TargetAddress type_table_ptr = memory.ReadAddress (address); address += address_size; TypeTable = MonoTypeTable.CreateTypeTable (this, memory, type_table_ptr); string shadow_location = language.GetShadowCopyLocation (ImageFile); if (shadow_location != null) ImageFile = shadow_location; try { Assembly = Cecil.AssemblyDefinition.ReadAssembly (ImageFile); } catch (Exception ex) { throw new SymbolTableException ( "Cannot load symbol file `{0}': {1}", ImageFile, ex); } ModuleDefinition = Assembly.MainModule; Report.Debug (DebugFlags.JitSymtab, "SYMBOL TABLE READER: {0}", ImageFile); string mdb_file = ImageFile + ".mdb"; try { File = C.MonoSymbolFile.ReadSymbolFile (ModuleDefinition, mdb_file); if (File == null) Report.Error ("Cannot load symbol file `{0}'", mdb_file); else if (ModuleDefinition.Mvid != File.Guid) { Report.Error ("Symbol file `{0}' does not match assembly `{1}'", mdb_file, ImageFile); File = null; } } catch (C.MonoSymbolFileException ex) { Report.Error (ex.Message); } catch (Exception ex) { Report.Error ("Cannot load symbol file `{0}': {1}", mdb_file, ex); } symtab = new MonoSymbolTable (this); name = Assembly.Name.FullName; module = process.Session.GetModule (name); if (module == null) { module = process.Session.CreateModule (name, this); } else { module.LoadModule (this); } #if FIXME if ((File != null) && (File.OffsetTable.IsAspxSource)) { Console.WriteLine ("ASPX SOURCE: {0} {1}", this, File); } #endif process.SymbolTableManager.AddSymbolFile (this); }
public AppDomainInfo(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetReader reader) { int addr_size = memory.TargetMemoryInfo.TargetAddressSize; reader.Offset = 2 * addr_size; ApplicationBase = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); ApplicationName = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); CachePath = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); ConfigFile = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); DynamicBase = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); reader.Offset += 3 * addr_size; ShadowCopyDirectories = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()); ShadowCopyFiles = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()) == "true"; }
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); }