Created
February 17, 2014 09:34
-
-
Save aniruddha-a/9047550 to your computer and use it in GitHub Desktop.
Perl highlighter for GDB backtrace output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
## | |
# Mon Feb 17 14:38:23 IST 2014 | |
# Aniruddha. A (aniruddha.a@gmail.com) | |
## | |
$FG_RESET = "[0m"; | |
$FG_RED = "[31m"; | |
$FG_GREEN = "[32m"; | |
$FG_YELLOW = "[33m"; | |
$FG_BLUE = "[34m"; | |
#$FG_MAGENTA="[35m"; | |
#$FG_CYAN="[36m"; | |
#0 0x00007ff994229425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 | |
$usual = qr/^(#\d+)\s+(0x.*) in (\w+) (.*) (at|from) (.*)/; | |
#12 a_handler_internal (handler=<optimized out>) at ../usr/lib/libutils/a_handler.c:350 | |
$noaddr = qr/^(#\d+)\s+(\w+) (.*) (at|from) (.*)/; | |
while (<STDIN>) { | |
if (/$usual/) { | |
if ( length( $1 . $2 . $3 . $4 ) > 79 ) { | |
print "$FG_YELLOW$1 $FG_BLUE $2 $FG_RED $3 $FG_YELLOW $4\n $5 $FG_GREEN $6 $FG_RESET\n"; | |
} else { | |
print "$FG_YELLOW$1 $FG_BLUE $2 $FG_RED $3 $FG_YELLOW $4 $5 $FG_GREEN $6 $FG_RESET\n"; | |
} | |
} elsif (/$noaddr/) { | |
if ( length( $1 . $2 . $3 ) > 79 ) { | |
print "$FG_YELLOW$1 $FG_RED $2 $FG_YELLOW $3\n $4 $FG_GREEN $5 $FG_RESET\n"; | |
} else { | |
print "$FG_YELLOW$1 $FG_RED $2 $FG_YELLOW $3 $4 $FG_GREEN $5 $FG_RESET\n"; | |
} | |
} else { | |
print; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment