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
path: root/mcs/class
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2020-06-18 00:46:44 +0300
committerGitHub <noreply@github.com>2020-06-18 00:46:44 +0300
commit6ea4cbcee040956cceaa53058cdb7de6529d2db0 (patch)
treeb174ed3a08e81552b179e4a74ecb018badbb44f3 /mcs/class
parentd45ff3af75b1fa9098004a73869edde06dfc4f2a (diff)
[2020-02] [merp] Add API methods for getting hashcode/reason of last crash (#19978)
* [merp] Add API methods for getting hashcode/reason of last crash * Add test * Review feedback and cleanup Co-authored-by: Alexis Christoforides <alexis@thenull.net>
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/corlib/Mono/Runtime.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/mcs/class/corlib/Mono/Runtime.cs b/mcs/class/corlib/Mono/Runtime.cs
index f59a7e93891..c85a3a3b1f5 100644
--- a/mcs/class/corlib/Mono/Runtime.cs
+++ b/mcs/class/corlib/Mono/Runtime.cs
@@ -27,6 +27,7 @@
//
using System;
+using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -255,6 +256,43 @@ namespace Mono {
}
}
+ static string get_breadcrumb_value (string file_prefix, string directory_str, bool clear)
+ {
+ var allfiles = Directory.GetFiles (directory_str, $"{file_prefix}_*" );
+ if (allfiles.Length == 0)
+ return string.Empty;
+
+ if (allfiles.Length > 1) {
+ // it's impossible to tell which breadcrumb is the last one (let's not trust filesystem timestamps)
+ // delete the multiple files so at least next crash can make sense
+ try {
+ Array.ForEach (allfiles, f => File.Delete (f) );
+ } catch (Exception) { }
+
+ return string.Empty;
+ }
+
+ if (clear)
+ File.Delete (allfiles [0]);
+
+ var filename = Path.GetFileName (allfiles [0]);
+ return filename.Substring (file_prefix.Length + 1);
+ }
+
+ static long CheckCrashReportHash (string directory_str, bool clear)
+ {
+ var value = get_breadcrumb_value ("crash_hash", directory_str, clear);
+ if (value == string.Empty)
+ return 0;
+ else
+ return Convert.ToInt64 (value, 16);
+ }
+
+ static string CheckCrashReportReason (string directory_str, bool clear)
+ {
+ return get_breadcrumb_value ("crash_reason", directory_str, clear);
+ }
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void AnnotateMicrosoftTelemetry_internal (IntPtr key, IntPtr val);