Skip to content

Commit

Permalink
mi: return "^running" as a successful launch reply, dap: mark class i…
Browse files Browse the repository at this point in the history
…nternals as private, docs
  • Loading branch information
dd86k committed Aug 29, 2024
1 parent 10f0062 commit 38ec3c7
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 174 deletions.
123 changes: 72 additions & 51 deletions source/adapters/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ import core.thread : Thread;
import std.datetime : Duration, dur;
import ddlogger;

// NOTE: Rationale for structure messaging
//
// Structures are used for messaging between the server and the client internally.
//
// They allow to:
// - Be used in message passing concurrency.
// - Add additional details when necessary.

//
// Request types
//

enum RequestType
{
unknown,
Expand All @@ -21,7 +33,7 @@ enum RequestType
/// Attach debugger to process
attach,

/// Set current working directory
/// Set current working directory of debugger.
currentWorkingDirectory,

/// Continue
Expand All @@ -36,44 +48,6 @@ enum RequestType
close,
}

enum EventType
{
/// When a breakpoint's state changes (modified, removed, etc.).
breakpoint,
/// When debugger's list of capabilities change, usually after startup.
capabilities,
/// Debuggee/tracee has resumed execution.
continued,
/// Debuggee/tracee has exited.
exited,
/// Debugger server is ready to accept configuration requests.
initialized,
/// Debugger server state changed (e.g., setting) and client needs to refresh.
invalidated,
/// Source file added, changed, or removed, from loaded sources.
loadedSource,
/// Memory range has received an update.
memory,
/// Module was (loaded, changed, removed).
module_,
/// Debuggee process message.
output,
/// A sub-process was spawned, or removed.
process,
///
progressEnd,
///
progressStart,
///
progressUpdate,
/// The debuggee stopped.
stopped,
/// The debuggee was terminated.
terminated,
/// Thread event.
thread,
}

// Stuff like if lines starts at 1, etc.
enum OptionType
{
Expand Down Expand Up @@ -116,14 +90,64 @@ struct AdapterRequest
}
}

//
// Reply types
//

/// Used to reply that the command was successfully executed
/// by the server.
struct AdapterReply
{
RequestType type;

union
{

}
RequestType type; // Initial request
}

/// Used to reply an error back to the client, that the request
/// has failed.
struct AdapterError
{
string message;
}

//
// Event types
//

enum EventType
{
/// When a breakpoint's state changes (modified, removed, etc.).
breakpoint,
/// When debugger's list of capabilities change, usually after startup.
capabilities,
/// Debuggee/tracee has resumed execution.
continued,
/// Debuggee/tracee has exited.
exited,
/// Debugger server is ready to accept configuration requests.
initialized,
/// Debugger server state changed (e.g., setting) and client needs to refresh.
invalidated,
/// Source file added, changed, or removed, from loaded sources.
loadedSource,
/// Memory range has received an update.
memory,
/// Module was (loaded, changed, removed).
module_,
/// Debuggee process message.
output,
/// A sub-process was spawned, or removed.
process,
///
progressEnd,
///
progressStart,
///
progressUpdate,
/// The debuggee stopped.
stopped,
/// The debuggee was terminated.
terminated,
/// Thread event.
thread,
}

struct AdapterEvent
Expand All @@ -136,12 +160,9 @@ struct AdapterEvent
}
}

struct AdapterError
{
string message;
}

// Base Adapter class to
/// Abstract Adapter class used to interface a protocol.
///
/// This class alone is incapable to interface with the server.
abstract class Adapter
{
this(ITransport t)
Expand Down
148 changes: 74 additions & 74 deletions source/adapters/dap.d
Original file line number Diff line number Diff line change
Expand Up @@ -61,79 +61,6 @@ private enum PathFormat { path, uri }
//TODO: Consider update seq atomically
class DAPAdapter : Adapter
{
int current_seq = 1;
int request_seq;
RequestType processCreation;

struct ClientCapabilities
{
string adapterId;
string id;
string name;
/// ISO-639
string locale;
/// 'path' or 'uri'
PathFormat pathFormat;

//TODO: Issue with linesStartAt1/columnsStartAt1: They default to one
Capability[] capabilities = [
{ "linesStartAt1" },
{ "columnsStartAt1" },
{ "supportsVariableType" },
{ "supportsVariablePaging" },
{ "supportsRunInTerminalRequest" },
{ "supportsMemoryReferences" },
{ "supportsProgressReporting" },
{ "supportsInvalidatedEvent" },
{ "supportsMemoryEvent" },
{ "supportsArgsCanBeInterpretedByShell" },
{ "supportsStartDebuggingRequest" },
];
}
ClientCapabilities client;

// NOTE: Set to true when server supports
struct ServerCapabilities
{
Capability[] capabilities = [
{ "supportsConfigurationDoneRequest" },
{ "supportsFunctionBreakpoints" },
{ "supportsConditionalBreakpoints" },
{ "supportsHitConditionalBreakpoints" },
{ "supportsEvaluateForHovers" },
{ "supportsStepBack" },
{ "supportsSetVariable" },
{ "supportsRestartFrame" },
{ "supportsGotoTargetsRequest" },
{ "supportsStepInTargetsRequest" },
{ "supportsCompletionsRequest" },
{ "supportsModulesRequest" },
{ "supportsExceptionOptions" },
{ "supportsValueFormattingOptions" },
{ "supportsExceptionInfoRequest" },
{ "supportTerminateDebuggee" },
{ "supportSuspendDebuggee" },
{ "supportsDelayedStackTraceLoading" },
{ "supportsLoadedSourcesRequest" },
{ "supportsLogPoints" },
{ "supportsTerminateThreadsRequest" },
{ "supportsSetExpression" },
{ "supportsTerminateRequest" },
{ "supportsDataBreakpoints" },
{ "supportsReadMemoryRequest" },
{ "supportsWriteMemoryRequest" },
{ "supportsDisassembleRequest" },
{ "supportsCancelRequest" },
{ "supportsBreakpointLocationsRequest" },
{ "supportsClipboardContext" },
{ "supportsSteppingGranularity" },
{ "supportsInstructionBreakpoints" },
{ "supportsExceptionFilterOptions" },
{ "supportsSingleThreadExecutionRequests" },
];
}
ServerCapabilities server;

this(ITransport t)
{
super(t);
Expand Down Expand Up @@ -349,7 +276,6 @@ class DAPAdapter : Adapter
JSONValue j;
j["seq"] = current_seq++;

//TODO: Final switch
switch (event.type) with (EventType) {
case output:
j["event"] = "output";
Expand Down Expand Up @@ -382,4 +308,78 @@ class DAPAdapter : Adapter
{
super.send(json.toString());
}

private:
int current_seq = 1;
int request_seq;
RequestType processCreation;

struct ClientCapabilities
{
string adapterId;
string id;
string name;
/// ISO-639
string locale;
/// 'path' or 'uri'
PathFormat pathFormat;

//TODO: Issue with linesStartAt1/columnsStartAt1: They default to one
Capability[] capabilities = [
{ "linesStartAt1" },
{ "columnsStartAt1" },
{ "supportsVariableType" },
{ "supportsVariablePaging" },
{ "supportsRunInTerminalRequest" },
{ "supportsMemoryReferences" },
{ "supportsProgressReporting" },
{ "supportsInvalidatedEvent" },
{ "supportsMemoryEvent" },
{ "supportsArgsCanBeInterpretedByShell" },
{ "supportsStartDebuggingRequest" },
];
}
ClientCapabilities client;

// NOTE: Set to true when server supports
struct ServerCapabilities
{
Capability[] capabilities = [
{ "supportsConfigurationDoneRequest" },
{ "supportsFunctionBreakpoints" },
{ "supportsConditionalBreakpoints" },
{ "supportsHitConditionalBreakpoints" },
{ "supportsEvaluateForHovers" },
{ "supportsStepBack" },
{ "supportsSetVariable" },
{ "supportsRestartFrame" },
{ "supportsGotoTargetsRequest" },
{ "supportsStepInTargetsRequest" },
{ "supportsCompletionsRequest" },
{ "supportsModulesRequest" },
{ "supportsExceptionOptions" },
{ "supportsValueFormattingOptions" },
{ "supportsExceptionInfoRequest" },
{ "supportTerminateDebuggee" },
{ "supportSuspendDebuggee" },
{ "supportsDelayedStackTraceLoading" },
{ "supportsLoadedSourcesRequest" },
{ "supportsLogPoints" },
{ "supportsTerminateThreadsRequest" },
{ "supportsSetExpression" },
{ "supportsTerminateRequest" },
{ "supportsDataBreakpoints" },
{ "supportsReadMemoryRequest" },
{ "supportsWriteMemoryRequest" },
{ "supportsDisassembleRequest" },
{ "supportsCancelRequest" },
{ "supportsBreakpointLocationsRequest" },
{ "supportsClipboardContext" },
{ "supportsSteppingGranularity" },
{ "supportsInstructionBreakpoints" },
{ "supportsExceptionFilterOptions" },
{ "supportsSingleThreadExecutionRequests" },
];
}
ServerCapabilities server;
}
Loading

0 comments on commit 38ec3c7

Please sign in to comment.