Top Banner
CS3214: Project 1
33

CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Aug 03, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

CS3214: Project 1

Page 2: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Today’s presentation• Git• gdb• Project 1

Page 3: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Project 1• Due Monday, February 20 at 11:59 PM• Office hours are on course website

Check Piazza for updates

Page 4: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Git

Page 5: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Version Control System• Keep snapshots of your code• Sync your code with other developers

Page 6: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Getting the code!• Generate SSH keys, add to profile• Step by step instructions:

https://docs.gitlab.com/ee/ssh/README.html• Fork the repository here:

https://git.cs.vt.edu/cs3214-staff/cs3214-esh

• MAKE IT PRIVATE • Give developer access to your partner

Page 7: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Git basics• Git keeps your

projects history like a timeline

• Each point in the timeline is called a commit

Page 8: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Committing code• Edit some amount of code• You can view the status of files as you work

• “git status” to see file status (edited, staged, etc)• Add changes to staging area:

• “git add <file>” Adds file to staging area• “git add .” Adds all files to staging area

• When ready, commit them• “git commit -m “message”” Commit with message

Page 9: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

• Push your changes to Gitlab“git push”

• Pull teammate’s changes from Gitlab“git pull”

Must pull before push!

Page 10: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Merge Conflict Resolution

<<<<<<< HEAD// Author: Richard Feynman=======// Author: Elon Musk>>>>>>> 52ea9255764f9b67b1ce91250e1d70ddca7ab2cc...

src/esh.c

Red: My changesBlue: Remote changes

● Perform necessary changes (don’t forget to remove extra markup) and save file● Stage changes ($ git add src/esh.c )● Commit changes ($ git commit )● Do another pull ($ git pull ), just in case● Push final changes ($ git push )

Page 11: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Git Commands - TL;DR VersionShows a list of files that have been modified; shows changes that have been staged and those that haven’t$ git statusCopies the specified repo to the current directory$ git clone <repo url>Add the specified files to the staging area$ git add <files>Commit all staged changes$ git commit -m “commit message here”Get changes from the remote repo (gitlab) and apply them to local copy$ git pullPush local changes to the remote repo (gitlab)$ git push

Always do PULL before PUSH!

ResourcesOfficial tutorial page:http://git-scm.com/docs/gittutorialFree Codeschool guided tutorial:https://www.codeschool.com/courses/try-gitWalk-through tutorial:http://gitimmersion.com/index.htmlAlso, google.comSeriously… git is very popular you will probably find everything you need just by searching for it.

Page 12: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Questions?

Page 13: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

GDBDebugging is key to success!

Page 14: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

$ gcc -g • Code MUST compile with -g for gdb to work

properly!• Also highly recommended to turn off

optimizations (-O0) as compilers may shift around or optimize out code

Page 15: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

$ gdb --args • $ gdb --args program arg1 arg2• Is saved as part of BASH history• Great alternative to “run arg1 arg2”

Page 16: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

(gdb) layout src• Show source code lines while debugging• Far superior alternative to list• Turn off with Ctrl-X+A

Page 17: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Backtrace and Frames• (gdb) bt (show function call trace)• (gdb) frame <num>• After selecting a frame, you can print all

variables declared in that function call

Page 18: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

(gdb) call function()• Make any function call while debugging• Can also call print function() instead, will

also show the return value• Don’t forget the ()!

Page 19: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Zoning in on the bug• Scenario: your program breaks after a while• Be clever with breakpoints (bp)• (gdb) ignore 1 100 (ignore bp 1 100 times)• (gdb) info b (show how many times bp was

hit)

Page 20: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Zoning in on the bug

Page 21: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Watchpoints• Very good at finding memory bugs• watch *0xADDRESS• Don’t forget the *

Page 22: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

GDB Commands - Summary

$ gcc -g -O0 $ gdb --args

(gdb) layout src(gdb) bt(gdb) frame <num>(gdb) info b(gdb) ignore <bp> <num>(gdb) watch *0x<address>(gdb) call function()

Page 23: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Graphical GDB• For those of you who prefer graphical

debuggers like Eclipse, try DDD

Page 24: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Questions?

Page 25: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Project 1

Page 26: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Base code-Already includes a parser!-Parser spits out hierarchical data structures-Most of the project will be playing with these data structures

Page 27: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

esh_* data structures

Page 28: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

List data structure• “Node contains (a pointer to) data” vs “Data

contains node”• Retrieve data from a struct list_elem

by using the list_entry macro • struct esh_command *cmd = list_entry(e, struct esh_command, elem);

Page 29: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

List data structureRegular linked list

class listnode<T> { T data; listnode<T> next;}

Page 30: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

List data structure“struct list”

struct list_elem { struct list_elem *prev; struct list_elem *next; };

Page 31: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

List data structure• Don’t:

• Use the same list_elem for multiple lists • Forget to list_init• Pass your struct list to a function (pass a pointer

instead)

Page 32: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Questions?

Page 33: CS3214: Project 1 - Virginia Techcs3214/spring2017/documents/CS3214__Project_1.pdfCS3214: Project 1. Today’s presentation • Git • gdb • Project 1. Project 1 • Due Monday,

Demo