[OS X TeX] Re: [texhax] Single-stepping through TeX
joseph.wright at morningstar2.co.uk
Fri Nov 18 22:58:13 CET 2011
On 18/11/2011 19:47, Doug McKenna wrote:
> Is there any way to single-step through a very simple TeX execution
> (after inputing the plain format), in order to watch with a debugger how
> it operates? Preferably using the XCode environment that in turn depends
> on gdb.
> I've got TeXLive 2010 installed, with the 2011 disk available.
> Although there's a directory in the distribution tree for web2c, I can't
> find any executables or sources or directions that make it easy (no doubt
> for some value of "easy") to convert TeX's source code into final
> runnable C code for the command line program "tex".
> Searching the web hasn't helped much either, except to make clear that
> the endeavor looks completely frought and complex.
> Doug McKenna
Like many people with a background in functional programming, you are
misunderstanding how TeX fundamentally works!
TeX is a macro expansion language, but unlike for example C preprocessor
macros you can't separate out macro expansion from execution of the
code. TeX macros do not have a fixed meaning, and so it's not possible
to 'first expand the definitions then execute the code'. Thus the input
to the command line TeX program /is/ the source you read.
Macro expansion has another important consequence: once a macro is
expanded, the fact that it was there at all is no longer important. Thus
there is no macro-based scope, only group-based scope. Thus
% Some code
scopes \myvar due to the grouping, but has nothing to do with the use of
The way to trace what TeX is doing is to use \tracingall, or if you use
LaTeX to load the trace package and use \traceon ... \traceoff. (The
later hides some noisy-but-boring LaTeX internals.) This will show you
in the log what is TeX is doing.
(I've kept the Mac list on the CC, but this is really a general TeX
issue, so suggest further replies go to TeXhax only.)
More information about the macostex-archives