Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Kok <ck@remobjects.com>2015-02-21 00:10:23 +0300
committerCarlo Kok <ck@remobjects.com>2015-02-21 00:10:23 +0300
commita432b8e6c966b12e05d244320e791acc63f5e7d8 (patch)
treebbead370460b5097780745d5b973141af0078bbe /symbols
parentb7d1a25ea0d990c641a8409cddc4e42da08b12f6 (diff)
Ability to write scopes in mdb (revert to old behavior if no scopes are available)
Diffstat (limited to 'symbols')
-rw-r--r--symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs33
1 files changed, 31 insertions, 2 deletions
diff --git a/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs b/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
index 6f4aa20..2963a61 100644
--- a/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
+++ b/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
@@ -135,12 +135,41 @@ namespace Mono.Cecil.Mdb {
start_cols [i],
false);
- if (body.HasVariables)
- AddVariables (body.Variables);
+
+
+ if (body.Scope != null)
+ WriteScope (body.Scope, true);
+ else
+ if (body.HasVariables)
+ AddVariables (body.Variables);
writer.CloseMethod ();
}
+ private void WriteScope (Scope scope, bool root)
+ {
+ if (scope.Start.Offset == scope.End.Offset) return;
+ writer.OpenScope (scope.Start.Offset);
+
+
+ if (scope.HasVariables)
+ {
+ foreach (var el in scope.Variables)
+ {
+ if (!String.IsNullOrEmpty (el.Name))
+ writer.DefineLocalVariable (el.Index, el.Name);
+ }
+ }
+
+ if (scope.HasScopes)
+ {
+ foreach (var el in scope.Scopes)
+ WriteScope (el, false);
+ }
+
+ writer.CloseScope (scope.End.Offset + scope.End.GetSize());
+ }
+
readonly static byte [] empty_header = new byte [0];
public bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header)