From 9705c9dd4b36369ed40f5ac528d84538b2505e53 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 29 Jul 2020 11:38:42 -0700 Subject: [PATCH 1/3] feat: add .dump() for fetching raw minidump contents --- README.md | 4 ++++ build.js | 2 +- lib/minidump.js | 5 +++++ package.json | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d0cd6b..b191927 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ Add search paths for looking up symbol files. Get the stack trace from `minidumpFilePath`, the `callback` would be called with `callback(error, report)` upon completion. +### minidump.dump(minidumpFilePath, callback) + +Parse and dump the raw contents of the minidump as text using `minidump_dump`. + ### minidump.dumpSymbol(binaryPath, callback) Dump debug symbols in minidump format from `binaryPath`, the `callback` would diff --git a/build.js b/build.js index ae4f8ae..37959f2 100644 --- a/build.js +++ b/build.js @@ -14,7 +14,7 @@ spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], { }, stdio: 'inherit' }) -const targets = ['src/processor/minidump_stackwalk'] +const targets = ['src/processor/minidump_stackwalk', 'src/processor/minidump_dump'] if (process.platform === 'linux') { targets.push('src/tools/linux/dump_syms/dump_syms') } diff --git a/lib/minidump.js b/lib/minidump.js index 078c4b8..44e9925 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -6,6 +6,7 @@ const format = require('./format') const exe = process.platform === 'win32' ? '.exe' : '' const commands = { minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe, + minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe, dump_syms: (() => { if (process.platform === 'darwin') { return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms_mac') @@ -75,6 +76,10 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg execute(stackwalk, args, callback) } +module.exports.dump = function (minidump, callback, commandArgs) { + execute(commands.minidump_dump, [minidump].concat(commandArgs || []), callback) +} + module.exports.dumpSymbol = function (binary, callback) { var dumpsyms = commands.dump_syms if (!dumpsyms) { diff --git a/package.json b/package.json index d6c4bed..9e9d005 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Read and process minidump file", "version": "0.19.0", "bin": { - "minidump_stackwalk": "build/src/processor/minidump_stackwalk" + "minidump_stackwalk": "build/src/processor/minidump_stackwalk", + "minidump_dump": "build/src/processor/minidump_dump" }, "types": "index.d.ts", "license": "MIT", From bba61adb5cc53832de56bc5a06934b4d70d018a8 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 29 Jul 2020 14:25:05 -0700 Subject: [PATCH 2/3] add test --- lib/minidump.js | 2 +- test/minidump-test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/minidump.js b/lib/minidump.js index 44e9925..e949b46 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -28,7 +28,7 @@ function execute (command, args, callback) { }) child.on('close', function (code) { if (code !== 0) { - callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code)) + callback(stderr ? new Error(stderr.toString()) : new Error('Command `' + command + '` failed: ' + code), stdout) } else { callback(null, stdout) } diff --git a/test/minidump-test.js b/test/minidump-test.js index 1798e94..e1605db 100644 --- a/test/minidump-test.js +++ b/test/minidump-test.js @@ -89,6 +89,17 @@ describe('minidump', function () { }) }) + describe('dump()', function() { + it('calls back with minidump info', function (done) { + minidump.dump(path.join(__dirname, 'fixtures', 'linux.dmp'), (err, rep) => { + const report = rep.toString('utf8') + assert.notEqual(report.length, 0) + assert.notEqual(report.indexOf('libXss.so.1.0.0'), -1) + done() + }) + }) + }) + describe('moduleList()', function () { describe('on a Linux dump', () => { it('calls back with a module list', function (done) { From bb1cca99ecd98b7e8f8532974ede74784fc0405b Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 29 Jul 2020 14:32:50 -0700 Subject: [PATCH 3/3] lint --- test/minidump-test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/minidump-test.js b/test/minidump-test.js index e1605db..61ca4d5 100644 --- a/test/minidump-test.js +++ b/test/minidump-test.js @@ -89,9 +89,12 @@ describe('minidump', function () { }) }) - describe('dump()', function() { + describe('dump()', function () { it('calls back with minidump info', function (done) { minidump.dump(path.join(__dirname, 'fixtures', 'linux.dmp'), (err, rep) => { + if (err) { + // do nothing, errors are fine here + } const report = rep.toString('utf8') assert.notEqual(report.length, 0) assert.notEqual(report.indexOf('libXss.so.1.0.0'), -1)