Browse Source

Demangle *after* parsing ASM.

This means the ASM parser sees "simpler" mangled names, which makes its
primitive RegExp-based parser much simpler and more correct. Once we've
extracted labels etc, we can demangle the symbols.

This should address #193
dev/git-series/gccdum
Matt Godbolt 6 years ago
parent
commit
b3d56fb935
  1. 1
      app.js
  2. 3
      etc/config/c++.defaults.properties
  3. 43
      lib/compile.js

1
app.js

@ -328,6 +328,7 @@ function findCompilers() {
versionFlag: props("versionFlag"),
versionRe: props("versionRe"),
compilerType: props("compilerType", ""),
demangler: props("demangler", ""),
intelAsm: props("intelAsm", ""),
needsMulti: !!props("needsMulti", true),
supportsBinary: !!props("supportsBinary", true),

3
etc/config/c++.defaults.properties

@ -2,7 +2,8 @@
compilers=/usr/bin/g++-4.4:/usr/bin/g++-4.5:/usr/bin/g++-4.6:/usr/bin/g++-4.7:/usr/bin/clang++:/usr/bin/g++
defaultCompiler=/usr/bin/g++
compileFilename=example.cpp
postProcess=c++filt
postProcess=
demangler=c++filt
#androidNdk=/opt/google/android-ndk-r9c
options=
supportsBinary=true

43
lib/compile.js

@ -190,20 +190,38 @@ Compile.prototype.compile = function (source, options, filters) {
});
return self.env.enqueue(function () {
return compileToAsmPromise.then(function (result) {
if (result.dirPath) {
fs.remove(result.dirPath);
result.dirPath = undefined;
}
if (result.okToCache) {
result.asm = asm.processAsm(result.asm, filters);
self.env.cachePut(key, result);
} else {
result.asm = {text: result.asm};
}
return compileToAsmPromise
.then(function (result) {
if (result.dirPath) {
fs.remove(result.dirPath);
result.dirPath = undefined;
}
if (result.okToCache) {
result.asm = asm.processAsm(result.asm, filters);
} else {
result.asm = {text: result.asm};
}
return result;
})
.then(_.bind(self.postProcessAsm, self))
.then(function (result) {
if (result.okToCache) self.env.cachePut(key, result);
return result;
});
});
};
Compile.prototype.postProcessAsm = function (result) {
if (!result.okToCache) return result;
var demangler = this.compiler.demangler;
if (!demangler) return result;
return this.exec(demangler, [], {input: _.pluck(result.asm, 'text').join("\n")})
.then(function (demangleResult) {
var lines = utils.splitLines(demangleResult.stdout);
for (var i = 0; i < result.asm.length; ++i)
result.asm[i].text = lines[i];
return result;
});
});
};
Compile.prototype.postProcess = function (result, outputFilename, filters) {
@ -321,6 +339,7 @@ Compile.prototype.exec = function (command, args, options) {
});
}, 0);
});
if (options.input) child.stdin.write(options.input);
child.stdin.end();
});
};

Loading…
Cancel
Save