diff --git a/src/frontend/extension.ts b/src/frontend/extension.ts index ca211a6..4c6fe0e 100644 --- a/src/frontend/extension.ts +++ b/src/frontend/extension.ts @@ -8,8 +8,7 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider("debugmemory", new MemoryContentProvider())); context.subscriptions.push(vscode.commands.registerCommand("code-debug.examineMemoryLocation", examineMemory)); context.subscriptions.push(vscode.commands.registerCommand("code-debug.getFileNameNoExt", () => { - if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) - { + if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) { vscode.window.showErrorMessage("No editor with valid file name active"); return; } @@ -18,8 +17,7 @@ export function activate(context: vscode.ExtensionContext) { return fileName.substr(0, fileName.length - ext.length); })); context.subscriptions.push(vscode.commands.registerCommand("code-debug.getFileBasenameNoExt", () => { - if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) - { + if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document || !vscode.window.activeTextEditor.document.fileName) { vscode.window.showErrorMessage("No editor with valid file name active"); return; } @@ -61,11 +59,19 @@ function getMemoryRange(range: string) { function examineMemory() { let socketlists = path.join(os.tmpdir(), "code-debug-sockets"); - if (!fs.existsSync(socketlists)) - return vscode.window.showErrorMessage("No debugging sessions available"); - fs.readdir(socketlists, (err, files) => { - if (err) + if (!fs.existsSync(socketlists)) { + if (process.platform == "win32") + return vscode.window.showErrorMessage("This command is not available on windows"); + else return vscode.window.showErrorMessage("No debugging sessions available"); + } + fs.readdir(socketlists, (err, files) => { + if (err) { + if (process.platform == "win32") + return vscode.window.showErrorMessage("This command is not available on windows"); + else + return vscode.window.showErrorMessage("No debugging sessions available"); + } var pickedFile = (file) => { vscode.window.showInputBox({ placeHolder: "Memory Location or Range", validateInput: range => getMemoryRange(range) === undefined ? "Range must either be in format 0xF00-0xF01, 0xF100+32 or 0xABC154" : "" }).then(range => { vscode.commands.executeCommand("vscode.previewHtml", vscode.Uri.parse("debugmemory://" + file + "#" + getMemoryRange(range))); @@ -75,6 +81,8 @@ function examineMemory() { pickedFile(files[0]); else if (files.length > 0) vscode.window.showQuickPick(files, { placeHolder: "Running debugging instance" }).then(file => pickedFile(file)); + else if (process.platform == "win32") + return vscode.window.showErrorMessage("This command is not available on windows"); else vscode.window.showErrorMessage("No debugging sessions available"); }); diff --git a/src/mibase.ts b/src/mibase.ts index 3342811..f0af6d8 100644 --- a/src/mibase.ts +++ b/src/mibase.ts @@ -65,13 +65,15 @@ export class MI2DebugSession extends DebugSession { }); }); this.commandServer.on("error", err => { - this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Error in command socket " + err.toString() + "\nCode-Debug WARNING: The examine memory location command won't work"); + if (process.platform != "win32") + this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Error in command socket " + err.toString() + "\nCode-Debug WARNING: The examine memory location command won't work"); }); if (!fs.existsSync(systemPath.join(os.tmpdir(), "code-debug-sockets"))) fs.mkdirSync(systemPath.join(os.tmpdir(), "code-debug-sockets")); this.commandServer.listen(systemPath.join(os.tmpdir(), "code-debug-sockets", "Debug-Instance-" + Math.floor(Math.random() * 36 * 36 * 36 * 36).toString(36))); } catch (e) { - this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Failed to start " + e.toString() + "\nCode-Debug WARNING: The examine memory location command won't work"); + if (process.platform != "win32") + this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Failed to start " + e.toString() + "\nCode-Debug WARNING: The examine memory location command won't work"); } }