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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
using System;
using System.Runtime.InteropServices;
using Mono.Debugger.Backend;
namespace Mono.Debugger.Languages.Native
{
internal class NativeLanguage : Language
{
BfdContainer bfd_container;
TargetFundamentalType integer_type;
TargetFundamentalType long_type;
NativePointerType pointer_type;
NativeOpaqueType void_type;
NativeStringType string_type;
TargetInfo info;
public NativeLanguage (BfdContainer bfd_container, TargetInfo info)
{
this.bfd_container = bfd_container;
this.info = info;
integer_type = new NativeFundamentalType (this, "int", FundamentalKind.Int32, 4);
long_type = new NativeFundamentalType (this, "long", FundamentalKind.Int64, 8);
pointer_type = new NativePointerType (this, "void *", info.TargetAddressSize);
void_type = new NativeOpaqueType (this, "void", 0);
string_type = new NativeStringType (this, info.TargetAddressSize);
}
public override string Name {
get { return "native"; }
}
public override bool IsManaged {
get { return false; }
}
internal override ProcessServant Process {
get { return bfd_container.Process; }
}
public override TargetFundamentalType IntegerType {
get { return integer_type; }
}
public override TargetFundamentalType LongIntegerType {
get { return long_type; }
}
public override TargetFundamentalType StringType {
get { return string_type; }
}
public override TargetType PointerType {
get { return pointer_type; }
}
public override TargetType VoidType {
get { return void_type; }
}
public override TargetInfo TargetInfo {
get { return info; }
}
public override TargetClassType ExceptionType {
get { return null; }
}
public override TargetClassType DelegateType {
get { return null; }
}
public override TargetClassType ObjectType {
get { return null; }
}
public override TargetClassType ArrayType {
get { return null; }
}
public override string SourceLanguage (StackFrame frame)
{
return "";
}
public override TargetType LookupType (string name)
{
return bfd_container.LookupType (name);
}
public override bool CanCreateInstance (Type type)
{
return false;
}
public override TargetFundamentalObject CreateInstance (Thread target, object value)
{
throw new InvalidOperationException ();
}
public override TargetPointerObject CreatePointer (StackFrame frame,
TargetAddress address)
{
TargetLocation location = new AbsoluteTargetLocation (address);
return new NativePointerObject (pointer_type, location);
}
public override TargetObject CreateObject (Thread target, TargetAddress address)
{
throw new NotSupportedException ();
}
public override TargetObject CreateNullObject (Thread target, TargetType type)
{
throw new NotSupportedException ();
}
public override TargetPointerType CreatePointerType (TargetType type)
{
return new NativePointerType (this, type.Name + "*", type, type.Size);
}
internal TargetAddress LookupSymbol (string name)
{
return bfd_container.LookupSymbol (name);
}
private bool disposed = false;
private void Dispose (bool disposing)
{
lock (this) {
if (disposed)
return;
disposed = true;
}
if (disposing) {
if (bfd_container != null) {
bfd_container.Dispose ();
bfd_container = null;
}
}
}
public void Dispose ()
{
Dispose (true);
// Take yourself off the Finalization queue
GC.SuppressFinalize (this);
}
~NativeLanguage ()
{
Dispose (false);
}
}
}
|