$ gcc -g -O0 -Wall -c hello.c
$ gcc -g hello.o
$ gcc -g -O0 -Wall hello.c
$ gdb a.out (gdb) break exit (gdb) run (gdb) quit
(gdb) print t (gdb) break pf (gdb) print pf(t) (gdb) next (gdb) step (gdb) finish
$ valgrind ./a.out
#include <stdlib.h> void myfunc (int n) { int* a = malloc(n * sizeof(int)); a[n] = 0; } int main () { myfunc(3); return 0; }
$ valgrind ./a.out ==30984== Command: ./a.out ==30984== ==30984== Invalid write of size 4 ==30984== at 0x400511: myfunc (bad.c:7) ==30984== by 0x400526: main (bad.c:12) ==30984== Address 0x518b04c is 0 bytes after a block of size 12 alloc'd
$ gcc -g -O0 -pg -c foo.c $ gcc -g -pg foo.o
$ gcc -g -O0 -pg foo.c
$ ./a.out
$ gprof a.out
Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 35.38 20.64 20.64 4771989280 0.00 0.00 IN 25.59 35.56 14.93 1049864543 0.00 0.00 scan 15.22 44.44 8.88 345772285 0.00 0.00 makeMove 8.52 49.41 4.97 868833748 0.00 0.00 INCL 7.34 53.69 4.28 10274416 0.00 0.00 evaluate
$ gcc -c -Q -O3 --help=optimizers | grep enabled
$ gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts $ gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts $ diff /tmp/O2-opts /tmp/O3-opts | grep enabled
$ gcc -O3 -ffast-math -c foo.c $ gcc -O3 -ffast-math foo.o
$ size a.out
$ gcc -Os -c foo.c $ gcc -Os foo.o
This document was produced using groff-1.22.