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
|
using System;
using System.Collections;
namespace Mono.Debugger
{
public interface ISymbolLookup
{
Method Lookup (TargetAddress address);
}
public interface ISymbolContainer
{
// <summary>
// StartAddress and EndAddress are only valid if this is true.
// </summary>
bool IsContinuous {
get;
}
TargetAddress StartAddress {
get;
}
TargetAddress EndAddress {
get;
}
}
public interface ISymbolRange : IComparable
{
TargetAddress StartAddress {
get;
}
TargetAddress EndAddress {
get;
}
// <summary>
// If the address you're looking for is within the
// [StartAddress,EndAddress] interface, use this property
// to get an ISymbolLookup instance which you can use to
// search the symbol. This'll automatically load the
// symbol table from disk if necessary.
// </summary>
ISymbolLookup SymbolLookup {
get;
}
}
public delegate void SymbolTableChangedHandler ();
// <summary>
// This interface is used to find a method by an address.
// </summary>
public interface ISymbolTable : ISymbolLookup, ISymbolContainer
{
// <summary>
// Whether this symbol table has an address range table.
// </summary>
bool HasRanges {
get;
}
// <summary>
// If HasRanges is true, this is a sorted (by start address)
// list of address ranges. To lookup a symbol by its address,
// first search in this table to find the correct ISymbolRange,
// then use its SymbolLookup property to get an ISymbolLookup
// on which you can do a Lookup().
// </summary>
// <remarks>
// When searching in more than one ISymbolTable, consider using
// an ISymbolTableCollection instead since this will merge the
// address ranges from all its symbol tables into one big table
// and thus a lookup fill me faster.
// </remarks>
ISymbolRange[] SymbolRanges {
get;
}
// <summary>
// If true, you may use the `Methods' property to get a list of all the
// methods in this symbol table.
// </summary>
bool HasMethods {
get;
}
// <summary>
// Get a list of all methods in this symbol table. May only be used if
// `HasMethods' is true.
// </summary>
Method[] Methods {
get;
}
bool IsLoaded {
get;
}
void UpdateSymbolTable ();
event SymbolTableChangedHandler SymbolTableChanged;
}
[Serializable]
public class Symbol : IComparable
{
public readonly string Name;
public readonly TargetAddress Address;
public readonly int Offset;
public Symbol (string name, TargetAddress address, int offset)
{
this.Name = name;
this.Address = address;
this.Offset = offset;
}
public int CompareTo (object obj)
{
Symbol symbol = (Symbol) obj;
if (symbol.Address < Address)
return 1;
else if (symbol.Address > Address)
return -1;
else
return 0;
}
public override string ToString ()
{
if (Offset > 0)
return String.Format ("{0}+0x{1:x}", Name, Offset);
else if (Offset < 0)
return String.Format ("{0}-0x{1:x}", Name, Offset);
else
return Name;
}
}
}
|