Author: martin
Date: 2008-02-11 03:01:32 -0500 (Mon, 11 Feb 2008)
New Revision: 95424
Modified:
branches/martin/debugger-terrania/symbolwriter/ChangeLog
branches/martin/debugger-terrania/symbolwriter/MonoSymbolFile.cs
branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
Log:
2008-02-02 Martin Baulig <[EMAIL PROTECTED]>
* MonoSymbolTable.cs
(OffsetTable.Version): Bump to 40.
(OffsetTable): Add `AnonymousScopeCount',
`AnonymousScopeTableOffset' and `AnonymousScopeTableSize'.
(CapturedVariable): New public struct.
(CapturedScope): New public struct.
(ScopeVariable): New public struct.
(AnonymousScopeEntry): New public class.
(SourceFileEntry.DefineMethod): Added overloaded version taking an
additional `ScopeVariable[]' argument.
* MonoSymbolFile.cs
(MonoSymbolFile.AnonymousScopeCount): New public property.
(MonoSymbolFile.GetAnonymousScope): New public method.
* MonoSymbolWriter.cs
(MonoSymbolWriter.DefineAnonymousScope): New public method.
(MonoSymbolWriter.DefineCapturedVariable): New public method.
(MonoSymbolWriter.DefineCapturedScope): New public method.
(MonoSymbolWriter.DefineScopeVariable): New public method.
Modified: branches/martin/debugger-terrania/symbolwriter/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/ChangeLog 2008-02-11
07:32:58 UTC (rev 95423)
+++ branches/martin/debugger-terrania/symbolwriter/ChangeLog 2008-02-11
08:01:32 UTC (rev 95424)
@@ -2,14 +2,24 @@
* MonoSymbolTable.cs
(OffsetTable.Version): Bump to 40.
+ (OffsetTable): Add `AnonymousScopeCount',
+ `AnonymousScopeTableOffset' and `AnonymousScopeTableSize'.
(CapturedVariable): New public struct.
- (AnonymousScope): New public struct.
- (SourceFileEntry.DefineMethod): Added overloaded version taking a
- additional `CapturedVariable[]' and `AnonymousScope[]' arguments.
+ (CapturedScope): New public struct.
+ (ScopeVariable): New public struct.
+ (AnonymousScopeEntry): New public class.
+ (SourceFileEntry.DefineMethod): Added overloaded version taking an
+ additional `ScopeVariable[]' argument.
+ * MonoSymbolFile.cs
+ (MonoSymbolFile.AnonymousScopeCount): New public property.
+ (MonoSymbolFile.GetAnonymousScope): New public method.
+
* MonoSymbolWriter.cs
(MonoSymbolWriter.DefineAnonymousScope): New public method.
(MonoSymbolWriter.DefineCapturedVariable): New public method.
+ (MonoSymbolWriter.DefineCapturedScope): New public method.
+ (MonoSymbolWriter.DefineScopeVariable): New public method.
2008-02-02 Martin Baulig <[EMAIL PROTECTED]>
Modified: branches/martin/debugger-terrania/symbolwriter/MonoSymbolFile.cs
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/MonoSymbolFile.cs
2008-02-11 07:32:58 UTC (rev 95423)
+++ branches/martin/debugger-terrania/symbolwriter/MonoSymbolFile.cs
2008-02-11 08:01:32 UTC (rev 95424)
@@ -131,6 +131,7 @@
ArrayList sources = new ArrayList ();
Hashtable method_source_hash = new Hashtable ();
Hashtable type_hash = new Hashtable ();
+ Hashtable anonymous_scopes;
OffsetTable ot;
int last_type_index;
@@ -164,6 +165,27 @@
methods.Add (entry);
}
+ internal void DefineAnonymousScope (int id)
+ {
+ if (anonymous_scopes == null)
+ anonymous_scopes = new Hashtable ();
+
+ anonymous_scopes.Add (id, new AnonymousScopeEntry (id));
+ }
+
+ internal void DefineCapturedVariable (int scope_id, string
name, string captured_name,
+ bool is_local)
+ {
+ AnonymousScopeEntry scope = (AnonymousScopeEntry)
anonymous_scopes [scope_id];
+ scope.AddCapturedVariable (name, captured_name,
is_local);
+ }
+
+ internal void DefineCapturedScope (int scope_id, int id, string
captured_name)
+ {
+ AnonymousScopeEntry scope = (AnonymousScopeEntry)
anonymous_scopes [scope_id];
+ scope.AddCapturedScope (id, captured_name);
+ }
+
internal int GetNextTypeIndex ()
{
return ++last_type_index;
@@ -241,6 +263,17 @@
ot.SourceTableSize = (int) bw.BaseStream.Position -
ot.SourceTableOffset;
//
+ // Write anonymous scope table.
+ //
+ ot.AnonymousScopeCount = anonymous_scopes != null ?
anonymous_scopes.Count : 0;
+ ot.AnonymousScopeTableOffset = (int)
bw.BaseStream.Position;
+ if (anonymous_scopes != null) {
+ foreach (AnonymousScopeEntry scope in
anonymous_scopes.Values)
+ scope.Write (bw);
+ }
+ ot.AnonymousScopeTableSize = (int)
bw.BaseStream.Position - ot.AnonymousScopeTableOffset;
+
+ //
// Fixup offset table.
//
ot.TypeCount = last_type_index;
@@ -367,6 +400,10 @@
get { return ot.TypeCount; }
}
+ public int AnonymousScopeCount {
+ get { return ot.AnonymousScopeCount; }
+ }
+
public int NamespaceCount {
get { return last_namespace_index; }
}
@@ -525,6 +562,23 @@
return (int) value;
}
+ public AnonymousScopeEntry GetAnonymousScope (int id)
+ {
+ if (anonymous_scopes != null)
+ return (AnonymousScopeEntry) anonymous_scopes
[id];
+ if (reader == null)
+ throw new InvalidOperationException ();
+
+ anonymous_scopes = new Hashtable ();
+ reader.BaseStream.Position =
ot.AnonymousScopeTableOffset;
+ for (int i = 0; i < ot.AnonymousScopeCount; i++) {
+ AnonymousScopeEntry scope = new
AnonymousScopeEntry (reader);
+ anonymous_scopes.Add (scope.ID, scope);
+ }
+
+ return (AnonymousScopeEntry) anonymous_scopes [id];
+ }
+
internal MyBinaryReader BinaryReader {
get {
if (reader == null)
Modified: branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
2008-02-11 07:32:58 UTC (rev 95423)
+++ branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
2008-02-11 08:01:32 UTC (rev 95424)
@@ -85,6 +85,9 @@
public int MethodTableOffset;
public int MethodTableSize;
public int TypeCount;
+ public int AnonymousScopeCount;
+ public int AnonymousScopeTableOffset;
+ public int AnonymousScopeTableSize;
#endregion
internal OffsetTable (BinaryReader reader)
@@ -99,6 +102,9 @@
MethodTableOffset = reader.ReadInt32 ();
MethodTableSize = reader.ReadInt32 ();
TypeCount = reader.ReadInt32 ();
+ AnonymousScopeCount = reader.ReadInt32 ();
+ AnonymousScopeTableOffset = reader.ReadInt32 ();
+ AnonymousScopeTableSize = reader.ReadInt32 ();
}
internal void Write (BinaryWriter bw)
@@ -113,6 +119,9 @@
bw.Write (MethodTableOffset);
bw.Write (MethodTableSize);
bw.Write (TypeCount);
+ bw.Write (AnonymousScopeCount);
+ bw.Write (AnonymousScopeTableOffset);
+ bw.Write (AnonymousScopeTableSize);
}
public override string ToString ()
@@ -276,16 +285,14 @@
public struct CapturedVariable
{
#region This is actually written to the symbol file
- public readonly int Scope;
public readonly string Name;
public readonly string CapturedName;
public readonly bool IsLocal;
#endregion
- public CapturedVariable (int scope, string name, string
captured_name,
+ public CapturedVariable (string name, string captured_name,
bool is_local)
{
- this.Scope = scope;
this.Name = name;
this.CapturedName = captured_name;
this.IsLocal = is_local;
@@ -293,15 +300,13 @@
internal CapturedVariable (MyBinaryReader reader)
{
- Scope = reader.ReadLeb128 ();
Name = reader.ReadString ();
CapturedName = reader.ReadString ();
IsLocal = reader.ReadBoolean ();
}
- internal void Write (MonoSymbolFile file, MyBinaryWriter bw)
+ internal void Write (MyBinaryWriter bw)
{
- bw.WriteLeb128 (Scope);
bw.Write (Name);
bw.Write (CapturedName);
bw.Write (IsLocal);
@@ -309,47 +314,146 @@
public override string ToString ()
{
- return String.Format ("[CapturedVariable
{0}:{1}:{2}:{3}]",
- Scope, Name, CapturedName,
IsLocal);
+ return String.Format ("[CapturedVariable {0}:{1}:{2}]",
+ Name, CapturedName, IsLocal);
}
}
- public struct AnonymousScope
+ public struct CapturedScope
{
#region This is actually written to the symbol file
- public readonly int ID;
+ public readonly int Scope;
+ public readonly string CapturedName;
+ #endregion
+
+ public CapturedScope (int scope, string captured_name)
+ {
+ this.Scope = scope;
+ this.CapturedName = captured_name;
+ }
+
+ internal CapturedScope (MyBinaryReader reader)
+ {
+ Scope = reader.ReadLeb128 ();
+ CapturedName = reader.ReadString ();
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.WriteLeb128 (Scope);
+ bw.Write (CapturedName);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[CapturedScope {0}:{1}]",
+ Scope, CapturedName);
+ }
+ }
+
+ public struct ScopeVariable
+ {
+ #region This is actually written to the symbol file
+ public readonly int Scope;
public readonly int Index;
- public readonly int Parent;
#endregion
- public AnonymousScope (int id, int parent, int index)
+ public ScopeVariable (int scope, int index)
{
- this.ID = id;
+ this.Scope = scope;
this.Index = index;
- this.Parent = parent;
}
- internal AnonymousScope (MyBinaryReader reader)
+ internal ScopeVariable (MyBinaryReader reader)
{
- ID = reader.ReadLeb128 ();
+ Scope = reader.ReadLeb128 ();
Index = reader.ReadLeb128 ();
- Parent = reader.ReadLeb128 ();
}
- internal void Write (MonoSymbolFile file, MyBinaryWriter bw)
+ internal void Write (MyBinaryWriter bw)
{
- bw.WriteLeb128 (ID);
+ bw.WriteLeb128 (Scope);
bw.WriteLeb128 (Index);
- bw.WriteLeb128 (Parent);
}
public override string ToString ()
{
- return String.Format ("[AnonymousScope {0}:{1}:{2}]",
- ID, Index, Parent);
+ return String.Format ("[ScopeVariable {0}:{1}]", Scope,
Index);
}
}
+ public class AnonymousScopeEntry
+ {
+ #region This is actually written to the symbol file
+ public readonly int ID;
+ #endregion
+
+ ArrayList captured_vars = new ArrayList ();
+ ArrayList captured_scopes = new ArrayList ();
+
+ public AnonymousScopeEntry (int id)
+ {
+ this.ID = id;
+ }
+
+ internal AnonymousScopeEntry (MyBinaryReader reader)
+ {
+ ID = reader.ReadLeb128 ();
+
+ int num_captured_vars = reader.ReadLeb128 ();
+ for (int i = 0; i < num_captured_vars; i++)
+ captured_vars.Add (new CapturedVariable
(reader));
+
+ int num_captured_scopes = reader.ReadLeb128 ();
+ for (int i = 0; i < num_captured_scopes; i++)
+ captured_scopes.Add (new CapturedScope
(reader));
+ }
+
+ internal void AddCapturedVariable (string name, string
captured_name, bool is_local)
+ {
+ captured_vars.Add (new CapturedVariable (name,
captured_name, is_local));
+ }
+
+ public CapturedVariable[] CapturedVariables {
+ get {
+ CapturedVariable[] retval = new
CapturedVariable [captured_vars.Count];
+ captured_vars.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
+ internal void AddCapturedScope (int scope, string captured_name)
+ {
+ captured_scopes.Add (new CapturedScope (scope,
captured_name));
+ }
+
+ public CapturedScope[] CapturedScopes {
+ get {
+ CapturedScope[] retval = new CapturedScope
[captured_scopes.Count];
+ captured_scopes.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.WriteLeb128 (ID);
+
+ bw.WriteLeb128 (captured_vars.Count);
+ foreach (CapturedVariable cv in captured_vars)
+ cv.Write (bw);
+
+ bw.WriteLeb128 (captured_scopes.Count);
+ foreach (CapturedScope cs in captured_scopes)
+ cs.Write (bw);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[AnonymousScope {0}]", ID);
+ }
+ }
+
public class SourceFileEntry
{
#region This is actually written to the symbol file
@@ -386,20 +490,19 @@
LineNumberEntry[] lines,
LexicalBlockEntry[] blocks,
int start, int end, int namespace_id)
{
- DefineMethod (name, token, null, null, locals, lines,
blocks,
- start, end, namespace_id);
+ DefineMethod (name, token, null, locals, lines, blocks,
start, end, namespace_id);
}
- public void DefineMethod (string name, int token,
CapturedVariable[] captured_vars,
- AnonymousScope[] scopes,
LocalVariableEntry[] locals,
- LineNumberEntry[] lines,
LexicalBlockEntry[] blocks,
- int start, int end, int namespace_id)
+ public void DefineMethod (string name, int token,
ScopeVariable[] scope_vars,
+ LocalVariableEntry[] locals,
LineNumberEntry[] lines,
+ LexicalBlockEntry[] blocks, int
start, int end,
+ int namespace_id)
{
if (!creating)
throw new InvalidOperationException ();
MethodEntry entry = new MethodEntry (
- file, this, name, (int) token, captured_vars,
scopes, locals, lines,
+ file, this, name, (int) token, scope_vars,
locals, lines,
blocks, start, end, namespace_id);
methods.Add (entry);
@@ -624,10 +727,8 @@
int NumLexicalBlocks;
int LexicalBlockTableOffset;
- public readonly int NumCapturedVariables;
- public readonly int NumAnonymousScopes;
- int CapturedVariableTableOffset;
- int AnonymousScopeTableOffset;
+ public readonly int NumScopeVariables;
+ int ScopeVariableTableOffset;
#endregion
int index;
@@ -636,10 +737,9 @@
public readonly SourceFileEntry SourceFile;
public readonly LineNumberEntry[] LineNumbers;
public readonly int[] LocalTypeIndices;
- public readonly CapturedVariable[] CapturedVariables;
- public readonly AnonymousScope[] AnonymousScopes;
public readonly LocalVariableEntry[] Locals;
public readonly LexicalBlockEntry[] LexicalBlocks;
+ public readonly ScopeVariable[] ScopeVariables;
public readonly MonoSymbolFile SymbolFile;
@@ -671,10 +771,8 @@
NamespaceID = reader.ReadInt32 ();
LocalNamesAmbiguous = reader.ReadInt32 () != 0;
- NumCapturedVariables = reader.ReadInt32 ();
- NumAnonymousScopes = reader.ReadInt32 ();
- CapturedVariableTableOffset = reader.ReadInt32 ();
- AnonymousScopeTableOffset = reader.ReadInt32 ();
+ NumScopeVariables = reader.ReadInt32 ();
+ ScopeVariableTableOffset = reader.ReadInt32 ();
SourceFile = file.GetSourceFile (SourceFileIndex);
@@ -725,36 +823,23 @@
reader.BaseStream.Position = old_pos;
}
- if (CapturedVariableTableOffset != 0) {
+ if (NumScopeVariables != 0) {
long old_pos = reader.BaseStream.Position;
- reader.BaseStream.Position =
CapturedVariableTableOffset;
+ reader.BaseStream.Position =
ScopeVariableTableOffset;
- CapturedVariables = new CapturedVariable
[NumCapturedVariables];
+ ScopeVariables = new ScopeVariable
[NumScopeVariables];
+ for (int i = 0; i < NumScopeVariables; i++)
+ ScopeVariables [i] = new ScopeVariable
(reader);
- for (int i = 0; i < NumCapturedVariables; i++)
- CapturedVariables [i] = new
CapturedVariable (reader);
-
reader.BaseStream.Position = old_pos;
}
-
- if (AnonymousScopeTableOffset != 0) {
- long old_pos = reader.BaseStream.Position;
- reader.BaseStream.Position =
AnonymousScopeTableOffset;
-
- AnonymousScopes = new AnonymousScope
[NumAnonymousScopes];
-
- for (int i = 0; i < NumAnonymousScopes; i++)
- AnonymousScopes [i] = new
AnonymousScope (reader);
-
- reader.BaseStream.Position = old_pos;
- }
}
internal MethodEntry (MonoSymbolFile file, SourceFileEntry
source,
- string name, int token,
CapturedVariable[] captured_vars,
- AnonymousScope[] scopes,
LocalVariableEntry[] locals,
- LineNumberEntry[] lines,
LexicalBlockEntry[] blocks,
- int start_row, int end_row, int
namespace_id)
+ string name, int token, ScopeVariable[]
scope_vars,
+ LocalVariableEntry[] locals,
LineNumberEntry[] lines,
+ LexicalBlockEntry[] blocks, int
start_row, int end_row,
+ int namespace_id)
{
this.SymbolFile = file;
@@ -809,11 +894,8 @@
for (int i = 0; i < NumLocals; i++)
LocalTypeIndices [i] = file.GetNextTypeIndex ();
- NumCapturedVariables = captured_vars != null ?
captured_vars.Length : 0;
- CapturedVariables = captured_vars;
-
- NumAnonymousScopes = scopes != null ? scopes.Length : 0;
- AnonymousScopes = scopes;
+ NumScopeVariables = scope_vars != null ?
scope_vars.Length : 0;
+ ScopeVariables = scope_vars;
}
static LineNumberEntry [] tmp_buff = new LineNumberEntry [20];
@@ -876,14 +958,6 @@
for (int i = 0; i < NumLocals; i++)
bw.Write (LocalTypeIndices [i]);
- CapturedVariableTableOffset = (int)
bw.BaseStream.Position;
- for (int i = 0; i < NumCapturedVariables; i++)
- CapturedVariables [i].Write (file, bw);
-
- AnonymousScopeTableOffset = (int)
bw.BaseStream.Position;
- for (int i = 0; i < NumAnonymousScopes; i++)
- AnonymousScopes [i].Write (file, bw);
-
LocalVariableTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < NumLocals; i++)
Locals [i].Write (file, bw);
@@ -897,6 +971,11 @@
LexicalBlockTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < NumLexicalBlocks; i++)
LexicalBlocks [i].Write (bw);
+
+ ScopeVariableTableOffset = (int) bw.BaseStream.Position;
+ for (int i = 0; i < NumScopeVariables; i++)
+ ScopeVariables [i].Write (bw);
+
file_offset = (int) bw.BaseStream.Position;
bw.Write (SourceFileIndex);
@@ -914,10 +993,8 @@
bw.Write (NamespaceID);
bw.Write (LocalNamesAmbiguous ? 1 : 0);
- bw.Write (NumCapturedVariables);
- bw.Write (NumAnonymousScopes);
- bw.Write (CapturedVariableTableOffset);
- bw.Write (AnonymousScopeTableOffset);
+ bw.Write (NumScopeVariables);
+ bw.Write (ScopeVariableTableOffset);
return new MethodSourceEntry (index, file_offset,
StartRow, EndRow);
}
Modified: branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
2008-02-11 07:32:58 UTC (rev 95423)
+++ branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
2008-02-11 08:01:32 UTC (rev 95424)
@@ -104,13 +104,22 @@
current_method.AddLocal (index, name, signature);
}
- public void DefineCapturedVariable (int scope, string name,
string captured_name,
+ public void DefineCapturedVariable (int scope_id, string name,
string captured_name,
bool is_local)
{
- current_method.AddCapturedVariable (
- scope, name, captured_name, is_local);
+ file.DefineCapturedVariable (scope_id, name,
captured_name, is_local);
}
+ public void DefineCapturedScope (int scope_id, int id, string
captured_name)
+ {
+ file.DefineCapturedScope (scope_id, id, captured_name);
+ }
+
+ public void DefineScopeVariable (int scope, int index)
+ {
+ current_method.AddScopeVariable (scope, index);
+ }
+
public void MarkSequencePoint (int offset, int line, int column)
{
if (current_method == null)
@@ -178,9 +187,9 @@
current_method.EndBlock (endOffset);
}
- public void DefineAnonymousScope (int id, int parent, int index)
+ public void DefineAnonymousScope (int id)
{
- current_method.AddAnonymousScope (id, parent, index);
+ file.DefineAnonymousScope (id);
}
public void WriteSymbolFile (Guid guid)
@@ -188,8 +197,8 @@
foreach (SourceMethod method in methods) {
method.SourceFile.Entry.DefineMethod (
method.Method.Name, method.Method.Token,
- method.CapturedVariables,
method.AnonymousScopes,
- method.Locals, method.Lines,
method.Blocks,
+ method.ScopeVariables, method.Locals,
+ method.Lines, method.Blocks,
method.Start.Row, method.End.Row,
method.Method.NamespaceID);
}
@@ -210,8 +219,7 @@
LineNumberEntry [] lines;
private ArrayList _locals;
private ArrayList _blocks;
- private ArrayList _anonymous_scopes;
- private ArrayList _captured;
+ private ArrayList _scope_vars;
private Stack _block_stack;
private int next_block_id = 0;
private ISourceMethod _method;
@@ -281,29 +289,6 @@
}
}
- public CapturedVariable[] CapturedVariables {
- get {
- if (_captured == null)
- return new CapturedVariable [0];
-
- CapturedVariable[] retval = new
CapturedVariable [_captured.Count];
- _captured.CopyTo (retval, 0);
- return retval;
- }
- }
-
- public AnonymousScope[] AnonymousScopes {
- get {
- if (_anonymous_scopes == null)
- return new AnonymousScope [0];
-
- AnonymousScope[] retval =
- new AnonymousScope
[_anonymous_scopes.Count];
- _anonymous_scopes.CopyTo (retval, 0);
- return retval;
- }
- }
-
public LocalVariableEntry[] Locals {
get {
if (_locals == null)
@@ -325,19 +310,23 @@
index, name, signature,
CurrentBlock.Index));
}
- public void AddAnonymousScope (int id, int parent, int
index)
- {
- if (_anonymous_scopes == null)
- _anonymous_scopes = new ArrayList ();
- _anonymous_scopes.Add (new AnonymousScope (id,
parent, index));
+ public ScopeVariable[] ScopeVariables {
+ get {
+ if (_scope_vars == null)
+ return new ScopeVariable [0];
+
+ ScopeVariable[] retval = new
ScopeVariable [_scope_vars.Count];
+ _scope_vars.CopyTo (retval);
+ return retval;
+ }
}
- public void AddCapturedVariable (int scope, string
name, string cname,
- bool is_local)
+ public void AddScopeVariable (int scope, int index)
{
- if (_captured == null)
- _captured = new ArrayList ();
- _captured.Add (new CapturedVariable (scope,
name, cname, is_local));
+ if (_scope_vars == null)
+ _scope_vars = new ArrayList ();
+ _scope_vars.Add (
+ new ScopeVariable (scope, index));
}
public ISourceFile SourceFile {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches