Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recitation 2: Abhijit Warkhedi2/25/20161 Today’s Agenda u CVS u GDB.

Similar presentations


Presentation on theme: "Recitation 2: Abhijit Warkhedi2/25/20161 Today’s Agenda u CVS u GDB."— Presentation transcript:

1 Recitation 2: Abhijit Warkhedi2/25/20161 Today’s Agenda u CVS u GDB

2 Recitation 2: Abhijit Warkhedi2/25/20162 What is CVS? u CVS is a version control system. u Allows retrieval of old versions of projects. u Reduces the need for communication between developers to coherently maintain files. u Stores all the versions of a file in a clever way that only stores the differences between versions.

3 Recitation 2: Abhijit Warkhedi2/25/20163 What CVS cannot do... u Not a build system. u Not a substitute for management. u Not a substitute for developer communication. u Does not have change control. u Not an automated testing program. u Does not have a built-in process model.

4 Recitation 2: Abhijit Warkhedi2/25/20164 File Management without CVS Project Files Dev_1 Dev_2Dev_3

5 Recitation 2: Abhijit Warkhedi2/25/20165 File Management with CVS Project Files Dev_1 Dev_2Dev_3

6 Recitation 2: Abhijit Warkhedi2/25/20166 Basic Concepts u All files stored in a central repository. u 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. u CVS is not limited to linear development.

7 Recitation 2: Abhijit Warkhedi2/25/20167 An Example 1.1 1.2 1.3 engine.cutil.cwindow.c prjv1 (tag) prjv2

8 Recitation 2: Abhijit Warkhedi2/25/20168 What is a tag? u A symbolic name given to a file revision or more typically a set of file revisions. u Tags can be used to represent versions of an entire project. u Should be used at strategic points in the development cycle.

9 Recitation 2: Abhijit Warkhedi2/25/20169 Non-linear development prjv1prjv2prjv3prjv4 b1b2 prjv1_fixes (branch)

10 Recitation 2: Abhijit Warkhedi2/25/201610 Why would I use a branch? u Allows for maintenance of bug fixes. u Provides means to backtrack and create experimental versions of a project. u Scenario: already tagged 3 versions of project. And users complain about bug in version 1 -- what do you do?

11 Recitation 2: Abhijit Warkhedi2/25/201611 Okay, how do I use this? u Creating the CVS repository. –setenv CVSROOT /usr/u/warkhedi/cvsroot –cvsinit u Assume project files in project directory. u Adding directory structure to CVS. –cd project –cvs import trialprj NONE INITIAL

12 Recitation 2: Abhijit Warkhedi2/25/201612 Here is how it looks... /usr/u/warkhedi/cvsroot trialprj engine.c,v util.c,v window.c,v

13 Recitation 2: Abhijit Warkhedi2/25/201613 Check in, Check out. u Checking out files in repository. –cvs co -d project1 trialprj –Creates files in project1 directory. –Notice CVS directory in project1. u E.g. modify engine.c u Checking in changes. –cvs commit –Only engine.c is checked in.

14 Recitation 2: Abhijit Warkhedi2/25/201614 Updating my copy engine.c 1.1 engine.c 1.2 engine.c 1.3 engine.c 1.1 (*) engine.c 1.3 (U) engine.c 1.4 local copy update commit

15 Recitation 2: Abhijit Warkhedi2/25/201615 3 Possibilities at an Update u If local file is un-modified: –CVS updates local copy with the latest. –U engine.c u 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.

16 Recitation 2: Abhijit Warkhedi2/25/201616 Let’s play tag... u Tag all files at a strategic point in time. u cvs tag -R prjv1. u Tagged files can have different revision numbers. u Later, the project version 1 can be checked out. –cvs co -r prjv1 -d project1 trialprj –remake to get object files for version 1.

17 Recitation 2: Abhijit Warkhedi2/25/201617 Creating Branches u cvs rtag -b -r prjv1 prjv1_fixes trialprj u CVS command rtag creates new tag in the repository. u Branch prjv1_fixes is spawned from tagged files of prjv1. u Bug fixes can be made on prjv1_fixes and subsequent branch versions can be merged later.

18 Recitation 2: Abhijit Warkhedi2/25/201618 Sticky tags u All subsequent commands operate on the tag. u 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. u Exception: branches. u Use update -A to eliminate sticky tags.

19 Recitation 2: Abhijit Warkhedi2/25/201619 An Example u cvs co -r prjv1 -d project1 trialprj u modify util.c u cvs commit –tries to commit to prjv1 –cannot commit changes to prjv1

20 Recitation 2: Abhijit Warkhedi2/25/201620 Another Example u cvs co -r prjv1_fixes -d project1_fixes trialprj u modify util.c u cvs commit –tries to commit to branch prjv1_fixes –works! makes sense.

21 Recitation 2: Abhijit Warkhedi2/25/201621 Merging Branches u cvs co -d latest trialprj u cd latest u cvs update -j prjv1_fixes –merges all changes in the branch into the latest copy. u cvs commit –all fixes incorporated into the mainline.

22 Recitation 2: Abhijit Warkhedi2/25/201622 Adding/Deleting Files u Adding a file to the repository. –cd project1 –cvs add mem.c –project1 must have CVS directory. u Removing a file from the repository. –cd project1 –cvs remove mem.c

23 Recitation 2: Abhijit Warkhedi2/25/201623 Status Checking u cvs status –provides complete information on all files in a directory –e.g. revision #s, stick tag, etc. u cvs diff –displays difference between the working version and the repository version. –diffs all files in the current directory.

24 Recitation 2: Abhijit Warkhedi2/25/201624 Lot more options available!! u Features discussed so far are most commonly used. u Feel free to explore others too. u Start experimenting now.

25 Recitation 2: Abhijit Warkhedi2/25/201625 GDB u Vanilla debugger. u XGDB - graphical version of GDB u Visual Studio debugger.

26 Recitation 2: Abhijit Warkhedi2/25/201626 What is a debugger? u Allows you to debug. Duh! u More specifically... –can step through code, set breakpoints, watch variables, examine structures, etc. u Source-Level debuggers. –allow user to visually interact with source code. u Assembly-Level debuggers. –well, they are just a pain to use.

27 Recitation 2: Abhijit Warkhedi2/25/201627 Example include #include 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); }

28 Recitation 2: Abhijit Warkhedi2/25/201628 Continued... u Compile program with -g option to include symbolic info. –gcc -g test.c –gdb a.out u break 7 -- sets breakpoint at line 7. u run -- runs the program. u Program stops at line 7.

29 Recitation 2: Abhijit Warkhedi2/25/201629 Continued... u step -- steps one source line. u watch x -- displays variable x upon change. u break sqr -- sets breakpoint on sqr() u continue u program displays change in x.

30 Recitation 2: Abhijit Warkhedi2/25/201630 Continued... u continue u program stops in sqr() u up -- goes up to main stack frame. u down -- back down to sqr() u step and print y -- displays value of y. u delete 1 -- deletes breakpoint 1

31 Recitation 2: Abhijit Warkhedi2/25/201631 Finally... u continue -- runs the program till the end. u watch is deleted when out of scope.

32 Recitation 2: Abhijit Warkhedi2/25/201632 Other useful features u next command –steps over an entire function. u finish command –execute until current stack frame returns. u And plenty others at your disposal!!


Download ppt "Recitation 2: Abhijit Warkhedi2/25/20161 Today’s Agenda u CVS u GDB."

Similar presentations


Ads by Google