Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
New 'FunctionBreakpointHandle' API.
Browse files Browse the repository at this point in the history
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
Martin Baulig committed Dec 4, 2009
1 parent 0a383c6 commit 82ed431
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 79 deletions.
10 changes: 10 additions & 0 deletions 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> 2009-11-29 Martin Baulig <martin@ximian.com>


* classes/DebuggerConfiguration.cs * classes/DebuggerConfiguration.cs
Expand Down
56 changes: 10 additions & 46 deletions backend/BreakpointHandle.cs
Expand Up @@ -111,22 +111,17 @@ public override void Remove (Inferior inferior)
} }
} }


internal class FunctionBreakpointHandle : BreakpointHandle internal abstract class FunctionBreakpointHandle : BreakpointHandle
{ {
TargetFunctionType function; TargetFunctionType function;
bool has_load_handler;
int line = -1, column; int line = -1, column;


internal int Index { internal int Index {
get; private set; get; private set;
} }


public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, int line) protected FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
: this (bpt, function, line, -1) int line, int column)
{ }

public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
int line, int column)
: base (bpt) : base (bpt)
{ {
this.function = function; this.function = function;
Expand All @@ -140,56 +135,25 @@ public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, in
get { return function; } get { return function; }
} }


public override void Insert (Inferior target) public int Line {
{ get { return line; }
throw new InternalError ();
} }


public override void Insert (Thread target) public int Column {
{ get { return column; }
if (has_load_handler)
return;

has_load_handler = function.InsertBreakpoint (target, this);
} }


internal void MethodLoaded (TargetAccess target, Method method) public override void Insert (Inferior target)
{ {
TargetAddress address; throw new InternalError ();
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 (Inferior target) public override void Remove (Inferior target)
{ {
throw new InternalError (); throw new InternalError ();
} }


public override void Remove (Thread target) internal abstract void MethodLoaded (TargetAccess target, Method method);
{
target.RemoveBreakpoint (this);

if (has_load_handler)
function.RemoveBreakpoint (target);
has_load_handler = false;
}


public override string ToString () public override string ToString ()
{ {
Expand Down
2 changes: 1 addition & 1 deletion classes/MainMethodBreakpoint.cs
Expand Up @@ -37,7 +37,7 @@ internal override BreakpointHandle Resolve (Thread target, StackFrame frame)
if (main == null) if (main == null)
return null; return null;


handle = new FunctionBreakpointHandle (this, main, -1); handle = main.GetBreakpointHandle (this, -1, -1);
} else { } else {
OperatingSystemBackend os = frame.Thread.Process.Servant.OperatingSystem; OperatingSystemBackend os = frame.Thread.Process.Servant.OperatingSystem;
TargetAddress main = os.LookupSymbol ("main"); TargetAddress main = os.LookupSymbol ("main");
Expand Down
2 changes: 1 addition & 1 deletion classes/SourceLocation.cs
Expand Up @@ -262,7 +262,7 @@ internal BreakpointHandle ResolveBreakpoint (Breakpoint breakpoint)
} }


if (function != null) if (function != null)
return new FunctionBreakpointHandle (breakpoint, function, line, column); return function.GetBreakpointHandle (breakpoint, line, column);


if ((source == null) || source.IsManaged) if ((source == null) || source.IsManaged)
throw new TargetException (TargetError.LocationInvalid); throw new TargetException (TargetError.LocationInvalid);
Expand Down
6 changes: 2 additions & 4 deletions languages/TargetFunctionType.cs
Expand Up @@ -57,10 +57,8 @@ protected TargetFunctionType (Language language)
get; get;
} }


internal abstract bool InsertBreakpoint (Thread target, internal abstract FunctionBreakpointHandle GetBreakpointHandle (
FunctionBreakpointHandle handle); Breakpoint breakpoint, int line, int column);

internal abstract void RemoveBreakpoint (Thread target);


public abstract TargetMethodSignature GetSignature (Thread target); public abstract TargetMethodSignature GetSignature (Thread target);
} }
Expand Down
80 changes: 60 additions & 20 deletions languages/mono/MonoFunctionType.cs
Expand Up @@ -19,7 +19,6 @@ internal class MonoFunctionType : TargetFunctionType
string name; string name;
int token; int token;


int load_handler;
MonoMethodSignature signature; MonoMethodSignature signature;


internal MonoFunctionType (IMonoStructType klass, Cecil.MethodDefinition mdef) internal MonoFunctionType (IMonoStructType klass, Cecil.MethodDefinition mdef)
Expand Down Expand Up @@ -151,26 +150,10 @@ internal static string GetMethodName (Cecil.MethodDefinition mdef)
get { return true; } get { return true; }
} }


internal override bool InsertBreakpoint (Thread thread, internal override FunctionBreakpointHandle GetBreakpointHandle (
FunctionBreakpointHandle handle) Breakpoint breakpoint, int line, int column)
{ {
if (!thread.CurrentFrame.Language.IsManaged) return new MyBreakpointHandle (breakpoint, this, line, column);
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;
}
} }


internal MonoClassInfo ResolveClass (TargetMemoryAccess target, bool fail) internal MonoClassInfo ResolveClass (TargetMemoryAccess target, bool fail)
Expand Down Expand Up @@ -207,5 +190,62 @@ public override TargetMethodSignature GetSignature (Thread thread)


return signature; 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;
}
}
}
} }
} }
9 changes: 2 additions & 7 deletions languages/native/NativeFunctionType.cs
Expand Up @@ -145,13 +145,8 @@ internal string GetPointerName ()
get { return false; } get { return false; }
} }


internal override bool InsertBreakpoint (Thread target, internal override FunctionBreakpointHandle GetBreakpointHandle (
FunctionBreakpointHandle handle) Breakpoint breakpoint, int line, int column)
{
throw new InvalidOperationException ();
}

internal override void RemoveBreakpoint (Thread target)
{ {
throw new InvalidOperationException (); throw new InvalidOperationException ();
} }
Expand Down

0 comments on commit 82ed431

Please sign in to comment.