320 likes | 401 Views
Today’s Agenda. CVS GDB. What is CVS?. CVS is a version control system. Allows retrieval of old versions of projects. Reduces the need for communication between developers to coherently maintain files.
E N D
Today’s Agenda • CVS • GDB
What is CVS? • CVS is a version control system. • Allows retrieval of old versions of projects. • Reduces the need for communication between developers to coherently maintain files. • Stores all the versions of a file in a clever way that only stores the differences between versions.
What CVS cannot do... • Not a build system. • Not a substitute for management. • Not a substitute for developer communication. • Does not have change control. • Not an automated testing program. • Does not have a built-in process model.
File Management without CVS Dev_1 Project Files Dev_2 Dev_3
File Management with CVS Dev_1 Project Files Dev_2 Dev_3
Basic Concepts • All files stored in a central repository. • Each version of a file has a unique revision number. • (e.g. 1.1, 1.2, 1.3.2.2) • always contains even number of digits. • CVS is not limited to linear development.
An Example engine.c util.c window.c 1.1 1.1 1.1 prjv1 (tag) 1.2 1.2 1.2 1.3 1.3 1.3 prjv2
What is a tag? • A symbolic name given to a file revision or more typically a set of file revisions. • Tags can be used to represent versions of an entire project. • Should be used at strategic points in the development cycle.
Non-linear development prjv1 prjv2 prjv3 prjv4 b1 b2 prjv1_fixes (branch)
Why would I use a branch? • Allows for maintenance of bug fixes. • Provides means to backtrack and create experimental versions of a project. • Scenario: already tagged 3 versions of project. And users complain about bug in version 1 -- what do you do?
Okay, how do I use this? • Creating the CVS repository. • setenv CVSROOT /usr/u/warkhedi/cvsroot • cvsinit • Assume project files in project directory. • Adding directory structure to CVS. • cd project • cvs import trialprj NONE INITIAL
Here is how it looks... /usr/u/warkhedi/cvsroot trialprj engine.c,v util.c,v window.c,v
Check in, Check out. • Checking out files in repository. • cvs co -d project1 trialprj • Creates files in project1 directory. • Notice CVS directory in project1. • E.g. modify engine.c • Checking in changes. • cvs commit • Only engine.c is checked in.
Updating my copy engine.c 1.1 engine.c 1.2 engine.c 1.3 local copy engine.c 1.1 (*) update commit engine.c 1.3 (U) engine.c 1.4
3 Possibilities at an Update • If local file is un-modified: • CVS updates local copy with the latest. • U engine.c • If local file is modified: • CVS attempts to merge the two files, textually. • If there is conflict (defined as change on same line), modify local file to indicate this else merge the two files quietly.
Let’s play tag... • Tag all files at a strategic point in time. • cvs tag -R prjv1 . • Tagged files can have different revision numbers. • Later, the project version 1 can be checked out. • cvs co -r prjv1 -d project1 trialprj • remake to get object files for version 1.
Creating Branches • cvs rtag -b -r prjv1 prjv1_fixes trialprj • CVS command rtag creates new tag in the repository. • Branch prjv1_fixes is spawned from tagged files of prjv1. • Bug fixes can be made on prjv1_fixes and subsequent branch versions can be merged later.
Sticky tags • All subsequent commands operate on the tag. • cvs co -r prjv1 -d project1 trialprj • when you checkout with a specific tag, all files have a sticky tag. • cannot commit files with sticky tag. • Exception: branches. • Use update -A to eliminate sticky tags.
An Example • cvs co -r prjv1 -d project1 trialprj • modify util.c • cvs commit • tries to commit to prjv1 • cannot commit changes to prjv1
Another Example • cvs co -r prjv1_fixes -d project1_fixes trialprj • modify util.c • cvs commit • tries to commit to branch prjv1_fixes • works! makes sense.
Merging Branches • cvs co -d latest trialprj • cd latest • cvs update -j prjv1_fixes • merges all changes in the branch into the latest copy. • cvs commit • all fixes incorporated into the mainline.
Adding/Deleting Files • Adding a file to the repository. • cd project1 • cvs add mem.c • project1 must have CVS directory. • Removing a file from the repository. • cd project1 • cvs remove mem.c
Status Checking • cvs status • provides complete information on all files in a directory • e.g. revision #s, stick tag, etc. • cvs diff • displays difference between the working version and the repository version. • diffs all files in the current directory.
Lot more options available!! • Features discussed so far are most commonly used. • Feel free to explore others too. • Start experimenting now.
GDB • Vanilla debugger. • XGDB - graphical version of GDB • Visual Studio debugger.
What is a debugger? • Allows you to debug. Duh! • More specifically... • can step through code, set breakpoints, watch variables, examine structures, etc. • Source-Level debuggers. • allow user to visually interact with source code. • Assembly-Level debuggers. • well, they are just a pain to use.
Example include <stdio.h> #include <stdlib.h> void main() { int x, y, z; x = 0; y = 0; while (x <= 5) { x++; y = y + x; z = sqr(y); printf("%d ", z); } printf("\n"); } int sqr(int x) { int y; return(y); }
Continued... • Compile program with -g option to include symbolic info. • gcc -g test.c • gdb a.out • break 7 -- sets breakpoint at line 7. • run -- runs the program. • Program stops at line 7.
Continued... • step -- steps one source line. • watch x -- displays variable x upon change. • break sqr -- sets breakpoint on sqr() • continue • program displays change in x.
Continued... • continue • program stops in sqr() • up -- goes up to main stack frame. • down -- back down to sqr() • step and print y -- displays value of y. • delete 1 -- deletes breakpoint 1
Finally... • continue -- runs the program till the end. • watch is deleted when out of scope.
Other useful features • next command • steps over an entire function. • finish command • execute until current stack frame returns. • And plenty others at your disposal!!