From 6f1c6539468cd88209fa811310909d2b6f6f6951 Mon Sep 17 00:00:00 2001 From: Hirsch Singhal Date: Thu, 22 Sep 2016 12:52:48 -0700 Subject: [PATCH 1/4] Add usermode crash dump APIs --- .../Core/DumpCollection.cs | 125 +++++++++++++++++- ...evicePortalWrapper.UniversalWindows.csproj | 4 +- 2 files changed, 126 insertions(+), 3 deletions(-) diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs index dce34655..fa088d6a 100644 --- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs +++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs @@ -4,6 +4,11 @@ // //---------------------------------------------------------------------------------------------- +using System; +using System.IO; +using System.Runtime.Serialization; +using System.Threading.Tasks; + namespace Microsoft.Tools.WindowsDevicePortal { /// @@ -14,7 +19,7 @@ public partial class DevicePortal /// /// API to retrieve list of the available bugcheck minidumps. /// - public static readonly string AvailableBugChecksApi = "api/debug/dump/kernel/dumplish"; + public static readonly string AvailableBugChecksApi = "api/debug/dump/kernel/dumplist"; /// /// API to retrieve list of the available crash dumps (for sideloaded applications). @@ -50,5 +55,123 @@ public partial class DevicePortal /// API to retrieve a live dump from a running user mode process. /// public static readonly string LiveProcessDumpApi = "api/debug/dump/usermode/live"; + + public async Task GetAppCrashDumps() + { + CrashDumpList cdl = await this.Get(AvailableCrashDumpsApi); + return cdl.CrashDumps; + } + + public async Task GetAppCrashDump(CrashDump crashdump) + { + string queryString = CrashDumpFileApi + string.Format("packageFullname={0}&fileName={1}", crashdump.PackageFullName, crashdump.Filename); + Uri uri = Utilities.BuildEndpoint( + this.deviceConnection.Connection, + queryString); + + return await this.Get(uri); + } + + public async Task DeleteAppCrashDump(CrashDump crashdump) + { + await this.Delete(CrashDumpFileApi, + string.Format("packageFullname={0}&fileName={1}", crashdump.PackageFullName, crashdump.Filename)); + } + + public async Task GetAppCrashDumpSettings(AppPackage app) + { + return await this.GetAppCrashDumpSettings(app.PackageFullName); + } + + public async Task GetAppCrashDumpSettings(string packageFullname) + { + return await this.Get( + CrashDumpSettingsApi, + string.Format("packageFullname={0}", packageFullname)); + } + + public async Task SetAppCrashDumpSettings(AppPackage app, bool enable = true) + { + string pfn = app.PackageFullName; + if (enable) + { + await this.Post( + CrashDumpSettingsApi, + string.Format("packageFullname={0}", pfn)); + } else + { + await this.Delete( + CrashDumpSettingsApi, + string.Format("packageFullname={0}", pfn)); + } + } + + #region Data contract + + /// + /// Per-app crash dump settings. + /// + [DataContract] + public class CrashDumpSettings + { + /// + /// Gets whether crash dumps are enabled for the app + /// + [DataMember(Name = "CrashDumpEnabled")] + public bool CrashDumpEnabled + { + get; private set; + } + } + + + public class CrashDump + { + /// + /// Gets whether crash dumps are enabled for the app + /// + [DataMember(Name = "FileDate")] + public DateTime FileDate + { + get; private set; + } + + /// + /// Gets whether crash dumps are enabled for the app + /// + [DataMember(Name = "FileName")] + public string Filename + { + get; private set; + } + + /// + /// Gets whether crash dumps are enabled for the app + /// + [DataMember(Name = "FileSize")] + public int FileSizeInBytes + { + get; private set; + } + + /// + /// Gets whether crash dumps are enabled for the app + /// + [DataMember(Name = "PackageFullName")] + public bool PackageFullName + { + get; private set; + } +} + + private class CrashDumpList + { + [DataMember(Name = "CrashDumps")] + public CrashDump[] CrashDumps + { + get; private set; + } + } + #endregion Data contract } } diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj index ac6abbce..52acc73d 100644 --- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj +++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj @@ -11,7 +11,7 @@ WindowsDevicePortalWrapper.UniversalWindows en-US UAP - 10.0.10586.0 + 10.0.14393.0 10.0.10240.0 14 512 @@ -126,7 +126,7 @@ 14.0 - +