@@ -92,6 +92,21 @@ async function getDAPExecutable(
9292 return undefined ;
9393}
9494
95+ function getDAPArguments ( session : vscode . DebugSession ) : string [ ] {
96+ // Check the debug configuration for arguments first
97+ const debugConfigArgs = session . configuration . debugAdapterArgs ;
98+ if (
99+ Array . isArray ( debugConfigArgs ) &&
100+ debugConfigArgs . findIndex ( ( entry ) => typeof entry !== "string" ) === - 1
101+ ) {
102+ return debugConfigArgs ;
103+ }
104+ // Fall back on the workspace configuration
105+ return vscode . workspace
106+ . getConfiguration ( "lldb-dap" )
107+ . get < string [ ] > ( "arguments" , [ ] ) ;
108+ }
109+
95110/**
96111 * This class defines a factory used to find the lldb-dap binary to use
97112 * depending on the session configuration.
@@ -101,7 +116,7 @@ export class LLDBDapDescriptorFactory
101116{
102117 async createDebugAdapterDescriptor (
103118 session : vscode . DebugSession ,
104- executable : vscode . DebugAdapterExecutable | undefined ,
119+ _executable : vscode . DebugAdapterExecutable | undefined ,
105120 ) : Promise < vscode . DebugAdapterDescriptor | undefined > {
106121 const config = vscode . workspace . getConfiguration (
107122 "lldb-dap" ,
@@ -116,40 +131,31 @@ export class LLDBDapDescriptorFactory
116131 const configEnvironment =
117132 config . get < { [ key : string ] : string } > ( "environment" ) || { } ;
118133 const dapPath = await getDAPExecutable ( session ) ;
134+ const dapArgs = getDAPArguments ( session ) ;
119135 const dbgOptions = {
120136 env : {
121- ...executable ?. options ?. env ,
122137 ...configEnvironment ,
123138 ...env ,
124139 } ,
125140 } ;
126- if ( dapPath ) {
127- if ( ! ( await isExecutable ( dapPath ) ) ) {
128- LLDBDapDescriptorFactory . showLLDBDapNotFoundMessage ( dapPath ) ;
129- return undefined ;
130- }
131- return new vscode . DebugAdapterExecutable ( dapPath , [ ] , dbgOptions ) ;
132- } else if ( executable ) {
133- if ( ! ( await isExecutable ( executable . command ) ) ) {
134- LLDBDapDescriptorFactory . showLLDBDapNotFoundMessage ( executable . command ) ;
135- return undefined ;
136- }
137- return new vscode . DebugAdapterExecutable (
138- executable . command ,
139- executable . args ,
140- dbgOptions ,
141- ) ;
141+ if ( dapPath === undefined || ! ( await isExecutable ( dapPath ) ) ) {
142+ LLDBDapDescriptorFactory . showLLDBDapNotFoundMessage ( dapPath ) ;
143+ return undefined ;
142144 }
143- return undefined ;
145+ return new vscode . DebugAdapterExecutable ( dapPath , dapArgs , dbgOptions ) ;
144146 }
145147
146148 /**
147149 * Shows a message box when the debug adapter's path is not found
148150 */
149- static async showLLDBDapNotFoundMessage ( path : string ) {
151+ static async showLLDBDapNotFoundMessage ( path : string | undefined ) {
150152 const openSettingsAction = "Open Settings" ;
153+ const message =
154+ path === undefined
155+ ? "Unable to find the LLDB debug adapter executable."
156+ : `Debug adapter path: ${ path } is not a valid file` ;
151157 const callbackValue = await vscode . window . showErrorMessage (
152- `Debug adapter path: ${ path } is not a valid file` ,
158+ message ,
153159 openSettingsAction ,
154160 ) ;
155161
0 commit comments