Author: martin
Date: 2008-02-06 02:54:17 -0500 (Wed, 06 Feb 2008)
New Revision: 94998
Modified:
branches/martin/debugger-terrania/debugger/ChangeLog
branches/martin/debugger-terrania/debugger/languages/mono/CapturedVariable.cs
branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
branches/martin/debugger-terrania/debugger/test/src/TestAnonymous.cs
branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
branches/martin/debugger-terrania/debugger/test/testsuite/TestAnonymous.cs
Log:
2008-02-06 Martin Baulig <[EMAIL PROTECTED]>
* test/testsuite/NUnit.cs: Also scan for `// @MDB BREAKPOINT: name'
patterns and automatically insert breakpoints.
Modified: branches/martin/debugger-terrania/debugger/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/debugger/ChangeLog 2008-02-06
07:40:31 UTC (rev 94997)
+++ branches/martin/debugger-terrania/debugger/ChangeLog 2008-02-06
07:54:17 UTC (rev 94998)
@@ -1,3 +1,8 @@
+2008-02-06 Martin Baulig <[EMAIL PROTECTED]>
+
+ * test/testsuite/NUnit.cs: Also scan for `// @MDB BREAKPOINT: name'
+ patterns and automatically insert breakpoints.
+
2008-02-02 Martin Baulig <[EMAIL PROTECTED]>
HEADS UP: We now require Mono 1.9 with some local changes; see
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/CapturedVariable.cs
===================================================================
---
branches/martin/debugger-terrania/debugger/languages/mono/CapturedVariable.cs
2008-02-06 07:40:31 UTC (rev 94997)
+++
branches/martin/debugger-terrania/debugger/languages/mono/CapturedVariable.cs
2008-02-06 07:54:17 UTC (rev 94998)
@@ -77,20 +77,16 @@
public TargetObject GetVariable (StackFrame frame,
TargetMemoryAccess target,
string name)
{
- if (!Resolve (target))
+ TargetObject obj = GetObject (frame, target);
+ if ((obj == null) || (obj is MonoNullObject))
return null;
- TargetStructObject obj;
- if (Parent != null)
- obj = (TargetStructObject) Parent.GetObject
(frame, target);
- else
- obj = (TargetStructObject) var.GetObject
(frame, target);
-
+ TargetStructObject sobj = (TargetStructObject) obj;
foreach (TargetFieldInfo field in fields) {
if (field.Name != name)
continue;
- return klass.GetInstanceField (target, obj,
field);
+ return klass.GetInstanceField (target, sobj,
field);
}
return null;
Modified:
branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
2008-02-06 07:40:31 UTC (rev 94997)
+++ branches/martin/debugger-terrania/debugger/languages/mono/MonoSymbolFile.cs
2008-02-06 07:54:17 UTC (rev 94998)
@@ -1023,38 +1023,8 @@
locals = new List<TargetVariable> ();
parameters = new List<TargetVariable> ();
- Cecil.ParameterDefinitionCollection param_info
= mdef.Parameters;
- for (int i = 0; i < param_info.Count; i++) {
- VariableInfo var =
address.ParamVariableInfo [i];
- TargetType type = mono.ReadType
(memory, var.MonoType);
- if (type == null)
- type = mono.VoidType;
+ var captured_vars = new
Dictionary<string,CapturedVariable> ();
- parameters.Add (new MonoVariable (
- param_info [i].Name, type,
false, type.IsByRef,
- this, var, 0, 0));
- }
-
- for (int i = 0; i < method.NumLocals; i++) {
- C.LocalVariableEntry local =
method.Locals [i];
-
- VariableInfo var =
address.LocalVariableInfo [local.Index];
- TargetType type = mono.ReadType
(memory, var.MonoType);
- if (type == null)
- type = mono.VoidType;
-
- if (local.BlockIndex > 0) {
- int index = local.BlockIndex -
1;
- JitLexicalBlockEntry block =
address.LexicalBlocks [index];
- locals.Add (new MonoVariable (
- local.Name, type, true,
type.IsByRef, this, var,
- block.StartAddress,
block.EndAddress));
- } else {
- locals.Add (new MonoVariable (
- local.Name, type, true,
type.IsByRef, this, var));
- }
- }
-
if (address.HasThis)
this_var = new MonoVariable (
"this", decl_type, true, true,
this,
@@ -1098,8 +1068,48 @@
locals.Add (cv);
else
parameters.Add (cv);
+
+ captured_vars.Add (captured.Name, cv);
}
+ Cecil.ParameterDefinitionCollection param_info
= mdef.Parameters;
+ for (int i = 0; i < param_info.Count; i++) {
+ if (captured_vars.ContainsKey
(param_info [i].Name))
+ continue;
+
+ VariableInfo var =
address.ParamVariableInfo [i];
+ TargetType type = mono.ReadType
(memory, var.MonoType);
+ if (type == null)
+ type = mono.VoidType;
+
+ parameters.Add (new MonoVariable (
+ param_info [i].Name, type,
false, type.IsByRef,
+ this, var, 0, 0));
+ }
+
+ for (int i = 0; i < method.NumLocals; i++) {
+ C.LocalVariableEntry local =
method.Locals [i];
+
+ if (captured_vars.ContainsKey
(local.Name))
+ continue;
+
+ VariableInfo var =
address.LocalVariableInfo [local.Index];
+ TargetType type = mono.ReadType
(memory, var.MonoType);
+ if (type == null)
+ type = mono.VoidType;
+
+ if (local.BlockIndex > 0) {
+ int index = local.BlockIndex -
1;
+ JitLexicalBlockEntry block =
address.LexicalBlocks [index];
+ locals.Add (new MonoVariable (
+ local.Name, type, true,
type.IsByRef, this, var,
+ block.StartAddress,
block.EndAddress));
+ } else {
+ locals.Add (new MonoVariable (
+ local.Name, type, true,
type.IsByRef, this, var));
+ }
+ }
+
has_variables = true;
}
Modified: branches/martin/debugger-terrania/debugger/test/src/TestAnonymous.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/test/src/TestAnonymous.cs
2008-02-06 07:40:31 UTC (rev 94997)
+++ branches/martin/debugger-terrania/debugger/test/src/TestAnonymous.cs
2008-02-06 07:54:17 UTC (rev 94998)
@@ -1,28 +1,39 @@
using System;
using System.Collections.Generic;
-delegate int Foo ();
+public static class RunTests
+{
+ public static void Main ()
+ {
+ Test1.X.Run (); // @MDB
LINE: main
+ }
+}
-class X
+namespace Test1
{
- public static void Test1<R> (R r, int a)
+ delegate int Foo ();
+
+ public class X
{
- for (int b = a; b > 0; b--) {
- R s = r;
- Console.WriteLine (s); // @MDB LINE:
test1
- Foo foo = delegate {
- Console.WriteLine (b); // @MDB LINE:
test1 foo
- Console.WriteLine (s);
- Console.WriteLine (a);
- Console.WriteLine (r);
- return 3;
- };
- a -= foo (); // @MDB LINE:
test2
+ public static void Test1<R> (R r, int a)
+ {
+ for (int b = a; b > 0; b--) {
+ R s = r;
+ Console.WriteLine (s); // @MDB
BREAKPOINT: test1
+ Foo foo = delegate {
+ Console.WriteLine (b); // @MDB
LINE: test1 foo
+ Console.WriteLine (s);
+ Console.WriteLine (a);
+ Console.WriteLine (r);
+ return 3;
+ };
+ a -= foo (); // @MDB
BREAKPOINT: test1 after foo
+ }
}
- }
- static void Main ()
- {
- Test1 (500L, 2); // @MDB LINE:
main
+ public static void Run ()
+ {
+ Test1 (500L, 2); // @MDB
LINE: test1 run
+ }
}
}
Modified: branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
2008-02-06 07:40:31 UTC (rev 94997)
+++ branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
2008-02-06 07:54:17 UTC (rev 94998)
@@ -199,6 +199,7 @@
public readonly string FileName;
Dictionary<string,int> lines;
+ Dictionary<string,int> automatic_breakpoints;
static TestSuite ()
{
@@ -223,13 +224,14 @@
inferior_stdout = new LineReader ();
inferior_stderr = new LineReader ();
-
- ReadSourceFile ();
}
+ const string mdb_line_re = @"//[EMAIL PROTECTED]
(LINE|BREAKPOINT):\s+(.*)$";
+
protected void ReadSourceFile ()
{
lines = new Dictionary<string,int> ();
+ automatic_breakpoints = new Dictionary<string,int> ();
using (StreamReader reader = new StreamReader
(FileName)) {
string text;
@@ -237,13 +239,29 @@
while ((text = reader.ReadLine ()) != null) {
line++;
- Match match = Regex.Match (text,
@"//[EMAIL PROTECTED] LINE:\s+(.*)$");
- if (match.Success)
- lines.Add (match.Groups
[1].Value, line);
+ Match match = Regex.Match (text,
mdb_line_re);
+ if (!match.Success)
+ continue;
+
+ string name = match.Groups [2].Value;
+ lines.Add (name, line);
+ if (match.Groups [1].Value ==
"BREAKPOINT")
+ automatic_breakpoints [name] =
AssertBreakpoint (line);
}
}
}
+ protected void AssertHitBreakpoint (Thread thread, string name,
string function)
+ {
+ AssertHitBreakpoint (thread, automatic_breakpoints
[name],
+ function, GetLine (name));
+ }
+
+ protected int GetBreakpoint (string text)
+ {
+ return automatic_breakpoints [text];
+ }
+
protected int GetLine (string text)
{
return lines [text];
@@ -298,6 +316,8 @@
engine = interpreter.DebuggerEngine;
parser = new LineParser (engine);
+
+ ReadSourceFile ();
}
[TestFixtureTearDown]
Modified:
branches/martin/debugger-terrania/debugger/test/testsuite/TestAnonymous.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/test/testsuite/TestAnonymous.cs
2008-02-06 07:40:31 UTC (rev 94997)
+++ branches/martin/debugger-terrania/debugger/test/testsuite/TestAnonymous.cs
2008-02-06 07:54:17 UTC (rev 94998)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using NUnit.Framework;
using Mono.Debugger;
@@ -14,10 +15,6 @@
: base ("TestAnonymous")
{ }
- int bpt_test1;
- int bpt_test2;
- int bpt_test1_foo;
-
[Test]
[Category("Generics")]
public void Main ()
@@ -28,24 +25,22 @@
Thread thread = process.MainThread;
- AssertStopped (thread, "X.Main()", GetLine ("main"));
- bpt_test1 = AssertBreakpoint (GetLine ("test1"));
- bpt_test2 = AssertBreakpoint (GetLine ("test2"));
-
+ AssertStopped (thread, "RunTests.Main()", GetLine
("main"));
AssertExecute ("continue");
- AssertHitBreakpoint (thread, bpt_test1,
"X.Test1(R,int)", GetLine ("test1"));
+ AssertHitBreakpoint (thread, "test1",
"Test1.X.Test1(R,int)");
+
AssertPrint (thread, "a", "(int) 2");
AssertPrint (thread, "b", "(int) 2");
AssertPrint (thread, "s", "(long) 500");
AssertExecute ("continue");
AssertTargetOutput ("500");
- AssertHitBreakpoint (thread, bpt_test2,
"X.Test1(R,int)", GetLine ("test2"));
+ AssertHitBreakpoint (thread, "test1 after foo",
"Test1.X.Test1(R,int)");
AssertExecute ("step");
// FIXME: Print a better method name
- AssertStopped (thread,
"X/<>c__CompilerGenerated2`1<R>.<Test1>c__3()",
+ AssertStopped (thread,
"Test1.X/<>c__CompilerGenerated2`1<R>.<Test1>c__3()",
GetLine ("test1 foo"));
AssertPrint (thread, "a", "(int) 2");
@@ -58,12 +53,12 @@
AssertTargetOutput ("500");
AssertTargetOutput ("2");
AssertTargetOutput ("500");
- AssertHitBreakpoint (thread, bpt_test1,
"X.Test1(R,int)", GetLine ("test1"));
+ AssertHitBreakpoint (thread, "test1",
"Test1.X.Test1(R,int)");
AssertPrint (thread, "b", "(int) 1");
- AssertExecute ("disable " + bpt_test1);
- AssertExecute ("disable " + bpt_test2);
+ AssertExecute ("disable " + GetBreakpoint ("test1"));
+ AssertExecute ("disable " + GetBreakpoint ("test1 after
foo"));
AssertExecute ("continue");
AssertTargetOutput ("500");
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches