Although you claim to have compiled with cc -g
on your executable myfilesys
, GDB does not see any, as evidenced in your attempt to use GDB's file
command:
(gdb) file myfilesys
Reading symbols from /.../myfilesys...(no debugging symbols found)...done.
Taking you at your word that you have actually used cc -g
for compiling myfilesys
, this means that you have either stripped the symbols from your binaries (I find this unlikely, but I mention the possibility), or none of your object files have debug symbols. Assuming the latter, you need to apply the cc -g -c
compilation to each individual source file. Then, each of the resulting object files will have debugging symbols, and the resulting executable will also have debugging symbols (so long as you do not strip them out after linking).
With standard makefiles such as gmake
, this can usually be easily accomplished by augmenting the CFLAGS
variable with -g
. Below is a complete makefile that illustrates this with three source files:
CFLAGS=-g
myfilesys: a.o b.o c.o
$(CC) $^ -o $@
GCC already has implicit rules that know how to create a .o
file from the corresponding .c
file. However, you can alter the command line arguments passed to the compiler by changing the CFLAGS
variable. Pre-processing directives and include directories are usually passed in by augmenting the CPPFLAGS
variable (C++ specific flags are read from CXXFLAGS
, but CPPFLAGS
options are passed to both the C and C++ compilers).
We need to define an explicit rule for creating the executable myfilesys
(the $(CC)
rule is indented with a tab character, a makefile requirement). After typing make
, the executable will have symbols, and GDB will not report missing symbols in your executable (it may report about missing symbols from any libraries that you use):
(gdb) file myfilesys
Reading symbols from /.../myfilesys...done.
file myfilesys
. This will print the filetype. Prints a good bit of information, make sure it says 'not stripped'. Feel free to add the output to your question....(no debugging symbols found)...
when loading in your file, it means it. Check to make sure your makefile is really doingcc -g -c
compilation of each.c
file, not just the last one to make yourmyfilesys
. If all your sources are in one directory, you can docc -g *.c -o myfilesys
.