Skip to content

Commit

Permalink
feat: Support processing full crash report instead of just crash lines (
Browse files Browse the repository at this point in the history
#2)

* feat: Support processing full crash report instead of just crash lines

This change generates a symbolicated report by symbolicating all the addresses in the original report. Until now, only symbolicating crash lines was supported. This makes it easier to have a final symbolicated report

* Add test
  • Loading branch information
nitsakh authored Aug 12, 2019
1 parent 3e72e5f commit be738c1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const {argv} = require('yargs')
const atos = require('./index')

atos(argv, (error, symbols) => {
atos(argv, (error, symbolicated) => {
if (error != null) {
console.error(error.stack || error.message)
process.exit(1)
} else {
console.log(symbols.join('\n'))
console.log(symbolicated.join('\n'))
}
})
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const extractZip = require('extract-zip')
const mapLimit = require('async/mapLimit')

module.exports = (options, callback) => {
const {version, quiet, file, content, mas, force} = options
const {version, quiet, file, mas, force} = options
const platform = options.mas ? 'mas' : 'darwin'
const directory = path.join(__dirname, 'cache', version + '-' + platform)

const addresses = parseAddresses(content != null ? content : fs.readFileSync(file, 'utf-8'))
const content = options.content != null ? options.content : fs.readFileSync(file, 'utf-8')
const addresses = parseAddresses(content)

download({version, quiet, directory, platform, force}, (error) => {
if (error != null) return callback(error)
Expand All @@ -30,8 +30,11 @@ module.exports = (options, callback) => {
}, (err, syms) => {
if (err) callback(err)
const concatted = syms.reduce((m, o) => m.concat(o), [])
const sorted = concatted.sort((a, b) => a.i - b.i)
callback(null, sorted.map(x => x.symbol))
let split = content.split('\n')
concatted.map((sym) => {
split[sym.i] = sym.symbol
})
callback(null, split)
})
})
}
Expand Down Expand Up @@ -122,7 +125,9 @@ module.exports.testing = {parseAddress, parseAddresses}
// 13 com.github.electron.framework 0x00000001016ee77f atom::api::WebContents::LoadURL(GURL const&, mate::Dictionary const&) + 831
const parseStackTraceAddress = (line) => {
const segments = line.split(/\s+/)

const index = parseInt(segments[0])
if (!isFinite(index)) return

const library = segments[1]
const address = segments[2]
const image = segments[3]
Expand Down
11 changes: 11 additions & 0 deletions spec/__snapshots__/symbolication.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ Array [
]
`;

exports[`atos returns content with addresses symbolicated 1`] = `
Array [
"content::RenderProcessHostImpl::Cleanup() (in Electron Framework) (render_process_host_impl.cc:1908)",
"content::ServiceWorkerProcessManager::Shutdown() (in Electron Framework) (service_worker_process_manager.cc:79)",
"",
"Thread 1 Crashed:: Chrome_IOThread",
"worker (in libnode.dylib) (threadpool.c:76)",
"uv__thread_start (in libnode.dylib) (thread.c:54)",
]
`;

exports[`atos returns an array of symbols for partially symbolicated addresses 1`] = `
Array [
"content::RenderProcessHostImpl::Cleanup() (in Electron Framework) (render_process_host_impl.cc:1908)",
Expand Down
21 changes: 21 additions & 0 deletions spec/symbolication.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ const post4Addresses = `
47 libdyld.dylib 0x00007fff7a6513d5 start + 1
`.trim()

const fullReportFixture = `
0 com.github.electron.framework 0x000000010d01fad3 0x10c497000 + 12094163
1 com.github.electron.framework 0x000000010d095014 0x10c497000 + 12574740
Thread 1 Crashed:: Chrome_IOThread
3 libnode.dylib 0x000000010ab5c383 0x10aa09000 + 1389443
4 libnode.dylib 0x000000010ab678e9 0x10aa09000 + 1435881
`.trim()

const TIMEOUT = 120000;

describe('atos', function () {
Expand Down Expand Up @@ -73,6 +82,18 @@ describe('atos', function () {
})
}, TIMEOUT)

it('returns content with addresses symbolicated', (done) => {
atos({
content: fullReportFixture,
quiet: true,
version: '1.4.14'
}, (error, symbols) => {
if (error != null) return done(error)
expect(symbols).toMatchSnapshot()
done()
})
}, TIMEOUT)

it('returns an array of symbols for addresses taken from sampling', (done) => {
atos({
content: samplingFixture,
Expand Down

0 comments on commit be738c1

Please sign in to comment.