What's in the -p and -g flag

I profiled C code, and for this I compiled the -p and -g flags. So, I wandered what these flags actually do, and what kind of premium do they add to the binary? Thanks

+5
source share
2 answers

-pprovides information for prof, and -pgprovides information for gprof.

Let's look at the last one. It explains how it worksgprof , but let me condense it here.

When routine B is compiled with -pg, some code is inserted at the entry point to the program that looks at which program calls it, for example A. Then it increments a counter saying A is called B.

, , . -, . -, , , , , .

, , 100 . , , , 676 , , " " 6,76 , .

, , , , , , , . " ". , , , , , .. .

1982 , - , .

+3

, GCC, ​​ GCC.

http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options

-p

, prof. , , , .

-g

(stabs, COFF, XCOFF DWARF 2). GDB .

, stabs, -g , GDB; GDB, , , . , , -gstabs +, -gstabs, -gxcoff +, -gxcoff -gvms (. ).

GCC -g -O. , , : ; ; , ; , .

, . , .

+4

All Articles