1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
using System;
using System.Xml;
using Mono.Debugger.Backend;
using System.Runtime.Serialization;
using Mono.Debugger.Languages;
using Mono.Debugger.Languages.Mono;
namespace Mono.Debugger
{
[Serializable]
public sealed class ExceptionCatchPoint : Event
{
int handle = -1;
public override bool IsPersistent {
get { return true; }
}
internal ExceptionCatchPoint (ThreadGroup group, TargetType exception)
: base (EventType.CatchException, exception.Name, group)
{
this.exception = exception;
}
internal ExceptionCatchPoint (int index, ThreadGroup group, string name)
: base (EventType.CatchException, index, name, group)
{ }
public override bool IsActivated {
get { return handle > 0; }
}
public override void Activate (Thread target)
{
lock (this) {
EnableCatchpoint (target);
}
}
public override void Deactivate (Thread target)
{
lock (this) {
DisableCatchpoint (target);
}
}
internal override void OnTargetExited ()
{
exception = null;
handle = -1;
}
public override void Remove (Thread target)
{
lock (this) {
DisableCatchpoint (target);
}
}
void EnableCatchpoint (Thread target)
{
lock (this) {
if (handle > 0)
return;
handle = target.AddEventHandler (this);
}
}
void DisableCatchpoint (Thread target)
{
lock (this) {
if (handle > 0)
target.RemoveEventHandler (handle);
handle = -1;
}
}
bool IsSubclassOf (TargetMemoryAccess target, TargetStructType type,
TargetType parent)
{
while (type != null) {
if (type == parent)
return true;
if (!type.HasParent)
return false;
type = type.GetParentType (target);
}
return false;
}
internal bool CheckException (MonoLanguageBackend mono, TargetMemoryAccess target,
TargetAddress address)
{
TargetClassObject exc = mono.CreateObject (target, address) as TargetClassObject;
if (exc == null)
return false; // OOOPS
if (exception == null)
exception = mono.LookupType (Name);
if (exception == null)
return false;
return IsSubclassOf (target, exc.Type, exception);
}
protected override void GetSessionData (XmlElement root, XmlElement element)
{
XmlElement exception_e = root.OwnerDocument.CreateElement ("Exception");
exception_e.SetAttribute ("type", Name);
element.AppendChild (exception_e);
}
TargetType exception;
}
}
|