This commit is contained in:
Andre Weinand 2016-02-20 10:48:13 +01:00
Родитель ea9cda0905
Коммит 564e0e042c
17 изменённых файлов: 180 добавлений и 189 удалений

9
.vscode/launch.json поставляемый
Просмотреть файл

@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
@ -11,6 +11,13 @@
],
"stopOnEntry": false
},
{
"name": "Run Server",
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/bin/Debug/monoDebug.exe",
"args": [ "--server=4711" ]
},
{
"name": "Run Tests",
"type": "node",

Просмотреть файл

@ -1,12 +1,13 @@
MONO_DEBUG = "./bin/Release/mono-debug.exe"
MONO_DEBUG_RELEASE = "./bin/Release/mono-debug.exe"
MONO_DEBUG_DEBUG = "./bin/Debug/mono-debug.exe"
SDB_EXE = "./sdb/bin/sdb.exe"
SDB_MAKE = "./sdb/Makefile"
all: vsix
@echo "vsix created"
vsix: $MONO_DEBUG
vsix: $MONO_DEBUG_RELEASE
vsce package
$SDB_MAKE:
@ -15,13 +16,20 @@ $SDB_MAKE:
$SDB_EXE: $SDB_MAKE
cd sdb; make -f Makefile
build: $MONO_DEBUG
build: $MONO_DEBUG_RELEASE
tsc -p ./tests
@echo "build finished"
$MONO_DEBUG: $SDB_EXE
debug: $MONO_DEBUG_DEBUG
tsc -p ./tests
@echo "build finished"
$MONO_DEBUG_RELEASE: $SDB_EXE
xbuild /p:Configuration=Release mono-debug.sln
$MONO_DEBUG_DEBUG: $SDB_EXE
xbuild /p:Configuration=Debug mono-debug.sln
clean:
rm -rf sdb

Просмотреть файл

@ -1,3 +0,0 @@
#!/bin/bash
make -f Makefile $*

Просмотреть файл

@ -60,18 +60,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\common\Events.cs" />
<Compile Include="src\common\Handles.cs" />
<Compile Include="src\common\IDebugSession.cs" />
<Compile Include="src\common\PathUtilities.cs" />
<Compile Include="src\common\Program.cs" />
<Compile Include="src\common\Results.cs" />
<Compile Include="src\common\Terminal.cs" />
<Compile Include="src\common\Types.cs" />
<Compile Include="src\common\Utilities.cs" />
<Compile Include="src\common\V8Protocol.cs" />
<Compile Include="src\MonoDebugSession.cs" />
<Compile Include="src\MonoEngineFactory.cs" />
<Compile Include="src\sdb\CommandLine.cs" />
<Compile Include="src\sdb\Debugger.cs" />
<Compile Include="sdb\src\Color.cs">
@ -98,6 +87,16 @@
<Compile Include="sdb\src\Utilities.cs">
<Link>src\sdb\src\Utilities.cs</Link>
</Compile>
<Compile Include="src\Terminal.cs" />
<Compile Include="src\Program.cs" />
<Compile Include="src\PathUtilities.cs" />
<Compile Include="src\Handles.cs" />
<Compile Include="src\Results.cs" />
<Compile Include="src\Utilities.cs" />
<Compile Include="src\Types.cs" />
<Compile Include="src\Events.cs" />
<Compile Include="src\DebugProtocol.cs" />
<Compile Include="src\DebugSession.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@ -116,7 +115,6 @@
</Target>
<ItemGroup>
<Folder Include="src\" />
<Folder Include="src\common\" />
<Folder Include="src\sdb\" />
<Folder Include="src\sdb\src\" />
</ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "mono-debug",
"displayName": "Mono Debug",
"version": "0.10.10",
"version": "0.10.11",
"publisher": "ms-vscode",
"description": "Visual Studio Code debugger extension for Mono",
"icon": "images/mono-debug-icon.svg",
@ -15,6 +15,7 @@
"private": true,
"scripts": {
"prepublish": "make build",
"vscode:prepublish": "make build",
"compile": "make build",
"watch": "tsc -w -p ./tests",
"test": "node ./node_modules/mocha/bin/mocha --timeout 999999 -u tdd ./tests/out/"

Просмотреть файл

@ -9,31 +9,31 @@ using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
namespace OpenDebug
namespace VSCodeDebug
{
public class V8Message
public class DPMessage
{
public int seq;
public string type;
public V8Message(string typ) {
public DPMessage(string typ) {
type = typ;
}
}
public class V8Request : V8Message
public class DPRequest : DPMessage
{
public string command;
public dynamic arguments;
public V8Request(int id, string cmd, dynamic arg) : base("request") {
public DPRequest(int id, string cmd, dynamic arg) : base("request") {
seq = id;
command = cmd;
arguments = arg;
}
}
public class V8Response : V8Message
public class DPResponse : DPMessage
{
public bool success;
public string message;
@ -41,10 +41,10 @@ namespace OpenDebug
public string command;
public dynamic body;
public V8Response() : base("response") {
public DPResponse() : base("response") {
}
public V8Response(int rseq, string cmd) : base("response") {
public DPResponse(int rseq, string cmd) : base("response") {
request_seq = rseq;
command = cmd;
}
@ -62,31 +62,31 @@ namespace OpenDebug
}
}
public class V8Event : V8Message
public class DPEvent : DPMessage
{
[JsonProperty(PropertyName = "event")]
public string eventType;
public dynamic body;
public V8Event() : base("event") {
public DPEvent() : base("event") {
}
public V8Event(dynamic m) : base("event") {
public DPEvent(dynamic m) : base("event") {
seq = m.seq;
eventType = m["event"];
body = m.body;
}
public V8Event(string type, dynamic bdy = null) : base("event") {
public DPEvent(string type, dynamic bdy = null) : base("event") {
eventType = type;
body = bdy;
}
}
/*
* The V8ServerProtocol can be used to implement a server that uses the V8 protocol.
* The ServerProtocol can be used to implement a server that uses the VSCode debug protocol.
*/
public class V8ServerProtocol
public class ServerProtocol
{
public bool TRACE;
public bool TRACE_RESPONSE;
@ -107,10 +107,10 @@ namespace OpenDebug
private bool _stopRequested;
private Action<string, dynamic, V8Response> _callback;
private Action<string, dynamic, DPResponse> _callback;
public V8ServerProtocol(Stream inputStream, Stream outputStream) {
public ServerProtocol(Stream inputStream, Stream outputStream) {
_sequenceNumber = 1;
_inputStream = inputStream;
_outputStream = outputStream;
@ -118,7 +118,7 @@ namespace OpenDebug
_rawData = new ByteBuffer();
}
public async Task<int> Start(Action<string, dynamic, V8Response> cb)
public async Task<int> Start(Action<string, dynamic, DPResponse> cb)
{
_callback = cb;
@ -147,7 +147,7 @@ namespace OpenDebug
public void SendEvent(string eventType, dynamic body)
{
SendMessage(new V8Event(eventType, body));
SendMessage(new DPEvent(eventType, body));
}
// ---- private ------------------------------------------------------------------------
@ -186,13 +186,13 @@ namespace OpenDebug
private void Dispatch(string req)
{
var request = JsonConvert.DeserializeObject<V8Request>(req);
var request = JsonConvert.DeserializeObject<DPRequest>(req);
if (request != null && request.type == "request") {
if (TRACE)
Console.Error.WriteLine(string.Format("C {0}: {1}", request.command, JsonConvert.SerializeObject(request.arguments)));
if (_callback != null) {
var response = new V8Response(request.seq, request.command);
var response = new DPResponse(request.seq, request.command);
_callback.Invoke(request.command, request.arguments, response);
@ -201,7 +201,7 @@ namespace OpenDebug
}
}
private void SendMessage(V8Message message)
private void SendMessage(DPMessage message)
{
message.seq = _sequenceNumber++;
@ -209,7 +209,7 @@ namespace OpenDebug
Console.Error.WriteLine(string.Format(" R: {0}", JsonConvert.SerializeObject(message)));
}
if (TRACE && message.type == "event") {
V8Event e = (V8Event)message;
DPEvent e = (DPEvent)message;
Console.Error.WriteLine(string.Format("E {0}: {1}", e.eventType, JsonConvert.SerializeObject(e.body)));
}
@ -223,7 +223,7 @@ namespace OpenDebug
}
}
private static byte[] ConvertToBytes(V8Message request)
private static byte[] ConvertToBytes(DPMessage request)
{
var asJson = JsonConvert.SerializeObject(request);
byte[] jsonBytes = Encoding.GetBytes(asJson);

Просмотреть файл

@ -6,34 +6,34 @@ using System;
using System.Threading.Tasks;
using Microsoft.CSharp.RuntimeBinder;
namespace OpenDebug
namespace VSCodeDebug
{
public interface IDebugSession
{
DebugResult Dispatch(string command, dynamic args);
DebugResponse Dispatch(string command, dynamic args);
Task<DebugResult> Initialize(dynamic arguments);
Task<DebugResult> Launch(dynamic arguments);
Task<DebugResult> Attach(dynamic arguments);
Task<DebugResult> Disconnect();
Task<DebugResponse> Initialize(dynamic arguments);
Task<DebugResponse> Launch(dynamic arguments);
Task<DebugResponse> Attach(dynamic arguments);
Task<DebugResponse> Disconnect();
Task<DebugResult> SetBreakpoints(Source source, int[] lines);
Task<DebugResult> SetFunctionBreakpoints();
Task<DebugResult> SetExceptionBreakpoints(string[] filter);
Task<DebugResponse> SetBreakpoints(Source source, int[] lines);
Task<DebugResponse> SetFunctionBreakpoints();
Task<DebugResponse> SetExceptionBreakpoints(string[] filter);
Task<DebugResult> Continue(int threadId);
Task<DebugResult> Next(int threadId);
Task<DebugResult> StepIn(int threadId);
Task<DebugResult> StepOut(int threadId);
Task<DebugResult> Pause(int threadId);
Task<DebugResponse> Continue(int threadId);
Task<DebugResponse> Next(int threadId);
Task<DebugResponse> StepIn(int threadId);
Task<DebugResponse> StepOut(int threadId);
Task<DebugResponse> Pause(int threadId);
Task<DebugResult> Threads();
Task<DebugResult> StackTrace(int threadId, int levels);
Task<DebugResult> Scopes(int frameId);
Task<DebugResult> Variables(int reference);
Task<DebugResult> Source(int sourceReference);
Task<DebugResponse> Threads();
Task<DebugResponse> StackTrace(int threadId, int levels);
Task<DebugResponse> Scopes(int frameId);
Task<DebugResponse> Variables(int reference);
Task<DebugResponse> Source(int sourceReference);
Task<DebugResult> Evaluate(string context, int frameId, string expression);
Task<DebugResponse> Evaluate(string context, int frameId, string expression);
}
public abstract class DebugSession : IDebugSession
@ -49,7 +49,7 @@ namespace OpenDebug
_debuggerPathsAreURI = debuggerPathsAreURI;
}
public virtual DebugResult Dispatch(string command, dynamic args)
public virtual DebugResponse Dispatch(string command, dynamic args)
{
int thread;
@ -69,7 +69,7 @@ namespace OpenDebug
_clientPathsAreURI = false;
break;
default:
return new DebugResult(1015, "initialize: bad value '{_format}' for pathFormat", new { _format = pathFormat });
return new DebugResponse(1015, "initialize: bad value '{_format}' for pathFormat", new { _format = pathFormat });
}
}
return Initialize(args).Result;
@ -115,14 +115,14 @@ namespace OpenDebug
case "variables":
int varRef = GetInt(args, "variablesReference", -1);
if (varRef == -1) {
return new DebugResult(1009, "variables: property 'variablesReference' is missing");
return new DebugResponse(1009, "variables: property 'variablesReference' is missing");
}
return Variables(varRef).Result;
case "source":
int sourceRef = GetInt(args, "sourceReference", -1);
if (sourceRef == -1) {
return new DebugResult(1010, "source: property 'sourceReference' is missing");
return new DebugResponse(1010, "source: property 'sourceReference' is missing");
}
return Source(sourceRef).Result;
@ -162,7 +162,7 @@ namespace OpenDebug
var lines = args.lines.ToObject<int[]>();
return SetBreakpoints(src2, lines).Result;
}
return new DebugResult(1012, "setBreakpoints: property 'source' is empty or misformed");
return new DebugResponse(1012, "setBreakpoints: property 'source' is empty or misformed");
case "setFunctionBreakpoints":
return SetFunctionBreakpoints().Result;
@ -182,82 +182,82 @@ namespace OpenDebug
int frameId = GetInt(args, "frameId", -1);
var expression = GetString(args, "expression");
if (expression == null) {
return new DebugResult(1013, "evaluate: property 'expression' is missing, null, or empty");
return new DebugResponse(1013, "evaluate: property 'expression' is missing, null, or empty");
}
return Evaluate(context, frameId, expression).Result;
default:
return new DebugResult(1014, "unrecognized request: {_request}", new { _request = command });
return new DebugResponse(1014, "unrecognized request: {_request}", new { _request = command });
}
}
public virtual Task<DebugResult> Initialize(dynamic args)
public virtual Task<DebugResponse> Initialize(dynamic args)
{
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public abstract Task<DebugResult> Launch(dynamic arguments);
public abstract Task<DebugResponse> Launch(dynamic arguments);
public virtual Task<DebugResult> Attach(dynamic arguments)
public virtual Task<DebugResponse> Attach(dynamic arguments)
{
return Task.FromResult(new DebugResult(1016, "Attach not supported"));
return Task.FromResult(new DebugResponse(1016, "Attach not supported"));
}
public virtual Task<DebugResult> Disconnect()
public virtual Task<DebugResponse> Disconnect()
{
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public virtual Task<DebugResult> SetFunctionBreakpoints()
public virtual Task<DebugResponse> SetFunctionBreakpoints()
{
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public virtual Task<DebugResult> SetExceptionBreakpoints(string[] filter)
public virtual Task<DebugResponse> SetExceptionBreakpoints(string[] filter)
{
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public abstract Task<DebugResult> SetBreakpoints(Source source, int[] lines);
public abstract Task<DebugResponse> SetBreakpoints(Source source, int[] lines);
public abstract Task<DebugResult> Continue(int thread);
public abstract Task<DebugResponse> Continue(int thread);
public abstract Task<DebugResult> Next(int thread);
public abstract Task<DebugResponse> Next(int thread);
public virtual Task<DebugResult> StepIn(int thread)
public virtual Task<DebugResponse> StepIn(int thread)
{
return Task.FromResult(new DebugResult(1017, "StepIn not supported"));
return Task.FromResult(new DebugResponse(1017, "StepIn not supported"));
}
public virtual Task<DebugResult> StepOut(int thread)
public virtual Task<DebugResponse> StepOut(int thread)
{
return Task.FromResult(new DebugResult(1018, "StepOut not supported"));
return Task.FromResult(new DebugResponse(1018, "StepOut not supported"));
}
public virtual Task<DebugResult> Pause(int thread)
public virtual Task<DebugResponse> Pause(int thread)
{
return Task.FromResult(new DebugResult(1019, "Pause not supported"));
return Task.FromResult(new DebugResponse(1019, "Pause not supported"));
}
public abstract Task<DebugResult> StackTrace(int thread, int levels);
public abstract Task<DebugResponse> StackTrace(int thread, int levels);
public abstract Task<DebugResult> Scopes(int frameId);
public abstract Task<DebugResponse> Scopes(int frameId);
public abstract Task<DebugResult> Variables(int reference);
public abstract Task<DebugResponse> Variables(int reference);
public virtual Task<DebugResult> Source(int sourceId)
public virtual Task<DebugResponse> Source(int sourceId)
{
return Task.FromResult(new DebugResult(1020, "Source not supported"));
return Task.FromResult(new DebugResponse(1020, "Source not supported"));
}
public virtual Task<DebugResult> Threads()
public virtual Task<DebugResponse> Threads()
{
return Task.FromResult(new DebugResult(new ThreadsResponseBody()));
return Task.FromResult(new DebugResponse(new ThreadsResponseBody()));
}
public virtual Task<DebugResult> Evaluate(string context, int frameId, string expression)
public virtual Task<DebugResponse> Evaluate(string context, int frameId, string expression)
{
return Task.FromResult(new DebugResult(1021, "Evaluate not supported"));
return Task.FromResult(new DebugResponse(1021, "Evaluate not supported"));
}
// protected

Просмотреть файл

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace OpenDebug
namespace VSCodeDebug
{
public class DebugEvent
{

Просмотреть файл

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
using System.Collections.Generic;
namespace OpenDebug
namespace VSCodeDebug
{
public class Handles<T>
{

Просмотреть файл

@ -14,7 +14,7 @@ using Mono.Debugging.Client;
using Microsoft.CSharp.RuntimeBinder;
namespace OpenDebug
namespace VSCodeDebug
{
public class SDBDebugSession : DebugSession, IDebugSession
{
@ -108,7 +108,7 @@ namespace OpenDebug
callback.Invoke(new InitializedEvent());
}
public override Task<DebugResult> Initialize(dynamic args)
public override Task<DebugResponse> Initialize(dynamic args)
{
var cap = new Capabilities();
@ -127,21 +127,21 @@ namespace OpenDebug
// This debug adapter does not support exception breakpoint filters
cap.exceptionBreakpointFilters = new dynamic[0];
return Task.FromResult(new DebugResult(cap));
return Task.FromResult(new DebugResponse(cap));
}
public override Task<DebugResult> Launch(dynamic args)
public override Task<DebugResponse> Launch(dynamic args)
{
_attachMode = false;
// validate argument 'program'
string programPath = getString(args, "program");
if (programPath == null) {
return Task.FromResult(new DebugResult(1001, "launch: property 'program' is missing or empty"));
return Task.FromResult(new DebugResponse(1001, "launch: property 'program' is missing or empty"));
}
programPath = ConvertClientPathToDebugger(programPath);
if (!File.Exists(programPath) && !Directory.Exists(programPath)) {
return Task.FromResult(new DebugResult(1002, "launch: program '{path}' does not exist", new { path = programPath }));
return Task.FromResult(new DebugResponse(1002, "launch: program '{path}' does not exist", new { path = programPath }));
}
// validate argument 'args'
@ -158,11 +158,11 @@ namespace OpenDebug
if (workingDirectory != null) {
workingDirectory = workingDirectory.Trim();
if (workingDirectory.Length == 0) {
return Task.FromResult(new DebugResult(1003, "launch: property 'workingDirectory' is empty"));
return Task.FromResult(new DebugResponse(1003, "launch: property 'workingDirectory' is empty"));
}
workingDirectory = ConvertClientPathToDebugger(workingDirectory);
if (!Directory.Exists(workingDirectory)) {
return Task.FromResult(new DebugResult(1004, "launch: workingDirectory '{path}' does not exist", new { path = workingDirectory }));
return Task.FromResult(new DebugResponse(1004, "launch: workingDirectory '{path}' does not exist", new { path = workingDirectory }));
}
}
workingDirectory = null; // TODO@AW Why?
@ -172,11 +172,11 @@ namespace OpenDebug
if (runtimeExecutable != null) {
runtimeExecutable = runtimeExecutable.Trim();
if (runtimeExecutable.Length == 0) {
return Task.FromResult(new DebugResult(1005, "launch: property 'runtimeExecutable' is empty"));
return Task.FromResult(new DebugResponse(1005, "launch: property 'runtimeExecutable' is empty"));
}
runtimeExecutable = ConvertClientPathToDebugger(runtimeExecutable);
if (!File.Exists(runtimeExecutable)) {
return Task.FromResult(new DebugResult(1006, "launch: runtimeExecutable '{path}' does not exist", new { path = runtimeExecutable }));
return Task.FromResult(new DebugResponse(1006, "launch: runtimeExecutable '{path}' does not exist", new { path = runtimeExecutable }));
}
}
@ -217,7 +217,7 @@ namespace OpenDebug
string mono_path = runtimeExecutable;
if (mono_path == null) {
if (!Terminal.IsOnPath(MONO)) {
return Task.FromResult(new DebugResult(3001, "launch: can't find runtime '{_runtime}' on PATH", new { _runtime = MONO }));
return Task.FromResult(new DebugResponse(3001, "launch: can't find runtime '{_runtime}' on PATH", new { _runtime = MONO }));
}
mono_path = MONO; // try to find mono through PATH
}
@ -244,7 +244,7 @@ namespace OpenDebug
if (externalConsole) {
var result = Terminal.LaunchInTerminal(workingDirectory, mono_path, mono_args, program, arguments, env);
if (!result.Success) {
return Task.FromResult(new DebugResult(3002, "launch: can't launch terminal ({reason})", new { reason = result.Message }));
return Task.FromResult(new DebugResponse(3002, "launch: can't launch terminal ({reason})", new { reason = result.Message }));
}
} else {
@ -295,7 +295,7 @@ namespace OpenDebug
_process.BeginErrorReadLine();
}
catch (Exception e) {
return Task.FromResult(new DebugResult(3002, "launch: can't launch terminal ({reason})", new { reason = e.Message }));
return Task.FromResult(new DebugResponse(3002, "launch: can't launch terminal ({reason})", new { reason = e.Message }));
}
}
@ -336,34 +336,34 @@ namespace OpenDebug
// TODO@AW in case of errors?
}
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> Attach(dynamic args)
public override Task<DebugResponse> Attach(dynamic args)
{
_attachMode = true;
// validate argument 'address'
var host = getString(args, "address");
if (host == null) {
return Task.FromResult(new DebugResult(1007, "attach: property 'address' is missing or empty"));
return Task.FromResult(new DebugResponse(1007, "attach: property 'address' is missing or empty"));
}
// validate argument 'port'
var port = getInt(args, "port", -1);
if (port == -1) {
return Task.FromResult(new DebugResult(1008, "attach: property 'port' is missing"));
return Task.FromResult(new DebugResponse(1008, "attach: property 'port' is missing"));
}
IPAddress address = Utilities.ResolveIPAddress(host);
if (address == null) {
return Task.FromResult(new DebugResult(3003, "attach: invalid address '{address}'", new { address = address }));
return Task.FromResult(new DebugResponse(3003, "attach: invalid address '{address}'", new { address = address }));
}
Debugger.Connect(address, port);
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> Disconnect()
public override Task<DebugResponse> Disconnect()
{
//CommandLine.WaitForSuspend();
@ -384,61 +384,61 @@ namespace OpenDebug
}
}
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> Continue(int thread)
public override Task<DebugResponse> Continue(int thread)
{
CommandLine.WaitForSuspend();
Debugger.Continue();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> Next(int thread)
public override Task<DebugResponse> Next(int thread)
{
CommandLine.WaitForSuspend();
Debugger.StepOverLine();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> StepIn(int thread)
public override Task<DebugResponse> StepIn(int thread)
{
CommandLine.WaitForSuspend();
Debugger.StepIntoLine();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> StepOut(int thread)
public override Task<DebugResponse> StepOut(int thread)
{
CommandLine.WaitForSuspend();
Debugger.StepOutOfMethod();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> Pause(int thread)
public override Task<DebugResponse> Pause(int thread)
{
Debugger.Pause();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> SetExceptionBreakpoints(string[] filter)
public override Task<DebugResponse> SetExceptionBreakpoints(string[] filter)
{
//CommandLine.WaitForSuspend();
return Task.FromResult(new DebugResult());
return Task.FromResult(new DebugResponse());
}
public override Task<DebugResult> SetBreakpoints(Source source, int[] clientLines)
public override Task<DebugResponse> SetBreakpoints(Source source, int[] clientLines)
{
if (source.path == null) {
// we do not support special sources
return Task.FromResult(new DebugResult(new SetBreakpointsResponseBody()));
return Task.FromResult(new DebugResponse(new SetBreakpointsResponseBody()));
}
string path = ConvertClientPathToDebugger(source.path);
if (!HasMonoExtension(path)) {
// we only support breakpoints in files mono can handle
return Task.FromResult(new DebugResult(new SetBreakpointsResponseBody()));
return Task.FromResult(new DebugResponse(new SetBreakpointsResponseBody()));
}
//CommandLine.WaitForSuspend();
@ -486,10 +486,10 @@ namespace OpenDebug
foreach (var l in clientLines) {
breakpoints.Add(new Breakpoint(true, l));
}
return Task.FromResult(new DebugResult(new SetBreakpointsResponseBody(breakpoints)));
return Task.FromResult(new DebugResponse(new SetBreakpointsResponseBody(breakpoints)));
}
public override Task<DebugResult> StackTrace(int threadReference, int maxLevels)
public override Task<DebugResponse> StackTrace(int threadReference, int maxLevels)
{
CommandLine.WaitForSuspend();
var stackFrames = new List<StackFrame>();
@ -520,10 +520,10 @@ namespace OpenDebug
}
}
return Task.FromResult(new DebugResult(new StackTraceResponseBody(stackFrames)));
return Task.FromResult(new DebugResponse(new StackTraceResponseBody(stackFrames)));
}
public override Task<DebugResult> Scopes(int frameId) {
public override Task<DebugResponse> Scopes(int frameId) {
var scopes = new List<Scope>();
@ -543,10 +543,10 @@ namespace OpenDebug
scopes.Add(new Scope("Local", _variableHandles.Create(locals)));
}
return Task.FromResult(new DebugResult(new ScopesResponseBody(scopes)));
return Task.FromResult(new DebugResponse(new ScopesResponseBody(scopes)));
}
public override Task<DebugResult> Variables(int reference)
public override Task<DebugResponse> Variables(int reference)
{
CommandLine.WaitForSuspend();
var variables = new List<Variable>();
@ -581,10 +581,10 @@ namespace OpenDebug
}
}
return Task.FromResult(new DebugResult(new VariablesResponseBody(variables)));
return Task.FromResult(new DebugResponse(new VariablesResponseBody(variables)));
}
public override Task<DebugResult> Threads()
public override Task<DebugResponse> Threads()
{
var threads = new List<Thread>();
var process = Debugger.ActiveProcess;
@ -599,10 +599,10 @@ namespace OpenDebug
}
threads = d.Values.ToList();
}
return Task.FromResult(new DebugResult(new ThreadsResponseBody(threads)));
return Task.FromResult(new DebugResponse(new ThreadsResponseBody(threads)));
}
public override Task<DebugResult> Evaluate(string context, int frameId, string expression)
public override Task<DebugResponse> Evaluate(string context, int frameId, string expression)
{
string error = null;
@ -630,7 +630,7 @@ namespace OpenDebug
if (val.HasChildren) {
handle = _variableHandles.Create(val.GetAllChildren());
}
return Task.FromResult(new DebugResult(new EvaluateResponseBody(val.DisplayValue, handle)));
return Task.FromResult(new DebugResponse(new EvaluateResponseBody(val.DisplayValue, handle)));
}
}
else {
@ -640,7 +640,7 @@ namespace OpenDebug
else {
error = "no active stackframe";
}
return Task.FromResult(new DebugResult(3004, "evaluate request failed ({_reason})", new { _reason = error } ));
return Task.FromResult(new DebugResponse(3004, "evaluate request failed ({_reason})", new { _reason = error } ));
}
//---- private ------------------------------------------

Просмотреть файл

@ -1,24 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
using System;
namespace OpenDebug
{
public class EngineFactory
{
public static IDebugSession CreateDebugSession(string adapterID, Action<DebugEvent> callback)
{
OperatingSystem os = Environment.OSVersion;
PlatformID pid = os.Platform;
if ((pid == PlatformID.MacOSX || pid == PlatformID.Unix) && adapterID == "mono") {
return new SDBDebugSession(callback);
}
return null;
}
}
}

Просмотреть файл

@ -5,7 +5,7 @@
using System;
using System.IO;
namespace OpenDebug
namespace VSCodeDebug
{
public class PathUtilities
{

Просмотреть файл

@ -7,7 +7,7 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
namespace OpenDebug
namespace VSCodeDebug
{
internal class Program
{
@ -88,14 +88,14 @@ namespace OpenDebug
private static void Dispatch(Stream inputStream, Stream outputStream)
{
V8ServerProtocol protocol = new V8ServerProtocol(inputStream, outputStream);
ServerProtocol protocol = new ServerProtocol(inputStream, outputStream);
protocol.TRACE = trace_requests;
protocol.TRACE_RESPONSE = trace_responses;
IDebugSession debugSession = null;
var r = protocol.Start((string command, dynamic args, V8Response response) => {
var r = protocol.Start((string command, dynamic args, DPResponse response) => {
if (args == null) {
args = new { };
@ -108,7 +108,12 @@ namespace OpenDebug
return;
}
debugSession = EngineFactory.CreateDebugSession(adapterID, (e) => protocol.SendEvent(e.type, e));
OperatingSystem os = Environment.OSVersion;
if ((os.Platform == PlatformID.MacOSX || os.Platform == PlatformID.Unix) && adapterID == "mono") {
debugSession = new SDBDebugSession((e) => protocol.SendEvent(e.type, e));
}
if (debugSession == null) {
response.SetBody(new ErrorResponseBody(new Message(1103, "initialize: can't create debug session for adapter '{_id}'", new { _id = adapterID })));
return;
@ -118,7 +123,7 @@ namespace OpenDebug
if (debugSession != null) {
try {
DebugResult dr = debugSession.Dispatch(command, args);
DebugResponse dr = debugSession.Dispatch(command, args);
if (dr != null) {
response.SetBody(dr.Body);
}

Просмотреть файл

@ -5,13 +5,12 @@
using System.Collections.Generic;
using System.Linq;
namespace OpenDebug
namespace VSCodeDebug
{
/*
* This monomorphic class is used to return results from a debugger request or to return errors.
* In addition events can be attached that are fired after the request results have been returned to the caller.
*/
public sealed class DebugResult
public sealed class DebugResponse
{
public bool Success { get; private set; } // boolean indicating success
public ResponseBody Body { get; private set; } // depending on value of success either the result or an error
@ -19,14 +18,14 @@ namespace OpenDebug
/*
* A success result without additional data.
*/
public DebugResult() {
public DebugResponse() {
Success = true;
}
/*
* A result with a response body. If body is a ErrorResponseBody then Success will be set to false.
*/
public DebugResult(ResponseBody body) {
public DebugResponse(ResponseBody body) {
Success = true;
Body = body;
if (body is ErrorResponseBody) {
@ -37,7 +36,7 @@ namespace OpenDebug
/*
* A failure result with a full error message.
*/
public DebugResult(int id, string format, dynamic arguments = null) {
public DebugResponse(int id, string format, dynamic arguments = null) {
Success = false;
Body = new ErrorResponseBody(new Message(id, format, arguments));
}

Просмотреть файл

@ -8,7 +8,7 @@ using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace OpenDebug
namespace VSCodeDebug
{
public class Terminal
{

Просмотреть файл

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
using System.IO;
namespace OpenDebug
namespace VSCodeDebug
{
public class Message {
public int id { get; set; }

Просмотреть файл

@ -10,7 +10,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using System.Reflection;
namespace OpenDebug
namespace VSCodeDebug
{
public class Utilities
{