I have created a lex file test.l and create lex.yy.c from it, which I then compile with gcc -g flags
I am linking it and I dont have a problem compiling the rest of my code which makes the call to yylex(), however, in GDB i dont seem to be able to dive on the call to yylex().
What am I doing wrong? I put breakpoints in the yylex() method itself, and this causes gdb to stop on my call to yylex() but never inside the function.
Do I need to compile the -l library with debug symbols or something?
I know it is running because i created my lex.yy.c file with -d, so I see the output of accepting tokens and whatnot.
Thanks
I think you are falling foul of the fact that lex, or at least flex, uses the #line directive to set the file that is used for errors, and symbolic debugging, to the .l file that the .c file was created from. You'll need to set the breakpoints in the .l file or use the -L option to instruct flex not to use the #line directive.
GDB requires the file name that appeared in the #line directive when setting breakpoints. If you manually converted the .l file to a .c file then this is probably what you used on the command line. If the conversion was done implicitly by make then it's just the basename of the .l file (without the folders).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With