internal override BreakpointHandle Resolve(Thread target, StackFrame frame) { if (handle != null) { return(handle); } if (frame.Thread.Process.IsManaged) { MonoLanguageBackend mono = frame.Thread.Process.MonoLanguage; MonoFunctionType main = mono.MainMethod; if (main == null) { return(null); } handle = main.GetBreakpointHandle(this, -1, -1); } else { OperatingSystemBackend os = frame.Thread.Process.OperatingSystem; TargetAddress main = os.LookupSymbol("main"); if (main.IsNull) { return(null); } handle = new AddressBreakpointHandle(this, main); } return(handle); }
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); }
public NativeLanguage(Process process, OperatingSystemBackend os, TargetInfo info) { this.process = process; this.os = os; this.info = info; this.type_hash = Hashtable.Synchronized(new Hashtable()); integer_type = new NativeFundamentalType(this, "int", FundamentalKind.Int32, 4); unsigned_type = new NativeFundamentalType(this, "unsigned int", FundamentalKind.UInt32, 4); long_type = new NativeFundamentalType(this, "long", FundamentalKind.Int64, 8); ulong_type = new NativeFundamentalType(this, "unsigned long", FundamentalKind.UInt64, 8); pointer_type = new NativePointerType(this, "void *", info.TargetAddressSize); void_type = new NativeOpaqueType(this, "void", 0); string_type = new NativeStringType(this, info.TargetAddressSize); }
internal Process(ThreadManager manager, ProcessStart start) : this(manager, start.Session) { this.start = start; is_attached = start.PID != 0; breakpoint_manager = new BreakpointManager(); exception_handlers = new Dictionary <int, ExceptionCatchPoint> (); symtab_manager = new SymbolTableManager(session); os = Inferior.CreateOperatingSystemBackend(this); native_language = new NativeLanguage(this, os, target_info); session.OnProcessCreated(this); }
private Process(Process parent, int pid) : this(parent.manager, parent.session) { this.start = new ProcessStart(parent.ProcessStart, pid); this.is_forked = true; this.initialized = true; this.parent = parent; breakpoint_manager = new BreakpointManager(parent.breakpoint_manager); exception_handlers = new Dictionary <int, ExceptionCatchPoint> (); foreach (KeyValuePair <int, ExceptionCatchPoint> catchpoint in parent.exception_handlers) { exception_handlers.Add(catchpoint.Key, catchpoint.Value); } symtab_manager = parent.symtab_manager; native_language = parent.native_language; os = parent.os; }
internal void ChildExecd(SingleSteppingEngine engine, Inferior inferior) { is_execed = true; if (!is_forked) { if (mono_language != null) { mono_language.Dispose(); } if (native_language != null) { native_language.Dispose(); } if (os != null) { os.Dispose(); } if (symtab_manager != null) { symtab_manager.Dispose(); } } if (breakpoint_manager != null) { breakpoint_manager.Dispose(); } session.OnProcessExecd(this); breakpoint_manager = new BreakpointManager(); exception_handlers = new Dictionary <int, ExceptionCatchPoint> (); symtab_manager = new SymbolTableManager(session); os = Inferior.CreateOperatingSystemBackend(this); native_language = new NativeLanguage(this, os, target_info); Inferior new_inferior = Inferior.CreateInferior(manager, this, start); try { new_inferior.InitializeAfterExec(inferior.PID); } catch (Exception ex) { if ((ex is TargetException) && (((TargetException)ex).Type == TargetError.PermissionDenied)) { Report.Error("Permission denied when trying to debug exec()ed child {0}, detaching!", inferior.PID); } else { Report.Error("InitializeAfterExec() failed on pid {0}: {1}", inferior.PID, ex); } new_inferior.DetachAfterFork(); return; } SingleSteppingEngine new_thread = new SingleSteppingEngine( manager, this, new_inferior, inferior.PID); ThreadServant[] threads; lock (thread_hash.SyncRoot) { threads = new ThreadServant [thread_hash.Count]; thread_hash.Values.CopyTo(threads, 0); } for (int i = 0; i < threads.Length; i++) { if (threads [i].PID != inferior.PID) { threads [i].Kill(); } } thread_hash [inferior.PID] = new_thread; inferior.Dispose(); inferior = null; manager.Debugger.OnProcessExecdEvent(this); manager.Debugger.OnThreadCreatedEvent(new_thread.Thread); initialized = is_forked = false; main_thread = new_thread; if ((engine.Thread.ThreadFlags & Thread.Flags.StopOnExit) != 0) { new_thread.Thread.ThreadFlags |= Thread.Flags.StopOnExit; } CommandResult result = engine.OnExecd(new_thread); new_thread.StartExecedChild(result); }