From d110f9161ea5f25a4baca4b570befa31be1b6e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sat, 16 Jul 2005 13:09:23 +0000 Subject: [PATCH] A bit work on properties git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@186 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Debugger/NDebugger.cs | 10 ++++ .../Project/Src/Threads/Function.cs | 49 +++++++++++++------ .../Project/Src/Variables/Evals/Eval.cs | 21 +++----- .../Project/Src/Variables/Evals/EvalQueue.cs | 12 ++--- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs index c785c3c099..e2a77053a7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs @@ -26,6 +26,14 @@ namespace DebuggerLibrary ApartmentState requiredApartmentState; + EvalQueue evalQueue = new EvalQueue(); + + internal EvalQueue EvalQueue { + get { + return evalQueue; + } + } + public ApartmentState RequiredApartmentState { get { return requiredApartmentState; @@ -108,6 +116,8 @@ namespace DebuggerLibrary ClearThreads(); CurrentProcess = null; + + evalQueue = new EvalQueue(); GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs index 614a5066d6..6417ad73c5 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs @@ -366,29 +366,49 @@ namespace DebuggerLibrary AddScopeToVariableCollection(symRootScope, ref collection); // Properties - /* IntPtr methodEnumPtr = IntPtr.Zero; uint methodsFetched; while(true) { uint methodToken; Module.MetaDataInterface.EnumMethods(ref methodEnumPtr, parentClassToken, out methodToken, 1, out methodsFetched); if (methodsFetched == 0) break; - + + uint unused; + uint pStringLenght = 0; // Terminating character included in pStringLenght + IntPtr pString = IntPtr.Zero; uint attrib; module.MetaDataInterface.GetMethodProps( methodToken, - out NDebugger.unused, - NDebugger.pString, - NDebugger.pStringLen, - out NDebugger.unused, // real string lenght + out unused, + pString, + pStringLenght, + out pStringLenght, // real string lenght + out attrib, + IntPtr.Zero, + out unused, + out unused, + out unused); + + // Allocate string buffer + pString = Marshal.AllocHGlobal((int)pStringLenght * 2); + + module.MetaDataInterface.GetMethodProps( + methodToken, + out unused, + pString, + pStringLenght, + out pStringLenght, // real string lenght out attrib, IntPtr.Zero, - out NDebugger.unused, - out NDebugger.unused, - out NDebugger.unused); - string name = NDebugger.pStringAsUnicode; + out unused, + out unused, + out unused); + + string name = Marshal.PtrToStringUni(pString); + Marshal.FreeHGlobal(pString); + if (name.StartsWith("get_") && (attrib & (uint)CorMethodAttr.mdSpecialName) != 0) { - name = "Prop:" + name; + name = name.Remove(0,4); ICorDebugValue[] evalArgs; ICorDebugFunction evalCorFunction; @@ -398,12 +418,11 @@ namespace DebuggerLibrary } else { evalArgs = new ICorDebugValue[] {argThis}; } - Eval eval = new Eval(evalCorFunction, evalArgs); - EvalQueue.AddEval(eval); - collection.Add(new PropertyVariable(eval, name)); + Eval eval = new Eval(debugger, evalCorFunction, evalArgs); + //debugger.EvalQueue.AddEval(eval); + //collection.Add(new PropertyVariable(debugger, eval, name)); } } - */ } catch (FrameNotAviableException) { System.Diagnostics.Debug.Fail("Unable to get local variables. Frame is not aviable"); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs index a6e89efaf9..e2a119d2b4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs @@ -22,20 +22,20 @@ namespace DebuggerLibrary bool complete = false; public event EventHandler EvalComplete; - - void OnEvalComplete() + + protected virtual void OnEvalComplete(EventArgs e) { if (EvalComplete != null) { - EvalComplete(this, EventArgs.Empty); + EvalComplete(this, e); } - } + } public Eval(NDebugger debugger, ICorDebugFunction corFunction, ICorDebugValue[] args) { this.debugger = debugger; this.corFunction = corFunction; this.args = args; - debugger.ManagedCallback.CorDebugEvalCompleted += new CorDebugEvalEventHandler(CorDebugEvalCompleted); + debugger.ManagedCallback.CorDebugEvalCompleted += new CorDebugEvalEventHandler(CorDebugEvalCompletedInManagedCallback); } /// @@ -74,18 +74,11 @@ namespace DebuggerLibrary return corValue; } - protected virtual void OnEvalComplete(EventArgs e) - { - if (EvalComplete != null) { - EvalComplete(this, e); - } - } - - void CorDebugEvalCompleted(object sender, CorDebugEvalEventArgs e) + void CorDebugEvalCompletedInManagedCallback(object sender, CorDebugEvalEventArgs e) { if (e.CorDebugEval == corEval) { complete = true; - OnEvalComplete(); + OnEvalComplete(EventArgs.Empty); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs index 77cfd842c0..2d16cd23d3 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs @@ -14,26 +14,26 @@ namespace DebuggerLibrary { class EvalQueue { - static ArrayList waitingEvals = new ArrayList(); + ArrayList waitingEvals = new ArrayList(); - public static event EventHandler AllEvalsComplete; + public event EventHandler AllEvalsComplete; - static public void AddEval(Eval eval) + public void AddEval(Eval eval) { waitingEvals.Add(eval); } - static public void PerformAllEvals() + public void PerformAllEvals() { while (waitingEvals.Count > 0) { PerformNextEval(); } } - static public void PerformNextEval() + public void PerformNextEval() { if (waitingEvals.Count == 0) { - return; + throw new DebuggerException("No eval in queue to perform."); } Eval eval = (Eval)waitingEvals[0]; waitingEvals.Remove(eval);