Académique Documents
Professionnel Documents
Culture Documents
DebuggingwithCode::BlocksCodeBlocks
DebuggingwithCode::Blocks
FromCodeBlocks
Contents
1Builddebugversionofyourproject
2AddWatches
2.1Inversion10.05
2.2In12.11orlatestnightlybuilds
3DoubleclickingintheCallstackwindow
4SetBreakpoints
5Notes
5.1Scriptsupport
5.2Singlefiledebugging
5.3Pathwithspaces
5.4Forking
5.5UpdatetothenewestversionofMinGW
5.6Use32bitCDBfor32bitprogramsand64bitCDBfor64bitprograms
5.7LimitsontheearlyversionofMinGW
5.8Seealso
Builddebugversionofyourproject
Makesurethattheprojectiscompiledwiththeg(debuggingsymbols)compileroptionon,andthes(stripsymbols)option
off.Thisensuresthattheexecutablehasdebugsymbolsincluded.
Compileroptimizationswitchesshouldbeturnedoff,strippingsymbols(s)mustbeturnedoff.
Keepinmindthatyoumayhavetorebuildyourprojectasuptodateobjectfilesmightnotberecompiledwithg
otherwise.PleasebeawarethatincompilersotherthanGCC,gand/orsmightbeadifferentswitch(smightnotbe
availableatall).
Menu=>Project=>BuildOptions
AddWatches
Inversion10.05
OpenTheDebuggerWatchesWindow
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
1/5
01/04/2016
DebuggingwithCode::BlocksCodeBlocks
Thelistofwatchescanbesavedtoafileandlaterreloaded.Todoso,rightclickinthelistofwatchesandselect"savewatch
file"(and"loadwatchfile"toreloadthemagain).
In12.11orlatestnightlybuilds
Inthelatestnightlybuildsthewatcheswindowhasbeenredesignedandworksdifferentlythattheonein10.05.
Currentlytherearethreewaysofaddingwatchesinit:
1.Clickintheemptylastrowinthewatcheswindow,typethenameofthevariable(orfullexpression)andhitenter.
2.Whilethedebuggerhasstoppedonabreakpointselectavariablenameorfullexpression,rightclicktoopenthe
contextmenuandthenselect"Addwatch'expression'".
3.Selectanexpressionintheeditoranddrag'n'dropitinthewatcheswindow.
Theautomaticinclusionoflocalvariablesandfunctionargumentshavebeingreimplementedin13.12.
DoubleclickingintheCallstackwindow
Note:whendebugging,doubleclickingonaframeinthe"callstack"debugwindowdoesnotautomaticallyupdatethe
variablesdisplayedinthe"watches"debugwindow.
Youhavetorightclickonaframeinthe"callstack"debugwindowandselect"Switchtothisframe".
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
2/5
01/04/2016
DebuggingwithCode::BlocksCodeBlocks
SetBreakpoints
Findthelinecontainingthevariabletobewatched.Setabreakpointinapositionthatwillallowyoutoobservethevariable
value.
Menu=>Debug=>ToggleBreakpoint
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
3/5
01/04/2016
DebuggingwithCode::BlocksCodeBlocks
Runthedebuggeruntilthebreakpointisreached.RightclickthevariabletosetawatchintheWatchWindow.
Breakpointsmayalsobetoggledwithaleftclickinthelefteditormargin.
Notes
Scriptsupport
Code::Blocksnativelyusesquirrelscriptlanguagetodealwithgdb,see:Debuggerscripts.Asgdb7.xsupportpythonpretty
printer,so,itcanalsousegdb(withpythonsupport)toshowsomecomplexvariablevalues.seeforumthreadunofficial
MinGWGDBgdbwithpythonreleased(http://forums.codeblocks.org/index.php/topic,11301.msg77000.html#msg77000)
andUseGDBpythonunderCodeblocks(http://code.google.com/p/qpgcc/wiki/GDB)formoredetails.
Singlefiledebugging
Todebugyourprogramyouneedtosetupaproject.Singlefileprogramsarenotsupported.
Pathwithspaces
Breakpointscouldnotworkifthepath/folderyou'veplacedyourprojectcontainsspacesorotherspecialcharacters.Tobe
safeuseEnglishletters,digitsand'_'.
Forking
Ifyourapplicationusesthe'fork'systemcallyou'llhavetroublestoppingthedebuggedprogramorsettingbreakpointsonthe
fly.HereisalinkexplainingtheforkingmodesofGDB:http://sourceware.org/gdb/onlinedocs/gdb/Forks.html
UpdatetothenewestversionofMinGW
Fromgdb6.8releasedonApril2008,itsupportsmanyfeatureswhichdoesnotexistinearlyversions.Youcanupdateby
installingbinariesfromTDMMingwpackage(http://www.tdragon.net/recentgcc/).
Use32bitCDBfor32bitprogramsand64bitCDBfor64bitprograms
Itseemsthatdebugginga32bitprogramwith64bitCDBdoesn'tworkonWindows7,but32bitCDBworksperfectly.
LimitsontheearlyversionofMinGW
IfyourarestillusingtheMinGWandgdb6.7from8.02setupfiles(http://www.codeblocks.org/downloads/5),setting
breakpointsintheconstructorwillnotwork.Herearesometricks.
BreakpointsdonotworkinconstructorsordestructorsinGDB6.7andearlierversion.Theydo,however,workinroutines
calledfromthem.ThisisanearlyGDBrestriction,notabug.Soyoucoulddosomethinglike:
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
4/5
01/04/2016
DebuggingwithCode::BlocksCodeBlocks
...andplaceabreakpointin"DebugCtorDtor"attheline"inti=0".Thedebuggerwillbreakatthatline.Ifyouthenstepthe
debugger(MenuDebug=>NextLineoralternativelyF7)you'llreachthecodeintheconstructor/destructor("is_initialized=
true/false").
Seealso
Debuggerscripts
PrettyPrinters
Retrievedfrom"http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks&oldid=7736"
Category: UserDocumentation
Thispagewaslastmodifiedon12April2014,at10:41.
http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
5/5