Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tehnici de debugging
Mihai Maruseac mihai.maruseac@gmail.com
ROSEdu

3 februarie 2010

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bug-uri ¸ si erori... Debugging elementar C Debugging Extra Debugging Extra Debugging Future

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Fundamental Axiom of Programming (Rick Cook) Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bugs

Bug = error, flaw, mistake, failure or flaw in computer code producing an unexpected result or behaviour.

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bugs

Bug = error, flaw, mistake, failure or flaw in computer code producing an unexpected result or behaviour. Jim Gray’s classification:
Bohrbug - repetabil, mereu ˆ ın acelas , i set de condit , ii (permanent fault)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bugs

Bug = error, flaw, mistake, failure or flaw in computer code producing an unexpected result or behaviour. Jim Gray’s classification:
Bohrbug - repetabil, mereu ˆ ın acelas , i set de condit , ii (permanent fault) Heisenbug - schimb˘ a comportamenul ˆ ın debugging (transient fault)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bugs

Bug = error, flaw, mistake, failure or flaw in computer code producing an unexpected result or behaviour. Jim Gray’s classification:
Bohrbug - repetabil, mereu ˆ ın acelas , i set de condit , ii (permanent fault) Heisenbug - schimb˘ a comportamenul ˆ ın debugging (transient fault) Mandelbug - cauze complexe s , i obscure, haotic, nedeterminist

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bugs

Bug = error, flaw, mistake, failure or flaw in computer code producing an unexpected result or behaviour. Jim Gray’s classification:
Bohrbug - repetabil, mereu ˆ ın acelas , i set de condit , ii (permanent fault) Heisenbug - schimb˘ a comportamenul ˆ ın debugging (transient fault) Mandelbug - cauze complexe s , i obscure, haotic, nedeterminist Schroedinbug

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Efecte

distrugerea navetelor spatiale (Mariner 1, Ariane 5, Surveyor) iradiere excesiv˘ a panic˘ a (Y2K)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Efecte

distrugerea navetelor spatiale (Mariner 1, Ariane 5, Surveyor) iradiere excesiv˘ a panic˘ a (Y2K) accidente militare (Patriot, Yorktown)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Efecte

distrugerea navetelor spatiale (Mariner 1, Ariane 5, Surveyor) iradiere excesiv˘ a panic˘ a (Y2K) accidente militare (Patriot, Yorktown) accidente media (Eve Online)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Efecte

distrugerea navetelor spatiale (Mariner 1, Ariane 5, Surveyor) iradiere excesiv˘ a panic˘ a (Y2K) accidente militare (Patriot, Yorktown) accidente media (Eve Online) spargerea securit˘ at , ii (Valgrind + OpenSSL on Debian; 2006-2008)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cauze

typo, thinko, mouso

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cauze

typo, thinko, mouso memory leaks, stack smashing, fandango on core (malloc..)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cauze

typo, thinko, mouso memory leaks, stack smashing, fandango on core (malloc..) race conditions

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cauze

typo, thinko, mouso memory leaks, stack smashing, fandango on core (malloc..) race conditions rounding errors

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cauze

typo, thinko, mouso memory leaks, stack smashing, fandango on core (malloc..) race conditions rounding errors conversii ˆ ıntre tipuri

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Solut , ii preventive

-Wall -Wextra..

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Solut , ii preventive

-Wall -Wextra.. Testarea codului

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Solut , ii preventive

-Wall -Wextra.. Testarea codului Unit testing

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Solut , ii preventive

-Wall -Wextra.. Testarea codului Unit testing Dup˘ a teste, sc˘ ap˘ am doar de Bohrbugs

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Solut , ii preventive

-Wall -Wextra.. Testarea codului Unit testing Dup˘ a teste, sc˘ ap˘ am doar de Bohrbugs Analiza (static˘ a a) codului

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Comentarii

Tehnic˘ a fundamental˘ a Funct a mereu , ioneaz˘ raport beneficii / efort foarte mic

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Print*

printf pentru cod ˆ ın user space printk pentru cod de kernel

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Print*

printf pentru cod ˆ ın user space printk pentru cod de kernel modificare cod convent , ii de indentare, formatare, .. interne proiectului analiz˘ a text >> analiz˘ a cod ad hoc. temporal. repetitiv reduce performant ıncarc˘ a output , e, ˆ buffered output (not stderr)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

#include <stdio.h> int main() { char a, sir[256]; int i = 0; for (a = 0; a < 256; a++) sir[i++] = a; printf("Result: %s\n", sir); return 0; }

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

#include <stdio.h> int main() { char a, sir[256]; int i = 0; for (a = 0; a < 256; a++){ printf(">>> %d %d %c\n", i, a, a); sir[i++] = a; } printf("Result: %s\n", sir); return 0; }

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Despre print*
modificarea codului: eficient a vs. rezultate ,˘ Cˆ and prefer˘ am print*?

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Despre print*
modificarea codului: eficient a vs. rezultate ,˘ Cˆ and prefer˘ am print*? Cod recursiv, prea mult efort cu alte instrumente Cod paralel Cod greu de depanat altfel (kernel code) Heisenbugs

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Despre print*
modificarea codului: eficient a vs. rezultate ,˘ Cˆ and prefer˘ am print*? Cod recursiv, prea mult efort cu alte instrumente Cod paralel Cod greu de depanat altfel (kernel code) Heisenbugs Jurnalizare

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Despre print*
modificarea codului: eficient a vs. rezultate ,˘ Cˆ and prefer˘ am print*? Cod recursiv, prea mult efort cu alte instrumente Cod paralel Cod greu de depanat altfel (kernel code) Heisenbugs Jurnalizare efort minim de eliminare macrou-ri de debug

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Despre print*
modificarea codului: eficient a vs. rezultate ,˘ Cˆ and prefer˘ am print*? Cod recursiv, prea mult efort cu alte instrumente Cod paralel Cod greu de depanat altfel (kernel code) Heisenbugs Jurnalizare efort minim de eliminare macrou-ri de debug Macro debug ideal (v. TT01) #define DEBUG(fmt, ...) fprintf(LOGFILE, fmt, ## VA ARGS )

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

GDB

GNU Debugger - Depanatorul standard Portabil: sisteme + limbaje Stallman, 1986

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

GDB

GNU Debugger - Depanatorul standard Portabil: sisteme + limbaje Stallman, 1986 5 lucruri majore:
Pornire program, specificare parametri Fort , are oprire program condit , ionat sau obligatoriu Examinare pas a (seg fault?) , i pentru oprire prematur˘ Schimbare variabile (instruct , iuni ?) Rulare invers˘ a - din versiunea 7.0 (2009)

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

GDB

GNU Debugger - Depanatorul standard Portabil: sisteme + limbaje Stallman, 1986 5 lucruri majore:
Pornire program, specificare parametri Fort , are oprire program condit , ionat sau obligatoriu Examinare pas a (seg fault?) , i pentru oprire prematur˘ Schimbare variabile (instruct , iuni ?) Rulare invers˘ a - din versiunea 7.0 (2009) - incomplet

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

GDB - basic

Compilare gcc -g -Wall -O0 sursa

Depanare gdb executabil

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

DDD

Limitare grav˘ a GDB: TUI

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

DDD

Limitare grav˘ a GDB: TUI Solut , ie: Data Display Debugger

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

DDD

Limitare grav˘ a GDB: TUI Solut , ie: Data Display Debugger Avantaj: date >> cod

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

DDD

Limitare grav˘ a GDB: TUI Solut , ie: Data Display Debugger Avantaj: date >> cod Compilare identic˘ a, execut ın GUI , ie ˆ

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

DDD

Limitare grav˘ a GDB: TUI Solut , ie: Data Display Debugger Avantaj: date >> cod Compilare identic˘ a, execut ın GUI , ie ˆ Demo...

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Cheatsheet GDB
Rulare program run (r) Listare cod program list (l) Afis are stiv˘ a apel backtrace (bt) , Introducere ˆ ıntrerupere break (b) Breakpoint condit b if cond , ional Continuare execut ie continue (c) , Avansare un pas (f˘ ar˘ a apel) next (n) Avansare o instruct step (s) , iune Continuare pˆ an˘ a la return finish (fin) Repetare comand˘ a anterioar˘ a blank Afis are cont inut variabil˘ a print (p) , , Afis a display (disp) , are permanent˘ Oprire la modificare watch (wa) Modificare variabil˘ a set var expr Pentru toate celelalte exist˘ a help (h).

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Valgrind

Remember Heisenbugs?

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Valgrind

Remember Heisenbugs? Valgrind - depanator memorie generic, framework analiz˘ a dinamic˘ a Mas a virtual˘ a - JIT , in˘

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Valgrind

Remember Heisenbugs? Valgrind - depanator memorie generic, framework analiz˘ a dinamic˘ a Mas a virtual˘ a - JIT , in˘ cod → Intermediate Representation − − − − − − − − − − − − − → Modific˘ ari ale IR → Cod mas a rulat ˆ ın gazd˘ a. , in˘
Instrument de testare

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Valgrind

