Tips and Tricks using the GCC, CPP and Binutils
For the http://www.lug-salem.de/ I am preparing a short presentation for showing how to use the gcc and cpp and so for collecting information.
the version I am using is :
gcc (GCC) 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)
the general idea is to specialize the information more and more, adding in more constants.
By dealing with the output of the preprocessor we can get a concise overview of the source code in one file. By looking at the assembler, we can see all types of information that is otherwise hard to find.
Here is the outline:
- preparation
- GNU/sourceforce/debian/cpan/google/redhat/
- documentation
- mailing list
- unpacking the project
- looking through the files available
- configuration and debugging m4, shell, sed, grep,test and friends
- aclocale, automake, autoconf
- modification of the makefiles,
- turning on the verbose mode and save temps in CFLAGS
CFLAGS = --verbose -save-temps
CXXFLAGS
- CPP and various options
- checking how to run the C preprocessor... gcc -E
- Macro Bodies
- MACRO DEFINITIONS
- non executed blocks
- DEPENDANCIES
- compilation with the gcc, what are the passes.
- CPP
- LEX
- PARSE
- AST
- RTL
- BACKEND
- What dump options are available
- CC1
- I files /usr/lib/gcc/i486-linux-gnu/4.0.3/cc1 -E -quiet -v -I. -I. -I.. -MD device.d -MF .deps/device.Tpo -MP -MT device.o -MQ device.o -DHAVE_CONFIG_H device.c -mtune=i686 -fworking-directory -O2 -fpch-preprocess -o device.i
- S files /usr/lib/gcc/i486-linux-gnu/4.0.3/cc1 -fpreprocessed device.i -quiet -dumpbase device.c -mtune=i686 -auxbase-strip device.o -g -O2 -version -o device.s
- tree files
- RTL
- flow graphs
- MAP FILES
- binutils
- NM, OBJDUMP, ReadElf for getting at the results
- Finding out the sizes of objects
- finding names of functions out of the addresses
- unmangling names
- using and scripting GDB for debugging and data collection
- stopping the command immediatly with a kill sig stop
- scripting the gdb
- Creating and Dealing with core dumps
- Ulimit
- debugging without debug information (map files and objdump)
- libbacktrace
- mapping OBJ files to ASM
- Doxygen and Co
- GraphViz
- Profiling, gprof, cache grid, memory profiles, strace, oprofile