#!/bin/env python #Caolán McNamara #cat abrt-stack | ./mapabrtstack #re-annotate missing debuginfo. #Up to you to have the correct debuginfo installed import sys import os.path import subprocess lines = sys.stdin.readlines() parseloadaddrs=False loadaddrs = {} for line in lines: if line[0:4] == 'From': parseloadaddrs=True elif line[0:4] == '(*):': parseloadaddrs=False elif parseloadaddrs==True: chunks = line.split() loadaddrs[chunks[4]] = int(chunks[0], 16) def getorigentrypoint(debugfromdso): readelf = subprocess.Popen("readelf -l " + debugfromdso, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) lines = readelf.stdout.readlines() for line in lines: if line[0:11] == 'Entry point': chunks = line.split() return int(chunks[2], 16) return -1 address = 0; for line in lines: if line[0:8] == 'warning:': continue if line[0:4] == 'From': break print line[0:-1] if line[0] == '#': chunks = line.split() if chunks[1][0:2] == '0x': address = int(chunks[1], 16) elif line[0:8] == ' from ': fromdso = line.split()[1] loadedentrypoint = loadaddrs[fromdso] debugfromdso = '/usr/lib/debug' + \ os.path.realpath(fromdso) + \ '.debug' origentrypoint = getorigentrypoint(debugfromdso) origaddress = address-loadedentrypoint+origentrypoint addr2line = subprocess.Popen("addr2line -e " + debugfromdso + " -C -f " + hex(origaddress), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) addr2lines = addr2line.stdout.readlines() for line in addr2lines: print " " + line[0:-1]