mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Optimize debugging symbols writing
This commit is contained in:
1 parent
c251b192a5
commit
70cc60e957
28 files changed
+669
-905
No files matched your search
@@ -48,10 +48,9 @@
|
||||
../../mcs/typemanager.cs
|
||||
../../mcs/typespec.cs
|
||||
../../mcs/visit.cs
|
||||
../../mcs/symbolwriter.cs
|
||||
../../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
|
||||
../../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
|
||||
../../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
|
||||
../../class/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
|
||||
../../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
|
||||
../../build/common/Consts.cs
|
||||
../../tools/monop/outline.cs
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
../Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
|
||||
../Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
|
||||
../Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
|
||||
../Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
|
||||
+1
@@ -4,4 +4,5 @@ Assembly/AssemblyInfo.cs
|
||||
MonoSymbolWriter.cs
|
||||
MonoSymbolTable.cs
|
||||
MonoSymbolFile.cs
|
||||
SourceMethodBuilder.cs
|
||||
SymbolWriterImpl.cs
|
||||
@@ -240,174 +240,4 @@ namespace Mono.CompilerServices.SymbolWriter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SourceMethodBuilder
|
||||
{
|
||||
List<LocalVariableEntry> _locals;
|
||||
List<CodeBlockEntry> _blocks;
|
||||
List<ScopeVariable> _scope_vars;
|
||||
#if NET_2_1
|
||||
System.Collections.Stack _block_stack;
|
||||
#else
|
||||
Stack<CodeBlockEntry> _block_stack;
|
||||
#endif
|
||||
List<LineNumberEntry> method_lines;
|
||||
|
||||
string _real_name;
|
||||
IMethodDef _method;
|
||||
ICompileUnit _comp_unit;
|
||||
// MethodEntry.Flags _method_flags;
|
||||
int _ns_id;
|
||||
|
||||
public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
|
||||
{
|
||||
this._comp_unit = comp_unit;
|
||||
this._method = method;
|
||||
this._ns_id = ns_id;
|
||||
method_lines = new List<LineNumberEntry> ();
|
||||
}
|
||||
|
||||
public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
|
||||
{
|
||||
int file_idx = file != null ? file.Index : 0;
|
||||
var lne = new LineNumberEntry (file_idx, line, offset, is_hidden);
|
||||
|
||||
if (method_lines.Count > 0) {
|
||||
var prev = method_lines[method_lines.Count - 1];
|
||||
|
||||
//
|
||||
// Same offset cannot be used for multiple lines
|
||||
//
|
||||
if (prev.Offset == offset) {
|
||||
//
|
||||
// Use the new location because debugger will adjust
|
||||
// the breakpoint to next line with sequence point
|
||||
//
|
||||
if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0)
|
||||
method_lines[method_lines.Count - 1] = lne;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
method_lines.Add (lne);
|
||||
}
|
||||
|
||||
public void StartBlock (CodeBlockEntry.Type type, int start_offset)
|
||||
{
|
||||
if (_block_stack == null) {
|
||||
#if NET_2_1
|
||||
_block_stack = new System.Collections.Stack ();
|
||||
#else
|
||||
_block_stack = new Stack<CodeBlockEntry> ();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_blocks == null)
|
||||
_blocks = new List<CodeBlockEntry> ();
|
||||
|
||||
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 end_offset)
|
||||
{
|
||||
CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop ();
|
||||
block.Close (end_offset);
|
||||
}
|
||||
|
||||
public CodeBlockEntry[] Blocks {
|
||||
get {
|
||||
if (_blocks == null)
|
||||
return new CodeBlockEntry [0];
|
||||
|
||||
CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count];
|
||||
_blocks.CopyTo (retval, 0);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
public CodeBlockEntry CurrentBlock {
|
||||
get {
|
||||
if ((_block_stack != null) && (_block_stack.Count > 0))
|
||||
return (CodeBlockEntry) _block_stack.Peek ();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public LocalVariableEntry[] Locals {
|
||||
get {
|
||||
if (_locals == null)
|
||||
return new LocalVariableEntry [0];
|
||||
else {
|
||||
LocalVariableEntry[] retval =
|
||||
new LocalVariableEntry [_locals.Count];
|
||||
_locals.CopyTo (retval, 0);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLocal (int index, string name)
|
||||
{
|
||||
if (_locals == null)
|
||||
_locals = new List<LocalVariableEntry> ();
|
||||
int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
|
||||
_locals.Add (new LocalVariableEntry (index, name, block_idx));
|
||||
}
|
||||
|
||||
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 AddScopeVariable (int scope, int index)
|
||||
{
|
||||
if (_scope_vars == null)
|
||||
_scope_vars = new List<ScopeVariable> ();
|
||||
_scope_vars.Add (
|
||||
new ScopeVariable (scope, index));
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public string RealMethodName {
|
||||
get { return _real_name; }
|
||||
}
|
||||
|
||||
[Obsolete ("It has no meaning")]
|
||||
public void SetRealMethodName (string name)
|
||||
{
|
||||
_real_name = name;
|
||||
}
|
||||
|
||||
public ICompileUnit SourceFile {
|
||||
get { return _comp_unit; }
|
||||
}
|
||||
|
||||
public IMethodDef Method {
|
||||
get { return _method; }
|
||||
}
|
||||
|
||||
public void DefineMethod (MonoSymbolFile file)
|
||||
{
|
||||
MethodEntry entry = new MethodEntry (
|
||||
file, _comp_unit.Entry, _method.Token, ScopeVariables,
|
||||
Locals, method_lines.ToArray (), Blocks, _real_name, 0, //_method_flags,
|
||||
_ns_id);
|
||||
|
||||
file.AddMethod (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// SourceMethodBuilder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Martin Baulig ([email protected])
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// (C) 2002 Ximian, Inc. http://www.ximian.com
|
||||
// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mono.CompilerServices.SymbolWriter
|
||||
{
|
||||
public class SourceMethodBuilder
|
||||
{
|
||||
List<LocalVariableEntry> _locals;
|
||||
List<CodeBlockEntry> _blocks;
|
||||
List<ScopeVariable> _scope_vars;
|
||||
#if NET_2_1
|
||||
System.Collections.Stack _block_stack;
|
||||
#else
|
||||
Stack<CodeBlockEntry> _block_stack;
|
||||
#endif
|
||||
readonly List<LineNumberEntry> method_lines;
|
||||
|
||||
readonly ICompileUnit _comp_unit;
|
||||
readonly int ns_id;
|
||||
readonly IMethodDef method;
|
||||
|
||||
public SourceMethodBuilder (ICompileUnit comp_unit)
|
||||
{
|
||||
this._comp_unit = comp_unit;
|
||||
method_lines = new List<LineNumberEntry> ();
|
||||
}
|
||||
|
||||
public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
|
||||
: this (comp_unit)
|
||||
{
|
||||
this.ns_id = ns_id;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
|
||||
{
|
||||
int file_idx = file != null ? file.Index : 0;
|
||||
var lne = new LineNumberEntry (file_idx, line, offset, is_hidden);
|
||||
|
||||
if (method_lines.Count > 0) {
|
||||
var prev = method_lines[method_lines.Count - 1];
|
||||
|
||||
//
|
||||
// Same offset cannot be used for multiple lines
|
||||
//
|
||||
if (prev.Offset == offset) {
|
||||
//
|
||||
// Use the new location because debugger will adjust
|
||||
// the breakpoint to next line with sequence point
|
||||
//
|
||||
if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0)
|
||||
method_lines[method_lines.Count - 1] = lne;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
method_lines.Add (lne);
|
||||
}
|
||||
|
||||
public void StartBlock (CodeBlockEntry.Type type, int start_offset)
|
||||
{
|
||||
if (_block_stack == null) {
|
||||
#if NET_2_1
|
||||
_block_stack = new System.Collections.Stack ();
|
||||
#else
|
||||
_block_stack = new Stack<CodeBlockEntry> ();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_blocks == null)
|
||||
_blocks = new List<CodeBlockEntry> ();
|
||||
|
||||
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 end_offset)
|
||||
{
|
||||
CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop ();
|
||||
block.Close (end_offset);
|
||||
}
|
||||
|
||||
public CodeBlockEntry[] Blocks {
|
||||
get {
|
||||
if (_blocks == null)
|
||||
return new CodeBlockEntry [0];
|
||||
|
||||
CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count];
|
||||
_blocks.CopyTo (retval, 0);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
public CodeBlockEntry CurrentBlock {
|
||||
get {
|
||||
if ((_block_stack != null) && (_block_stack.Count > 0))
|
||||
return (CodeBlockEntry) _block_stack.Peek ();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public LocalVariableEntry[] Locals {
|
||||
get {
|
||||
if (_locals == null)
|
||||
return new LocalVariableEntry [0];
|
||||
else {
|
||||
return _locals.ToArray ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICompileUnit SourceFile {
|
||||
get {
|
||||
return _comp_unit;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLocal (int index, string name)
|
||||
{
|
||||
if (_locals == null)
|
||||
_locals = new List<LocalVariableEntry> ();
|
||||
int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
|
||||
_locals.Add (new LocalVariableEntry (index, name, block_idx));
|
||||
}
|
||||
|
||||
public ScopeVariable[] ScopeVariables {
|
||||
get {
|
||||
if (_scope_vars == null)
|
||||
return new ScopeVariable [0];
|
||||
|
||||
return _scope_vars.ToArray ();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddScopeVariable (int scope, int index)
|
||||
{
|
||||
if (_scope_vars == null)
|
||||
_scope_vars = new List<ScopeVariable> ();
|
||||
_scope_vars.Add (
|
||||
new ScopeVariable (scope, index));
|
||||
}
|
||||
|
||||
public void DefineMethod (MonoSymbolFile file)
|
||||
{
|
||||
DefineMethod (file, method.Token);
|
||||
}
|
||||
|
||||
public void DefineMethod (MonoSymbolFile file, int token)
|
||||
{
|
||||
MethodEntry entry = new MethodEntry (
|
||||
file, _comp_unit.Entry, token, ScopeVariables,
|
||||
Locals, method_lines.ToArray (), Blocks, null, 0, ns_id);
|
||||
|
||||
file.AddMethod (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-61
@@ -12,6 +12,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if STATIC
|
||||
using IKVM.Reflection;
|
||||
@@ -396,8 +397,6 @@ namespace Mono.CSharp {
|
||||
if (Instance != null)
|
||||
throw new InternalErrorException ();
|
||||
|
||||
SymbolWriter.OpenCompilerGeneratedBlock (ec);
|
||||
|
||||
//
|
||||
// Create an instance of this storey
|
||||
//
|
||||
@@ -426,7 +425,6 @@ namespace Mono.CSharp {
|
||||
var fexpr = new FieldExpr (field, Location);
|
||||
fexpr.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location);
|
||||
fexpr.EmitAssign (ec, source, false, false);
|
||||
|
||||
Instance = fexpr;
|
||||
} else {
|
||||
var local = TemporaryVariableReference.Create (source.Type, block, Location);
|
||||
@@ -439,8 +437,6 @@ namespace Mono.CSharp {
|
||||
|
||||
// TODO: Implement properly
|
||||
//SymbolWriter.DefineScopeVariable (ID, Instance.Builder);
|
||||
|
||||
SymbolWriter.CloseCompilerGeneratedBlock (ec);
|
||||
}
|
||||
|
||||
void EmitHoistedFieldsInitialization (ResolveContext rc, EmitContext ec)
|
||||
@@ -495,32 +491,6 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public override void Emit ()
|
||||
{
|
||||
base.Emit ();
|
||||
|
||||
SymbolWriter.DefineAnonymousScope (ID);
|
||||
|
||||
if (hoisted_this != null)
|
||||
hoisted_this.EmitSymbolInfo ();
|
||||
|
||||
if (hoisted_locals != null) {
|
||||
foreach (HoistedVariable local in hoisted_locals)
|
||||
local.EmitSymbolInfo ();
|
||||
}
|
||||
|
||||
if (hoisted_params != null) {
|
||||
foreach (HoistedParameter param in hoisted_params)
|
||||
param.EmitSymbolInfo ();
|
||||
}
|
||||
|
||||
if (used_parent_storeys != null) {
|
||||
foreach (StoreyFieldPair sf in used_parent_storeys) {
|
||||
SymbolWriter.DefineCapturedScope (ID, sf.Storey.ID, sf.Field.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Returns a field which holds referenced storey instance
|
||||
//
|
||||
@@ -725,8 +695,6 @@ namespace Mono.CSharp {
|
||||
return inner_access;
|
||||
}
|
||||
|
||||
public abstract void EmitSymbolInfo ();
|
||||
|
||||
public void Emit (EmitContext ec, bool leave_copy)
|
||||
{
|
||||
GetFieldExpression (ec).Emit (ec, leave_copy);
|
||||
@@ -771,6 +739,12 @@ namespace Mono.CSharp {
|
||||
this.parameter = hp.parameter;
|
||||
}
|
||||
|
||||
public Field Field {
|
||||
get {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
public void EmitHoistingAssignment (EmitContext ec)
|
||||
{
|
||||
//
|
||||
@@ -785,25 +759,13 @@ namespace Mono.CSharp {
|
||||
|
||||
parameter.Parameter.HoistedVariant = temp;
|
||||
}
|
||||
|
||||
public override void EmitSymbolInfo ()
|
||||
{
|
||||
SymbolWriter.DefineCapturedParameter (storey.ID, field.Name, field.Name);
|
||||
}
|
||||
|
||||
public Field Field {
|
||||
get { return field; }
|
||||
}
|
||||
}
|
||||
|
||||
class HoistedLocalVariable : HoistedVariable
|
||||
{
|
||||
readonly string name;
|
||||
|
||||
public HoistedLocalVariable (AnonymousMethodStorey storey, LocalVariable local, string name)
|
||||
: base (storey, name, local.Type)
|
||||
{
|
||||
this.name = local.Name;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -813,11 +775,6 @@ namespace Mono.CSharp {
|
||||
: base (storey, field)
|
||||
{
|
||||
}
|
||||
|
||||
public override void EmitSymbolInfo ()
|
||||
{
|
||||
SymbolWriter.DefineCapturedLocal (storey.ID, name, field.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public class HoistedThis : HoistedVariable
|
||||
@@ -827,21 +784,18 @@ namespace Mono.CSharp {
|
||||
{
|
||||
}
|
||||
|
||||
public Field Field {
|
||||
get {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
public void EmitHoistingAssignment (EmitContext ec)
|
||||
{
|
||||
SimpleAssign a = new SimpleAssign (GetFieldExpression (ec), new CompilerGeneratedThis (ec.CurrentType, field.Location));
|
||||
if (a.Resolve (new ResolveContext (ec.MemberContext)) != null)
|
||||
a.EmitStatement (ec);
|
||||
}
|
||||
|
||||
public override void EmitSymbolInfo ()
|
||||
{
|
||||
SymbolWriter.DefineCapturedThis (storey.ID, field.Name);
|
||||
}
|
||||
|
||||
public Field Field {
|
||||
get { return field; }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1322,9 +1276,9 @@ namespace Mono.CSharp {
|
||||
Block = new ToplevelBlock (am.block, parameters);
|
||||
}
|
||||
|
||||
public override EmitContext CreateEmitContext (ILGenerator ig)
|
||||
public override EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
|
||||
{
|
||||
EmitContext ec = new EmitContext (this, ig, ReturnType);
|
||||
EmitContext ec = new EmitContext (this, ig, ReturnType, sourceMethod);
|
||||
ec.CurrentAnonymousMethod = AnonymousMethod;
|
||||
return ec;
|
||||
}
|
||||
|
||||
+23
-6
@@ -50,7 +50,7 @@ namespace Mono.CSharp
|
||||
// TODO: make it private and move all builder based methods here
|
||||
public AssemblyBuilder Builder;
|
||||
protected AssemblyBuilderExtension builder_extra;
|
||||
MonoSymbolWriter symbol_writer;
|
||||
MonoSymbolFile symbol_writer;
|
||||
|
||||
bool is_cls_compliant;
|
||||
bool wrap_non_exception_throws;
|
||||
@@ -179,6 +179,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public MonoSymbolFile SymbolWriter {
|
||||
get {
|
||||
return symbol_writer;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddModule (ImportedModuleDefinition module)
|
||||
@@ -446,10 +452,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
if (Compiler.Settings.GenerateDebugInfo) {
|
||||
symbol_writer = new MonoSymbolWriter (file_name);
|
||||
|
||||
// TODO: global variables
|
||||
SymbolWriter.symwriter = symbol_writer;
|
||||
symbol_writer = new MonoSymbolFile ();
|
||||
}
|
||||
|
||||
module.EmitContainer ();
|
||||
@@ -820,7 +823,21 @@ namespace Mono.CSharp
|
||||
if (symbol_writer != null && Compiler.Report.Errors == 0) {
|
||||
// TODO: it should run in parallel
|
||||
Compiler.TimeReporter.Start (TimeReporter.TimerType.DebugSave);
|
||||
symbol_writer.WriteSymbolFile (SymbolWriter.GetGuid (module.Builder));
|
||||
|
||||
var filename = file_name + ".mdb";
|
||||
try {
|
||||
// We mmap the file, so unlink the previous version since it may be in use
|
||||
File.Delete (filename);
|
||||
} catch {
|
||||
// We can safely ignore
|
||||
}
|
||||
|
||||
module.WriteDebugSymbol (symbol_writer);
|
||||
|
||||
using (FileStream fs = new FileStream (filename, FileMode.Create, FileAccess.Write)) {
|
||||
symbol_writer.CreateSymbolFile (module.Builder.ModuleVersionId, fs);
|
||||
}
|
||||
|
||||
Compiler.TimeReporter.Stop (TimeReporter.TimerType.DebugSave);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Security.Permissions;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if NET_2_1
|
||||
using XmlElement = System.Object;
|
||||
@@ -348,6 +349,15 @@ namespace Mono.CSharp
|
||||
tc.VerifyMembers ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
if (containers != null) {
|
||||
foreach (TypeContainer tc in containers) {
|
||||
tc.WriteDebugSymbol (file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class TypeDefinition : TypeContainer, ITypeDefinition
|
||||
@@ -1250,6 +1260,18 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
|
||||
public SourceMethodBuilder CreateMethodSymbolEntry ()
|
||||
{
|
||||
if (Module.DeclaringAssembly.SymbolWriter == null)
|
||||
return null;
|
||||
|
||||
var source_file = GetCompilationSourceFile ();
|
||||
if (source_file == null)
|
||||
return null;
|
||||
|
||||
return new SourceMethodBuilder (source_file.SymbolUnitEntry);
|
||||
}
|
||||
|
||||
//
|
||||
// Creates a proxy base method call inside this container for hoisted base member calls
|
||||
//
|
||||
@@ -2247,6 +2269,13 @@ namespace Mono.CSharp
|
||||
cached_method |= CachedMethods.GetHashCode;
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
foreach (var m in members) {
|
||||
m.WriteDebugSymbol (file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method container contains Equals method
|
||||
/// </summary>
|
||||
|
||||
+27
-7
@@ -12,6 +12,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if STATIC
|
||||
using MetaType = IKVM.Reflection.Type;
|
||||
@@ -76,11 +77,13 @@ namespace Mono.CSharp
|
||||
|
||||
readonly IMemberContext member_context;
|
||||
|
||||
readonly SourceMethodBuilder methodSymbols;
|
||||
|
||||
DynamicSiteClass dynamic_site_container;
|
||||
|
||||
Label? return_label;
|
||||
|
||||
public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type)
|
||||
public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type, SourceMethodBuilder methodSymbols)
|
||||
{
|
||||
this.member_context = rc;
|
||||
this.ig = ig;
|
||||
@@ -89,7 +92,8 @@ namespace Mono.CSharp
|
||||
if (rc.Module.Compiler.Settings.Checked)
|
||||
flags |= Options.CheckedScope;
|
||||
|
||||
if (SymbolWriter.HasSymbolWriter) {
|
||||
if (methodSymbols != null) {
|
||||
this.methodSymbols = methodSymbols;
|
||||
if (!rc.Module.Compiler.Settings.Optimize)
|
||||
flags |= Options.AccurateDebugInfo;
|
||||
} else {
|
||||
@@ -209,16 +213,22 @@ namespace Mono.CSharp
|
||||
if (loc.IsNull)
|
||||
return false;
|
||||
|
||||
if (loc.SourceFile.IsHiddenLocation (loc))
|
||||
var sf = loc.SourceFile;
|
||||
if (sf.IsHiddenLocation (loc))
|
||||
return false;
|
||||
|
||||
SymbolWriter.MarkSequencePoint (ig, loc);
|
||||
#if NET_4_0
|
||||
methodSymbols.MarkSequencePoint (ig.ILOffset, sf.SourceFileEntry, loc.Row, loc.Column, false);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DefineLocalVariable (string name, LocalBuilder builder)
|
||||
{
|
||||
SymbolWriter.DefineLocalVariable (name, builder);
|
||||
if ((flags & Options.OmitDebugInfo) != 0)
|
||||
return;
|
||||
|
||||
methodSymbols.AddLocal (builder.LocalIndex, name);
|
||||
}
|
||||
|
||||
public void BeginCatchBlock (TypeSpec type)
|
||||
@@ -238,7 +248,12 @@ namespace Mono.CSharp
|
||||
|
||||
public void BeginScope ()
|
||||
{
|
||||
SymbolWriter.OpenScope(ig);
|
||||
if ((flags & Options.OmitDebugInfo) != 0)
|
||||
return;
|
||||
|
||||
#if NET_4_0
|
||||
methodSymbols.StartBlock (CodeBlockEntry.Type.Lexical, ig.ILOffset);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void EndExceptionBlock ()
|
||||
@@ -248,7 +263,12 @@ namespace Mono.CSharp
|
||||
|
||||
public void EndScope ()
|
||||
{
|
||||
SymbolWriter.CloseScope(ig);
|
||||
if ((flags & Options.OmitDebugInfo) != 0)
|
||||
return;
|
||||
|
||||
#if NET_4_0
|
||||
methodSymbols.EndBlock (ig.ILOffset);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -16,6 +16,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if NET_2_1
|
||||
using XmlElement = System.Object;
|
||||
@@ -838,6 +839,10 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
}
|
||||
|
||||
#region IMemberContext Members
|
||||
|
||||
public virtual CompilerContext Compiler {
|
||||
|
||||
@@ -393,7 +393,6 @@ namespace Mono.CSharp
|
||||
if (!full_flag)
|
||||
return;
|
||||
|
||||
SymbolWriter.Reset ();
|
||||
Linq.QueryBlock.TransparentParameter.Reset ();
|
||||
TypeInfo.Reset ();
|
||||
}
|
||||
|
||||
@@ -1044,10 +1044,6 @@ namespace Mono.CSharp
|
||||
{
|
||||
}
|
||||
|
||||
public override void EmitSymbolInfo ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override FieldExpr GetFieldExpression (EmitContext ec)
|
||||
{
|
||||
return new FieldExpr (field, field.Location);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if STATIC
|
||||
using IKVM.Reflection.Emit;
|
||||
@@ -587,9 +588,9 @@ namespace Mono.CSharp
|
||||
Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
|
||||
}
|
||||
|
||||
public override EmitContext CreateEmitContext (ILGenerator ig)
|
||||
public override EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
|
||||
{
|
||||
EmitContext ec = new EmitContext (this, ig, MemberType);
|
||||
EmitContext ec = new EmitContext (this, ig, MemberType, sourceMethod);
|
||||
ec.CurrentAnonymousMethod = expr;
|
||||
|
||||
if (expr is AsyncInitializer)
|
||||
|
||||
+5
-6
@@ -11,7 +11,6 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
using System.Diagnostics;
|
||||
@@ -81,15 +80,15 @@ namespace Mono.CSharp
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public SourceFileEntry CreateSymbolInfo (MonoSymbolWriter symwriter)
|
||||
public SourceFileEntry CreateSymbolInfo (MonoSymbolFile symwriter)
|
||||
{
|
||||
if (hidden_lines != null)
|
||||
hidden_lines.Sort ();
|
||||
|
||||
if (guid != null)
|
||||
file = symwriter.DefineDocument (FullPathName, guid, checksum);
|
||||
else {
|
||||
file = symwriter.DefineDocument (FullPathName);
|
||||
if (guid != null) {
|
||||
file = new SourceFileEntry (symwriter, FullPathName, guid, checksum);
|
||||
} else {
|
||||
file = new SourceFileEntry (symwriter, FullPathName);
|
||||
if (AutoGenerated)
|
||||
file.SetAutoGenerated ();
|
||||
}
|
||||
|
||||
+2
-4
@@ -67,8 +67,8 @@
|
||||
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs">
|
||||
<Link>MonoSymbolTable.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs">
|
||||
<Link>MonoSymbolWriter.cs</Link>
|
||||
<Compile Include="..\class\Mono.CompilerServices.SymbolWriter\SourceMethodBuilder.cs">
|
||||
<Link>SourceMethodBuilder.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="argument.cs" />
|
||||
<Compile Include="assembly.cs" />
|
||||
@@ -150,8 +150,6 @@
|
||||
</Compile>
|
||||
<Compile Include="support.cs">
|
||||
</Compile>
|
||||
<Compile Include="symbolwriter.cs">
|
||||
</Compile>
|
||||
<Compile Include="typemanager.cs">
|
||||
</Compile>
|
||||
<Compile Include="linq.cs" />
|
||||
|
||||
@@ -50,10 +50,9 @@ support.cs
|
||||
typemanager.cs
|
||||
typespec.cs
|
||||
visit.cs
|
||||
symbolwriter.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
|
||||
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
|
||||
../build/common/Consts.cs
|
||||
../tools/monop/outline.cs
|
||||
|
||||
+57
-76
@@ -18,6 +18,7 @@ using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if NET_2_1
|
||||
using XmlElement = System.Object;
|
||||
@@ -37,8 +38,6 @@ using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
#endif
|
||||
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
public abstract class MethodCore : InterfaceMemberBase, IParametersMember
|
||||
@@ -565,9 +564,9 @@ namespace Mono.CSharp {
|
||||
return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
|
||||
}
|
||||
|
||||
public virtual EmitContext CreateEmitContext (ILGenerator ig)
|
||||
public virtual EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
|
||||
{
|
||||
return new EmitContext (this, ig, MemberType);
|
||||
return new EmitContext (this, ig, MemberType, sourceMethod);
|
||||
}
|
||||
|
||||
public override bool Define ()
|
||||
@@ -691,7 +690,6 @@ namespace Mono.CSharp {
|
||||
MethodData.Emit (Parent);
|
||||
|
||||
Block = null;
|
||||
MethodData = null;
|
||||
}
|
||||
|
||||
protected void Error_ConditionalAttributeIsNotValid ()
|
||||
@@ -776,53 +774,10 @@ namespace Mono.CSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class SourceMethod : IMethodDef
|
||||
{
|
||||
MethodBase method;
|
||||
|
||||
SourceMethod (MethodBase method, ICompileUnit file)
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
this.method = method;
|
||||
SymbolWriter.OpenMethod (file, this);
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return method.Name; }
|
||||
}
|
||||
|
||||
public int Token {
|
||||
get {
|
||||
MethodToken token;
|
||||
var mb = method as MethodBuilder;
|
||||
if (mb != null)
|
||||
token = mb.GetToken ();
|
||||
else
|
||||
token = ((ConstructorBuilder) method).GetToken ();
|
||||
#if STATIC
|
||||
if (token.IsPseudoToken)
|
||||
return ((ModuleBuilder) method.Module).ResolvePseudoToken (token.Token);
|
||||
#endif
|
||||
return token.Token;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseMethod ()
|
||||
{
|
||||
SymbolWriter.CloseMethod ();
|
||||
}
|
||||
|
||||
public static SourceMethod Create (TypeDefinition parent, MethodBase method)
|
||||
{
|
||||
if (!SymbolWriter.HasSymbolWriter)
|
||||
return null;
|
||||
|
||||
var source_file = parent.GetCompilationSourceFile ();
|
||||
if (source_file == null)
|
||||
return null;
|
||||
|
||||
return new SourceMethod (method, source_file.SymbolUnitEntry);
|
||||
if (MethodData != null)
|
||||
MethodData.WriteDebugSymbol (file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1505,11 +1460,13 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public class Constructor : MethodCore, IMethodData {
|
||||
public class Constructor : MethodCore, IMethodData
|
||||
{
|
||||
public ConstructorBuilder ConstructorBuilder;
|
||||
public ConstructorInitializer Initializer;
|
||||
SecurityType declarative_security;
|
||||
bool has_compliant_args;
|
||||
SourceMethodBuilder debug_builder;
|
||||
|
||||
// <summary>
|
||||
// Modifiers allowed for a constructor.
|
||||
@@ -1546,9 +1503,9 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
bool IMethodData.IsAccessor {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1715,15 +1672,11 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
if (block.Resolve (null, bc, this)) {
|
||||
EmitContext ec = new EmitContext (this, ConstructorBuilder.GetILGenerator (), bc.ReturnType);
|
||||
debug_builder = Parent.CreateMethodSymbolEntry ();
|
||||
EmitContext ec = new EmitContext (this, ConstructorBuilder.GetILGenerator (), bc.ReturnType, debug_builder);
|
||||
ec.With (EmitContext.Options.ConstructorScope, true);
|
||||
|
||||
SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder);
|
||||
|
||||
block.Emit (ec);
|
||||
|
||||
if (source != null)
|
||||
source.CloseMethod ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1781,6 +1734,21 @@ namespace Mono.CSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
if (debug_builder == null)
|
||||
return;
|
||||
|
||||
var token = ConstructorBuilder.GetToken ();
|
||||
int t = token.Token;
|
||||
#if STATIC
|
||||
if (token.IsPseudoToken)
|
||||
t = Module.Builder.ResolvePseudoToken (t);
|
||||
#endif
|
||||
|
||||
debug_builder.DefineMethod (file, t);
|
||||
}
|
||||
|
||||
#region IMethodData Members
|
||||
|
||||
public MemberName MethodName {
|
||||
@@ -1795,16 +1763,11 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public EmitContext CreateEmitContext (ILGenerator ig)
|
||||
EmitContext IMethodData.CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public bool IsExcluded()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1824,7 +1787,7 @@ namespace Mono.CSharp {
|
||||
Attributes OptAttributes { get; }
|
||||
ToplevelBlock Block { get; set; }
|
||||
|
||||
EmitContext CreateEmitContext (ILGenerator ig);
|
||||
EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1851,6 +1814,7 @@ namespace Mono.CSharp {
|
||||
protected MethodAttributes flags;
|
||||
protected TypeSpec declaring_type;
|
||||
protected MethodSpec parent_method;
|
||||
SourceMethodBuilder debug_builder;
|
||||
|
||||
MethodBuilder builder;
|
||||
public MethodBuilder MethodBuilder {
|
||||
@@ -2103,17 +2067,28 @@ namespace Mono.CSharp {
|
||||
if (block != null) {
|
||||
BlockContext bc = new BlockContext (mc, block, method.ReturnType);
|
||||
if (block.Resolve (null, bc, method)) {
|
||||
EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator ());
|
||||
|
||||
SourceMethod source = SourceMethod.Create (parent, MethodBuilder);
|
||||
debug_builder = member.Parent.CreateMethodSymbolEntry ();
|
||||
EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator (), debug_builder);
|
||||
|
||||
block.Emit (ec);
|
||||
|
||||
if (source != null)
|
||||
source.CloseMethod ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
if (debug_builder == null)
|
||||
return;
|
||||
|
||||
var token = builder.GetToken ();
|
||||
int t = token.Token;
|
||||
#if STATIC
|
||||
if (token.IsPseudoToken)
|
||||
t = member.Module.Builder.ResolvePseudoToken (t);
|
||||
#endif
|
||||
|
||||
debug_builder.DefineMethod (file, t);
|
||||
}
|
||||
}
|
||||
|
||||
public class Destructor : MethodOrOperator
|
||||
@@ -2251,9 +2226,9 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public EmitContext CreateEmitContext (ILGenerator ig)
|
||||
public EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod)
|
||||
{
|
||||
return new EmitContext (this, ig, ReturnType);
|
||||
return new EmitContext (this, ig, ReturnType, sourceMethod);
|
||||
}
|
||||
|
||||
public bool IsAccessor {
|
||||
@@ -2384,6 +2359,12 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
if (method_data != null)
|
||||
method_data.WriteDebugSymbol (file);
|
||||
}
|
||||
|
||||
public MethodSpec Spec { get; protected set; }
|
||||
|
||||
//
|
||||
|
||||
@@ -664,9 +664,9 @@ namespace Mono.CSharp {
|
||||
|
||||
public override void PrepareEmit ()
|
||||
{
|
||||
// Compiler.SymbolWriter
|
||||
if (SymbolWriter.symwriter != null) {
|
||||
CreateUnitSymbolInfo (SymbolWriter.symwriter);
|
||||
var sw = Module.DeclaringAssembly.SymbolWriter;
|
||||
if (sw != null) {
|
||||
CreateUnitSymbolInfo (sw);
|
||||
}
|
||||
|
||||
base.PrepareEmit ();
|
||||
@@ -675,10 +675,10 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// Creates symbol file index in debug symbol file
|
||||
//
|
||||
void CreateUnitSymbolInfo (MonoSymbolWriter symwriter)
|
||||
void CreateUnitSymbolInfo (MonoSymbolFile symwriter)
|
||||
{
|
||||
var si = file.CreateSymbolInfo (symwriter);
|
||||
comp_unit = symwriter.DefineCompilationUnit (si);
|
||||
comp_unit = new CompileUnitEntry (symwriter, si);;
|
||||
|
||||
if (include_files != null) {
|
||||
foreach (SourceFile include in include_files.Values) {
|
||||
|
||||
+1
-1
@@ -508,7 +508,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
int top = param.Count;
|
||||
var ec = new EmitContext (new ProxyMethodContext (container), proxy.GetILGenerator (), null);
|
||||
var ec = new EmitContext (new ProxyMethodContext (container), proxy.GetILGenerator (), null, null);
|
||||
ec.EmitThis ();
|
||||
// TODO: GetAllParametersArguments
|
||||
for (int i = 0; i < top; i++)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if NET_2_1
|
||||
using XmlElement = System.Object;
|
||||
@@ -686,6 +687,15 @@ namespace Mono.CSharp
|
||||
Set.UpdateName (this);
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
if (get != null)
|
||||
get.WriteDebugSymbol (file);
|
||||
|
||||
if (set != null)
|
||||
set.WriteDebugSymbol (file);
|
||||
}
|
||||
|
||||
//
|
||||
// Represents header string for documentation comment.
|
||||
//
|
||||
@@ -1339,6 +1349,12 @@ namespace Mono.CSharp
|
||||
base.Emit ();
|
||||
}
|
||||
|
||||
public override void WriteDebugSymbol (MonoSymbolFile file)
|
||||
{
|
||||
add.WriteDebugSymbol (file);
|
||||
remove.WriteDebugSymbol (file);
|
||||
}
|
||||
|
||||
//
|
||||
// Represents header string for documentation comment.
|
||||
//
|
||||
|
||||
+2
-22
@@ -2318,9 +2318,6 @@ namespace Mono.CSharp {
|
||||
EmitScopeInitializers (ec);
|
||||
|
||||
DoEmit (ec);
|
||||
|
||||
if (SymbolWriter.HasSymbolWriter)
|
||||
EmitSymbolInfo (ec);
|
||||
}
|
||||
|
||||
protected void EmitScopeInitializers (EmitContext ec)
|
||||
@@ -2329,10 +2326,6 @@ namespace Mono.CSharp {
|
||||
s.Emit (ec);
|
||||
}
|
||||
|
||||
protected virtual void EmitSymbolInfo (EmitContext ec)
|
||||
{
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public override string ToString ()
|
||||
{
|
||||
@@ -2465,16 +2458,12 @@ namespace Mono.CSharp {
|
||||
ec.Emit (OpCodes.Nop);
|
||||
}
|
||||
|
||||
bool emit_debug_info = SymbolWriter.HasSymbolWriter && Parent != null && !(am_storey is IteratorStorey);
|
||||
if (emit_debug_info)
|
||||
if (Parent != null)
|
||||
ec.BeginScope ();
|
||||
|
||||
DoEmit (ec);
|
||||
|
||||
if (SymbolWriter.HasSymbolWriter)
|
||||
EmitSymbolInfo (ec);
|
||||
|
||||
if (emit_debug_info)
|
||||
if (Parent != null)
|
||||
ec.EndScope ();
|
||||
|
||||
if (ec.EmitAccurateDebugInfo && !HasUnreachableClosingBrace && !IsCompilerGenerated && ec.Mark (EndLocation)) {
|
||||
@@ -3344,15 +3333,6 @@ namespace Mono.CSharp {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void EmitSymbolInfo (EmitContext ec)
|
||||
{
|
||||
AnonymousExpression ae = ec.CurrentAnonymousMethod;
|
||||
if ((ae != null) && (ae.Storey != null))
|
||||
SymbolWriter.DefineScopeVariable (ae.Storey.ID);
|
||||
|
||||
base.EmitSymbolInfo (ec);
|
||||
}
|
||||
}
|
||||
|
||||
public class SwitchLabel {
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
//
|
||||
// symbolwriter.cs: The debug symbol writer
|
||||
//
|
||||
// Authors: Martin Baulig ([email protected])
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// Dual licensed under the terms of the MIT X11 or GNU GPL
|
||||
//
|
||||
// Copyright 2003 Ximian, Inc (http://www.ximian.com)
|
||||
// Copyright 2004-2010 Novell, Inc
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
#if STATIC
|
||||
using IKVM.Reflection;
|
||||
using IKVM.Reflection.Emit;
|
||||
#else
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
#endif
|
||||
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
static class SymbolWriter
|
||||
{
|
||||
#if !NET_4_0 && !STATIC
|
||||
delegate int GetILOffsetFunc (ILGenerator ig);
|
||||
static GetILOffsetFunc get_il_offset_func;
|
||||
|
||||
delegate Guid GetGuidFunc (ModuleBuilder mb);
|
||||
static GetGuidFunc get_guid_func;
|
||||
|
||||
static void Initialize ()
|
||||
{
|
||||
var mi = typeof (ILGenerator).GetMethod (
|
||||
"Mono_GetCurrentOffset",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (mi == null)
|
||||
throw new MissingMethodException ("Mono_GetCurrentOffset");
|
||||
|
||||
get_il_offset_func = (GetILOffsetFunc) System.Delegate.CreateDelegate (
|
||||
typeof (GetILOffsetFunc), mi);
|
||||
|
||||
mi = typeof (ModuleBuilder).GetMethod (
|
||||
"Mono_GetGuid",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (mi == null)
|
||||
throw new MissingMethodException ("Mono_GetGuid");
|
||||
|
||||
get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
|
||||
typeof (GetGuidFunc), mi);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int GetILOffset (ILGenerator ig)
|
||||
{
|
||||
#if NET_4_0 || STATIC
|
||||
return ig.ILOffset;
|
||||
#else
|
||||
if (get_il_offset_func == null)
|
||||
Initialize ();
|
||||
|
||||
return get_il_offset_func (ig);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Guid GetGuid (ModuleBuilder module)
|
||||
{
|
||||
#if NET_4_0 || STATIC
|
||||
return module.ModuleVersionId;
|
||||
#else
|
||||
if (get_guid_func == null)
|
||||
Initialize ();
|
||||
|
||||
return get_guid_func (module);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool HasSymbolWriter {
|
||||
get { return symwriter != null; }
|
||||
}
|
||||
|
||||
public static MonoSymbolWriter symwriter;
|
||||
|
||||
public static void DefineLocalVariable (string name, LocalBuilder builder)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
symwriter.DefineLocalVariable (builder.LocalIndex, name);
|
||||
}
|
||||
}
|
||||
|
||||
public static SourceMethodBuilder OpenMethod (ICompileUnit file, IMethodDef method)
|
||||
{
|
||||
if (symwriter != null)
|
||||
return symwriter.OpenMethod (file, -1 /* Not used */, method);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void CloseMethod ()
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.CloseMethod ();
|
||||
}
|
||||
|
||||
public static int OpenScope (ILGenerator ig)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ig);
|
||||
return symwriter.OpenScope (offset);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CloseScope (ILGenerator ig)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ig);
|
||||
symwriter.CloseScope (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DefineAnonymousScope (int id)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineAnonymousScope (id);
|
||||
}
|
||||
|
||||
public static void DefineScopeVariable (int scope, LocalBuilder builder)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
symwriter.DefineScopeVariable (scope, builder.LocalIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DefineScopeVariable (int scope)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineScopeVariable (scope, -1);
|
||||
}
|
||||
|
||||
public static void DefineCapturedLocal (int scope_id, string name,
|
||||
string captured_name)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineCapturedLocal (scope_id, name, captured_name);
|
||||
}
|
||||
|
||||
public static void DefineCapturedParameter (int scope_id, string name,
|
||||
string captured_name)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineCapturedParameter (scope_id, name, captured_name);
|
||||
}
|
||||
|
||||
public static void DefineCapturedThis (int scope_id, string captured_name)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineCapturedThis (scope_id, captured_name);
|
||||
}
|
||||
|
||||
public static void DefineCapturedScope (int scope_id, int id, string captured_name)
|
||||
{
|
||||
if (symwriter != null)
|
||||
symwriter.DefineCapturedScope (scope_id, id, captured_name);
|
||||
}
|
||||
|
||||
public static void OpenCompilerGeneratedBlock (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.OpenCompilerGeneratedBlock (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CloseCompilerGeneratedBlock (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.CloseCompilerGeneratedBlock (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartIteratorBody (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.StartIteratorBody (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EndIteratorBody (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.EndIteratorBody (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartIteratorDispatcher (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.StartIteratorDispatcher (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EndIteratorDispatcher (EmitContext ec)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
int offset = GetILOffset (ec.ig);
|
||||
symwriter.EndIteratorDispatcher (offset);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MarkSequencePoint (ILGenerator ig, Location loc)
|
||||
{
|
||||
if (symwriter != null) {
|
||||
SourceFileEntry file = loc.SourceFile.SourceFileEntry;
|
||||
int offset = GetILOffset (ig);
|
||||
symwriter.MarkSequencePoint (offset, file, loc.Row, loc.Column, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Reset ()
|
||||
{
|
||||
symwriter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,12 @@
|
||||
<method token="0x6000001">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x7" end="0x22" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000002">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x7" end="0x22" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000003">
|
||||
<sequencepoints>
|
||||
|
||||
@@ -15,16 +15,12 @@
|
||||
<method token="0x6000002">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0x6" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000003">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0x6" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000004">
|
||||
<sequencepoints />
|
||||
|
||||
@@ -54,9 +54,7 @@
|
||||
<locals>
|
||||
<entry name="a" il_index="1" scope_ref="0" />
|
||||
</locals>
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0xd" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000006">
|
||||
<sequencepoints />
|
||||
|
||||
@@ -7,16 +7,12 @@
|
||||
<method token="0x6000001">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x7" end="0x22" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000002">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x7" end="0x22" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000003">
|
||||
<sequencepoints>
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
<method token="0x6000002">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0x6" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000003">
|
||||
<sequencepoints>
|
||||
@@ -31,9 +29,7 @@
|
||||
<method token="0x6000004">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0x6" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000005">
|
||||
<sequencepoints>
|
||||
@@ -47,9 +43,7 @@
|
||||
<method token="0x6000006">
|
||||
<sequencepoints />
|
||||
<locals />
|
||||
<scopes>
|
||||
<entry index="0" start="0x0" end="0x6" />
|
||||
</scopes>
|
||||
<scopes />
|
||||
</method>
|
||||
<method token="0x6000007">
|
||||
<sequencepoints />
|
||||
|
||||
+272
-272
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user