如何调试 BibTeX 代码?我想知道如何:
- 逐步执行,
- 进入和退出函数调用,
- 设置断点,
- 可视化堆栈,
- 观察各种变量的值,
等等。是否有任何针对 BibTeX 的调试选项,例如包unravel
(可在 CTAN 上获取和在 GitHub 上) 适合 LaTeX 吗?
我之所以问这个问题,是因为我一直在经历texdoc tamethebeast
(尼古拉斯·马基驯服 BeaST:BibTeX 的 B 到 X) 一段时间了,希望更好地理解第 4 章中介绍的一些示例,特别是后面的一些示例(从该章第 20 节开始),因为它们似乎变得相当复杂。有是检查 BibTeX 代码如何执行和操作堆栈的更好方法,而不是在原始文本文件中以带注释的文本控制流图形式一步一步地写出来,或者——我一想到就不寒而栗!——拿出铅笔和纸!(如果我在打字的电脑旁边有空间,那么最后一个选项就不会那么麻烦了,但是,仍然,似乎...毫无必要地过时,我该说...?)
答案1
我认为最好的办法是编译您自己的bibtex
可执行文件并启用该trace
标志。
来自 BibTeX 源代码(bibtex.web
):
@^debugging@> @^statistics@> Some of the code below is intended to be used only when diagnosing the strange behavior that sometimes occurs when \BibTeX\ is being installed or when system wizards are fooling around with \BibTeX\ without quite knowing what they are doing. Such code will not normally be compiled; it is delimited by the codewords `$|debug|\ldots|gubed|$', with apologies to people who wish to preserve the purity of English. Similarly, there is some conditional code delimited by `$|stat|\ldots|tats|$' that is intended only for use when statistics are to be kept about \BibTeX's memory/cpu usage, and there is conditional code delimited by `$|trace|\ldots|ecart|$' that is intended to be a trace facility for use mainly when debugging \.{.bst} files. @d debug == @{ { remove the `|@{|' when debugging } @d gubed == @t@>@} { remove the `|@}|' when debugging } @f debug == begin @f gubed == end @# @d stat == @{ { remove the `|@{|' when keeping statistics } @d tats == @t@>@} { remove the `|@}|' when keeping statistics } @f stat == begin @f tats == end @# @d trace == @{ { remove the `|@{|' when in |trace| mode } @d ecart == @t@>@} { remove the `|@}|' when in |trace| mode } @f trace == begin @f ecart == end