Todays Agenda u CVS u GDB Recitation 2
Today’s Agenda u CVS u GDB Recitation 2: Abhijit Warkhedi 9/25/2020 1
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. Recitation 2: Abhijit Warkhedi 9/25/2020 2
What CVS cannot do. . . u Not a build system. u Not a substitute for management. u Not a substitute for developer communication. u Does u Not not have change control. an automated testing program. u Does not have a built-in process model. Recitation 2: Abhijit Warkhedi 9/25/2020 3
File Management without CVS Dev_1 Project Files Dev_2 Recitation 2: Abhijit Warkhedi Dev_3 9/25/2020 4
File Management with CVS Dev_1 Project Files Dev_2 Recitation 2: Abhijit Warkhedi Dev_3 9/25/2020 5
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. Recitation 2: Abhijit Warkhedi 9/25/2020 6
An Example engine. c prjv 1 (tag) prjv 2 util. c window. c 1. 1 1. 2 1. 3 Recitation 2: Abhijit Warkhedi 9/25/2020 7
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. Recitation 2: Abhijit Warkhedi 9/25/2020 8
Non-linear development prjv 1_fixes (branch) Recitation 2: Abhijit Warkhedi prjv 2 prjv 3 b 1 b 2 9/25/2020 prjv 4 9
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? Recitation 2: Abhijit Warkhedi 9/25/2020 10
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 Recitation 2: Abhijit Warkhedi 9/25/2020 11
Here is how it looks. . . /usr/u/warkhedi/cvsroot trialprj engine. c, v util. c, v window. c, v Recitation 2: Abhijit Warkhedi 9/25/2020 12
Check in, Check out. u Checking out files in repository. – cvs co -d project 1 trialprj – Creates files in project 1 directory. – Notice CVS directory in project 1. u E. g. modify engine. c u Checking in changes. – cvs commit – Only engine. c is checked in. Recitation 2: Abhijit Warkhedi 9/25/2020 13
Updating my copy engine. c 1. 1 engine. c 1. 2 engine. c 1. 3 local copy engine. c 1. 1 (*) update engine. c 1. 3 (U) Recitation 2: Abhijit Warkhedi 9/25/2020 commit engine. c 1. 4 14
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. Recitation 2: Abhijit Warkhedi 9/25/2020 15
Let’s play tag. . . u Tag u cvs all files at a strategic point in time. tag -R prjv 1. u Tagged u Later, files can have different revision numbers. the project version 1 can be checked out. – cvs co -r prjv 1 -d project 1 trialprj – remake to get object files for version 1. Recitation 2: Abhijit Warkhedi 9/25/2020 16
Creating Branches u cvs rtag -b -r prjv 1_fixes trialprj u CVS command rtag creates new tag in the repository. u Branch prjv 1_fixes is spawned from tagged files of prjv 1. u Bug fixes can be made on prjv 1_fixes and subsequent branch versions can be merged later. Recitation 2: Abhijit Warkhedi 9/25/2020 17
Sticky tags u All subsequent commands operate on the tag. u cvs co -r prjv 1 -d project 1 trialprj – when you checkout with a specific tag, all files have a sticky tag. – cannot commit files with sticky tag. u Exception: u Use branches. update -A to eliminate sticky tags. Recitation 2: Abhijit Warkhedi 9/25/2020 18
An Example u cvs co -r prjv 1 -d project 1 trialprj u modify u cvs util. c commit – tries to commit to prjv 1 – cannot commit changes to prjv 1 Recitation 2: Abhijit Warkhedi 9/25/2020 19
Another Example u cvs co -r prjv 1_fixes -d project 1_fixes trialprj u modify u cvs util. c commit – tries to commit to branch prjv 1_fixes – works! makes sense. Recitation 2: Abhijit Warkhedi 9/25/2020 20
Merging Branches u cvs u cd co -d latest trialprj latest u cvs update -j prjv 1_fixes – merges all changes in the branch into the latest copy. u cvs commit – all fixes incorporated into the mainline. Recitation 2: Abhijit Warkhedi 9/25/2020 21
Adding/Deleting Files u Adding a file to the repository. – cd project 1 – cvs add mem. c – project 1 must have CVS directory. u Removing a file from the repository. – cd project 1 – cvs remove mem. c Recitation 2: Abhijit Warkhedi 9/25/2020 22
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. Recitation 2: Abhijit Warkhedi 9/25/2020 23
Lot more options available!! u Features discussed so far are most commonly used. u Feel free to explore others too. u Start experimenting now. Recitation 2: Abhijit Warkhedi 9/25/2020 24
GDB u Vanilla debugger. u XGDB - graphical version of GDB u Visual Studio debugger. Recitation 2: Abhijit Warkhedi 9/25/2020 25
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. Recitation 2: Abhijit Warkhedi 9/25/2020 26
Example include <stdio. h> #include <stdlib. h> int sqr(int x) { int y; return(y); } 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"); Recitation 2: Abhijit Warkhedi 9/25/2020 27
Continued. . . u Compile program with -g option to include symbolic info. – gcc -g test. c – gdb a. out u break u run 7 -- sets breakpoint at line 7. -- runs the program. u Program Recitation 2: Abhijit Warkhedi stops at line 7. 9/25/2020 28
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 Recitation 2: Abhijit Warkhedi displays change in x. 9/25/2020 29
Continued. . . u continue u program u up stops in sqr() -- goes up to main stack frame. u down u step -- back down to sqr() and print y -- displays value of y. u delete 1 -- deletes breakpoint 1 Recitation 2: Abhijit Warkhedi 9/25/2020 30
Finally. . . u continue -- runs the program till the end. u watch is deleted when out of scope. Recitation 2: Abhijit Warkhedi 9/25/2020 31
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!! Recitation 2: Abhijit Warkhedi 9/25/2020 32
- Slides: 32