Professional Documents
Culture Documents
Building
Make
Debugging
Gdb
Documenting
Doxygen
2
Build chain
An automatic build chain is useful to:
Com Com com files" Com com Com ile thousands of sou!ce files" ile #uickly: $ithout !unning manually the ile! and $ithout !ecom iling u %to%date ile easily: thi!d a!ties must be able to ile the code" ile on &a!ious latfo!ms"
3
Cons:
.ot easily o!table" - ace +indentation, sensiti&e semantics"
'
Makefile
Makefile contains:
Configu!ation &a!iables"
0"g" $hich com ile! and linke! to use1 flags to be assed to com ile! and linke!"
Makefile
9a!iables:
9A*.AM0: 9A;)0;<-(
Assigns a a list of &alues1 at !eading time + o!table,"
9A*.AM0:: 9A;)0;<-(
Assigns to a &a!iable a list of &alues immediately +G.),"
9A*.AM0=: 9A;)0;<-(
Adds the list of &alues to !e&ious assigned &alues"
>+9A*.AM0,
*eads a &a!iable"
8
Makefile
Common &a!iable names:
CC: the C como ile!
C@;AG-: flags fo! the C com ile!"
Makefile
C!edefined mac!os:
>D: the ta!get" >2: the fi!st de endency" >E: all the de endencies" >F: modified files" G: the cu!!ent file"
"CI5.J
Collects as de endencies ta!gets $hich do not match any gene!ated file name +e"g" all1 clean,"
H
Makefile: *unning
*un make $ith Makefile1 on default ta!get:
make
"x,:
Makefile 0xam le K
@iles:
<m lementation: main.c com.c set.c Ieade!s: com.h set.h1 located into include"
Auxilia!y lib!a!ies:
-tanda!d C math lib!a!y" Custom libsupport.so located into lib"
KK
Makefile 0xam le K
# Configuring: CC:= gcc LD:= gcc CFLAGS:= -c -Wall -Iinclude LDFLAGS:= -Llib LDLIBS:= -lsupport -lm
K2
Makefile 0xam le K
# Sources: S CS:= main!c com!c set!c # "b#ects: "B$S:= $(SRCS,.c=.o)
K3
Makefile 0xam le K
# De%ault target: all: m&app!' m&app!': ()"B$S* @echo Lin+ing (, @$(LD) $(LDFLAGS) -o $@ $^ $(LDLI S) clean: ,rm -!o m&app!'
K'
Makefile 0xam le K
# Compiling. b& using # pattern matc/ing: !.o: !.c ,ec/o (, ,()CC* ()CFLAGS* -o (, (0 ."#$%&: '(( c(e'n
K/
Makefile 0xam le K
0xam le K !os:
9e!y sho!t" 9e!y !eusable"
0xam le K cons:
.ot fine tuned: does not ca tu!e de endencies !elated to heade! files"
K8
Makefile 0xam le 2
# Fine tuned compiling: )'in.o: )'in.c co).h *e+.h ,ec/o (, ,()CC* ()CFLAGS* -o (, (0 *e+.o: *e+.c *e+.h ,ec/o (, ,()CC* ()CFLAGS* -o (, (0 co).o: co).c co).h *e+.h ,ec/o (, ,()CC* ()CFLAGS* -o (, (0
K?
Makefile 0xam le 2
0xam le 2 !os:
Ca tu!es all the de endencies" 9e!y safe1 e&en in case of a!allel com iling"
0xam le 2 cons:
;onge! to $!ite" Cannot be !eused"
KB
Agenda
Building
Make
Debugging
Gdb
Documenting
Doxygen
KH
Debugging
9e!ification and debugging:
5ne of the ha!dest hases of de&elo ment" (he most time consuming acti&ity +?L%BLG,
2L
Debugge!
A debugge! allo$s:
(o sus end the execution of a !og!am in s ecific oints" (o execute the !og!am ste by ste " (o ins ect &a!iable &alues at !un%time"
2K
Debugge!
GDB +Gnu Debugge!,:
@!ee and o en sou!ce" -tanda!d tool used $ith gcc" *e#ui!es an en!iched executable:
gcc %g: com ile $ith debugging infos" gcc %ggdb: as %g1 but ta!geting gdb ex licitly"
GDB Patch
Patch oint
-us ends the execution $hene&e! a $atched ex !ession changes its &alue" )seful to check the e&olution of a &a!iable" Gdb syntax:
$atch 2ex !ession3
2/
28
@!ame
C!ints infos about the cu!!ent method stack" GDB synthax:
f!ame 4 f +sho!t desc!, info f!ame 4 info f +long,
2?
GDB 0xecution
0xecutes a !og!am f!om the beginning: !un 4 ! Continues the execution1 f!om the !eached oint: continue 4 c 0xecute the next line atomically: next 4 n 0xecute the next inst!uction1 going into e&entual methods called: ste 4 s *e eat the last command: Q!etu!n
2B
Agenda
Building
Make
Debugging
Gdb
Documenting
Doxygen
2H
Documenting
Documentation:
@o! use!:
Manuals1 guides1 tuto!ials1 etc"" AC< documentation +fo! lib!a!ies,"
Documenting
-ou!ce code documentation:
Comments fo! the AC<"
Automatic gene!ation of AC< documentation"
3K
Doxygen
Doxygen:
(ool fo! automatic gene!ation of AC< documentation" *uns on many latfo!ms" @!ee and o en sou!ce" -u o!ts many languages"
C1 C==1 Ra&a"
-u
*unning Doxygen
Gene!ate a configu!ation file +Doxyfile,:
doxygen %g
*un doxygen:
doxygen
Doxygen Configu!ation
Main configu!ation a!amete!s:
C*5R0C(N.AM0 +e"g" My;ib, 5)(C)(ND<*0C(5*J +e"g" doc, <.C)( 4 @<;0NCA((0*.- +e"g" s!c, *0C)*-<90 +e"g" J0-, 0AC;)D0 4 0AC;)D0NCA((0*.- +S"Ma&a, G0.0*A(0NS +e"g" G0.0*A(0NI(M;,
3'
Doxygen (ags
Doxygen a!ses s ecial comments:
4SS Comment a!sed +C, S4
4S Comment not a!sed +C, S4
Doxygen (ags
Main tags:
Db!ief 2comment3
A sho!t comment"
D!etu!n 2comment3
@o! method !etu!n &alue"
Doxygen (ags
(ags fo! global documentation:
<nfo!mation about file content:
4SS Dfile S 2comment 3 S4
Doxygen 0xam le
1-- ,name List accessors! -1 1-,2 -1 1-- ,brie% Gets t/e element at gi3en position! - Linear comple'it&! - ,param l 4/e list! - ,param pos 4/e position! - ,return 4/e stored element! -1 3oid - getList5lement) List - l. int pos *6 1-,7 -1
3B