Skip to content

Commit 6ed6deb

Browse files
authored
feat: add .dump() for fetching raw minidump contents (#39)
2 parents f63f8d3 + bb1cca9 commit 6ed6deb

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Add search paths for looking up symbol files.
2626
Get the stack trace from `minidumpFilePath`, the `callback` would be called
2727
with `callback(error, report)` upon completion.
2828

29+
### minidump.dump(minidumpFilePath, callback)
30+
31+
Parse and dump the raw contents of the minidump as text using `minidump_dump`.
32+
2933
### minidump.dumpSymbol(binaryPath, callback)
3034

3135
Dump debug symbols in minidump format from `binaryPath`, the `callback` would

build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], {
1414
},
1515
stdio: 'inherit'
1616
})
17-
const targets = ['src/processor/minidump_stackwalk']
17+
const targets = ['src/processor/minidump_stackwalk', 'src/processor/minidump_dump']
1818
if (process.platform === 'linux') {
1919
targets.push('src/tools/linux/dump_syms/dump_syms')
2020
}

lib/minidump.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const format = require('./format')
66
const exe = process.platform === 'win32' ? '.exe' : ''
77
const commands = {
88
minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe,
9+
minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe,
910
dump_syms: (() => {
1011
if (process.platform === 'darwin') {
1112
return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms_mac')
@@ -27,7 +28,7 @@ function execute (command, args, callback) {
2728
})
2829
child.on('close', function (code) {
2930
if (code !== 0) {
30-
callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code))
31+
callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code), stdout)
3132
} else {
3233
callback(null, stdout)
3334
}
@@ -75,6 +76,10 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg
7576
execute(stackwalk, args, callback)
7677
}
7778

79+
module.exports.dump = function (minidump, callback, commandArgs) {
80+
execute(commands.minidump_dump, [minidump].concat(commandArgs || []), callback)
81+
}
82+
7883
module.exports.dumpSymbol = function (binary, callback) {
7984
var dumpsyms = commands.dump_syms
8085
if (!dumpsyms) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Read and process minidump file",
55
"version": "0.19.0",
66
"bin": {
7-
"minidump_stackwalk": "build/src/processor/minidump_stackwalk"
7+
"minidump_stackwalk": "build/src/processor/minidump_stackwalk",
8+
"minidump_dump": "build/src/processor/minidump_dump"
89
},
910
"types": "index.d.ts",
1011
"license": "MIT",

test/minidump-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ describe('minidump', function () {
8989
})
9090
})
9191

92+
describe('dump()', function () {
93+
it('calls back with minidump info', function (done) {
94+
minidump.dump(path.join(__dirname, 'fixtures', 'linux.dmp'), (err, rep) => {
95+
if (err) {
96+
// do nothing, errors are fine here
97+
}
98+
const report = rep.toString('utf8')
99+
assert.notEqual(report.length, 0)
100+
assert.notEqual(report.indexOf('libXss.so.1.0.0'), -1)
101+
done()
102+
})
103+
})
104+
})
105+
92106
describe('moduleList()', function () {
93107
describe('on a Linux dump', () => {
94108
it('calls back with a module list', function (done) {

0 commit comments

Comments
 (0)