From 9be683d76423cb4ee0c0d0a32f6aaa2a4d67bcfa Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Mon, 19 Nov 2012 18:51:45 +0100 Subject: work better with lines like "#9 0x00007ff08691590d in ?? ()" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- gdb-bt-reformat | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb-bt-reformat b/gdb-bt-reformat index 6b3fb84..ab7bbcb 100755 --- a/gdb-bt-reformat +++ b/gdb-bt-reformat @@ -8,15 +8,17 @@ import re import textwrap DEF_IDENT = '[A-Za-z_][A-Za-z0-9_]*' +#DEF_UNKNOWN = map(lambda c: '\\' + c, '??') # re needs escaped version +DEF_UNKNOWN = '[?][?]' DEF_HEX = '0x[0-9A-Za-z]+' DEF_MSG = '[<][ A-Za-z0-9_]+[>]' DEF_PATH = '[A-Za-z0-9._/]+' RE_BT = re.compile(\ '(?P^\#[0-9]+\s+)'\ '(?:(?P%(DEF_HEX)s) in )?'\ - '(?P%(DEF_IDENT)s(?:(?: |::)%(DEF_IDENT)s)*)'\ + '(?P%(DEF_IDENT)s(?:(?: |::)%(DEF_IDENT)s)*|(?P%(DEF_UNKNOWN)s))'\ ' (?P[(](?:(?<=[( ])%(DEF_IDENT)s=(?:%(DEF_IDENT)s|%(DEF_MSG)s|%(DEF_HEX)s)(?:, )?)*[)])'\ - ' at (?P%(DEF_PATH)s):(?P[1-9][0-9]*)' + '(?(unknown)| at (?P%(DEF_PATH)s):(?P[1-9][0-9]*))' % locals()) @@ -33,8 +35,9 @@ def main(): args = textwrap.wrap(found['args'], subsequent_indent=space[1:]) res = found['init'] + found['where'] res += (args[0] == '()' and '()' or space + '\n'.join(args)) - res += space + 'at ' + found['path'] + ':' + found['line'] + '\n' - print res + if not found['unknown']: + res += space + 'at ' + found['path'] + ':' + found['line'] + print res + '\n' else: space = None print >>stderr, "bad line:", line -- cgit