From: Mikhail Pilin Date: Fri, 15 Jan 2021 22:24:11 +0000 (+0100) Subject: Add ProfilerAlreadyActiveException in DiagnosticsClient.AttachProfiler() (#1911) X-Git-Tag: submit/tizen/20210909.063632~17^2~193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb913be072988a90a1ca57f1e18d74bc5f831a4b;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Add ProfilerAlreadyActiveException in DiagnosticsClient.AttachProfiler() (#1911) --- diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs index 33ae677b2..6b11c7507 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs @@ -140,6 +140,10 @@ namespace Microsoft.Diagnostics.NETCore.Client { throw new UnsupportedCommandException("The target runtime does not support profiler attach"); } + if (hr == (uint)DiagnosticsIpcError.ProfilerAlreadyActive) + { + throw new ProfilerAlreadyActiveException("The request to attach a profiler was denied because a profiler is already loaded"); + } throw new ServerErrorException($"Profiler attach failed (HRESULT: 0x{hr:X8})"); case DiagnosticsServerResponseId.OK: return; diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClientExceptions.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClientExceptions.cs index 5016e4f7e..79ae879d4 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClientExceptions.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClientExceptions.cs @@ -34,4 +34,10 @@ namespace Microsoft.Diagnostics.NETCore.Client { public UnsupportedCommandException(string msg): base(msg) {} } + + // When the runtime already has loaded profiler + public class ProfilerAlreadyActiveException : ServerErrorException + { + public ProfilerAlreadyActiveException(string msg): base(msg) {} + } } \ No newline at end of file diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs index b015673e1..372d49ef3 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs @@ -15,10 +15,11 @@ namespace Microsoft.Diagnostics.NETCore.Client /// internal enum DiagnosticsIpcError : uint { - BadEncoding = 0x80131384, - UnknownCommand = 0x80131385, - UnknownMagic = 0x80131386, - UnknownError = 0x80131387 + ProfilerAlreadyActive = 0x8013136A, + BadEncoding = 0x80131384, + UnknownCommand = 0x80131385, + UnknownMagic = 0x80131386, + UnknownError = 0x80131387 } ///