tags:

views:

117

answers:

2

If I set a breakpoint in a Bison .y file, is there a way I can inspect the contents of $$ pseudo variable at that breakpoint?

+2  A: 

$$ is be the top of the semantic value stack. It may be a little difficult to interpret. If you really need to, the stack pointer might be called yyssp and the stack might be called yyvsa, so something like yyvsa[yyssp] might give you what you want, depending on the version of bison you're using. Look at .tab.c code that was generated.

Richard Pennington
+1  A: 

Bison keeps the stacks as local variables in yyparse(), dynamically allocated.

Probably the easiest way to solve a temporary debugging issue is to patch y.tab.c so that the line *++yyvsp = yylval also drops a copy in a global. You may also want to hack YYPOPSTACK() to do the same thing.

DigitalRoss