@@ -18,26 +18,29 @@ import { DebugProtocol } from '@vscode/debugprotocol';
1818import * as vscode from 'vscode' ;
1919import { isDebugRequest , isDebugResponse } from '../../common/debug-requests' ;
2020import { VariableRange } from '../../common/memory-range' ;
21- import { ReadMemoryArguments , ReadMemoryResult , WriteMemoryArguments , WriteMemoryResult } from '../../common/messaging' ;
21+ import { ConnectionContext , ReadMemoryArguments , ReadMemoryResult ,
22+ WriteMemoryArguments , WriteMemoryResult } from '../../common/messaging' ;
2223import { MemoryDisplaySettingsContribution } from '../../common/webview-configuration' ;
2324import { Logger } from '../logger' ;
2425
2526/** Represents capabilities that may be achieved with particular debug adapters but are not part of the DAP */
2627export interface AdapterCapabilities {
2728 /** Resolve variables known to the adapter to their locations. Fallback if {@link getResidents} is not present */
28- getVariables ?( session : vscode . DebugSession ) : Promise < VariableRange [ ] > ;
29+ getVariables ?( session : vscode . DebugSession , context ?: ConnectionContext ) : Promise < VariableRange [ ] > ;
2930 /** Resolve symbols resident in the memory at the specified range. Will be preferred to {@link getVariables} if present. */
30- getResidents ?( session : vscode . DebugSession , params : DebugProtocol . ReadMemoryArguments ) : Promise < VariableRange [ ] > ;
31+ getResidents ?( session : vscode . DebugSession , params : DebugProtocol . ReadMemoryArguments , context ?: ConnectionContext ) : Promise < VariableRange [ ] > ;
3132 /** Resolves the address of a given variable in bytes with the current context. */
32- getAddressOfVariable ?( session : vscode . DebugSession , variableName : string ) : Promise < string | undefined > ;
33+ getAddressOfVariable ?( session : vscode . DebugSession , variableName : string , context ?: ConnectionContext ) : Promise < string | undefined > ;
3334 /** Resolves the size of a given variable in bytes within the current context. */
34- getSizeOfVariable ?( session : vscode . DebugSession , variableName : string ) : Promise < bigint | undefined > ;
35+ getSizeOfVariable ?( session : vscode . DebugSession , variableName : string , context ?: ConnectionContext ) : Promise < bigint | undefined > ;
3536 /** Retrieve the suggested default display settings for the memory view. */
3637 getMemoryDisplaySettings ?( session : vscode . DebugSession ) : Promise < Partial < MemoryDisplaySettingsContribution > > ;
3738 /** Initialize the trackers of this adapter's for the debug session. */
3839 initializeAdapterTracker ?( session : vscode . DebugSession ) : vscode . DebugAdapterTracker | undefined ;
39- readMemory ?( session : vscode . DebugSession , params : ReadMemoryArguments ) : Promise < ReadMemoryResult > ;
40- writeMemory ?( session : vscode . DebugSession , params : WriteMemoryArguments ) : Promise < WriteMemoryResult > ;
40+ readMemory ?( session : vscode . DebugSession , params : ReadMemoryArguments , context ?: ConnectionContext ) : Promise < ReadMemoryResult > ;
41+ writeMemory ?( session : vscode . DebugSession , params : WriteMemoryArguments , context ?: ConnectionContext ) : Promise < WriteMemoryResult > ;
42+ getConnectionContexts ?( session : vscode . DebugSession ) : Promise < ConnectionContext [ ] > ;
43+ getCurrentConnectionContext ?( session : vscode . DebugSession ) : Promise < ConnectionContext | undefined > ;
4144}
4245
4346export type WithChildren < Original > = Original & { children ?: Array < WithChildren < DebugProtocol . Variable > > } ;
@@ -108,14 +111,14 @@ export class AdapterVariableTracker implements vscode.DebugAdapterTracker {
108111 this . pendingMessages . clear ( ) ;
109112 }
110113
111- async getLocals ( session : vscode . DebugSession ) : Promise < VariableRange [ ] > {
114+ async getLocals ( session : vscode . DebugSession , context ?: ConnectionContext ) : Promise < VariableRange [ ] > {
112115 this . logger . debug ( 'Retrieving local variables in' , session . name + ' Current variables:\n' , this . variablesTree ) ;
113116 if ( this . currentFrame === undefined ) { return [ ] ; }
114117 const maybeRanges = await Promise . all ( Object . values ( this . variablesTree ) . reduce < Array < Promise < VariableRange | undefined > > > ( ( previous , parent ) => {
115118 if ( this . isDesiredVariable ( parent ) && parent . children ?. length ) {
116119 this . logger . debug ( 'Resolving children of' , parent . name ) ;
117120 parent . children . forEach ( child => {
118- previous . push ( this . variableToVariableRange ( child , session ) ) ;
121+ previous . push ( this . variableToVariableRange ( child , session , context ) ) ;
119122 } ) ;
120123 } else {
121124 this . logger . debug ( 'Ignoring' , parent . name ) ;
@@ -129,19 +132,23 @@ export class AdapterVariableTracker implements vscode.DebugAdapterTracker {
129132 return candidate . presentationHint !== 'registers' && candidate . name !== 'Registers' ;
130133 }
131134
132- protected variableToVariableRange ( _variable : DebugProtocol . Variable , _session : vscode . DebugSession ) : Promise < VariableRange | undefined > {
135+ protected variableToVariableRange ( _variable : DebugProtocol . Variable , _session : vscode . DebugSession ,
136+ _context ?: ConnectionContext ) : Promise < VariableRange | undefined > {
133137 throw new Error ( 'To be implemented by derived classes!' ) ;
134138 }
135139
136140 /** Resolves the address of a given variable in bytes within the current context. */
137- getAddressOfVariable ?( variableName : string , session : vscode . DebugSession ) : Promise < string | undefined > ;
141+ getAddressOfVariable ?( variableName : string , session : vscode . DebugSession , context ?: ConnectionContext ) : Promise < string | undefined > ;
138142
139143 /** Resolves the size of a given variable in bytes within the current context. */
140- getSizeOfVariable ?( variableName : string , session : vscode . DebugSession ) : Promise < bigint | undefined > ;
144+ getSizeOfVariable ?( variableName : string , session : vscode . DebugSession , context ?: ConnectionContext ) : Promise < bigint | undefined > ;
141145
142- readMemory ?( session : vscode . DebugSession , params : ReadMemoryArguments ) : Promise < ReadMemoryResult > ;
146+ readMemory ?( session : vscode . DebugSession , params : ReadMemoryArguments , context ?: ConnectionContext ) : Promise < ReadMemoryResult > ;
143147
144- writeMemory ?( session : vscode . DebugSession , params : WriteMemoryArguments ) : Promise < WriteMemoryResult > ;
148+ writeMemory ?( session : vscode . DebugSession , params : WriteMemoryArguments , context ?: ConnectionContext ) : Promise < WriteMemoryResult > ;
149+
150+ getConnectionContexts ?( session : vscode . DebugSession ) : Promise < ConnectionContext [ ] > ;
151+ getCurrentConnectionContext ?( session : vscode . DebugSession ) : Promise < ConnectionContext | undefined > ;
145152}
146153
147154export class VariableTracker implements AdapterCapabilities {
@@ -163,15 +170,15 @@ export class VariableTracker implements AdapterCapabilities {
163170 }
164171 }
165172
166- async getVariables ( session : vscode . DebugSession ) : Promise < VariableRange [ ] > {
167- return this . sessions . get ( session . id ) ?. getLocals ( session ) ?? [ ] ;
173+ async getVariables ( session : vscode . DebugSession , context ?: ConnectionContext ) : Promise < VariableRange [ ] > {
174+ return this . sessions . get ( session . id ) ?. getLocals ( session , context ) ?? [ ] ;
168175 }
169176
170- async getAddressOfVariable ( session : vscode . DebugSession , variableName : string ) : Promise < string | undefined > {
171- return this . sessions . get ( session . id ) ?. getAddressOfVariable ?.( variableName , session ) ;
177+ async getAddressOfVariable ( session : vscode . DebugSession , variableName : string , context ?: ConnectionContext ) : Promise < string | undefined > {
178+ return this . sessions . get ( session . id ) ?. getAddressOfVariable ?.( variableName , session , context ) ;
172179 }
173180
174- async getSizeOfVariable ( session : vscode . DebugSession , variableName : string ) : Promise < bigint | undefined > {
175- return this . sessions . get ( session . id ) ?. getSizeOfVariable ?.( variableName , session ) ;
181+ async getSizeOfVariable ( session : vscode . DebugSession , variableName : string , context ?: ConnectionContext ) : Promise < bigint | undefined > {
182+ return this . sessions . get ( session . id ) ?. getSizeOfVariable ?.( variableName , session , context ) ;
176183 }
177184}
0 commit comments