From 8a5d002e97a8000ae9d68dba6270e6145585ce40 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 20 Feb 2018 14:37:34 +0100 Subject: [PATCH] [gdb] color the parent directory in backtrace Assuming that the debug session would be in a "project/build/" directory, like for a classical CMake built project. --- .gdbinit | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gdbinit b/.gdbinit index 794ea2a..b9774fe 100644 --- a/.gdbinit +++ b/.gdbinit @@ -84,9 +84,13 @@ end define hook-backtrace - # match the [path]file[.ext]: (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)) - # shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*([^()]+[()]*) (\(.*\)) at (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,none,green,cpp,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold & - shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "([\w\s]*?)(=)([^,]*?)([,\)])" yellow,blue,magenta,blue normal & + # Note: match path = [path]file[.ext] = (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)) + # This line color highlights: + # – lines that link to source code, + # – function call in green, + # – arguments names in yellow, values in magenta, + # — the parent directory in bold red (assuming that the debug session would be in a "project/build/" directory). + shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "([\w\s]*?)(=)([^,]*?)([,\)])" yellow,blue,magenta,blue normal | colout "/($(basename $(dirname $(pwd))))/" red bold & logging_on end define hookpost-backtrace