Re: Bison disables breakpoints?
Re: Bison disables breakpoints?
- Subject: Re: Bison disables breakpoints?
- From: email@hidden
- Date: Thu, 17 Apr 2014 12:04:04 -0700
How are you setting breakpoints, in rpcalc.y or in rpcalc.tab.c?
For any of the code that is directly generated from the .y file, bison puts in #line directives which route the debug line table back to the .y file. So some parts of the rpcalc.tab.c will claim to be from rpcalc.y, and others from fpcalc.tab.c.
Setting breakpoints worked for me, provided you know which file to specify for the breakpoint:
> lldb rpcalc
Current executable set to 'rpcalc' (x86_64).
(lldb) b s -f rpcalc.y -l 72
Breakpoint 1: where = rpcalc`main + 22 at rpcalc.y:72, address = 0x0000000100001c96
(lldb) run
Process 62453 launched: '/private/tmp/rpcalc' (x86_64)
Process 62453 stopped
* thread #1: tid = 0x2781f, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100001c96 rpcalc`main at rpcalc.y:72
69 int
70 main (void)
71 {
-> 72 puts("Here");
73 puts("Here");
74
75 return yyparse ();
Note there is an old bug in lldb that "source list" doesn't redirect through the #line directive:
(lldb) source list -f rpcalc.y -l 72
error: Could not find source file "rpcalc.y".
but that doesn't keep the breakpoints from working.
You can also invoke bison with the -l (--no-lines) option, which will cause it not to generate these #line directives, and then you can set breakpoints in the rpcalc.tab.c w/o having to worry about whether those lines are redirected or not.
Jim
On Apr 17, 2014, at 10:20 AM, McLaughlin, Michael P. <email@hidden> wrote:
> Uncertain whether this is OT or not.
>
> When I run Apple’s supplied Bison (2.3) on the simple rpcalc.y file (very slightly modified, appended below) and compile the result with cc, everything works as expected.
>
> When I compile Bison’s output (rpcalc.tab.c) in Xcode 5.1.1 (as a C tool), again the program runs perfectly.
>
> However, if I put a breakpoint anywhere, it does not trigger. This is all with the standard (unmodified) Xcode C-tool template—Debug configuration, etc.
>
> Is Bison known to disable LLDB breakpoints?
>
> *** rpcalc.y ***
>
> /* Reverse polish notation calculator. */
> %{
> #include <stdio.h>
> #include <math.h>
>
> #define YYSTYPE double
>
> int yylex (void);
> void yyerror (char const *);
> %}
>
> %token NUM
>
> %% /* Grammar rules and actions follow. */
>
> input:
> /* empty */
> | input line
> ;
> line:
> '\n'
> | expr '\n' { printf ("%.10g\n", $1); }
> ;
> expr:
> NUM { $$ = $1; }
> | expr expr '+' { $$ = $1 + $2; }
> | expr expr '-' { $$ = $1 - $2; }
> | expr expr '*' { $$ = $1 * $2; }
> | expr expr '/' { $$ = $1 / $2; }
> | expr expr '^' { $$ = pow ($1, $2); } /* exponentiation */
> | expr 'n' { $$ = -$1; } /* Unary minus */
> ;
> %%
>
> /* The lexical analyzer returns a double floating point
> number on the stack and the token NUM, or the numeric code
> of the character read if not a number. It skips all blanks
> and tabs, and returns 0 for end-of-input. */
> #include <ctype.h>
> int
> yylex (void)
> {
> int c;
> /* Skip white space. */
> while ((c = getchar ()) == ' ' || c == '\t')
> continue;
> /* Process numbers. */
> if (c == '.' || isdigit (c))
> {
> ungetc (c, stdin);
> scanf ("%lf", &yylval);
> return NUM;
> }
> /* Return end-of-input. */
> if (c == EOF)
> return 0;
> /* Return a single char. */
> return c;
> }
>
> #include <stdio.h>
> /* Called by yyparse on error. */
> void
> yyerror (char const *s)
> {
> fprintf (stderr, "%s\n", s);
> }
>
> int
> main (void)
> {
> puts("Here");
> puts("Here");
>
> return yyparse ();
> }
>
> --
> Michael P. McLaughlin
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden