b5b371e366
Former-commit-id: d40ff8b7324ef82332036575ffce8f36dd9ece5a
658 lines
21 KiB
Diff
658 lines
21 KiB
Diff
From 06a984fc8019f9f4c7214342f3f8502c5354d83f Mon Sep 17 00:00:00 2001
|
|
From: Marcos Henrich <marcos.henrich@xamarin.com>
|
|
Date: Wed, 18 Feb 2015 19:22:39 +0000
|
|
Subject: [PATCH] [mono-symbolicate] Added tool man page and script.
|
|
|
|
---
|
|
man/Makefile.am | 3 ++-
|
|
man/mono-symbolicate.1 | 39 +++++++++++++++++++++++++++++++++++++++
|
|
scripts/Makefile.am | 3 ++-
|
|
scripts/mono-symbolicate.in | 2 ++
|
|
4 files changed, 45 insertions(+), 2 deletions(-)
|
|
create mode 100644 man/mono-symbolicate.1
|
|
create mode 100644 scripts/mono-symbolicate.in
|
|
|
|
Index: xamarin-pkg-mono/man/Makefile.am
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/man/Makefile.am 2015-04-07 13:24:26.349635351 +0100
|
|
+++ xamarin-pkg-mono/man/Makefile.am 2015-04-07 13:24:26.317635351 +0100
|
|
@@ -56,6 +56,7 @@
|
|
xsd.1 \
|
|
mono-configuration-crypto.1 \
|
|
ccrewrite.1 \
|
|
- cccheck.1
|
|
+ cccheck.1 \
|
|
+ mono-symbolicate.1
|
|
|
|
EXTRA_DIST = $(man_MANS)
|
|
Index: xamarin-pkg-mono/man/mono-symbolicate.1
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/man/mono-symbolicate.1 2015-04-07 13:24:26.317635351 +0100
|
|
@@ -0,0 +1,39 @@
|
|
+.\"
|
|
+.\" mono-symbolicate manual page.
|
|
+.\" Copyright 2015 Xamarin
|
|
+.\" Author:
|
|
+.\" Marcos Henrich <marcos.henrich@xamarin.com>
|
|
+.\"
|
|
+.TH "mono-symbolicate" 1
|
|
+.SH NAME
|
|
+mono-symbolicate \- Mono Symbolicate Tool
|
|
+.SH SYNOPSIS
|
|
+.PP
|
|
+.B mono-symbolicate exefile stacktracesfile [directories...]
|
|
+.SH DESCRIPTION
|
|
+mono-symbolicate is a tool that converts a stack trace with <filename unknown>:0
|
|
+into one with file names and line numbers.
|
|
+.PP
|
|
+The output of calling this tool will be the provided
|
|
+.I stacktracesfile
|
|
+where <filename unknown>:0 parts are replaced by
|
|
+a file name and a line number.
|
|
+.PP
|
|
+For the tool to work it needs to load referenced assemblies, it will first look
|
|
+in the same folder as
|
|
+.I exefile
|
|
+then from one of the provided
|
|
+.I directories.
|
|
+.PP
|
|
+The tool assumes that the folder with a referenced assembly called for example
|
|
+name.dll will also include name.dll.mdb,
|
|
+if the referenced assembly is AOT compiled then the tool is also expecting to find
|
|
+name.dll.msym.
|
|
+.SH AUTHOR
|
|
+Written by Marcos Henrich
|
|
+.SH COPYRIGHT
|
|
+Copyright (C) 2015 Xamarin.
|
|
+.SH MAILING LISTS
|
|
+Visit http://lists.ximian.com/mailman/listinfo/mono-devel-list for details.
|
|
+.SH WEB SITE
|
|
+Visit http://www.mono-project.com for details
|
|
Index: xamarin-pkg-mono/scripts/Makefile.am
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/scripts/Makefile.am 2015-04-07 13:24:26.349635351 +0100
|
|
+++ xamarin-pkg-mono/scripts/Makefile.am 2015-04-07 13:24:26.317635351 +0100
|
|
@@ -100,7 +100,8 @@
|
|
ccrewrite$(SCRIPT_SUFFIX) \
|
|
cccheck$(SCRIPT_SUFFIX) \
|
|
mdbrebase$(SCRIPT_SUFFIX) \
|
|
- ikdasm$(SCRIPT_SUFFIX)
|
|
+ ikdasm$(SCRIPT_SUFFIX) \
|
|
+ mono-symbolicate$(SCRIPT_SUFFIX)
|
|
|
|
MDOC_SUBCOMMANDS = \
|
|
mdoc-assemble \
|
|
Index: xamarin-pkg-mono/scripts/mono-symbolicate.in
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/scripts/mono-symbolicate.in 2015-04-07 13:24:26.317635351 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+#!/bin/sh
|
|
+exec @bindir@/mono $MONO_OPTIONS @mono_instdir@/4.5/mono-symbolicate.exe "$@"
|
|
Index: xamarin-pkg-mono/mcs/tools/Makefile
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/mcs/tools/Makefile 2015-04-07 13:24:26.349635351 +0100
|
|
+++ xamarin-pkg-mono/mcs/tools/Makefile 2015-04-07 13:24:26.321635351 +0100
|
|
@@ -45,7 +45,7 @@
|
|
security \
|
|
mdbrebase \
|
|
ikdasm \
|
|
- symbolicate
|
|
+ mono-symbolicate
|
|
|
|
build_SUBDIRS = gacutil security culevel
|
|
net_4_5_SUBDIRS := $(net_4_5_dirs)
|
|
Index: xamarin-pkg-mono/mcs/tools/symbolicate/LocationProvider.cs
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/mcs/tools/symbolicate/LocationProvider.cs 2015-04-07 13:24:26.349635351 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,144 +0,0 @@
|
|
-using System;
|
|
-using System.IO;
|
|
-using System.Linq;
|
|
-using System.Diagnostics;
|
|
-using System.Collections.Generic;
|
|
-using Mono.Cecil;
|
|
-using Mono.CompilerServices.SymbolWriter;
|
|
-
|
|
-namespace Symbolicate
|
|
-{
|
|
- struct Location {
|
|
- public string FileName;
|
|
- public int Line;
|
|
- }
|
|
-
|
|
- class LocationProvider {
|
|
- class AssemblyLocationProvider {
|
|
- AssemblyDefinition assembly;
|
|
- MonoSymbolFile symbolFile;
|
|
-
|
|
- public AssemblyLocationProvider (AssemblyDefinition assembly, MonoSymbolFile symbolFile)
|
|
- {
|
|
- this.assembly = assembly;
|
|
- this.symbolFile = symbolFile;
|
|
- }
|
|
-
|
|
- public bool TryGetLocation (string methodFullName, string[] methodParamsTypes, int ilOffset, out Location location)
|
|
- {
|
|
- location = default (Location);
|
|
- if (symbolFile == null)
|
|
- return false;
|
|
-
|
|
- var typeNameEnd = methodFullName.LastIndexOf (".");
|
|
- var typeName = methodFullName.Substring (0, typeNameEnd);
|
|
- var methodName = methodFullName.Substring (typeNameEnd + 1, methodFullName.Length - typeNameEnd - 1);
|
|
-
|
|
- var type = assembly.MainModule.Types.FirstOrDefault (t => t.FullName == typeName);
|
|
- if (type == null)
|
|
- return false;
|
|
-
|
|
- var method = type.Methods.FirstOrDefault (m => {
|
|
- if (m.Name != methodName)
|
|
- return false;
|
|
-
|
|
- if (m.Parameters.Count != methodParamsTypes.Length)
|
|
- return false;
|
|
-
|
|
- for (var i = 0; i < methodParamsTypes.Length; i++) {
|
|
- var paramType = m.Parameters[i].ParameterType;
|
|
- if (paramType.Name != methodParamsTypes[i])
|
|
- return false;
|
|
- }
|
|
-
|
|
- return true;
|
|
- });
|
|
-
|
|
- if (method == null)
|
|
- return false;
|
|
-
|
|
- var methodSymbol = symbolFile.Methods [method.MetadataToken.RID-1];
|
|
-
|
|
- foreach (var lineNumber in methodSymbol.GetLineNumberTable ().LineNumbers) {
|
|
- if (lineNumber.Offset < ilOffset)
|
|
- continue;
|
|
-
|
|
- location.FileName = symbolFile.Sources [lineNumber.File-1].FileName;
|
|
- location.Line = lineNumber.Row;
|
|
- return true;
|
|
- }
|
|
-
|
|
- return false;
|
|
- }
|
|
- }
|
|
-
|
|
- Dictionary<string, AssemblyLocationProvider> assemblies;
|
|
- HashSet<string> directories;
|
|
-
|
|
- public LocationProvider () {
|
|
- assemblies = new Dictionary<string, AssemblyLocationProvider> ();
|
|
- directories = new HashSet<string> ();
|
|
- }
|
|
-
|
|
- public void AddAssembly (string assemblyPath)
|
|
- {
|
|
- assemblyPath = Path.GetFullPath (assemblyPath);
|
|
- if (assemblies.ContainsKey (assemblyPath))
|
|
- return;
|
|
-
|
|
- if (!File.Exists (assemblyPath))
|
|
- throw new ArgumentException ("assemblyPath does not exist: "+ assemblyPath);
|
|
-
|
|
- var assembly = AssemblyDefinition.ReadAssembly (assemblyPath);
|
|
- MonoSymbolFile symbolFile = null;
|
|
-
|
|
- var symbolPath = assemblyPath + ".mdb";
|
|
- if (!File.Exists (symbolPath))
|
|
- Debug.WriteLine (".mdb file was not found for " + assemblyPath);
|
|
- else
|
|
- symbolFile = MonoSymbolFile.ReadSymbolFile (assemblyPath + ".mdb");
|
|
-
|
|
- assemblies.Add (assemblyPath, new AssemblyLocationProvider (assembly, symbolFile));
|
|
-
|
|
- directories.Add (Path.GetDirectoryName (assemblyPath));
|
|
-
|
|
- foreach (var assemblyRef in assembly.MainModule.AssemblyReferences) {
|
|
- string refPath = null;
|
|
- foreach (var dir in directories) {
|
|
- refPath = Path.Combine (dir, assemblyRef.Name);
|
|
- if (File.Exists (refPath))
|
|
- break;
|
|
- refPath = Path.Combine (dir, assemblyRef.Name + ".dll");
|
|
- if (File.Exists (refPath))
|
|
- break;
|
|
- refPath = Path.Combine (dir, assemblyRef.Name + ".exe");
|
|
- if (File.Exists (refPath))
|
|
- break;
|
|
- refPath = null;
|
|
- }
|
|
- if (refPath != null)
|
|
- AddAssembly (refPath);
|
|
- }
|
|
- }
|
|
-
|
|
- public void AddDirectory (string directory)
|
|
- {
|
|
- if (Directory.Exists (directory))
|
|
- throw new ArgumentException ("Directory " + directory + " does not exist.");
|
|
-
|
|
- directories.Add (directory);
|
|
- }
|
|
-
|
|
- public bool TryGetLocation (string methodName, string[] methodParams, int ilOffset, out Location location)
|
|
- {
|
|
- location = default (Location);
|
|
- foreach (var assembly in assemblies.Values) {
|
|
- if (assembly.TryGetLocation (methodName, methodParams, ilOffset, out location))
|
|
- return true;
|
|
- }
|
|
-
|
|
- return false;
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
Index: xamarin-pkg-mono/mcs/tools/symbolicate/Makefile
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/mcs/tools/symbolicate/Makefile 2015-04-07 13:24:26.349635351 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,39 +0,0 @@
|
|
-thisdir = tools/symbolicate
|
|
-SUBDIRS =
|
|
-include ../../build/rules.make
|
|
-
|
|
-PROGRAM = symbolicate.exe
|
|
-
|
|
-LOCAL_MCS_FLAGS = \
|
|
- /r:Mono.Cecil.dll \
|
|
- /r:Mono.CompilerServices.SymbolWriter.dll \
|
|
- /r:System.Xml
|
|
-
|
|
-include ../../build/executable.make
|
|
-
|
|
-LIB_PATH = $(topdir)/class/lib/$(PROFILE)
|
|
-
|
|
-MONO = MONO_PATH=$(LIB_PATH)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH $(RUNTIME)
|
|
-
|
|
-OUT_DIR = Test/out
|
|
-TEST_CS = Test/StackTraceDumper.cs
|
|
-TEST_EXE = $(OUT_DIR)/StackTraceDumper.exe
|
|
-RELEASE_FILE = $(OUT_DIR)/release.out
|
|
-SYMBOLICATE_FILE = $(OUT_DIR)/symbolicate.out
|
|
-SYMBOLICATE_EXPECTED_FILE = Test/symbolicate.expected
|
|
-
|
|
-build-test:
|
|
- @mkdir -p $(OUT_DIR)
|
|
- @$(MCS) -debug $(TEST_CS) -out:$(TEST_EXE)
|
|
-
|
|
-check: all build-test
|
|
- @MONO_DEBUG=gen-compact-seq-points $(MONO) $(TEST_EXE) > $(RELEASE_FILE)
|
|
- @$(MONO) $(LIB_PATH)/symbolicate.exe $(TEST_EXE) $(RELEASE_FILE) | sed "s/\[.*Test\//in /" > $(SYMBOLICATE_FILE)
|
|
- @DIFF=$$(diff $(SYMBOLICATE_FILE) $(SYMBOLICATE_EXPECTED_FILE)); \
|
|
- if [ ! -z "$$DIFF" ]; then \
|
|
- echo "Symbolicate tests failed."; \
|
|
- echo "If $(SYMBOLICATE_FILE) is correct copy it to $(SYMBOLICATE_EXPECTED_FILE)."; \
|
|
- echo "Otherwise runtime sequence points need to be fixed."; \
|
|
- echo "$$DIFF"; \
|
|
- exit 1; \
|
|
- fi
|
|
Index: xamarin-pkg-mono/mcs/tools/symbolicate/symbolicate.cs
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/mcs/tools/symbolicate/symbolicate.cs 2015-04-07 13:24:26.349635351 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,69 +0,0 @@
|
|
-using System;
|
|
-using System.IO;
|
|
-using System.Globalization;
|
|
-using System.Text.RegularExpressions;
|
|
-
|
|
-namespace Symbolicate
|
|
-{
|
|
- public class Program
|
|
- {
|
|
- static Regex regex = new Regex (@"\w*at (?<MethodName>.+) \((?<MethodParams>.*)\) \[0x(?<IL>.+)\] in <filename unknown>:0");
|
|
-
|
|
- public static int Main (String[] args)
|
|
- {
|
|
- if (args.Length < 2) {
|
|
- Console.Error.WriteLine ("Usage: symbolicate <assembly path> <input file> [lookup directories]");
|
|
- return 1;
|
|
- }
|
|
-
|
|
- var assemblyPath = args [0];
|
|
- var inputFile = args [1];
|
|
-
|
|
- var locProvider = new LocationProvider ();
|
|
-
|
|
- for (var i = 2; i < args.Length; i++)
|
|
- locProvider.AddDirectory (args [i]);
|
|
-
|
|
- locProvider.AddAssembly (assemblyPath);
|
|
-
|
|
- using (StreamReader r = new StreamReader (inputFile)) {
|
|
- for (var line = r.ReadLine (); line != null; line = r.ReadLine ()) {
|
|
- line = SymbolicateLine (line, locProvider);
|
|
- Console.WriteLine (line);
|
|
- }
|
|
- }
|
|
-
|
|
- return 0;
|
|
- }
|
|
-
|
|
- static string SymbolicateLine (string line, LocationProvider locProvider)
|
|
- {
|
|
- var match = regex.Match (line);
|
|
- if (!match.Success)
|
|
- return line;
|
|
-
|
|
- var methodName = match.Groups ["MethodName"].Value;
|
|
- var methodParams = ParseParametersTypes (match.Groups ["MethodParams"].Value);
|
|
- var ilOffset = int.Parse (match.Groups ["IL"].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
|
-
|
|
- Location location;
|
|
- if (!locProvider.TryGetLocation (methodName, methodParams, ilOffset, out location))
|
|
- return line;
|
|
-
|
|
- return line.Replace ("<filename unknown>:0", string.Format ("{0}:{1}", location.FileName, location.Line));
|
|
- }
|
|
-
|
|
- static string[] ParseParametersTypes (string parameters)
|
|
- {
|
|
- if (string.IsNullOrEmpty (parameters))
|
|
- return new string [0];
|
|
-
|
|
- var paramsArray = parameters.Split (',');
|
|
- var paramsTypes = new string [paramsArray.Length];
|
|
- for (var i = 0; i < paramsArray.Length; i++)
|
|
- paramsTypes [i] = paramsArray [i].Trim ().Split (new char[]{' '}, 2)[0];
|
|
-
|
|
- return paramsTypes;
|
|
- }
|
|
- }
|
|
-}
|
|
\ No newline at end of file
|
|
Index: xamarin-pkg-mono/mcs/tools/symbolicate/symbolicate.exe.sources
|
|
===================================================================
|
|
--- xamarin-pkg-mono.orig/mcs/tools/symbolicate/symbolicate.exe.sources 2015-04-07 13:24:26.349635351 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,2 +0,0 @@
|
|
-symbolicate.cs
|
|
-LocationProvider.cs
|
|
\ No newline at end of file
|
|
Index: xamarin-pkg-mono/mcs/tools/mono-symbolicate/LocationProvider.cs
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/mcs/tools/mono-symbolicate/LocationProvider.cs 2015-04-07 13:24:26.321635351 +0100
|
|
@@ -0,0 +1,144 @@
|
|
+using System;
|
|
+using System.IO;
|
|
+using System.Linq;
|
|
+using System.Diagnostics;
|
|
+using System.Collections.Generic;
|
|
+using Mono.Cecil;
|
|
+using Mono.CompilerServices.SymbolWriter;
|
|
+
|
|
+namespace Symbolicate
|
|
+{
|
|
+ struct Location {
|
|
+ public string FileName;
|
|
+ public int Line;
|
|
+ }
|
|
+
|
|
+ class LocationProvider {
|
|
+ class AssemblyLocationProvider {
|
|
+ AssemblyDefinition assembly;
|
|
+ MonoSymbolFile symbolFile;
|
|
+
|
|
+ public AssemblyLocationProvider (AssemblyDefinition assembly, MonoSymbolFile symbolFile)
|
|
+ {
|
|
+ this.assembly = assembly;
|
|
+ this.symbolFile = symbolFile;
|
|
+ }
|
|
+
|
|
+ public bool TryGetLocation (string methodFullName, string[] methodParamsTypes, int ilOffset, out Location location)
|
|
+ {
|
|
+ location = default (Location);
|
|
+ if (symbolFile == null)
|
|
+ return false;
|
|
+
|
|
+ var typeNameEnd = methodFullName.LastIndexOf (".");
|
|
+ var typeName = methodFullName.Substring (0, typeNameEnd);
|
|
+ var methodName = methodFullName.Substring (typeNameEnd + 1, methodFullName.Length - typeNameEnd - 1);
|
|
+
|
|
+ var type = assembly.MainModule.Types.FirstOrDefault (t => t.FullName == typeName);
|
|
+ if (type == null)
|
|
+ return false;
|
|
+
|
|
+ var method = type.Methods.FirstOrDefault (m => {
|
|
+ if (m.Name != methodName)
|
|
+ return false;
|
|
+
|
|
+ if (m.Parameters.Count != methodParamsTypes.Length)
|
|
+ return false;
|
|
+
|
|
+ for (var i = 0; i < methodParamsTypes.Length; i++) {
|
|
+ var paramType = m.Parameters[i].ParameterType;
|
|
+ if (paramType.Name != methodParamsTypes[i])
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ return true;
|
|
+ });
|
|
+
|
|
+ if (method == null)
|
|
+ return false;
|
|
+
|
|
+ var methodSymbol = symbolFile.Methods [method.MetadataToken.RID-1];
|
|
+
|
|
+ foreach (var lineNumber in methodSymbol.GetLineNumberTable ().LineNumbers) {
|
|
+ if (lineNumber.Offset < ilOffset)
|
|
+ continue;
|
|
+
|
|
+ location.FileName = symbolFile.Sources [lineNumber.File-1].FileName;
|
|
+ location.Line = lineNumber.Row;
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ Dictionary<string, AssemblyLocationProvider> assemblies;
|
|
+ HashSet<string> directories;
|
|
+
|
|
+ public LocationProvider () {
|
|
+ assemblies = new Dictionary<string, AssemblyLocationProvider> ();
|
|
+ directories = new HashSet<string> ();
|
|
+ }
|
|
+
|
|
+ public void AddAssembly (string assemblyPath)
|
|
+ {
|
|
+ assemblyPath = Path.GetFullPath (assemblyPath);
|
|
+ if (assemblies.ContainsKey (assemblyPath))
|
|
+ return;
|
|
+
|
|
+ if (!File.Exists (assemblyPath))
|
|
+ throw new ArgumentException ("assemblyPath does not exist: "+ assemblyPath);
|
|
+
|
|
+ var assembly = AssemblyDefinition.ReadAssembly (assemblyPath);
|
|
+ MonoSymbolFile symbolFile = null;
|
|
+
|
|
+ var symbolPath = assemblyPath + ".mdb";
|
|
+ if (!File.Exists (symbolPath))
|
|
+ Debug.WriteLine (".mdb file was not found for " + assemblyPath);
|
|
+ else
|
|
+ symbolFile = MonoSymbolFile.ReadSymbolFile (assemblyPath + ".mdb");
|
|
+
|
|
+ assemblies.Add (assemblyPath, new AssemblyLocationProvider (assembly, symbolFile));
|
|
+
|
|
+ directories.Add (Path.GetDirectoryName (assemblyPath));
|
|
+
|
|
+ foreach (var assemblyRef in assembly.MainModule.AssemblyReferences) {
|
|
+ string refPath = null;
|
|
+ foreach (var dir in directories) {
|
|
+ refPath = Path.Combine (dir, assemblyRef.Name);
|
|
+ if (File.Exists (refPath))
|
|
+ break;
|
|
+ refPath = Path.Combine (dir, assemblyRef.Name + ".dll");
|
|
+ if (File.Exists (refPath))
|
|
+ break;
|
|
+ refPath = Path.Combine (dir, assemblyRef.Name + ".exe");
|
|
+ if (File.Exists (refPath))
|
|
+ break;
|
|
+ refPath = null;
|
|
+ }
|
|
+ if (refPath != null)
|
|
+ AddAssembly (refPath);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void AddDirectory (string directory)
|
|
+ {
|
|
+ if (Directory.Exists (directory))
|
|
+ throw new ArgumentException ("Directory " + directory + " does not exist.");
|
|
+
|
|
+ directories.Add (directory);
|
|
+ }
|
|
+
|
|
+ public bool TryGetLocation (string methodName, string[] methodParams, int ilOffset, out Location location)
|
|
+ {
|
|
+ location = default (Location);
|
|
+ foreach (var assembly in assemblies.Values) {
|
|
+ if (assembly.TryGetLocation (methodName, methodParams, ilOffset, out location))
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
Index: xamarin-pkg-mono/mcs/tools/mono-symbolicate/Makefile
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/mcs/tools/mono-symbolicate/Makefile 2015-04-07 13:24:42.057635359 +0100
|
|
@@ -0,0 +1,39 @@
|
|
+thisdir = tools/mono-symbolicate
|
|
+SUBDIRS =
|
|
+include ../../build/rules.make
|
|
+
|
|
+PROGRAM = mono-symbolicate.exe
|
|
+
|
|
+LOCAL_MCS_FLAGS = \
|
|
+ /r:Mono.Cecil.dll \
|
|
+ /r:Mono.CompilerServices.SymbolWriter.dll \
|
|
+ /r:System.Xml
|
|
+
|
|
+include ../../build/executable.make
|
|
+
|
|
+LIB_PATH = $(topdir)/class/lib/$(PROFILE)
|
|
+
|
|
+MONO = MONO_PATH=$(LIB_PATH)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH $(RUNTIME)
|
|
+
|
|
+OUT_DIR = Test/out
|
|
+TEST_CS = Test/StackTraceDumper.cs
|
|
+TEST_EXE = $(OUT_DIR)/StackTraceDumper.exe
|
|
+RELEASE_FILE = $(OUT_DIR)/release.out
|
|
+SYMBOLICATE_FILE = $(OUT_DIR)/symbolicate.out
|
|
+SYMBOLICATE_EXPECTED_FILE = Test/symbolicate.expected
|
|
+
|
|
+build-test:
|
|
+ @mkdir -p $(OUT_DIR)
|
|
+ @$(MCS) -debug $(TEST_CS) -out:$(TEST_EXE)
|
|
+
|
|
+check: all build-test
|
|
+ @MONO_DEBUG=gen-compact-seq-points $(MONO) $(TEST_EXE) > $(RELEASE_FILE)
|
|
+ @$(MONO) $(LIB_PATH)/symbolicate.exe $(TEST_EXE) $(RELEASE_FILE) | sed "s/\[.*Test\//in /" > $(SYMBOLICATE_FILE)
|
|
+ @DIFF=$$(diff $(SYMBOLICATE_FILE) $(SYMBOLICATE_EXPECTED_FILE)); \
|
|
+ if [ ! -z "$$DIFF" ]; then \
|
|
+ echo "Symbolicate tests failed."; \
|
|
+ echo "If $(SYMBOLICATE_FILE) is correct copy it to $(SYMBOLICATE_EXPECTED_FILE)."; \
|
|
+ echo "Otherwise runtime sequence points need to be fixed."; \
|
|
+ echo "$$DIFF"; \
|
|
+ exit 1; \
|
|
+ fi
|
|
Index: xamarin-pkg-mono/mcs/tools/mono-symbolicate/symbolicate.cs
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/mcs/tools/mono-symbolicate/symbolicate.cs 2015-04-07 13:24:26.321635351 +0100
|
|
@@ -0,0 +1,69 @@
|
|
+using System;
|
|
+using System.IO;
|
|
+using System.Globalization;
|
|
+using System.Text.RegularExpressions;
|
|
+
|
|
+namespace Symbolicate
|
|
+{
|
|
+ public class Program
|
|
+ {
|
|
+ static Regex regex = new Regex (@"\w*at (?<MethodName>.+) \((?<MethodParams>.*)\) \[0x(?<IL>.+)\] in <filename unknown>:0");
|
|
+
|
|
+ public static int Main (String[] args)
|
|
+ {
|
|
+ if (args.Length < 2) {
|
|
+ Console.Error.WriteLine ("Usage: symbolicate <assembly path> <input file> [lookup directories]");
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
+ var assemblyPath = args [0];
|
|
+ var inputFile = args [1];
|
|
+
|
|
+ var locProvider = new LocationProvider ();
|
|
+
|
|
+ for (var i = 2; i < args.Length; i++)
|
|
+ locProvider.AddDirectory (args [i]);
|
|
+
|
|
+ locProvider.AddAssembly (assemblyPath);
|
|
+
|
|
+ using (StreamReader r = new StreamReader (inputFile)) {
|
|
+ for (var line = r.ReadLine (); line != null; line = r.ReadLine ()) {
|
|
+ line = SymbolicateLine (line, locProvider);
|
|
+ Console.WriteLine (line);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ static string SymbolicateLine (string line, LocationProvider locProvider)
|
|
+ {
|
|
+ var match = regex.Match (line);
|
|
+ if (!match.Success)
|
|
+ return line;
|
|
+
|
|
+ var methodName = match.Groups ["MethodName"].Value;
|
|
+ var methodParams = ParseParametersTypes (match.Groups ["MethodParams"].Value);
|
|
+ var ilOffset = int.Parse (match.Groups ["IL"].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
|
+
|
|
+ Location location;
|
|
+ if (!locProvider.TryGetLocation (methodName, methodParams, ilOffset, out location))
|
|
+ return line;
|
|
+
|
|
+ return line.Replace ("<filename unknown>:0", string.Format ("{0}:{1}", location.FileName, location.Line));
|
|
+ }
|
|
+
|
|
+ static string[] ParseParametersTypes (string parameters)
|
|
+ {
|
|
+ if (string.IsNullOrEmpty (parameters))
|
|
+ return new string [0];
|
|
+
|
|
+ var paramsArray = parameters.Split (',');
|
|
+ var paramsTypes = new string [paramsArray.Length];
|
|
+ for (var i = 0; i < paramsArray.Length; i++)
|
|
+ paramsTypes [i] = paramsArray [i].Trim ().Split (new char[]{' '}, 2)[0];
|
|
+
|
|
+ return paramsTypes;
|
|
+ }
|
|
+ }
|
|
+}
|
|
\ No newline at end of file
|
|
Index: xamarin-pkg-mono/mcs/tools/mono-symbolicate/mono-symbolicate.exe.sources
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ xamarin-pkg-mono/mcs/tools/mono-symbolicate/mono-symbolicate.exe.sources 2015-04-07 13:24:26.321635351 +0100
|
|
@@ -0,0 +1,2 @@
|
|
+symbolicate.cs
|
|
+LocationProvider.cs
|
|
\ No newline at end of file
|