delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq101.html   search  

| Previous | Next | Up | Top |

12.8 GDB cannot list source that was #include'd

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:
  1. Run f2c with the -g option:
    
          f2c -g myprog.f
    
    
  2. Compile using gcc with the -g option:
    
          gcc -g myprog.c -o myprog.exe -lf2c -lm
    
    
  3. Copy the original Fortran source over the generated C:
    
          copy myprog.f myprog.c
    
    
  4. Debug with gdb:
    
          gdb myprog.exe
    
    


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

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