How to highlight and color gdb output during interactive debugging?

前端 未结 11 1504
南方客
南方客 2020-12-02 03:42

Please don\'t reply I should use ffffd, nemiver, emacs, vim, or any other front-end, I just prefer gdb as it is, but would like to see its output with some terminal colors.

11条回答
  •  情话喂你
    2020-12-02 04:00

    #into .gdbinit
    shell mkfifo /tmp/colorPipe
    
    define hook-disassemble
    echo \n
    shell cat /tmp/colorPipe | c++filt | highlight --syntax=asm -s darkness -Oxterm256 &
    set logging redirect on
    set logging on /tmp/colorPipe
    end 
    
    define hookpost-disassemble
    hookpost-list
    end 
    
    define hook-list
    echo \n
    shell cat /tmp/colorPipe | c++filt | highlight --syntax=cpp -s darkness -Oxterm256 &
    set logging redirect on
    set logging on /tmp/colorPipe
    end 
    
    define hookpost-list
    set logging off 
    set logging redirect off 
    shell sleep 0.1s
    end 
    
    define hook-quit
    shell rm /tmp/colorPipe
    end 
    
    define re
    hookpost-disassemble
    echo \033[0m
    end 
    document re
    Restore colorscheme
    end 
    

    Warning: Buggy. No TUI support, 'user-mode' hack.

    Found the main part here and modified it a bit. Needs highlight, c++filt. If colors get messed up issue re command.

提交回复
热议问题