Remember Heisenbugs? Valgrind - depanator memorie generic, framework analiz˘ a dinamic˘ a Mas a virtual˘ a - JIT , in˘ cod → Intermediate Representation − − − − − − − − − − − − − → Modific˘ ari ale IR → Cod mas a rulat ˆ ın gazd˘ a. , in˘ performant a–– ,˘
Instrument de testare

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Valgrind

Remember Heisenbugs? Valgrind - depanator memorie generic, framework analiz˘ a dinamic˘ a Mas a virtual˘ a - JIT , in˘ cod → Intermediate Representation − − − − − − − − − − − − − → Modific˘ ari ale IR → Cod mas a rulat ˆ ın gazd˘ a. , in˘ performant a–– ,˘ cod IR - ideal pentru scrierea de instrumente de testare
Instrument de testare

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Memcheck

Implicit Cod extra ˆ ın jurul fiec˘ arei instruct , iuni

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Memcheck

Implicit Cod extra ˆ ın jurul fiec˘ arei instruct , iuni Sanitizare memorie: validitate + adresabilitate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Memcheck

Implicit Cod extra ˆ ın jurul fiec˘ arei instruct , iuni Sanitizare memorie: validitate + adresabilitate Mecanism propriu de adresare s , i alocare memorie

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Memcheck

Implicit Cod extra ˆ ın jurul fiec˘ arei instruct , iuni Sanitizare memorie: validitate + adresabilitate Mecanism propriu de adresare s , i alocare memorie De 20 de ori mai lent, extrem de util Probleme detectate:
memorie neinit a , ializat˘ citiri / scrieri zone eliberate citiri / scrieri final zone alocate scurgeri memorie

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Python

5 tehnici de debug: print - mai eficient pentru limbaje interpretate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Python

5 tehnici de debug: print - mai eficient pentru limbaje interpretate logging - 5 nivele personalizate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Python

5 tehnici de debug: print - mai eficient pentru limbaje interpretate logging - 5 nivele personalizate code.interact - doar o simpl˘ a insert , ie

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Python

5 tehnici de debug: print - mai eficient pentru limbaje interpretate logging - 5 nivele personalizate code.interact - doar o simpl˘ a insert , ie invocare pdb (gdb python) prin cod

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Python

5 tehnici de debug: print - mai eficient pentru limbaje interpretate logging - 5 nivele personalizate code.interact - doar o simpl˘ a insert , ie invocare pdb (gdb python) prin cod invocare pdb din linia de comand˘ a

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):
Nu respect˘ a standardul de la gdb

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):
Nu respect˘ a standardul de la gdb stop at/in ˆ ın loc de break

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):
Nu respect˘ a standardul de la gdb stop at/in ˆ ın loc de break methods

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):
Nu respect˘ a standardul de la gdb stop at/in ˆ ın loc de break methods greu de folosit, nedocumentat

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Java

4 tehnici de debug: System.out.println - BAD Applets - draw text jdb (gdb java):
Nu respect˘ a standardul de la gdb stop at/in ˆ ın loc de break methods greu de folosit, nedocumentat

Folosire GUI

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

MPI

paralelism + debugging = probleme depan˘ am un singur thread sau toate? Cel mai bine folosim jurnalizare Exist˘ a utilitare de debug: Total View Putem folosi gdb cu un mic trick/cheat

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

MPI

paralelism + debugging = probleme depan˘ am un singur thread sau toate? Cel mai bine folosim jurnalizare Exist˘ a utilitare de debug: Total View Putem folosi gdb cu un mic trick/cheat Paralelizare gdb + xterm mpirun -np N xterm -e gdb program

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Expert debugging
printk vs printf

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Expert debugging
printk vs printf
logging levels: <linux/kernel.hi> printk(KERN CRIT ”msg”); syslogd - jurnalizare line buffered sau nu, ˆ ın funct , ie de console loglevel buffer circular mic (4KB - 1MB) slows down the system

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Expert debugging
printk vs printf
logging levels: <linux/kernel.hi> printk(KERN CRIT ”msg”); syslogd - jurnalizare line buffered sau nu, ˆ ın funct , ie de console loglevel buffer circular mic (4KB - 1MB) slows down the system

debugging by querying: ps, netstat, ioctl, sysfs, /proc

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Expert debugging
printk vs printf
logging levels: <linux/kernel.hi> printk(KERN CRIT ”msg”); syslogd - jurnalizare line buffered sau nu, ˆ ın funct , ie de console loglevel buffer circular mic (4KB - 1MB) slows down the system

