Download presentation
Presentation is loading. Please wait.
Published byDamian Lyons Modified over 9 years ago
1
Debugging, Build and Version Control Rudra Dutta CSC 230 - Spring 2007, Section 001
2
Copyright Rudra Dutta, NCSU, Spring, 20072 Practical Considerations In a practical environment, code must be integrated, maintained, packaged, and coding is a team effort Debugging – In general, and specifically “debugging” with printf Building – Minimal build - such as with make Other more powerful tools as well Commenting – Sensible commenting - turning comments into documentation Distribution - building libraries Version control – Allow the process of software evolution to be itself maintainable
3
Copyright Rudra Dutta, NCSU, Spring, 20073 Debugging - General Generally, debugging should start with examination of logic – Investigate using tests with boundary conditions – “Observe before modify” Debugging tools such as gdb allows easy examination of variables while stepping through code – Sometimes integrated into IDE – Compiling options may be required – Irritating situation - bug goes away when compiled as debug “Debugging” with printf – Insert printf at various points in the code to observe values – Major value: forces separation of code into easily understood statements – Minor value: comparatively platform and tool independent
4
Copyright Rudra Dutta, NCSU, Spring, 20074 Commenting First line of documentation With auto-generation, can effectively become nearly complete documentation – Auto-generating tools available, such as Doxygen – Similar to other language platforms, nothing specific to C Every function should document – Function call interface – Change to globals – Other side-effects on arguments – Forbidden calls – Boundary conditions – Sample calls – Author, modifier, date,...
5
Copyright Rudra Dutta, NCSU, Spring, 20075 Building Libraries Object files, one of which contains a main(), can be linked together to produce an executable Object files, none of which contains a main(), can also be archived together to produce a shared archive, or “library” Use the ar utility or equivalent Convention: “name” of archive is used (in slightly different ways) to find archive – Actual file will be called lib.a – Linked by gcc -l … – Needs to be in /usr/lib – Can be overridden by -L option
6
Copyright Rudra Dutta, NCSU, Spring, 20076 Archive Random Access A table of contents must be added before the library can be used – ranlib Another utility: libtool – Migrating to libtool on many platforms – Intended to replace both ar and ranlib – But check behavior Important to understand: – At the borderline between language and OS – For example: what is the format of binaries and object files?
7
Copyright Rudra Dutta, NCSU, Spring, 20077 Static and Dynamic Link Properly, an OS topic Multiply defined terms, various contexts For our purposes: – libtool or equivalent can produce libraries suitable for dynamic linking and/or loading However, may need support from compiler producing object files
8
Copyright Rudra Dutta, NCSU, Spring, 20078 Version Control Keep multiple programmers working on a project from clobbering each other Check out file - write ownership – Read-only access remains to others Check in modified copy - creates another version – May create complete version of code Can check out back versions CMVC, CVS, Subversion
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.