Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Name: Frank Wan
- UserID: cs30xqm
- Description
- -----------
- This program welcomes the user to CSE 30, Winter 2017.
- Then it states the due date of the assignment,
- and squares the number given as an argument.
- How To Compile
- --------------
- The user must be in the program's directory, where all the
- source code is located along with the Makefile.
- Then, the user types 'make'
- How To Run
- ----------
- The user types the executable name followed by an integer.
- Example input: ./a.out 5
- Normal Output
- -------------
- [cs30xqm@ieng9]:pa0:80$ ./a.out 5
- Welcome to CSE 30, Winter 2017
- PA0 is due on January 17, 2017
- The square of 5 is 25
- Normal output is printed to stdout.
- Abnormal Output
- ---------------
- If the user does not provide arguments:
- [cs30xqm@ieng9]:pa0:85$ ./a.out
- ./a.out: missing integer arg
- Usage: ./a.out [INTEGER]
- Integer value to square
- If the user provides too many arguments:
- [cs30xqm@ieng9]:pa0:90$ ./a.out 5 5
- ./a.out: too many arguments
- Usage: ./a.out [INTEGER]
- Integer value to square
- Abnormal output is printed to stderr.
- Testing
- -------
- Using the sample pa0test executable, we can compare the output of pa0test
- and this program using the diff tool. If there is no difference
- in output on the same input, this program has the correct output.
- Questions
- ---------
- 0) Why is it considered an integrity violation if a student submits code copied
- from someone/somewhere else?
- We agreed and signed that we would only submit work that is a truthful
- demonstration of our own knowledge and abilities.
- 1) List the 4 compilation errors and 1 compilation warning you found in the
- source files. Please include the name of the file that consists the error,
- the line number, and your fix for the error.
- Error 1:
- File: pa0.c
- Line Numbers: 56, 57
- Fix: Added #include <stdio.h> for fprintf function
- Error 2:
- File: pa0.c
- Line Numbers: 102
- Fix: Added & in front of dueDate
- Error 3:
- File: pa0.c
- Line Numbers: 109
- Fix: Missing a return, so added return 0;
- Error 4:
- File: printDueDate.c
- Line Numbers: 32, 34
- Fix: Added #include "pa0.h" for DueDate struct
- Warning 1:
- File: pa0.c
- Line Numbers: 108
- Fix: changed argv[NUM_TO_SQUARE_INDEX] to argVal
- 2) Why is the program not printing the correct output when you first run it
- after successful compilation? How did you fix it?
- The program was decrementing argVal instead of argc, so argc would not be
- equal to EXPECTED_ARGS, which triggered error messages being printed.
- 3) What line of C code do you see printed to the screen?
- 45 int argVal = 0; /* Value to square from command line */
- 4) What happens if you type nexti at this point? Why?
- (gdb) nexti
- 50 --argc;
- 1: x/i $pc
- => 0x10cfc <main+16>: ld [ %fp + 0x44 ], %g1
- nexti executes the next line of machine code, which would be decrementing argc.
- The second dueDate.day says 17, because it is printed after the line
- dueDate.day = DUEDATE_DAY;
- is executed
- 5) Type x/s $i0. What does this do? What do you see printed to the screen?
- This prints what is stored inside $i0:
- (gdb) x/s $i0
- 0x109f0: "Winter 2017"
- 6) What is a breakpoint? How do you set one? (You did this earlier)
- A breakpoint is where the debugger stops when that point is reached.
- We can set a breakpoint by typing 'break [function]' or 'break [line number]'
- Earlier we did break main, which sets a breakpoint in main()
- 7) What function are you debugging if gdb displays the following?
- <foobar+32>: sethi %hi(0x20400), %o6
- We are debugging function foobar
- 8) What is the difference between step and next? What is the difference between
- step/next and stepi/nexti?
- Step goes into any function, while next goes over them
- Step/next looks at the source code, while stepi/nexti look at machine code
- 9) What are $o0, $i0, etc, referring to?
- They are referring to registers.
- 10) What is the difference between the x and p commands? Which should you use to
- look at the contents of a register? Which should you use to look at something in
- memory? What do x/s and p/d mean (what do the /s and /d specify)?
- x prints things stored in memory, while p prints named variables
- You should use x for looking at contents of a register and something in memory.
- The /s in x/s means display as a null terminated string
- The /d in p/d means display as a signed integer
- 11) How do you remove a file from git tracking (without actually deleting the file)?
- git rm --cached [file]
- 12) How do you view the list of commits you've made?
- git log
- 13) How do you force Git to ignore a file or all of the files with a specific extension?
- In the .gitignore file, make a new line with the file you want git to ignore.
- For file extensions, do the same but with *.[file extension]
- 14) What is the name of the directory that contains the Git metadata for your repository?
- .git
- 15) After a successful call to strtol(), why should endptr point to the null character?
- It means the entire string was successfully processed. If there was an error,
- it would point to the first invalid character.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement