Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. Name: Frank Wan
  2. UserID: cs30xqm
  3.  
  4. Description
  5. -----------
  6. This program welcomes the user to CSE 30, Winter 2017.
  7. Then it states the due date of the assignment,
  8. and squares the number given as an argument.
  9.  
  10. How To Compile
  11. --------------
  12. The user must be in the program's directory, where all the
  13. source code is located along with the Makefile.
  14. Then, the user types 'make'
  15.  
  16. How To Run
  17. ----------
  18. The user types the executable name followed by an integer.
  19. Example input: ./a.out 5
  20.  
  21. Normal Output
  22. -------------
  23. [cs30xqm@ieng9]:pa0:80$ ./a.out 5
  24. Welcome to CSE 30, Winter 2017
  25. PA0 is due on January 17, 2017
  26. The square of 5 is 25
  27.  
  28. Normal output is printed to stdout.
  29.  
  30. Abnormal Output
  31. ---------------
  32. If the user does not provide arguments:
  33.  
  34. [cs30xqm@ieng9]:pa0:85$ ./a.out
  35. ./a.out: missing integer arg
  36. Usage: ./a.out [INTEGER]
  37. Integer value to square
  38.  
  39. If the user provides too many arguments:
  40.  
  41. [cs30xqm@ieng9]:pa0:90$ ./a.out 5 5
  42. ./a.out: too many arguments
  43. Usage: ./a.out [INTEGER]
  44. Integer value to square
  45.  
  46. Abnormal output is printed to stderr.
  47.  
  48. Testing
  49. -------
  50. Using the sample pa0test executable, we can compare the output of pa0test
  51. and this program using the diff tool. If there is no difference
  52. in output on the same input, this program has the correct output.
  53.  
  54. Questions
  55. ---------
  56. 0) Why is it considered an integrity violation if a student submits code copied
  57. from someone/somewhere else?
  58.  
  59. We agreed and signed that we would only submit work that is a truthful
  60. demonstration of our own knowledge and abilities.
  61.  
  62. 1) List the 4 compilation errors and 1 compilation warning you found in the
  63. source files. Please include the name of the file that consists the error,
  64. the line number, and your fix for the error.
  65.  
  66. Error 1:
  67. File: pa0.c
  68. Line Numbers: 56, 57
  69. Fix: Added #include <stdio.h> for fprintf function
  70.  
  71. Error 2:
  72. File: pa0.c
  73. Line Numbers: 102
  74. Fix: Added & in front of dueDate
  75.  
  76. Error 3:
  77. File: pa0.c
  78. Line Numbers: 109
  79. Fix: Missing a return, so added return 0;
  80.  
  81. Error 4:
  82. File: printDueDate.c
  83. Line Numbers: 32, 34
  84. Fix: Added #include "pa0.h" for DueDate struct
  85.  
  86. Warning 1:
  87. File: pa0.c
  88. Line Numbers: 108
  89. Fix: changed argv[NUM_TO_SQUARE_INDEX] to argVal
  90.  
  91. 2) Why is the program not printing the correct output when you first run it
  92. after successful compilation? How did you fix it?
  93.  
  94. The program was decrementing argVal instead of argc, so argc would not be
  95. equal to EXPECTED_ARGS, which triggered error messages being printed.
  96.  
  97. 3) What line of C code do you see printed to the screen?
  98.  
  99. 45 int argVal = 0; /* Value to square from command line */
  100.  
  101. 4) What happens if you type nexti at this point? Why?
  102.  
  103. (gdb) nexti
  104. 50 --argc;
  105. 1: x/i $pc
  106. => 0x10cfc <main+16>: ld [ %fp + 0x44 ], %g1
  107.  
  108. nexti executes the next line of machine code, which would be decrementing argc.
  109.  
  110. The second dueDate.day says 17, because it is printed after the line
  111. dueDate.day = DUEDATE_DAY;
  112. is executed
  113.  
  114. 5) Type x/s $i0. What does this do? What do you see printed to the screen?
  115.  
  116. This prints what is stored inside $i0:
  117.  
  118. (gdb) x/s $i0
  119. 0x109f0: "Winter 2017"
  120.  
  121. 6) What is a breakpoint? How do you set one? (You did this earlier)
  122.  
  123. A breakpoint is where the debugger stops when that point is reached.
  124.  
  125. We can set a breakpoint by typing 'break [function]' or 'break [line number]'
  126.  
  127. Earlier we did break main, which sets a breakpoint in main()
  128.  
  129. 7) What function are you debugging if gdb displays the following?
  130.  
  131. <foobar+32>: sethi %hi(0x20400), %o6
  132.  
  133. We are debugging function foobar
  134.  
  135. 8) What is the difference between step and next? What is the difference between
  136. step/next and stepi/nexti?
  137.  
  138. Step goes into any function, while next goes over them
  139. Step/next looks at the source code, while stepi/nexti look at machine code
  140.  
  141. 9) What are $o0, $i0, etc, referring to?
  142.  
  143. They are referring to registers.
  144.  
  145. 10) What is the difference between the x and p commands? Which should you use to
  146. look at the contents of a register? Which should you use to look at something in
  147. memory? What do x/s and p/d mean (what do the /s and /d specify)?
  148.  
  149. x prints things stored in memory, while p prints named variables
  150.  
  151. You should use x for looking at contents of a register and something in memory.
  152.  
  153. The /s in x/s means display as a null terminated string
  154. The /d in p/d means display as a signed integer
  155.  
  156. 11) How do you remove a file from git tracking (without actually deleting the file)?
  157.  
  158. git rm --cached [file]
  159.  
  160. 12) How do you view the list of commits you've made?
  161.  
  162. git log
  163.  
  164. 13) How do you force Git to ignore a file or all of the files with a specific extension?
  165.  
  166. In the .gitignore file, make a new line with the file you want git to ignore.
  167. For file extensions, do the same but with *.[file extension]
  168.  
  169. 14) What is the name of the directory that contains the Git metadata for your repository?
  170.  
  171. .git
  172.  
  173. 15) After a successful call to strtol(), why should endptr point to the null character?
  174.  
  175. It means the entire string was successfully processed. If there was an error,
  176. it would point to the first invalid character.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement