projtec:gdb
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projtec:gdb [2017/11/14 10:50] – orel | projtec:gdb [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| * GDB : https:// | * GDB : https:// | ||
| * Valgrind : http:// | * Valgrind : http:// | ||
| - | * KCacheGrind | + | * KCacheGrind |
| + | * cppcheck (analyse statique de code, linter) : http:// | ||
| * GCov | * GCov | ||
| + | |||
| + | |||
| + | ==== Valgrind ==== | ||
| + | |||
| + | Pour détecter les problèmes d' | ||
| + | |||
| + | $ gcc -Wall -g -O0 monprog.c -o monprog | ||
| + | $ valgrind --leak-check=full ./monprog | ||
| + | | ||
| + | |||
| + | ==== Analyse statique de code avec cppcheck ==== | ||
| + | |||
| + | $ cppcheck --enable=all --xml -I ../include *.c 2> report.xml | ||
| + | $ cppcheck-htmlreport --source-dir=. --report-dir=report --file=report.xml | ||
| + | |||
| + | => Open ' | ||
| + | |||
| + | Ici un exemple d' | ||
| + | |||
| + | ==== Utilisation de kcachegrind ==== | ||
| + | |||
| + | $ valgrind --tool=callgrind program | ||
| + | |||
| + | => callgrind.out.< | ||
| + | |||
| + | $ kcahegrind callgrind.out.< | ||
| + | |||
| + | ==== Compilation & Exécution avec GDB ==== | ||
| Voici 4 cas de figures très classiques : | Voici 4 cas de figures très classiques : | ||
| Line 13: | Line 42: | ||
| * Votre programme boucle de temps en temps ? Réflexe : lancer gdb et attacher gdb au processus de votre programme. | * Votre programme boucle de temps en temps ? Réflexe : lancer gdb et attacher gdb au processus de votre programme. | ||
| - | ==== Valgrind ==== | ||
| - | |||
| - | //todo// | ||
| - | |||
| - | ==== Compilation & Exécution avec GDB ==== | ||
| Il est nécessaire au préalable de compiler son code C avec les CFLAGS " | Il est nécessaire au préalable de compiler son code C avec les CFLAGS " | ||
| Line 28: | Line 52: | ||
| * quit (q) : quitter gdb | * quit (q) : quitter gdb | ||
| - | * run ('r') : lancer l’execution | + | * run [< |
| - | * break < | + | * break < |
| + | * clear, delete | ||
| + | * watch <var> (w), rwatch < | ||
| * step, next, continue, finish (s,n,c) : avancer d’un pas (en entrant ou pas dans les sous-fonctions), | * step, next, continue, finish (s,n,c) : avancer d’un pas (en entrant ou pas dans les sous-fonctions), | ||
| - | * print <var>, list (p, l) : afficher la valeur d’une variable, afficher | + | * print <var> (p) : afficher la valeur d’une variable |
| + | * print *array@len : pour afficher | ||
| + | * list : afficher 10 lignes de code autour de l' | ||
| * backtrace / frame <num> : afficher la pile d’execution, | * backtrace / frame <num> : afficher la pile d’execution, | ||
| - | * display <var> / undisplay < | + | * display <var> / undisplay < |
| - | * x < | + | * x /xw < |
| + | * call foo(1), call strlen(" | ||
| + | * set var x = 1 : modification de la variable x | ||
| + | * shell <cmd> : exécute une commande shell | ||
| + | * file < | ||
| (gdb) list | (gdb) list | ||
| Line 69: | Line 100: | ||
| (gdb) attach 12271 | (gdb) attach 12271 | ||
| | | ||
| + | ==== Autres Trucs ==== | ||
| + | |||
| + | * Ctrl-X Ctrl-A : ouvre une petite fenêtre avec le code source paginée, qui suit l' | ||
| + | * Refcard : http:// | ||
| + | |||
| + | |||
projtec/gdb.1510656645.txt.gz · Last modified: 2024/03/18 15:05 (external edit)