debugging by querying: ps, netstat, ioctl, sysfs, /proc debugging by watching: strace

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Expert debugging
printk vs printf
logging levels: <linux/kernel.hi> printk(KERN CRIT ”msg”); syslogd - jurnalizare line buffered sau nu, ˆ ın funct , ie de console loglevel buffer circular mic (4KB - 1MB) slows down the system

debugging by querying: ps, netstat, ioctl, sysfs, /proc debugging by watching: strace using gdb

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Kernel debugging with gdb

invocare ca s , i cum nucleul ar fi aplicat , ie: gdb /usr/src/linux/vmlinux /proc/kcore

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Kernel debugging with gdb

invocare ca s , i cum nucleul ar fi aplicat , ie: gdb /usr/src/linux/vmlinux /proc/kcore

folosire kdb - pe kdb-enabled kernels

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Kernel debugging with gdb

invocare ca s , i cum nucleul ar fi aplicat , ie: gdb /usr/src/linux/vmlinux /proc/kcore

folosire kdb - pe kdb-enabled kernels virtualizare - greu de realizat

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Kernel debugging with gdb

invocare ca s , i cum nucleul ar fi aplicat , ie: gdb /usr/src/linux/vmlinux /proc/kcore

folosire kdb - pe kdb-enabled kernels virtualizare - greu de realizat User Mode Linux

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g Compil˘ am cu -g3 -gdwarf-2

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g Compil˘ am cu -g3 -gdwarf-2 macro expand expression

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g Compil˘ am cu -g3 -gdwarf-2 macro expand expression info macro macro

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g Compil˘ am cu -g3 -gdwarf-2 macro expand expression info macro macro ## s , i # - nesuportate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

C Preprocessor Macros

Implicit, toate sunt expandate Chiar s , i la -g Compil˘ am cu -g3 -gdwarf-2 macro expand expression info macro macro ## s , i # - nesuportate macro-uri cu num˘ ar variabil de argumente - nesuportate

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time?

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars passcount

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars passcount tstart, tstop

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars passcount tstart, tstop tfind, tdump - examinare

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars passcount tstart, tstop tfind, tdump - examinare save-tracepoints file

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Tracepoints
Cum depan˘ am aplicat , iile real-time? trace and collect = tracepoints trace linie actions collect vars passcount tstart, tstop tfind, tdump - examinare save-tracepoints file funct a doar pentru remote debugging , ioneaz˘

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Remote debugging

Necesit˘ a o copie a programului pe gazd˘ a

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Remote debugging

Necesit˘ a o copie a programului pe gazd˘ a Invocare uzual˘ a

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Remote debugging

Necesit˘ a o copie a programului pe gazd˘ a Invocare uzual˘ a comand˘ a remote: target remote:port

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Remote debugging

Necesit˘ a o copie a programului pe gazd˘ a Invocare uzual˘ a comand˘ a remote: target remote:port gdbserver

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Running app

Putem depana un program care ruleaz˘ a?

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Running app

Putem depana un program care ruleaz˘ a? attach PID

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Running app

Putem depana un program care ruleaz˘ a? attach PID Procesul va rula s a detas , i dup˘ , are

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

State of the Art

Completare posibilitate rulare ˆ ınapoi Debugging s , i anti-debugging Automatic online debugging (compilare online automat˘ acodepad) Differential debugging

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bibliografie, resurse utile
http://www.quotationspage.com/quote/781.html http://catb.org/jargon/html/index.html http: //sourceware.org/gdb/current/onlinedocs/gdb.html http://oopweb.com/CPP/Documents/DebugCPP/Volume/ techniques.html http: //www.gnu.org/software/gdb/news/reversible.html http://www.gnu.org/software/ddd/ http://aymanh.com/python-debugging-techniques http://docs.python.org/library/pdb.html http://docs.python.org/library/logging.html http://www.javaworld.com/javaworld/javaqa/ 2000-06/04-qa-0623-jdb.html

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Bibliografie, resurse utile (cont.)

http://www.totalviewtech.com/ http://user-mode-linux.sourceforge.net/ http://www.linuxjournal.com/article/5749 http://www-zeuthen.desy.de/dv/documentation/ unixguide/infohtml/gdb/gdb_23.html http://codepad.org/

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

ˆ Intreb˘ ari ? ...

Bug-uri ¸ si erori...

Debugging elementar

C Debugging

Extra Debugging

Extra Debugging

Future

Fundamental Axiom of Programming (Rick Cook) Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.