First commit

This commit is contained in:
2026-03-29 18:36:02 +02:00
commit eb123a60cb
7 changed files with 209 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
adapter/node_modules/*

14
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}

80
adapter/debugAdapter.js Normal file
View File

@@ -0,0 +1,80 @@
const {
LoggingDebugSession,
InitializedEvent,
TerminatedEvent,
OutputEvent
} = require('vscode-debugadapter');
const { spawn } = require('child_process');
class MyLuaDebugSession extends LoggingDebugSession {
constructor() {
super("myLuaDebug.txt");
this.setDebuggerLinesStartAt1(true);
this.setDebuggerColumnsStartAt1(true);
}
initializeRequest(response, args) {
this.sendEvent(new InitializedEvent());
this.sendResponse(response);
}
launchRequest(response, args) {
const program = args.program;
const cwd = args.cwd || process.cwd();
this.process = spawn(program, [], {
cwd: cwd,
stdio: ['ignore', 'pipe', 'pipe']
});
this.process.stdout.on('data', data => {
const text = data.toString();
if (text.startsWith("@@DEBUG@@")) {
const json = JSON.parse(text.substring(9));
if (json.type === "luaError") {
const e = new OutputEvent(json.message + "\n", "stderr");
e.body.source = { path: json.file };
e.body.line = json.line;
this.sendEvent(e);
}
return;
}
// salida normal
this.sendEvent(new OutputEvent(text, "stdout"));
});
this.process.stderr.on('data', data => {
this.sendEvent(new OutputEvent(data.toString(), "stderr"));
});
this.process.on('exit', () => {
this.sendEvent(new TerminatedEvent());
});
this.sendResponse(response);
}
setBreakPointsRequest(response, args) {
const path = args.source.path;
const bps = args.breakpoints.map(bp => bp.line);
// Guardamos los breakpoints internamente
this.breakpoints[path] = bps;
// Enviar confirmación a VSCode
response.body = {
breakpoints: bps.map(line => ({ verified: true, line }))
};
this.sendResponse(response);
}
}
new MyLuaDebugSession().start(process.stdin, process.stdout);

46
adapter/package-lock.json generated Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "mini-adapter",
"version": "0.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "mini-adapter",
"version": "0.0.1",
"dependencies": {
"vscode-debugadapter": "^1.51.0",
"vscode-debugprotocol": "^1.51.0"
}
},
"node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"license": "MIT",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/vscode-debugadapter": {
"version": "1.51.0",
"resolved": "https://registry.npmjs.org/vscode-debugadapter/-/vscode-debugadapter-1.51.0.tgz",
"integrity": "sha512-mObaXD5/FH/z6aL2GDuyCLbnwLsYRCAJWgFid01vKW9Y5Si8OvINK+Tn+Yl/lRUbetjNuZW3j1euMEz6z8Yzqg==",
"deprecated": "This package has been renamed to @vscode/debugadapter, please update to the new name",
"license": "MIT",
"dependencies": {
"mkdirp": "^1.0.4",
"vscode-debugprotocol": "1.51.0"
}
},
"node_modules/vscode-debugprotocol": {
"version": "1.51.0",
"resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.51.0.tgz",
"integrity": "sha512-dzKWTMMyebIMPF1VYMuuQj7gGFq7guR8AFya0mKacu+ayptJfaRuM0mdHCqiOth4FnRP8mPhEroFPx6Ift8wHA==",
"deprecated": "This package has been renamed to @vscode/debugprotocol, please update to the new name",
"license": "MIT"
}
}
}

9
adapter/package.json Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "mini-adapter",
"version": "0.0.1",
"main": "debugAdapter.js",
"dependencies": {
"vscode-debugadapter": "^1.51.0",
"vscode-debugprotocol": "^1.51.0"
}
}

24
extension.js Normal file
View File

@@ -0,0 +1,24 @@
const vscode = require('vscode');
const path = require('path');
function activate(context) {
const factory = {
createDebugAdapterDescriptor(session, executable) {
const command = "node";
const args = [path.join(__dirname, "adapter", "debugAdapter.js")];
return new vscode.DebugAdapterExecutable(command, args);
}
};
const registration = vscode.debug.registerDebugAdapterDescriptorFactory(
"myLuaApp",
factory
);
context.subscriptions.push(registration);
}
function deactivate() {}
module.exports = { activate, deactivate };

35
package.json Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "mini-debugger",
"displayName": "Mini Debugger",
"description": "Debug Lua inside my C/C++ application",
"version": "0.0.1",
"publisher": "raimon",
"engines": {
"vscode": "^1.85.0"
},
"categories": ["Debuggers"],
"activationEvents": ["onDebug"],
"main": "./extension.js",
"contributes": {
"debuggers": [
{
"type": "myLuaApp",
"label": "Debug My Lua App",
"program": "./adapter/debugAdapter.js",
"runtime": "node",
"languages": ["lua"],
"configurationAttributes": {
"launch": {
"properties": {
"program": {
"type": "string",
"description": "Ruta a tu aplicación C/C++"
}
},
"required": ["program"]
}
}
}
]
}
}