public static void Write(FileInfo file) { var state = new DebuggerState { WorkingDirectory = WorkingDirectory, Arguments = Arguments, EnvironmentVariables = EnvironmentVariables, Watches = Watches, NextWatchId = _nextWatchId, Breakpoints = Breakpoints.ToDictionary(x => x.Key, x => Tuple.Create(x.Value, BreakEvents.Contains(x.Value))), NextBreakpointId = _nextBreakpointId, Catchpoints = BreakEvents.GetCatchpoints(), Aliases = Aliases, }; try { using (var stream = file.Open(FileMode.Create, FileAccess.Write)) new BinaryFormatter().Serialize(stream, state); } catch (Exception ex) { Log.Error("Could not write database file '{0}':", file); Log.Error(ex.ToString()); } }
public static void Read(FileInfo file) { DebuggerState state; try { using (var stream = file.Open(FileMode.Open, FileAccess.Read)) state = (DebuggerState) new BinaryFormatter().Deserialize(stream); } catch (Exception ex) { Log.Error("Could not read database file '{0}':", file); Log.Error(ex.ToString()); return; } ResetState(); WorkingDirectory = state.WorkingDirectory; Arguments = state.Arguments; EnvironmentVariables = state.EnvironmentVariables; Watches = state.Watches; Aliases = state.Aliases; Breakpoints.Clear(); BreakEvents.Clear(); foreach (var kvp in state.Breakpoints) { Breakpoints.Add(kvp.Key, kvp.Value.Item1); if (kvp.Value.Item2) { BreakEvents.Add(kvp.Value.Item1); } } foreach (var cp in state.Catchpoints) { BreakEvents.Add(cp); } _nextWatchId = state.NextWatchId; _nextBreakpointId = state.NextBreakpointId; }
public static void Disconnect() { lock (_lock) { if (_session == null) { return; } CommandLine.InferiorExecuting = true; _kind = SessionKind.Disconnected; Breakpoints.Clear(); BreakEvents.Clear(); _session.Continue(); _session = null; } }