Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit f35328f

Browse files
iivlevstellaraccident
authored andcommitted
Possibility to dump all threads
1 parent a347d9e commit f35328f

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

bin/dump.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
var toolRunner = require('./tool-runner');
17+
var optimist = require('optimist').boolean(['allzones']);
1718
var util = toolRunner.util;
1819
toolRunner.launch(runTool);
1920

@@ -24,10 +25,13 @@ toolRunner.launch(runTool);
2425
* @param {!Array.<string>} args Command line arguments.
2526
* @param {function(number)} done Call to end the program with a return code.
2627
*/
27-
function runTool(platform, args, done) {
28-
var inputFile = args[0];
28+
function runTool(platform, args_, done) {
29+
var args = optimist.argv;
30+
var allzones = args['allzones'];
31+
32+
var inputFile = args['_'][0];
2933
if (!inputFile) {
30-
console.log('usage: dump.js file.wtf-trace');
34+
console.log('usage: dump.js [--allzones] file.wtf-trace');
3135
done(1);
3236
return;
3337
}
@@ -39,7 +43,7 @@ function runTool(platform, args, done) {
3943
console.log('ERROR: unable to open ' + inputFile, db, db.stack);
4044
done(1);
4145
} else {
42-
done(dumpDatabase(db));
46+
done(dumpDatabase(db, allzones));
4347
}
4448
});
4549
};
@@ -48,9 +52,10 @@ function runTool(platform, args, done) {
4852
/**
4953
* Dump the database.
5054
* @param {!wtf.db.Database} db Database.
55+
* @param {!boolean} allzones Whether it's needed to dump all the zones or just the first one
5156
* @return {number} Return code.
5257
*/
53-
function dumpDatabase(db) {
58+
function dumpDatabase(db, allzones) {
5459
var sources = db.getSources();
5560
for (var n = 0; n < sources.length; n++) {
5661
util.logContextInfo(sources[n].getContextInfo());
@@ -62,12 +67,15 @@ function dumpDatabase(db) {
6267
return 0;
6368
}
6469

65-
var zone = zones[0];
66-
var eventList = zone.getEventList();
67-
var it = eventList.begin();
68-
for (; !it.done(); it.next()) {
69-
util.logEvent(it, zone);
70-
}
70+
var count = allzones ? zones.length : 1;
71+
for (var i = 0; i < count; ++i) {
72+
var zone = zones[i];
73+
var eventList = zone.getEventList();
74+
var it = eventList.begin();
75+
for (; !it.done(); it.next()) {
76+
util.logEvent(it, zone);
77+
}
7178

79+
}
7280
return 0;
7381
};

bin/save-trace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fs = require('fs');
44
http = require('http');
55
os = require('os');
6-
optimist = require('optimist')
6+
optimist = require('optimist');
77

88
main(optimist.default('port', 8000).argv);
99

0 commit comments

Comments
 (0)