Re: yacc & dbx

megatest!djones@decwrl.dec.com (Dave Jones)
1 Feb 91 02:34:36 GMT

          From comp.compilers

Related articles
yacc & dbx htf@castle.edinburgh.ac.uk (H T Fallside) (1991-01-29)
Re: yacc & dbx michi@ptcburp.ptcbu.oz.au (1991-01-31)
Re: yacc & dbx megatest!djones@decwrl.dec.com (1991-02-01)
Re: yacc & dbx lupine!rfg@uunet.UU.NET (1991-02-02)
| List of all articles for this month |
Newsgroups: comp.compilers
From: megatest!djones@decwrl.dec.com (Dave Jones)
Keywords: yacc, debug
Organization: Megatest Corporation, San Jose, Ca
References: <9101291603.aa15778@castle.ed.ac.uk>
Date: 1 Feb 91 02:34:36 GMT

> Anyone have any suggestions about ways of getting dbx to behave sensibly
> with a yacc generated parser as part of the program - ie indexing into the
> source during debug ?
>
> thanks in advance, hamish
> [Yacc generates #line directives that let any sensible debugger use the .y
> as the source file. If your dbx can't handle them, try gdb. -John]


The BSD (original) yacc has a problem in that its has some #line directives
for the .y file before the code for yyparse. Thus, when the program counter
is somewhere in the yaccpar part of yyparse (not in the user-defined
actions), dbx displays the .y file anyway, and appears to hop around in
that file at random. To make it sensical, you need only to add a #line
directive just before the declaration of yyparse. I once posted a little
nawk (new AWK) script to run over your y.output file, and somebody sent
me mail containing a small improvement over it. I can't find them now,
but the following will give you the idea.


At the time I posted the original, our moderator - (Hi, John) - tagged it with
a comment to the effect that the script was incorrect, and that it appeared to
"do the opposite of what is wanted." Well, John, look again. It will still
display the .y file when executing the actions defined there. What it will not
do is display the .y file while executing instructions from yaccpar.


Here 'tis:


^^^^ snip ^^^^ snip ^^^^ snip ^^^^ snip ^^^^ snip ^^^^ snip ^^^^ snip


/^yyparse/ { print "# line " NR + 1 " \"y.tab.c\""
print $0
                            next
                      }




                      {
                            print $0
                      }
[I don't think it was me, as far as I can tell this was never in
comp.compilers before. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.