简体   繁体   English

是否可以在 cdb/windbg 中突出显示语法?

[英]Is it possible to have syntax highlighting in cdb/windbg?

我正在 Windows 上试验命令行调试器,我想知道是否有办法在 cdb 或 windbg 控制台中突出显示语法?

since you tagged windbg and have windbg in title this answer is for windbg only由于您标记了windbg并且标题中有windbg,因此此答案仅适用于windbg

i presume that you are aware windbg is gui and cdb is console application我想你知道 windbg 是 gui 而 cdb 是控制台应用程序

windbg src window supports syntax highlighting and provides some options to change the colors and you can dock it side by side windbg src 窗口支持语法高亮,并提供了一些更改颜色的选项,您可以并排停靠

cdb does not support color unless you are a magician除非您是魔术师,否则 cdb 不支持颜色

magic recipe for magicians that can run colored cdb可以运行彩色 cdb 的魔术师的魔术配方

( it is mentioned that you can create a tools.ini file (有提到可以创建一个tools.ini文件
create two entries col_mode: TRUE , col: srcchar R--创建两个条目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我不知道 cmd.exe 是真控制台还是假控制台
I could never coax it to output in color except for .printf /D with dml )除了带有 dml 的 .printf /D 之外,我永远无法哄它以彩色输出)

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关于将 tools.ini 放在何处的注释,您可以将 tools.ini 放在您希望的任何位置,只需确保环境变量 INIT 指向放置它的目录

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在下面的示例中,我在 debugee 目录或当前工作目录中有 tools.ini,用 .\\ 和 .\\tools.ini 表示,我将 ENV VAR init 设置为 .\\ 即当前目录

here is a screenshot for windbg srcwindow with syntax highlighted src这是 windbg srcwindow 的屏幕截图,其中语法突出显示了 src

followed by a colored cmd.exe dml .printf output后跟彩色 cmd.exe dml .printf 输出

在此处输入图片说明

as you can see the .symopt+10 has been enabled from tools.ini如您所见,已从 tools.ini 启用 .symopt+10

so cdb has parsed and understood the color entires所以 cdb 已经解析并理解了颜色整体

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:

:\>

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM