Google breakpad stackwalker无法加载符号

清泛原创
Google breakpad安装好以后,按要求生成.sym,但是最终 minidump_stackwalk 打印出来的堆栈还是提示找不到符号。

这是因为它要求符号文件有一定的规则:

#!/bin/sh
mkdir tmp
dump_syms c++11 > tmp/c++11.sym
head -n1 tmp/c++11.sym
#todo:
mkdir -p ./symbols/c++11/6EDC6ACDB282125843FD59DA9C81BD830
mv tmp/c++11.sym ./symbols/c++11/6EDC6ACDB282125843FD59DA9C81BD830
rm -rf tmp
路径有要求,GUID来自 .so 文件的头部。

为了方便,写个 python 脚本 gen_symbols.py 自动生成:

#!/usr/bin/python
import sys
import getopt
import os
import errno
from os.path import basename

def make_sure_path_exists(path):
    try:
        os.makedirs(path)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise


def main(argv):

	if len(sys.argv) < 2:
		print ("Please input binary files.")
		sys.exit(2)
		
	for i in range(1,len(sys.argv)):

		binary = sys.argv[i]
		
		outputFile =  basename(binary) + ".sym"
		command = '{0} {1} > {2}'.format("dump_syms",binary,outputFile)

		print ('--> Running {0}'.format(command) )
		os.system(command)

		symFile = open(outputFile, 'r')
		firstLine = symFile.readline()

		print ('First line {0}'.format(firstLine))
		lineArguments = firstLine.split(' ')
		print ('Magic file {0}'.format(lineArguments[-2]))

		symbolsDir = ("symbols/" + basename(binary) + "/" +
					  lineArguments[-2] + "/")

		make_sure_path_exists(symbolsDir)
		os.rename(outputFile,symbolsDir + basename(outputFile))

if __name__ == "__main__":
    main(sys.argv[1:])

./gen_symbols.py xx1.so xx2.so
这样就可以自动生成了。

参考:https://stackoverflow.com/questions/23537187/stackwalker-loads-all-symbol-files-but-still-doesnt-symbolicate-anything

分享到:
评论加载中,请稍后...
创APP如搭积木 - 创意无限,梦想即时!
回到顶部