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
#linedirective to set the file that is used for errors, and symbolic debugging, to the.lfile that the.cfile was created from. You’ll need to set the breakpoints in the.lfile or use the-Loption to instruct flex not to use the#linedirective.GDB requires the file name that appeared in the
#linedirective when setting breakpoints. If you manually converted the.lfile to a.cfile 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.lfile (without the folders).