mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 1294915 - Rewrite locations to URLs, r=jonco
MozReview-Commit-ID: ag7GgVmpxE --HG-- extra : rebase_source : 15594fe7d6e7e5eaf849c5f54c9410b3ae864ab7
This commit is contained in:
parent
9fcb90d900
commit
4bc841bcc2
@ -631,6 +631,37 @@ function elapsedTime()
|
|||||||
return "[" + seconds.toFixed(2) + "s] ";
|
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...");
|
print(elapsedTime() + "Loading types...");
|
||||||
loadTypes('src_comp.xdb');
|
loadTypes('src_comp.xdb');
|
||||||
print(elapsedTime() + "Starting analysis...");
|
print(elapsedTime() + "Starting analysis...");
|
||||||
@ -762,6 +793,11 @@ function processAssign(entry, location, lhs, edge)
|
|||||||
dumpError(entry, location, "Unknown assignment " + JSON.stringify(lhs));
|
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)
|
function process(entry, body, addCallee)
|
||||||
{
|
{
|
||||||
if (!("PEdge" in body))
|
if (!("PEdge" in body))
|
||||||
@ -794,8 +830,7 @@ function process(entry, body, addCallee)
|
|||||||
if (!(edge.Index[0] in nonMainThreadPoints))
|
if (!(edge.Index[0] in nonMainThreadPoints))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var rawLocation = body.PPoint[edge.Index[0] - 1].Location;
|
var location = get_location(body.PPoint[edge.Index[0] - 1].Location);
|
||||||
var location = rawLocation.CacheString + ":" + rawLocation.Line;
|
|
||||||
|
|
||||||
var callees = getCallees(edge);
|
var callees = getCallees(edge);
|
||||||
for (var callee of callees) {
|
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)
|
function sameBlockId(id0, id1)
|
||||||
{
|
{
|
||||||
if (id0.Kind != id1.Kind)
|
if (id0.Kind != id1.Kind)
|
||||||
|
@ -70,12 +70,15 @@ sixgill = "$TOOLTOOL_DIR/sixgill/usr/libexec/sixgill"
|
|||||||
sixgill_bin = "$TOOLTOOL_DIR/sixgill/usr/bin"
|
sixgill_bin = "$TOOLTOOL_DIR/sixgill/usr/bin"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
local rev
|
||||||
|
rev=$(cd $GECKO_DIR && hg log -r . -T '{node|short}')
|
||||||
cat > run-analysis.sh <<EOF
|
cat > run-analysis.sh <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ \$# -eq 0 ]; then
|
if [ \$# -eq 0 ]; then
|
||||||
set gcTypes
|
set gcTypes
|
||||||
fi
|
fi
|
||||||
export ANALYSIS_SCRIPTDIR="$ANALYSIS_SRCDIR"
|
export ANALYSIS_SCRIPTDIR="$ANALYSIS_SRCDIR"
|
||||||
|
export URLPREFIX="https://hg.mozilla.org/mozilla-unified/file/$rev/"
|
||||||
exec "$ANALYSIS_SRCDIR/analyze.py" "\$@"
|
exec "$ANALYSIS_SRCDIR/analyze.py" "\$@"
|
||||||
EOF
|
EOF
|
||||||
chmod +x run-analysis.sh
|
chmod +x run-analysis.sh
|
||||||
@ -111,7 +114,7 @@ function grab_artifacts () {
|
|||||||
# Do not error out if no files found
|
# Do not error out if no files found
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
set +e
|
set +e
|
||||||
for f in *.txt *.lst; do
|
for f in *.txt *.lst run-analysis.sh; do
|
||||||
gzip -9 -c "$f" > "${artifacts}/$f.gz"
|
gzip -9 -c "$f" > "${artifacts}/$f.gz"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user