| Previous | Next | Up | Top |
Q: My source file #include's another source file, but I cannot set a breakpoint in that included code, because GDB says there is no such line, or no such source file...
Q: I cannot debug code produced by Flex, or Bison, or F2C, because GDB somehow messes up all the source file and line number info!
Q: Why can't I step with a debugger into an inline function defined in a header file?
A: This is a genuine limitation of the COFF format used by DJGPP. It can only handle a single source file for a given object file. It does include correct line numbers, but
the name of the source file is wrong, so debugging such files just doesn't work. Using stabs debugging info (see the previous section) doesn't have this limitation, so upgrade to GCC 2.8.0 or later
if you can.
For source files that include other source files, you can work around this even with COFF debugging, by just inserting the included source with your editor while you debug the program. For code
produced by other programs, like F2C or Bison, Duncan Murdoch suggests a work-around: to copy the original source file
(.y, .f, etc.) over the generated C file. For example, here's how you should go about debugging a Fortran program myprog.f using GCC,
F2C and GDB:
- Run f2c with the -g option:
f2c -g myprog.f
- Compile using gcc with the -g option:
gcc -g myprog.c -o myprog.exe -lf2c -lm
- Copy the original Fortran source over the generated C:
copy myprog.f myprog.c
- Debug with gdb:
gdb myprog.exe

You can help support this site by
visiting the advertisers that sponsor it! (only once each, though)