Author: martin
Date: 2008-02-15 06:46:57 -0500 (Fri, 15 Feb 2008)
New Revision: 95732
Modified:
branches/martin/debugger-terrania/symbolwriter/ChangeLog
branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
Log:
2008-02-15 Martin Baulig <[EMAIL PROTECTED]>
* MonoSymbolTable.cs
(CodeBlockEntry): New public class.
(MethodEntry): Replace the old lexical blocks with a new concept
of `code blocks'. Keep backwards compatibility.
* MonoSymbolWriter.cs
(MonoSymbolWriter): Add OpenCompilerGeneratedBlock(),
CloseCompilerGeneratedBlock(), StartIteratorBody(),
EndIteratorBody(), StartIteratorDispatcher(),
EndIteratorDispatcher().
Modified: branches/martin/debugger-terrania/symbolwriter/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/ChangeLog 2008-02-15
10:37:15 UTC (rev 95731)
+++ branches/martin/debugger-terrania/symbolwriter/ChangeLog 2008-02-15
11:46:57 UTC (rev 95732)
@@ -1,3 +1,16 @@
+2008-02-15 Martin Baulig <[EMAIL PROTECTED]>
+
+ * MonoSymbolTable.cs
+ (CodeBlockEntry): New public class.
+ (MethodEntry): Replace the old lexical blocks with a new concept
+ of `code blocks'. Keep backwards compatibility.
+
+ * MonoSymbolWriter.cs
+ (MonoSymbolWriter): Add OpenCompilerGeneratedBlock(),
+ CloseCompilerGeneratedBlock(), StartIteratorBody(),
+ EndIteratorBody(), StartIteratorDispatcher(),
+ EndIteratorDispatcher().
+
2008-02-02 Martin Baulig <[EMAIL PROTECTED]>
* MonoSymbolTable.cs
Modified: branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
2008-02-15 10:37:15 UTC (rev 95731)
+++ branches/martin/debugger-terrania/symbolwriter/MonoSymbolTable.cs
2008-02-15 11:46:57 UTC (rev 95732)
@@ -240,6 +240,60 @@
}
}
+ public class CodeBlockEntry
+ {
+ public int Index;
+ public int Parent;
+ #region This is actually written to the symbol file
+ public Type BlockType;
+ public int StartOffset;
+ public int EndOffset;
+ #endregion
+
+ public enum Type {
+ Lexical = 1,
+ CompilerGenerated = 2,
+ IteratorBody = 3,
+ IteratorDispatcher = 4
+ }
+
+ public CodeBlockEntry (int index, int parent, Type type, int
start_offset)
+ {
+ this.Index = index;
+ this.Parent = parent;
+ this.BlockType = type;
+ this.StartOffset = start_offset;
+ }
+
+ internal CodeBlockEntry (int index, MyBinaryReader reader)
+ {
+ this.Index = index;
+ this.BlockType = (Type) reader.ReadInt32 ();
+ this.Parent = reader.ReadInt32 ();
+ this.StartOffset = reader.ReadInt32 ();
+ this.EndOffset = reader.ReadInt32 ();
+ }
+
+ public void Close (int end_offset)
+ {
+ this.EndOffset = end_offset;
+ }
+
+ internal void Write (MyBinaryWriter bw)
+ {
+ bw.Write ((int) BlockType);
+ bw.Write (Parent);
+ bw.Write (StartOffset);
+ bw.Write (EndOffset);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("[CodeBlock {0}:{1}:{2}:{3}:{4}]",
+ Index, Parent, BlockType,
StartOffset, EndOffset);
+ }
+ }
+
public struct LocalVariableEntry
{
#region This is actually written to the symbol file
@@ -490,20 +544,21 @@
LineNumberEntry[] lines,
LexicalBlockEntry[] blocks,
int start, int end, int namespace_id)
{
- DefineMethod (name, token, null, locals, lines, blocks,
start, end, namespace_id);
+ DefineMethod (name, token, null, locals, lines, blocks,
null,
+ start, end, 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)
+ LexicalBlockEntry[] lexical,
CodeBlockEntry[] blocks,
+ int start, int end, int namespace_id)
{
if (!creating)
throw new InvalidOperationException ();
MethodEntry entry = new MethodEntry (
file, this, name, (int) token, scope_vars,
locals, lines,
- blocks, start, end, namespace_id);
+ lexical, blocks, start, end, namespace_id);
methods.Add (entry);
file.AddMethod (entry);
@@ -727,6 +782,9 @@
int NumLexicalBlocks;
int LexicalBlockTableOffset;
+ public readonly int NumCodeBlocks;
+ int CodeBlockTableOffset;
+
public readonly int NumScopeVariables;
int ScopeVariableTableOffset;
#endregion
@@ -739,6 +797,7 @@
public readonly int[] LocalTypeIndices;
public readonly LocalVariableEntry[] Locals;
public readonly LexicalBlockEntry[] LexicalBlocks;
+ public readonly CodeBlockEntry[] CodeBlocks;
public readonly ScopeVariable[] ScopeVariables;
public readonly MonoSymbolFile SymbolFile;
@@ -771,6 +830,9 @@
NamespaceID = reader.ReadInt32 ();
LocalNamesAmbiguous = reader.ReadInt32 () != 0;
+ NumCodeBlocks = reader.ReadInt32 ();
+ CodeBlockTableOffset = reader.ReadInt32 ();
+
NumScopeVariables = reader.ReadInt32 ();
ScopeVariableTableOffset = reader.ReadInt32 ();
@@ -823,6 +885,17 @@
reader.BaseStream.Position = old_pos;
}
+ if (CodeBlockTableOffset != 0) {
+ long old_pos = reader.BaseStream.Position;
+ reader.BaseStream.Position =
CodeBlockTableOffset;
+
+ CodeBlocks = new CodeBlockEntry [NumCodeBlocks];
+ for (int i = 0; i < NumCodeBlocks; i++)
+ CodeBlocks [i] = new CodeBlockEntry (i,
reader);
+
+ reader.BaseStream.Position = old_pos;
+ }
+
if (NumScopeVariables != 0) {
long old_pos = reader.BaseStream.Position;
reader.BaseStream.Position =
ScopeVariableTableOffset;
@@ -838,8 +911,8 @@
internal MethodEntry (MonoSymbolFile file, SourceFileEntry
source,
string name, int token, ScopeVariable[]
scope_vars,
LocalVariableEntry[] locals,
LineNumberEntry[] lines,
- LexicalBlockEntry[] blocks, int
start_row, int end_row,
- int namespace_id)
+ LexicalBlockEntry[] lexical,
CodeBlockEntry[] blocks,
+ int start_row, int end_row, int
namespace_id)
{
this.SymbolFile = file;
@@ -851,7 +924,7 @@
StartRow = start_row;
EndRow = end_row;
NamespaceID = namespace_id;
- LexicalBlocks = blocks;
+ LexicalBlocks = lexical;
NumLexicalBlocks = LexicalBlocks != null ?
LexicalBlocks.Length : 0;
LineNumbers = BuildLineNumberTable (lines);
@@ -894,6 +967,9 @@
for (int i = 0; i < NumLocals; i++)
LocalTypeIndices [i] = file.GetNextTypeIndex ();
+ NumCodeBlocks = blocks != null ? blocks.Length : 0;
+ CodeBlocks = blocks;
+
NumScopeVariables = scope_vars != null ?
scope_vars.Length : 0;
ScopeVariables = scope_vars;
}
@@ -972,6 +1048,10 @@
for (int i = 0; i < NumLexicalBlocks; i++)
LexicalBlocks [i].Write (bw);
+ CodeBlockTableOffset = (int) bw.BaseStream.Position;
+ for (int i = 0; i < NumCodeBlocks; i++)
+ CodeBlocks [i].Write (bw);
+
ScopeVariableTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < NumScopeVariables; i++)
ScopeVariables [i].Write (bw);
@@ -993,6 +1073,9 @@
bw.Write (NamespaceID);
bw.Write (LocalNamesAmbiguous ? 1 : 0);
+ bw.Write (NumCodeBlocks);
+ bw.Write (CodeBlockTableOffset);
+
bw.Write (NumScopeVariables);
bw.Write (ScopeVariableTableOffset);
Modified: branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
===================================================================
--- branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
2008-02-15 10:37:15 UTC (rev 95731)
+++ branches/martin/debugger-terrania/symbolwriter/MonoSymbolWriter.cs
2008-02-15 11:46:57 UTC (rev 95732)
@@ -170,23 +170,56 @@
return source.DefineNamespace (name, using_clauses,
parent);
}
- public int OpenScope (int startOffset)
+ public int OpenScope (int start_offset)
{
if (current_method == null)
return 0;
- current_method.StartBlock (startOffset);
+ current_method.StartBlock (CodeBlockEntry.Type.Lexical,
start_offset);
return 0;
}
- public void CloseScope (int endOffset)
+ public void CloseScope (int end_offset)
{
if (current_method == null)
return;
- current_method.EndBlock (endOffset);
+ current_method.EndBlock (end_offset);
}
+ public void OpenCompilerGeneratedBlock (int start_offset)
+ {
+ current_method.StartBlock
(CodeBlockEntry.Type.CompilerGenerated,
+ start_offset);
+ }
+
+ public void CloseCompilerGeneratedBlock (int end_offset)
+ {
+ current_method.EndBlock (end_offset);
+ }
+
+ public void StartIteratorBody (int start_offset)
+ {
+ current_method.StartBlock
(CodeBlockEntry.Type.IteratorBody,
+ start_offset);
+ }
+
+ public void EndIteratorBody (int end_offset)
+ {
+ current_method.EndBlock (end_offset);
+ }
+
+ public void StartIteratorDispatcher (int start_offset)
+ {
+ current_method.StartBlock
(CodeBlockEntry.Type.IteratorDispatcher,
+ start_offset);
+ }
+
+ public void EndIteratorDispatcher (int end_offset)
+ {
+ current_method.EndBlock (end_offset);
+ }
+
public void DefineAnonymousScope (int id)
{
file.DefineAnonymousScope (id);
@@ -198,7 +231,7 @@
method.SourceFile.Entry.DefineMethod (
method.Method.Name, method.Method.Token,
method.ScopeVariables, method.Locals,
- method.Lines, method.Blocks,
+ method.Lines, null, method.Blocks,
method.Start.Row, method.End.Row,
method.Method.NamespaceID);
}
@@ -221,13 +254,10 @@
private ArrayList _blocks;
private ArrayList _scope_vars;
private Stack _block_stack;
- private int next_block_id = 0;
private ISourceMethod _method;
private ISourceFile _file;
private LineNumberEntry _start, _end;
- private LexicalBlockEntry _implicit_block;
-
public SourceMethod (ISourceFile file, ISourceMethod
method,
int startLine, int startColumn,
int endLine, int endColumn)
@@ -237,49 +267,47 @@
this._start = new LineNumberEntry (startLine,
0);
this._end = new LineNumberEntry (endLine, 0);
-
- this._implicit_block = new LexicalBlockEntry
(0, 0);
}
- public void StartBlock (int startOffset)
+ public void StartBlock (CodeBlockEntry.Type type, int
start_offset)
{
- LexicalBlockEntry block = new LexicalBlockEntry
(
- ++next_block_id, startOffset);
if (_block_stack == null)
_block_stack = new Stack ();
- _block_stack.Push (block);
if (_blocks == null)
_blocks = new ArrayList ();
+
+ int parent = CurrentBlock != null ?
CurrentBlock.Index : -1;
+
+ CodeBlockEntry block = new CodeBlockEntry (
+ _blocks.Count + 1, parent, type,
start_offset);
+
+ _block_stack.Push (block);
_blocks.Add (block);
}
- public void EndBlock (int endOffset)
+ public void EndBlock (int end_offset)
{
- LexicalBlockEntry block =
- (LexicalBlockEntry) _block_stack.Pop ();
-
- block.Close (endOffset);
+ CodeBlockEntry block = (CodeBlockEntry)
_block_stack.Pop ();
+ block.Close (end_offset);
}
- public LexicalBlockEntry[] Blocks {
+ public CodeBlockEntry[] Blocks {
get {
if (_blocks == null)
- return new LexicalBlockEntry
[0];
- else {
- LexicalBlockEntry[] retval =
- new LexicalBlockEntry
[_blocks.Count];
- _blocks.CopyTo (retval, 0);
- return retval;
- }
+ return new CodeBlockEntry [0];
+
+ CodeBlockEntry[] retval = new
CodeBlockEntry [_blocks.Count];
+ _blocks.CopyTo (retval, 0);
+ return retval;
}
}
- public LexicalBlockEntry CurrentBlock {
+ public CodeBlockEntry CurrentBlock {
get {
if ((_block_stack != null) &&
(_block_stack.Count > 0))
- return (LexicalBlockEntry)
_block_stack.Peek ();
+ return (CodeBlockEntry)
_block_stack.Peek ();
else
- return _implicit_block;
+ return null;
}
}
@@ -302,12 +330,12 @@
}
}
- public void AddLocal (int index, string name, byte[]
signature)
+ public void AddLocal (int index, string name, byte[]
sig)
{
if (_locals == null)
_locals = new ArrayList ();
- _locals.Add (new LocalVariableEntry (
- index, name, signature,
CurrentBlock.Index));
+ int block_idx = CurrentBlock != null ?
CurrentBlock.Index : 0;
+ _locals.Add (new LocalVariableEntry (index,
name, sig, block_idx));
}
public ScopeVariable[] ScopeVariables {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches