bonjour à la communauté,
Je fais mes premiers pas dans la programmation en C sous linux. Je sollicite votre aide puisque je n'arrive pas à configurer le débogueur.
Le programme de test, qui s'appelle testDebogueur.c, est le suivant:
#include <stdio.h>
static void fun1(void) {
char *cp = 0 ;
*cp = '!' ;
}
int main (int argc, char* argv[]) {
fun1();
return 0;
}
Assez logiquement la compilation ne génère aucune erreur, même si un niveau d'avertissement élévé est employé,
[xxx@localhost C]$ gcc -Wall -D_GNU_SOURCE testDebogueur.c -o test
[xxx@localhost C]$
L'interprêteur génère une erreur de segmentation puisque l'on essaie de stocker un point d'exclamation en utilisant un pointeur null.
[xxx@localhost C]$ ./test
Segmentation fault
Si j'utilise le paramètre -g, comme on s'y attend l'exécutable est plus gros. Il pèse 6KB au lieu de 4,6KB.
Par ailleurs, gdb est bien présent sur mon système,
[xxx@localhost C]$ gdb
GNU gdb Red Hat Linux (6.6-16.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".
(gdb)
Mais quand j'exécute ce programme, aucun fichier core n'est créé. J'ai tendance à penser que ce problème est propre à la configuration de mon système (fc7). C'est pour cette raison que je me permets de poster ici.
Est-ce que gcc n'est pas complètement opérationnel?
ou bien est ce que c'est gdb qui ne l'est pas?
ou bien leur liaison?
Comment diagnostiquez davantage?
Pour info en mode verbose,
[xxx@localhost C]$ gcc -D_GNU_SOURCE testDebogueur.c -o test -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-27)
/usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1 -quiet -v -D_GNU_SOURCE testDebogueur.c -quiet -dumpbase testDebogueur.c -mtune=generic -auxbase testDebogueur -version -o /tmp/ccrzE0YY.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.2/include
/usr/include
End of search list.
GNU C version 4.1.2 20070925 (Red Hat 4.1.2-27) (i386-redhat-linux)
compiled by GNU C version 4.1.2 20070925 (Red Hat 4.1.2-27).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 53c9f9515bf7a4d930482540205071f7
as -V -Qy -o /tmp/cc4FlbhN.o /tmp/ccrzE0YY.s
GNU assembler version 2.17.50.0.12-4 (i386-redhat-linux) using BFD version 2.17.50.0.12-4 20070128
/usr/libexec/gcc/i386-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.. /tmp/cc4FlbhN.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o
Je soupçonne que gdb n'est pas configuré correctement:
-> This GDB was configured as "i386-redhat-linux-gnu".
-> ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
Par avance, je vous remercie pour votre aide.