From e1ac21aa7a0493ce95bfe45b8d96bc021f2f9ac4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 28 Jul 2013 10:04:56 +0800 Subject: [PATCH] Add script translate addresses in crash report into symbols. --- script/translate-crash-log-addresses.coffee | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 script/translate-crash-log-addresses.coffee diff --git a/script/translate-crash-log-addresses.coffee b/script/translate-crash-log-addresses.coffee new file mode 100755 index 000000000000..84c05b1973b8 --- /dev/null +++ b/script/translate-crash-log-addresses.coffee @@ -0,0 +1,54 @@ +#!/usr/bin/env coffee +# Usage: +# Copy the crash log into pasteboard and then run +# pbpaste | ./script/translate-crash-log-addresses.coffee + +atos = (addresses, callback) -> + path = require 'path' + exec = require('child_process').exec + + exec 'atos -o vendor/brightray/vendor/download/libchromiumcontent/Release/libchromiumcontent.dylib -arch i386 '.concat(addresses...), (error, stdout, stderr) -> + throw error if error? + callback stdout.split('\n') + +parse_stack_trace = (raw) -> + lines = {} + addresses = [] + for line in raw + columns = line.split /\ +/ + if columns[1] == 'libchromiumcontent.dylib' and /0x[a-f0-9]+/.test columns[3] + lines[columns[0]] = addresses.length + addresses.push '0x' + parseInt(columns[5]).toString(16) + ' ' + + atos addresses, (parsed) -> + for line in raw + columns = line.split /\ +/ + frame = columns[0] + if lines[frame]? + console.log frame, parsed[lines[frame]] + else + console.log line + +parse_log_file = (content) -> + state = 'start' + stack_trace = [] + lines = content.split /\r?\n/ + + for line in lines + if state == 'start' + if /Thread \d+ Crashed::/.test line + console.log line + state = 'parse' + else if state == 'parse' + break if line == '' + stack_trace.push line + + parse_stack_trace stack_trace + +input = '' +process.stdin.resume() +process.stdin.setEncoding 'utf8' +process.stdin.on 'data', (chunk) -> + input += chunk +process.stdin.on 'end', -> + parse_log_file input