here

Transcription

here
CS352 Assignment #7 One Programming Problem Due Date: ​
Wed, May 6 at 5:00 PM (Note the earlier time.) Turnin: Submit all files to the ​
cs352s15assg7 ​
turnin directory. Recall that this command looks like turnin cs352s15assg7 add.c list.c run.c input.c free.c You may check what files have been submitted by typing “turnin ­ls cs352s15assg7”. Your program will be put through a series of test cases and compared to ours using diff. This means that things like spelling, punctuation and whitespace are very important if you would like to pass all the test cases without needing to appeal. Additionally, ​
your filenames will need to match exactly​
in order for the script to pick it up. If you have any questions about the output of your scripts or the format of the filenames, please stop by our office hours, post on Piazza or email us. Remember, no late work will be accepted. All of the same rules apply to this assignment as applied to Assignment #6. Additionally, we will be running valgrind on each test case to check how you are handling memory. Valgrind is run like this: valgrind b2 < test.c A program that has no memory leaks will produce this to stdout: ==32532== HEAP SUMMARY: ==32532== in use at exit: 0 bytes in 0 blocks ==32532== total heap usage: 4 allocs, 4 frees, 82 bytes allocated ==32532== ==32532== All heap blocks were freed ­­ no leaks are possible ==32532== ==32532== For counts of detected and suppressed errors, rerun with: ­v ==32532== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) We will therefore be grepping for “All heap blocks were freed ­­ no leaks are possible” AND for “ERROR SUMMARY: 0 errors from 0 contexts” after we check the output for each test case. A correct answer therefore constitutes correct output, exit status, and running valgrind clean. “All heap blocks were freed ­­ no leaks are possible” ensures that you freed all the memory you allocated. Keep in mind that this includes the Value list, the Stmt list, any nodes that were malloc­ed then produced an error, and any nodes that were overwritten. “ERROR SUMMARY: 0 errors from 0 contexts” ensures that you did not produce any errors when freeing and that you manage all the declarations effectively in your code. This involves, but is not limited to, initializing all your variables before you use them and ensuring you’re malloc­ing enough space for your strings. We will be releasing the test script on Wednesday night that will checks for both of the above statements. If you have any questions, please ask them early! Better B2 Interpreter (b2) This assignment is an extension of Assignment #6. There will be a new Makefile, main.c and interpreter.h to enable part of this. In addition to the other files that you turn in, there will also be an additional file, free.c. There are two additional requirements: 1. The program must not have any memory problems as reported by the Valgrind tool. This includes memory leaks, etc. (The additional file, free.c, will include the routine you use to free memory upon a normal exit.) 2. The program must support SIGINT (aka Ctrl­C) interrupts in the following way: a. If the B2 interpreter is interpreting a B2 program, then SIGINT should cause the interpreter to i.
immediately cease interpretation, ii.
print “INTERRUPTED\n” iii.
return to the outer loop that will await more input commands or program statements b. If B2 is awaiting input commands or program statements, then it should do the default action of ceasing program execution when it receives a SIGINT. I.e., it should use the default signal handler in this case. Note: all of the original test cases for Assignment #6 must continue to pass, as well as tests that the signal handlers work. The tests for the new functionality will count significantly more than the previous tests.