Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New 'FunctionBreakpointHandle' API.

2009-12-04  Martin Baulig  <martin@ximian.com>

	* backend/BreakpointHandle.cs
	(FunctionBreakpointHandle): Make this class abstract.

	* languages/TargetFunctionType.cs
	(TargetFunctionType): Replace InsertBreakpoint() and
	RemoveBreakpoint() with a new GetBreakpointHandle() API which
	returns a `FunctionBreakpointHandle'.

svn path=/trunk/debugger/; revision=147681
  • Loading branch information...
commit 82ed43163432702fc91883c2071b604a55110a1a 1 parent 0a383c6
Martin Baulig authored
View
10 ChangeLog
@@ -1,3 +1,13 @@
+2009-12-04 Martin Baulig <martin@ximian.com>
+
+ * backend/BreakpointHandle.cs
+ (FunctionBreakpointHandle): Make this class abstract.
+
+ * languages/TargetFunctionType.cs
+ (TargetFunctionType): Replace InsertBreakpoint() and
+ RemoveBreakpoint() with a new GetBreakpointHandle() API which
+ returns a `FunctionBreakpointHandle'.
+
2009-11-29 Martin Baulig <martin@ximian.com>
* classes/DebuggerConfiguration.cs
View
56 backend/BreakpointHandle.cs
@@ -111,22 +111,17 @@ public override void Remove (Inferior inferior)
}
}
- internal class FunctionBreakpointHandle : BreakpointHandle
+ internal abstract class FunctionBreakpointHandle : BreakpointHandle
{
TargetFunctionType function;
- bool has_load_handler;
int line = -1, column;
internal int Index {
get; private set;
}
- public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, int line)
- : this (bpt, function, line, -1)
- { }
-
- public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
- int line, int column)
+ protected FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
+ int line, int column)
: base (bpt)
{
this.function = function;
@@ -140,41 +135,17 @@ public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, in
get { return function; }
}
- public override void Insert (Inferior target)
- {
- throw new InternalError ();
+ public int Line {
+ get { return line; }
}
- public override void Insert (Thread target)
- {
- if (has_load_handler)
- return;
-
- has_load_handler = function.InsertBreakpoint (target, this);
+ public int Column {
+ get { return column; }
}
- internal void MethodLoaded (TargetAccess target, Method method)
+ public override void Insert (Inferior target)
{
- TargetAddress address;
- if (line != -1) {
- if (method.HasLineNumbers)
- address = method.LineNumberTable.Lookup (line, column);
- else
- address = TargetAddress.Null;
- } else if (method.HasMethodBounds)
- address = method.MethodStartAddress;
- else
- address = method.StartAddress;
-
- if (address.IsNull)
- return;
-
- try {
- target.InsertBreakpoint (this, address, method.Domain);
- } catch (TargetException ex) {
- Report.Error ("Can't insert breakpoint {0} at {1}: {2}",
- Breakpoint.Index, address, ex.Message);
- }
+ throw new InternalError ();
}
public override void Remove (Inferior target)
@@ -182,14 +153,7 @@ public override void Remove (Inferior target)
throw new InternalError ();
}
- public override void Remove (Thread target)
- {
- target.RemoveBreakpoint (this);
-
- if (has_load_handler)
- function.RemoveBreakpoint (target);
- has_load_handler = false;
- }
+ internal abstract void MethodLoaded (TargetAccess target, Method method);
public override string ToString ()
{
View
2  classes/MainMethodBreakpoint.cs
@@ -37,7 +37,7 @@ internal override BreakpointHandle Resolve (Thread target, StackFrame frame)
if (main == null)
return null;
- handle = new FunctionBreakpointHandle (this, main, -1);
+ handle = main.GetBreakpointHandle (this, -1, -1);
} else {
OperatingSystemBackend os = frame.Thread.Process.Servant.OperatingSystem;
TargetAddress main = os.LookupSymbol ("main");
View
2  classes/SourceLocation.cs
@@ -262,7 +262,7 @@ internal BreakpointHandle ResolveBreakpoint (Breakpoint breakpoint)
}
if (function != null)
- return new FunctionBreakpointHandle (breakpoint, function, line, column);
+ return function.GetBreakpointHandle (breakpoint, line, column);
if ((source == null) || source.IsManaged)
throw new TargetException (TargetError.LocationInvalid);
View
6 languages/TargetFunctionType.cs
@@ -57,10 +57,8 @@ protected TargetFunctionType (Language language)
get;
}
- internal abstract bool InsertBreakpoint (Thread target,
- FunctionBreakpointHandle handle);
-
- internal abstract void RemoveBreakpoint (Thread target);
+ internal abstract FunctionBreakpointHandle GetBreakpointHandle (
+ Breakpoint breakpoint, int line, int column);
public abstract TargetMethodSignature GetSignature (Thread target);
}
View
80 languages/mono/MonoFunctionType.cs
@@ -19,7 +19,6 @@ internal class MonoFunctionType : TargetFunctionType
string name;
int token;
- int load_handler;
MonoMethodSignature signature;
internal MonoFunctionType (IMonoStructType klass, Cecil.MethodDefinition mdef)
@@ -151,26 +150,10 @@ internal static string GetMethodName (Cecil.MethodDefinition mdef)
get { return true; }
}
- internal override bool InsertBreakpoint (Thread thread,
- FunctionBreakpointHandle handle)
+ internal override FunctionBreakpointHandle GetBreakpointHandle (
+ Breakpoint breakpoint, int line, int column)
{
- if (!thread.CurrentFrame.Language.IsManaged)
- throw new TargetException (TargetError.InvalidContext);
-
- load_handler = klass.File.MonoLanguage.RegisterMethodLoadHandler (
- thread, this, handle);
- return load_handler > 0;
- }
-
- internal override void RemoveBreakpoint (Thread thread)
- {
- if (!thread.CurrentFrame.Language.IsManaged)
- throw new TargetException (TargetError.InvalidContext);
-
- if (load_handler > 0) {
- klass.File.MonoLanguage.RemoveMethodLoadHandler (thread, load_handler);
- load_handler = -1;
- }
+ return new MyBreakpointHandle (breakpoint, this, line, column);
}
internal MonoClassInfo ResolveClass (TargetMemoryAccess target, bool fail)
@@ -207,5 +190,62 @@ public override TargetMethodSignature GetSignature (Thread thread)
return signature;
}
+
+ protected class MyBreakpointHandle : FunctionBreakpointHandle
+ {
+ MonoFunctionType function;
+ int load_handler = -1;
+
+ public MyBreakpointHandle (Breakpoint bpt, MonoFunctionType function,
+ int line, int column)
+ : base (bpt, function, line, column)
+ {
+ this.function = function;
+ }
+
+ public override void Insert (Thread thread)
+ {
+ if (load_handler > 0)
+ return;
+
+ load_handler = function.SymbolFile.MonoLanguage.RegisterMethodLoadHandler (
+ thread, function, this);
+ }
+
+ internal override void MethodLoaded (TargetAccess target, Method method)
+ {
+ TargetAddress address;
+ if (Line != -1) {
+ if (method.HasLineNumbers)
+ address = method.LineNumberTable.Lookup (Line, Column);
+ else
+ address = TargetAddress.Null;
+ } else if (method.HasMethodBounds)
+ address = method.MethodStartAddress;
+ else
+ address = method.StartAddress;
+
+ if (address.IsNull)
+ return;
+
+ try {
+ target.InsertBreakpoint (this, address, method.Domain);
+ } catch (TargetException ex) {
+ Report.Error ("Can't insert breakpoint {0} at {1}: {2}",
+ Breakpoint.Index, address, ex.Message);
+ }
+ }
+
+ public override void Remove (Thread thread)
+ {
+ thread.RemoveBreakpoint (this);
+
+ if (load_handler > 0) {
+ function.SymbolFile.MonoLanguage.RemoveMethodLoadHandler (
+ thread, load_handler);
+ load_handler = -1;
+ }
+ }
+ }
}
}
View
9 languages/native/NativeFunctionType.cs
@@ -145,13 +145,8 @@ internal string GetPointerName ()
get { return false; }
}
- internal override bool InsertBreakpoint (Thread target,
- FunctionBreakpointHandle handle)
- {
- throw new InvalidOperationException ();
- }
-
- internal override void RemoveBreakpoint (Thread target)
+ internal override FunctionBreakpointHandle GetBreakpointHandle (
+ Breakpoint breakpoint, int line, int column)
{
throw new InvalidOperationException ();
}
Please sign in to comment.
Something went wrong with that request. Please try again.