From dddb775c17f32b30ca3b6644c4ec29c06b4d6f6f Mon Sep 17 00:00:00 2001 From: Basant-khalil Date: Sat, 22 Jul 2023 11:40:22 -0400 Subject: [PATCH] add commands in the extension.js for printing logging messages to track the status of the extension attaching --- .vscode/launch.json | 13 +++++++ cider-dap/calyxDebug/extension.js | 65 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 cider-dap/calyxDebug/extension.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 116775c4d9..ba8d2186dc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,19 @@ { "version": "0.2.0", "configurations": [ + { + "type": "cider-dap", + "request": "launch", + "name": "Launch Program (Single Session)", + "program": "/AskForProgramName", + "stopOnEntry": true + }, + { + "type": "cider-dap", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/Program" + }, { "name": "Python: Current File", "type": "python", diff --git a/cider-dap/calyxDebug/extension.js b/cider-dap/calyxDebug/extension.js new file mode 100644 index 0000000000..afdb96246b --- /dev/null +++ b/cider-dap/calyxDebug/extension.js @@ -0,0 +1,65 @@ +const vscode = require('vscode'); +const cp = require('child_process'); + +let outputChannel; + +function startDebugging() { + // After attaching and starting debugging, call the panel printing function + logToPanel('Debugger attached and debugging started.'); + logToPanel('Some additional information...'); +} + +function logToPanel(message) { + // Create an output channel + if (!outputChannel) { + outputChannel = vscode.window.createOutputChannel('Cider DAP'); + } + + // Log the message to the output channel + outputChannel.appendLine(message); + + // Show the message in the panel as well + vscode.window.showInformationMessage(message); +} + +function activate(context) { + // Create the outputChannel only once when the extension activates + outputChannel = vscode.window.createOutputChannel('Cider DAP'); + + // Register a command to start debugging + const disposableStartDebugging = vscode.commands.registerCommand('extension.cider-dap.startDebugging', startDebugging); + context.subscriptions.push(disposableStartDebugging); + + // Register a command for testing purposes + const disposableTest = vscode.commands.registerCommand('extension.cider-dap.test', function () { + // The code you want to run when the command is executed + + // Log to the output channel + logToPanel('Executing extension.cider-dap.test'); + + // Listen for stdout data + const proc = cp.spawn('your_command_here', ['arg1', 'arg2']); // Replace 'your_command_here' with the actual command to be executed + proc.stdout.on('data', (data) => { + logToPanel(`stdout: ${data}`); + }); + + // Listen for stderr data + proc.stderr.on('data', (data) => { + logToPanel(`stderr: ${data}`); + }); + + // Listen for close event + proc.on('close', (code) => { + logToPanel(`child process exited with code ${code}`); + }); + }); + + context.subscriptions.push(disposableTest); +} + +function deactivate() { } + +module.exports = { + activate, + deactivate +};