I am experimenting with command line debuggers on windows and I was wondering if there’s a way to have syntax highlighting in either cdb or the windbg console?
since you tagged windbg and have windbg in title this answer is for windbg only
i presume that you are aware windbg is gui and cdb is console application
windbg src window supports syntax highlighting and provides some options to change the colors and you can dock it side by side
cdb does not support color unless you are a magician
magic recipe for magicians that can run colored cdb
(
it is mentioned that you can create a tools.ini file
create two entries col_mode: TRUE , col: srcchar R--
but there is a caveat that this only works in true console
I don't know if cmd.exe is true console or false console
I could never coax it to output in color except for .printf /D with dml
)
Regarding the comment where to put tools.ini one can put tools.ini anywhere one wishes just has to make sure the environment variable INIT points to the directory where one has put it
in the example below i have tools.ini in the debugee directory or current working Directory denoted with .\ and .\tools.ini and i am setting the ENV VAR init to .\ viz current directory
here is a screenshot for windbg srcwindow with syntax highlighted src
followed by a colored cmd.exe dml .printf output
as you can see the .symopt+10 has been enabled from tools.ini
so cdb has parsed and understood the color entires
but single stepping doesn't get color
:\>set INIT
Environment variable INIT not defined
:\>cdb -c ".symopt;q" classmagic.exe | awk "/Reading/,/quit/"
0:000> cdb: Reading initial command '.symopt;q'
Symbol options are 0xB0327: <<<<<<<<<<<<<<<<<<<<
0x00000001 - SYMOPT_CASE_INSENSITIVE
0x00000002 - SYMOPT_UNDNAME
0x00000004 - SYMOPT_DEFERRED_LOADS
0x00000020 - SYMOPT_OMAP_FIND_NEAREST
xxxxxxxxxxxxx
quit:
:\>set INIT=.\
:\>cat .\tools.ini
[CDB]
col_mode: TRUE
col srcchar R--
lines: TRUE <<<<<<<<<<<<<<<<<<
:\>cdb -c ".symopt;q" classmagic.exe | awk "/Reading/,/quit/"
0:000> cdb: Reading initial command '.symopt;q'
Symbol options are 0xB0337: <<<<<<<<<<<<<<
0x00000001 - SYMOPT_CASE_INSENSITIVE
0x00000002 - SYMOPT_UNDNAME
0x00000004 - SYMOPT_DEFERRED_LOADS
0x00000010 - SYMOPT_LOAD_LINES <<<<<<<<<<<<<<<<
0x00000020 - SYMOPT_OMAP_FIND_NEAREST
xxxxxxxxxxxxxxxxxxxxxx
quit:
:\>