From ae8cec1f33a438a6295516ce3fb034166009e672 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 28 May 2014 14:14:48 -0400 Subject: [PATCH] [Mono.Debugger.Soft] minor code cleanup --- .../Mono.Debugger.Soft/ObjectMirror.cs | 8 ++--- .../Mono.Debugger.Soft/ThreadMirror.cs | 20 ++++++------ .../Mono.Debugger.Soft/VirtualMachine.cs | 32 +++++++++---------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs index b877e2402f5..030fa3e3e4a 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs @@ -301,15 +301,15 @@ namespace Mono.Debugger.Soft } catch (CommandException ex) { if (ex.ErrorCode == ErrorCode.INVALID_ARGUMENT) throw new ArgumentException ("Incorrect number or types of arguments", "arguments"); - else - throw; + + throw; } throw new NotImplementedException (); } else { if (r.Exception != null) throw new InvocationException ((ObjectMirror)r.VM.DecodeValue (r.Exception)); - else - return r.VM.DecodeValue (r.Value); + + return r.VM.DecodeValue (r.Value); } } diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs index bf248278690..541118d66d6 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs @@ -7,8 +7,8 @@ namespace Mono.Debugger.Soft public class ThreadMirror : ObjectMirror { string name; - bool framesCacheIsInvalid = true; - bool fetchingInProgress; + bool cacheInvalid = true; + bool fetching; object fetchingLocker = new object (); ManualResetEvent fetchingEvent = new ManualResetEvent (false); ThreadInfo info; @@ -27,15 +27,15 @@ namespace Mono.Debugger.Soft } internal void InvalidateFrames () { - framesCacheIsInvalid = true; + cacheInvalid = true; } internal void FetchFrames (bool mustFetch = false) { lock (fetchingLocker) { - if (fetchingInProgress || !framesCacheIsInvalid) + if (fetching || !cacheInvalid) return; - framesCacheIsInvalid = false; - fetchingInProgress = true; + cacheInvalid = false; + fetching = true; fetchingEvent.Reset (); } vm.conn.Thread_GetFrameInfo (id, 0, -1, (frame_info) => { @@ -49,10 +49,10 @@ namespace Mono.Debugger.Soft } lock (fetchingLocker) { vm.AddThreadToInvalidateList (this); - fetchingInProgress = false; + fetching = false; //In case it was invalidated during waiting for response from //runtime and mustFetch was set refetch - if (framesCacheIsInvalid && mustFetch) { + if (cacheInvalid && mustFetch) { FetchFrames (mustFetch); return; } @@ -152,8 +152,8 @@ namespace Mono.Debugger.Soft } catch (CommandException ex) { if (ex.ErrorCode == ErrorCode.INVALID_ARGUMENT) throw new ArgumentException ("loc doesn't refer to a location in the current method of this thread.", "loc"); - else - throw; + + throw; } } } diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs index af027d808a3..ee5806d4722 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs @@ -121,13 +121,13 @@ namespace Mono.Debugger.Soft public void Resume () { try { - InvalidateThreadsAndFramesCache (); + InvalidateThreadAndFrameCaches (); conn.VM_Resume (); } catch (CommandException ex) { if (ex.ErrorCode == ErrorCode.NOT_SUSPENDED) throw new VMNotSuspendedException (); - else - throw; + + throw; } } @@ -153,23 +153,23 @@ namespace Mono.Debugger.Soft } HashSet threadsToInvalidate = new HashSet (); - ThreadMirror[] threadsCache; - object threadCacheLocker=new object(); + ThreadMirror[] threadCache; + object threadCacheLocker = new object (); - internal void InvalidateThreadsAndFramesCache () { + void InvalidateThreadAndFrameCaches () { lock (threadsToInvalidate) { foreach (var thread in threadsToInvalidate) thread.InvalidateFrames (); threadsToInvalidate.Clear (); } lock (threadCacheLocker) { - threadsCache = null; + threadCache = null; } } - internal void InvalidateThreadsCache () { + internal void InvalidateThreadCache () { lock (threadCacheLocker) { - threadsCache = null; + threadCache = null; } } @@ -182,13 +182,13 @@ namespace Mono.Debugger.Soft public IList GetThreads () { lock (threadCacheLocker) { - if (threadsCache == null) { + if (threadCache == null) { long[] ids = vm.conn.VM_GetThreads (); - threadsCache = new ThreadMirror [ids.Length]; + threadCache = new ThreadMirror [ids.Length]; for (int i = 0; i < ids.Length; ++i) - threadsCache [i] = GetThread (ids [i]); + threadCache [i] = GetThread (ids [i]); } - return threadsCache; + return threadCache; } } @@ -708,11 +708,11 @@ namespace Mono.Debugger.Soft vm.notify_vm_event (EventType.VMDeath, suspend_policy, req_id, thread_id, null, ei.ExitCode); break; case EventType.ThreadStart: - vm.InvalidateThreadsCache (); + vm.InvalidateThreadCache (); l.Add (new ThreadStartEvent (vm, req_id, id)); break; case EventType.ThreadDeath: - vm.InvalidateThreadsCache (); + vm.InvalidateThreadCache (); l.Add (new ThreadDeathEvent (vm, req_id, id)); break; case EventType.AssemblyLoad: @@ -753,8 +753,6 @@ namespace Mono.Debugger.Soft case EventType.UserLog: l.Add (new UserLogEvent (vm, req_id, thread_id, ei.Level, ei.Category, ei.Message)); break; - default: - break; } } -- 2.25.1