Skip to content

Commit 2cd6095

Browse files
committed
fix launch debugger
1 parent 8f59c59 commit 2cd6095

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/launchDebugger.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as path from 'path';
77
import * as vscode from 'vscode';
88
import { log } from './log';
99
import * as utils from './utils';
10-
import { config } from './config';
10+
import { config as settings } from './config';
1111
import { Option } from './option';
1212
import * as process from './process';
1313

@@ -40,7 +40,7 @@ async function getDebuggableTargets(): Promise<Array<string>> {
4040
let targets = "";
4141
let getTargetsPathScript = utils.getAssetsScriptPath("debuggable_targets.lua");
4242
if (fs.existsSync(getTargetsPathScript)) {
43-
targets = (await process.iorunv(config.executable, ["l", getTargetsPathScript], { "COLORTERM": "nocolor" }, config.workingDirectory)).stdout.trim();
43+
targets = (await process.iorunv(settings.executable, ["l", getTargetsPathScript], { "COLORTERM": "nocolor" }, settings.workingDirectory)).stdout.trim();
4444
}
4545
if (targets) {
4646
return process.getAnnotatedJSON(targets)[0];
@@ -57,7 +57,7 @@ async function getInformations(targetName: string): Promise<TargetInformations>
5757
let getTargetInformationsScript = utils.getAssetsScriptPath("target_informations.lua");
5858
if (fs.existsSync(getTargetInformationsScript)) {
5959
try {
60-
const result = await process.iorunv(config.executable, ["l", getTargetInformationsScript, targetName], { "COLORTERM": "nocolor" }, config.workingDirectory);
60+
const result = await process.iorunv(settings.executable, ["l", getTargetInformationsScript, targetName], { "COLORTERM": "nocolor" }, settings.workingDirectory);
6161
const targetInformations = result.stdout.trim();
6262

6363
if (targetInformations) {
@@ -86,7 +86,7 @@ async function findGdbPath(): Promise<string> {
8686
let gdbPath = "";
8787
let findGdbScript = utils.getAssetsScriptPath("find_gdb.lua");
8888
if (fs.existsSync(findGdbScript)) {
89-
gdbPath = (await process.iorunv(config.executable, ["l", findGdbScript], { "COLORTERM": "nocolor" }, config.workingDirectory)).stdout.trim();
89+
gdbPath = (await process.iorunv(settings.executable, ["l", findGdbScript], { "COLORTERM": "nocolor" }, settings.workingDirectory)).stdout.trim();
9090
if (gdbPath) {
9191
gdbPath = gdbPath.split('\n')[0].trim();
9292
}
@@ -211,24 +211,24 @@ class XmakeConfigurationProvider implements vscode.DebugConfigurationProvider {
211211
if (!config.args) {
212212
let args = [];
213213

214-
if (config.debuggingTargetsArguments && config.target in config.debuggingTargetsArguments)
215-
args = config.debuggingTargetsArguments[config.target];
216-
else if (config.debuggingTargetsArguments && "default" in config.debuggingTargetsArguments)
217-
args = config.debuggingTargetsArguments["default"];
218-
else if (config.runningTargetsArguments && config.target in config.runningTargetsArguments)
219-
args = config.runningTargetsArguments[config.target];
220-
else if (config.runningTargetsArguments && "default" in config.runningTargetsArguments)
221-
args = config.runningTargetsArguments["default"];
214+
if (settings.debuggingTargetsArguments && config.target in settings.debuggingTargetsArguments)
215+
args = settings.debuggingTargetsArguments[config.target];
216+
else if (settings.debuggingTargetsArguments && "default" in settings.debuggingTargetsArguments)
217+
args = settings.debuggingTargetsArguments["default"];
218+
else if (settings.runningTargetsArguments && config.target in settings.runningTargetsArguments)
219+
args = settings.runningTargetsArguments[config.target];
220+
else if (settings.runningTargetsArguments && "default" in settings.runningTargetsArguments)
221+
args = settings.runningTargetsArguments["default"];
222222

223223
config.args = args;
224224
}
225225

226226
// Get xmake env and merge it with config envs
227227
const sep = os.platform() == "win32" ? ';' : ':'
228228
let xmakeEnvs = targetInformations.envs;
229-
if (config.envBehaviour === 'override') {
229+
if (settings.envBehaviour === 'override') {
230230
config.env = { ...xmakeEnvs, ...config.env };
231-
} else if (config.envBehaviour === 'merge' && config.env !== undefined) {
231+
} else if (settings.envBehaviour === 'merge' && config.env !== undefined) {
232232
// Merge behaviour between xmake envs and launch.json envs
233233
for (const key in xmakeEnvs) {
234234
// If the key exist in debug envs
@@ -254,7 +254,7 @@ class XmakeConfigurationProvider implements vscode.DebugConfigurationProvider {
254254
}
255255

256256
// Switch to lldb if needed
257-
if (config.debugConfigType == "codelldb") {
257+
if (settings.debugConfigType == "codelldb") {
258258
config.type = 'lldb';
259259
config.stopOnEntry = config.stopAtEntry;
260260
// Code LLDB doesn't support newExternal
@@ -270,7 +270,7 @@ class XmakeConfigurationProvider implements vscode.DebugConfigurationProvider {
270270
}
271271

272272
// Switch to LLDB DAP if needed
273-
if (config.debugConfigType == "lldb-dap") {
273+
if (settings.debugConfigType == "lldb-dap") {
274274
config.type = 'lldb-dap';
275275
config.stopOnEntry = config.stopOnEntry;
276276
// LLDB DAP doesn't support newExternal
@@ -286,7 +286,7 @@ class XmakeConfigurationProvider implements vscode.DebugConfigurationProvider {
286286
}
287287

288288
// Switch to GDB DAP if needed
289-
if (config.debugConfigType == "gdb-dap") {
289+
if (settings.debugConfigType == "gdb-dap") {
290290
config.type = 'gdb';
291291
config.stopOnEntry = config.stopOnEntry;
292292
// GDB DAP doesn't support newExternal
@@ -330,7 +330,7 @@ class XmakeConfigurationProvider implements vscode.DebugConfigurationProvider {
330330
config = { ...config, ...setupCommands };
331331

332332
// Merge the custom debug config with actual config
333-
config = { ...config, ...config.customDebugConfig };
333+
config = { ...config, ...settings.customDebugConfig };
334334

335335
return config;
336336
}
@@ -348,10 +348,10 @@ export function initDebugger(context: vscode.ExtensionContext, option: Option) {
348348
}
349349

350350
// Check if the configured debugger is available
351-
if (config.debugConfigType == "lldb-dap" && !lldbdap) {
351+
if (settings.debugConfigType == "lldb-dap" && !lldbdap) {
352352
log.info("LLDB DAP is configured but not available, falling back to available debuggers");
353353
}
354-
if (config.debugConfigType == "codelldb" && !codelldb) {
354+
if (settings.debugConfigType == "codelldb" && !codelldb) {
355355
log.info("CodeLLDB is configured but not available, falling back to available debuggers");
356356
}
357357

@@ -362,4 +362,4 @@ export function initDebugger(context: vscode.ExtensionContext, option: Option) {
362362

363363
const provider = new XmakeConfigurationProvider(option);
364364
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('xmake', provider, vscode.DebugConfigurationProviderTriggerKind.Dynamic));
365-
}
365+
}

0 commit comments

Comments
 (0)