I am working under linux, it seems to me that the effect of "-g" and "-ggdb" are no much difference. I only find using "-ggdb" will generate binary several bytes bigger.
So what's the core difference that gdb should have one "-g" option and another "-ggdb" option?
The compiled program should be stored at some where, for the debuggers (GDB here) to look into it and follow.
This is technically called as "Debugging data format".
Some universaslly accepted debugging data formats are (there are some more):
COFF - Common Object File Format - on UNIX like systems.
PE/COFF - Portable Executable - pretty famous on windows, usually dotnet uses it.
DWARF - popular on UNIX like systems.
etc..
The GDB options you asked in your question are related to generating these debugging data formats.
Based on documenation the funcdamental difference is: option "g" provides the debugging data in particular system's native format. option "-ggdb" is bit rich and expensive. provides the debugging data in most expressive format available.
I recommend you to read this documentation, and this topic.
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