forked from microsoft/vs-threading
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands.cs
More file actions
52 lines (45 loc) · 1.74 KB
/
Copy pathCommands.cs
File metadata and controls
52 lines (45 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace CpsDbg
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
internal static class Commands
{
private const string DumpAsyncCommand = "dumpasync";
private static readonly Dictionary<string, ICommandHandler> CommandHandlers = new Dictionary<string, ICommandHandler>(StringComparer.OrdinalIgnoreCase)
{
{ "dumpasync", new DumpAsyncCommand() },
};
[DllExport(DumpAsyncCommand, CallingConvention.StdCall)]
internal static void DumpAsync(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
ExecuteCommand(client, DumpAsyncCommand, args);
}
private static void ExecuteCommand(IntPtr client, string command, [MarshalAs(UnmanagedType.LPStr)] string args)
{
ICommandHandler handler;
if (!CommandHandlers.TryGetValue(command, out handler))
{
return;
}
DebuggerContext? context = DebuggerContext.GetDebuggerContext(client);
if (context is null)
{
return;
}
try
{
handler.Execute(context, args);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
context.Output.WriteLine($"Encountered an unhandled exception running '{command}':");
context.Output.WriteLine(ex.ToString());
}
}
}
}