D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] gnu compiler experts anywhere?

 

On 03/11/10 13:12, Simon Williams wrote:
I should have added that compiling for debugging makes the damn thing
work. It should be possible to generate a separate symbol file that the
debugger can use to follow the code after a segfault rather than adding
it to the executable.

Meh. I hate those. Had more than one myself. Almost as much 'fun' as a multithreaded program.

I've done a bit of googling, and I'm actually really surprised that I haven't found anything on this. It happens often enough. I can't see anything in the man pages for gcc or gdb.

I'm not sure a symbol table is what you're looking for. In the man page for gcc, -g says "produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2)". Whereas -s (not normally used) says "remove all symbol table and relocation information from the executable". I think this implies that all executables have at least some form of symbol table unless explicitly removed, and -g just gives more information.

Check out -d for gdb which lets you tell it where to find source code. It might be able to give you enough debugging information without using -g.

Maybe you could try some other options that change the debugging information and see if that causes the program to fail:
-fno-merge-debug-strings
-feliminate-unused-debug-symbols
-feliminate-unused-debug-types
-femit-class-debug-always

[edit]: I've just noticed the link James posted. I think that's what you're looking for: http://www.bytetalk.net/2010/07/how-to-generate-seperate-g-symbol-file.html

I've done the generating seperate symbol file and that does seem to work - I can run the release version, it segfaults and running gdb on the core and loading the symbol file and doing a backtrace seems to point to the right place. What worries me is that the whole thing is built using ccmake and cmake and generates files on the fly so there is no guarantee that the symbol table extracted from the debug version bears any resemblance to the release version. Fortunately this one blows up pretty quickly but there must be a more reliable way...
I dont think I can bear joining the GCC newsgroups thou...
Tom te tom te tom

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq