Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ npm install minidump
```

## Building
* Clone the repository recursively
* Run `npm install`

* `git clone --recurse-submodules https://github.com/electron/node-minidump`
* `npm install`

## Docs

Expand Down
98 changes: 52 additions & 46 deletions lib/minidump.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,81 @@
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var fs = require('fs')
var path = require('path')
var spawn = require('child_process').spawn

var searchPaths = [
path.resolve(__dirname, '..', 'build', 'Release'),
path.resolve(__dirname, '..', 'build', 'Debug'),
path.resolve(__dirname, '..', 'bin'),
];
function searchCommand(command) {
if (process.platform == 'win32') {
path.resolve(__dirname, '..', 'bin')
]

function searchCommand (command) {
var binaryPath = null
if (process.platform === 'win32') {
command += '.exe'
var binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command)
if (fs.existsSync(binaryPath))
return binaryPath;
binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command)
if (fs.existsSync(binaryPath)) {
return binaryPath
}
} else {
for (var i in searchPaths) {
var binaryPath = path.join(searchPaths[i], command);
if (fs.existsSync(binaryPath))
return binaryPath;
binaryPath = path.join(searchPaths[i], command)
if (fs.existsSync(binaryPath)) {
return binaryPath
}
}
}
}

function execute(command, args, callback) {
var stdout = new Buffer(0);
var stderr = new Buffer(0);
var child = spawn(command, args);
child.stdout.on('data', function(chunk) {
stdout = Buffer.concat([stdout, chunk]);
});
child.stderr.on('data', function(chunk) {
stderr = Buffer.concat([stderr, chunk]);
});
child.on('close', function(code) {
if (code != 0)
callback(stderr ? new Error(stderr.toString()) : new Error("Command `" + command + "` failed: " + code));
else
callback(null, stdout);
});
function execute (command, args, callback) {
var stdout = new Buffer(0)
var stderr = new Buffer(0)
var child = spawn(command, args)
child.stdout.on('data', function (chunk) {
stdout = Buffer.concat([stdout, chunk])
})
child.stderr.on('data', function (chunk) {
stderr = Buffer.concat([stderr, chunk])
})
child.on('close', function (code) {
if (code !== 0) {
callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code))
} else {
callback(null, stdout)
}
})
}

var globalSymbolPaths = [];
module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths);
var globalSymbolPaths = []
module.exports.addSymbolPath = Array.prototype.push.bind(globalSymbolPaths)

module.exports.walkStack = function(minidump, symbolPaths, callback) {
module.exports.walkStack = function (minidump, symbolPaths, callback) {
if (!callback) {
callback = symbolPaths;
symbolPaths = [];
callback = symbolPaths
symbolPaths = []
}

var stackwalk = searchCommand('minidump_stackwalk');
var stackwalk = searchCommand('minidump_stackwalk')
if (!stackwalk) {
callback(new Error('Unable to find "minidump_stackwalk"'));
return;
callback(new Error('Unable to find "minidump_stackwalk"'))
return
}

args = [minidump].concat(symbolPaths, globalSymbolPaths)
execute(stackwalk, args, callback);
var args = [minidump].concat(symbolPaths, globalSymbolPaths)
execute(stackwalk, args, callback)
}

module.exports.dumpSymbol = function(binary, callback) {
var dumpsyms = searchCommand('dump_syms');
module.exports.dumpSymbol = function (binary, callback) {
var dumpsyms = searchCommand('dump_syms')
if (!dumpsyms) {
callback(new Error('Unable to find "dump_syms"'));
return;
callback(new Error('Unable to find "dump_syms"'))
return
}

// Search for binary.dSYM on OS X.
dsymPath = binary + '.dSYM';
if (process.platform == 'darwin' && fs.existsSync(dsymPath))
binary = dsymPath;
var dsymPath = binary + '.dSYM'
if (process.platform === 'darwin' && fs.existsSync(dsymPath)) {
binary = dsymPath
}

execute(dumpsyms, ['-r', '-c', binary], callback)
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"url": "https://github.com/electron/node-minidump/issues"
},
"scripts": {
"test": "mocha test"
"test": "mocha test && standard"
},
"devDependencies": {
"electron-download": "^3.0.1",
"extract-zip": "^1.5.0",
"mocha": "^3.1.2",
"standard": "^8.4.0",
"temp": "^0.8.3"
}
}
7 changes: 5 additions & 2 deletions test/minidump-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ var electronDownload = require('electron-download')
var extractZip = require('extract-zip')
var temp = require('temp').track()

var describe = global.describe
var it = global.it

describe('minidump', function () {
this.timeout(3 * 60 * 1000)

Expand Down Expand Up @@ -105,7 +108,7 @@ var downloadElectron = function (callback) {
} else {
callback(null, path.join(electronPath, 'electron'))
}
})
})
})
}

Expand All @@ -123,6 +126,6 @@ var downloadElectronSymbols = function (platform, callback) {
extractZip(zipPath, {dir: symbolsPath}, function (error) {
if (error) return callback(error)
callback(null, path.join(symbolsPath, 'electron.breakpad.syms'))
})
})
})
}