Browse Source

removed logs

dev/git-series/gccdum
cppchedy 5 years ago
parent
commit
58ae9a972e
  1. 1
      bower.json
  2. 6
      lib/base-compiler.js
  3. 52
      lib/cfg.js

1
bower.json

@ -32,6 +32,5 @@
"big-integer": "https://github.com/peterolson/BigInteger.js.git#^1.6.22",
"file-saver": "filesaver#^1.3.3",
"vis": "4.20.1"
}
}

6
lib/base-compiler.js

@ -45,7 +45,6 @@ function Compile(compiler, env) {
this.asm = new asm.AsmParser(env.compilerProps);
this.cfg = new cfg.ControlFlowGraph({});
logger.log(cfg);
this.compiler.supportsIntel = !!this.compiler.intelAsm;
}
@ -231,8 +230,6 @@ Compile.prototype.compile = function (source, options, backendOptions, filters)
var astPromise;
if (backendOptions && backendOptions.produceAst) {
if (self.couldSupportASTDump(options, self.compiler.version)) {
console.log(options);
console.log(self.compiler);
astPromise = self.generateAST(inputFilename, options);
}
else {
@ -373,9 +370,6 @@ Compile.prototype.supportCFGGeneration = function(compilerVersion){
return (compilerVersion.indexOf("g++") === 0);
};
Compile.prototype.filtersAreSet = function(filters){
};
Compile.prototype.processAstOutput = function (output) {
output = output.stdout;

52
lib/cfg.js

@ -24,14 +24,14 @@
// POSSIBILITY OF SUCH DAMAGE.
var _ = require('underscore-node');
var _ = require('underscore-node'),
logger = require('./logger').logger;
function ControlFlowGraph(rules){
this.rules = rules;
}
function seperateCodeFromData(asmArr) {
function separateCodeFromData(asmArr) {
var isCode = function(asmArr, index){
return (((asmArr[index].source !== null) &&
@ -63,7 +63,7 @@ function seperateCodeFromData(asmArr) {
}
var gccX86 = {
filterData: seperateCodeFromData,
filterData: separateCodeFromData,
isFunctionEnd:function(x) { return ((x[0] != ' ') && (x[0] != '.') &&
(x.indexOf(':') != -1)) ;},
@ -190,36 +190,42 @@ ControlFlowGraph.prototype.splitToCanonicalBasicBlock = function (basicBlock) {
ControlFlowGraph.prototype.concatInstructions = function (asmArr, first, last) {
var makeShorter = function(instruction){
if(instruction.length > 50){
return instruction.substr(0, 50);
}
return instruction;
return instruction.substr(0, 50);
};
if(first == last) return "";//if last -1 is changed to last this line is no longuer needed
console.log("look");
var result = "";
//TODO: include \n for long templated instructions
while(first != last-1) {//added to delete last \n and handle the last concat outside loop
console.log(asmArr[first].text);
logger.debug(asmArr[first].text);
result += makeShorter(asmArr[first].text) + "\n";
++first;
}
//last concat withou \n
result += makeShorter(asmArr[first].text);
console.log(asmArr[first].text);
logger.debug(asmArr[first].text);
return result;
};
/*
*
* current function is buggy need investigation
ControlFlowGraph.prototype.concatInstructions = function (asmArr, first, last) {
return _.chain(asmArr.slice(first, last))
.map(function (x) { return x.text.substr(0, 50); }
.value()
.join("\n"));
};
*/
ControlFlowGraph.prototype.makeNodes = function (asmArr, arrOfCanonicalBasicBlock) {
var node = {};
var nodes = [];
_.each(arrOfCanonicalBasicBlock, _.bind(function(x){
console.log("node name:");
console.log(x.nameId);
logger.debug("node name:");
logger.debug(x.nameId);
node.id = x.nameId;
node.label = x.nameId + ((x.nameId.indexOf(":") !== -1)? "":":") +"\n"+
this.concatInstructions(asmArr,x.start, x.end);
@ -279,28 +285,28 @@ ControlFlowGraph.prototype.makeEdges = function (asmArr, arrOfCanonicalBasicBloc
//we have to deal only with jmp destination, jmp instruction are always taken.
//edge from jump inst
console.log("jmp");
logger.debug("jmp");
targetNode = extractNodeNameFromInstruction(lastInst);
setEdge(edge, x.nameId, targetNode, 'blue');
edges.push(JSON.parse(JSON.stringify(edge)));
console.log(edge);
logger.debug(edge);
}
break;
case conditionalJmpInst:
{
console.log("condit jmp");
logger.debug("condit jmp");
//deal with : branche taken, branch not taken
targetNode = extractNodeNameFromInstruction(lastInst);
setEdge(edge, x.nameId, targetNode, 'green');
edges.push(JSON.parse(JSON.stringify(edge)));
console.log(edge);
logger.debug(edge);
targetNode = hasName(asmArr,x)? asmArr[x.end].text: generateName(x.nameId, x.end);
setEdge(edge, x.nameId, targetNode, "red");
edges.push(JSON.parse(JSON.stringify(edge)));
console.log(edge);
logger.debug(edge);
}
break;
case notRetInst:
@ -311,17 +317,17 @@ ControlFlowGraph.prototype.makeEdges = function (asmArr, arrOfCanonicalBasicBloc
var nextNodeName = asmArr[x.end].text;
setEdge(edge, x.nameId, nextNodeName, 'grey');
edges.push(JSON.parse(JSON.stringify(edge)));
console.log("not ret inst");
console.log(edge);
logger.debug("not ret inst");
logger.debug(edge);
}
break;
default:
console.log("expect ret instruction or it's variants(rep ret): "+ lastInst);
logger.debug("expect ret instruction or it's variants(rep ret): "+ lastInst);
break;
}
});
console.log(edges);
logger.debug(edges);
return edges;
};

Loading…
Cancel
Save