From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757167AbcHXQj0 (ORCPT ); Wed, 24 Aug 2016 12:39:26 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35282 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754598AbcHXQjZ (ORCPT ); Wed, 24 Aug 2016 12:39:25 -0400 From: Alexander Potapenko To: dvyukov@google.com, kcc@google.com, aryabinin@virtuozzo.com, adech.fo@gmail.com, akpm@linux-foundation.org, alexander.levin@verizon.com, tj@kernel.org Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] scripts: add ksymbolize.py Date: Wed, 24 Aug 2016 18:37:35 +0200 Message-Id: <1472056655-30791-1-git-send-email-glider@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit the script that symbolizes BUG messages and KASAN error reports by adding file:line information to each stack frame. The script is a copy of https://github.com/google/sanitizers/blob/master/address-sanitizer/tools/kasan_symbolize.py , originally written by Andrey Konovalov. Cc: Andrey Ryabinin Cc: Dmitry Vyukov Signed-off-by: Alexander Potapenko --- MAINTAINERS | 1 + scripts/ksymbolize.py | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 321 insertions(+) create mode 100755 scripts/ksymbolize.py diff --git a/MAINTAINERS b/MAINTAINERS index 20bb1d0..35ae6dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6592,6 +6592,7 @@ F: include/linux/kasan*.h F: lib/test_kasan.c F: mm/kasan/ F: scripts/Makefile.kasan +F: scripts/ksymbolize.py KCONFIG M: "Yann E. MORIN" diff --git a/scripts/ksymbolize.py b/scripts/ksymbolize.py new file mode 100755 index 0000000..f64dc43 --- /dev/null +++ b/scripts/ksymbolize.py @@ -0,0 +1,320 @@ +#!/usr/bin/python + +# Tool for symbolizing stack traces in BUG reports. + +from collections import defaultdict +import getopt +import os +import re +import sys +import subprocess + +# A hexadecimal number without the leading 0x. +HEXNUM = '[0-9A-Fa-f]+' + +# An address in the form []. +FRAME_ADDR = ( + '(\[\<(?P' + HEXNUM + ')\>\])?\s*' +) + +# A function name with an offset and function size, plus an optional module +# name, e.g.: +# __asan_load8+0x64/0x66 +FRAME_BODY = ( + '(?P' + + '(?P[^\+]+)' + + '\+' + + '0x(?P' + HEXNUM + ')' + + '/' + + '0x(?P' + HEXNUM + ')' + + '( \[(?P.+)\])?' + + ')') + +# Matches the timestamp prefix of a log line. +TIME_RE = re.compile( + '^(?P