Bug 1294915 - Rewrite locations to URLs, r=jonco

MozReview-Commit-ID: ag7GgVmpxE

--HG--
extra : rebase_source : 15594fe7d6e7e5eaf849c5f54c9410b3ae864ab7
This commit is contained in:
Steve Fink 2017-04-13 15:51:25 -07:00
Родитель 9fcb90d900
Коммит 4bc841bcc2
3 изменённых файлов: 105 добавлений и 3 удалений

Просмотреть файл

@ -631,6 +631,37 @@ function elapsedTime()
return "[" + seconds.toFixed(2) + "s] ";
}
var options = parse_options([
{
name: '--strip-prefix',
default: os.getenv('SOURCE') || '',
type: 'string'
},
{
name: '--add-prefix',
default: os.getenv('URLPREFIX') || '',
type: 'string'
},
{
name: '--verbose',
type: 'bool'
},
]);
function add_trailing_slash(str) {
if (str == '')
return str;
return str.endsWith("/") ? str : str + "/";
}
var removePrefix = add_trailing_slash(options.strip_prefix);
var addPrefix = add_trailing_slash(options.add_prefix);
if (options.verbose) {
printErr(`Removing prefix ${removePrefix} from paths`);
printErr(`Prepending ${addPrefix} to paths`);
}
print(elapsedTime() + "Loading types...");
loadTypes('src_comp.xdb');
print(elapsedTime() + "Starting analysis...");
@ -762,6 +793,11 @@ function processAssign(entry, location, lhs, edge)
dumpError(entry, location, "Unknown assignment " + JSON.stringify(lhs));
}
function get_location(rawLocation) {
const filename = rawLocation.CacheString.replace(removePrefix, '');
return addPrefix + filename + "#" + rawLocation.Line;
}
function process(entry, body, addCallee)
{
if (!("PEdge" in body))
@ -794,8 +830,7 @@ function process(entry, body, addCallee)
if (!(edge.Index[0] in nonMainThreadPoints))
continue;
var rawLocation = body.PPoint[edge.Index[0] - 1].Location;
var location = rawLocation.CacheString + ":" + rawLocation.Line;
var location = get_location(body.PPoint[edge.Index[0] - 1].Location);
var callees = getCallees(edge);
for (var callee of callees) {

Просмотреть файл

@ -51,6 +51,70 @@ function xprint(x, padding)
}
}
function parse_options(parameters, inArgs = scriptArgs) {
const options = {};
const optional = {};
const positional = [];
for (const param of parameters) {
if (param.name.startsWith("-")) {
optional[param.name] = param;
param.dest = param.dest || param.name.substring(2).replace("-", "_");
} else {
positional.push(param);
param.dest = param.dest || param.name.replace("-", "_");
}
param.type = param.type || 'bool';
if ('default' in param)
options[param.dest] = param.default;
}
options.rest = [];
const args = [...inArgs];
while (args.length > 0) {
let param;
let pos = -1;
if (args[0] in optional)
param = optional[args[0]];
else {
pos = args[0].indexOf("=");
if (pos != -1) {
param = optional[args[0].substring(0, pos)];
pos++;
}
}
if (!param) {
if (positional.length > 0) {
param = positional.shift();
options[param.dest] = args.shift();
} else {
options.rest.push(args.shift());
}
continue;
}
if (param.type != 'bool') {
if (pos != -1) {
options[param.dest] = args.shift().substring(pos);
} else {
args.shift();
if (args.length == 0)
throw(new Error(`--${param.name} requires an argument`));
options[param.dest] = args.shift();
}
} else {
if (pos != -1)
throw(new Error(`--${param.name} does not take an argument`));
options[param.dest] = true;
args.shift();
}
}
return options;
}
function sameBlockId(id0, id1)
{
if (id0.Kind != id1.Kind)

Просмотреть файл

@ -70,12 +70,15 @@ sixgill = "$TOOLTOOL_DIR/sixgill/usr/libexec/sixgill"
sixgill_bin = "$TOOLTOOL_DIR/sixgill/usr/bin"
EOF
local rev
rev=$(cd $GECKO_DIR && hg log -r . -T '{node|short}')
cat > run-analysis.sh <<EOF
#!/bin/sh
if [ \$# -eq 0 ]; then
set gcTypes
fi
export ANALYSIS_SCRIPTDIR="$ANALYSIS_SRCDIR"
export URLPREFIX="https://hg.mozilla.org/mozilla-unified/file/$rev/"
exec "$ANALYSIS_SRCDIR/analyze.py" "\$@"
EOF
chmod +x run-analysis.sh
@ -111,7 +114,7 @@ function grab_artifacts () {
# Do not error out if no files found
shopt -s nullglob
set +e
for f in *.txt *.lst; do
for f in *.txt *.lst run-analysis.sh; do
gzip -9 -c "$f" > "${artifacts}/$f.gz"
done