Merge pull request +15696 from c9/pull/core/455

rewriting gdbshim when updated
pull/333/merge
Harutyun Amirjanyan 2017-10-05 23:10:51 +04:00 zatwierdzone przez GitHub
commit f924015491
1 zmienionych plików z 18 dodań i 7 usunięć

Wyświetl plik

@ -27,13 +27,16 @@ define(function(require, exports, module) {
var Path = require("path");
var GDBProxyService = require("./lib/GDBProxyService");
/***** Initialization *****/
var plugin = new Plugin("CS50", main.consumes);
var emit = plugin.getEmitter();
emit.setMaxListeners(1000);
// increment when shim is updated to force rewrite
var SHIM_VERSION = 1;
var TYPE = "gdb";
var attached = false;
@ -58,21 +61,29 @@ define(function(require, exports, module) {
["autoshow", "true"]
]);
});
// must register ASAP, or debugger won't be ready for reconnects
debug.registerDebugger(TYPE, plugin);
// writeFile root is workspace directory, unless given ~
var shimPath = "~/.c9/bin/c9gdbshim.js";
var shimVersion = "~/.c9/bin/.c9gdbshim" + SHIM_VERSION;
var shim = require("text!./shim.js");
fs.exists(shimPath, function(exists) {
if (exists) return; // TODO use localfs extend when it is ready
fs.writeFile(shimPath, shim, "utf8", function(err) {
fs.exists(shimVersion, function(exists) {
if (exists)
return;
fs.writeFile("~/.c9/bin/c9gdbshim.js", shim, "utf8", function(err) {
if (err) {
// unregister the debugger on error
debug.unregisterDebugger(TYPE, plugin);
return console.log("Error writing gdb shim: " + err);
}
// remember we wrote current version
fs.writeFile(shimVersion, "", function(err) {
if (err)
return console.log("Error writing shim version: " + err);
});
});
});
}