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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos Henrich <marcos.henrich@xamarin.com>2016-05-20 14:03:46 +0300
committerMarcos Henrich <marcos.henrich@xamarin.com>2016-07-09 00:40:38 +0300
commit59cccab00da71a4d7e98947060718eab42e46682 (patch)
tree0faedba02e6ed4894fe233c3e19aae2ce99a984a
parentc235a59c5cddbdc86f679340f47c1586d434db2a (diff)
[corlib] Added metadata handlers to StackTrace
Added a reflectable static method that can be used to customize data displayed after a stack trace. Added metadata handler that display the AOTID of the executing assembly.
-rw-r--r--mcs/class/corlib/System.Diagnostics/StackTrace.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/mcs/class/corlib/System.Diagnostics/StackTrace.cs b/mcs/class/corlib/System.Diagnostics/StackTrace.cs
index 420b497fc9a..8b3f76a439e 100644
--- a/mcs/class/corlib/System.Diagnostics/StackTrace.cs
+++ b/mcs/class/corlib/System.Diagnostics/StackTrace.cs
@@ -37,6 +37,7 @@ using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
+using System.IO;
namespace System.Diagnostics {
@@ -60,6 +61,15 @@ namespace System.Diagnostics {
readonly StackTrace[] captured_traces;
private bool debug_info;
+ private static Dictionary<string, Func<StackTrace, string>> metadataHandlers;
+
+ static StackTrace ()
+ {
+ metadataHandlers = new Dictionary<string, Func<StackTrace, string>> ();
+
+ InitMetadataHandlers ();
+ }
+
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public StackTrace ()
{
@@ -295,13 +305,38 @@ namespace System.Diagnostics {
}
AddFrames (sb);
+
+ foreach (var handler in metadataHandlers) {
+ var lines = handler.Value (this);
+ using (var reader = new StringReader (lines)) {
+ string line;
+ while ((line = reader.ReadLine()) != null) {
+ sb.AppendLine ();
+ sb.Append (string.Format ("[{0}] {1}", handler.Key, line));
+ }
+ }
+ }
+
return sb.ToString ();
}
+
internal String ToString (TraceFormat traceFormat)
{
// TODO:
return ToString ();
}
+
+ static void InitMetadataHandlers ()
+ {
+ string aotid = Assembly.GetAotId ();
+ if (aotid != "00000000-0000-0000-0000-000000000000")
+ AddMetadataHandler ("AOTID", st => { return aotid; });
+ }
+
+ private static void AddMetadataHandler (string id, Func<StackTrace, string> handler)
+ {
+ metadataHandlers.Add (id, handler);
+ }
}
}