https://sites.google.com/view/langagecansi/gdb
https://dept-info.labri.fr/~thibault/gdb.html.fr
http://sdz.tdct.org/sdz/deboguer-son-programme-avec-gdb.html
https://beta.hackndo.com/introduction-a-gdb/
https://www.rocq.inria.fr/secret/Anne.Canteaut/COURS_C/gdb.html
Parfois il faut lancer cette commande avant de debogger dans gdb
set debug-file-directory
ou la mettre dans votre home dans
.gdbinit
Utilisation de gdb pour comprendre l'usage de argc et argv
voir le cours C base
gcc bonjour.c -o bonjour -g
le g pour ajouter les balises de debuggage !! important
lancer gdb avec la commande suivante:
gdb bonjour
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bonjour...done.
(gdb) start prenom
Temporary breakpoint 1 at 0x699: file bonjour.c, line 6.
Starting program: /home/onrub/Works/Codec/gdb/bonjour prenom
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Temporary breakpoint 1, main (argc=2, argv=0x7fffffffde48) at bonjour.c:6
6 if (argc!=2) /* si il n y a pas un argument derriere l executable*/
(gdb) print argc
$1 = 2
(gdb) s
11 argv[1][2]=0;
(gdb) p argv[1]
$2 = 0x7fffffffe1fd "prenom"
(gdb) step
12 printf("Bonjour %s \n", argv[1]);
(gdb) print argv[1]
$3 = 0x7fffffffe1fd "pr"
(gdb) step
Bonjour pr
15 return EXIT_SUCCESS;
(gdb)
On peut améliorer l'affichage avec la commande
layout src
permet de voir notre code et l'invité de commande du debugger
escape pour passer de la console au programme (list)
et i pour revenir à a la console