Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!world!iecc!compilers-sender From: megatest!djones@decwrl.dec.com (Dave Jones) Newsgroups: comp.compilers Subject: Re: yacc & dbx Keywords: yacc, debug Message-ID: <15093@megatest.UUCP> Date: 1 Feb 91 02:34:36 GMT References: <9101291603.aa15778@castle.ed.ac.uk> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: megatest!djones@decwrl.dec.com (Dave Jones) Organization: Megatest Corporation, San Jose, Ca Lines: 42 Approved: compilers@iecc.cambridge.ma.us > 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] -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.