This assignment is designed to build on your understanding of the stack and pointers you used to create the stack dump function in the recitation. In this assignment you will build a strack trace function to print only the stack frames in an executing program, rather than all of the memory. The function will follow the frame pointer links until there are no frames left. After printing a heading line for the columns in the stack trace, each frame will be printed on a single line and include:
trace.cto understand the details of the assignment.
Perform the following steps:
Save Target As....
trace.hThe header file describing the functions you need to implement. You should not modify this file. You do not turn this file in.
trace.cThe source file where you should implement the functions for this assignment. You will turn this file is for grading.
testTrace.cA sample source file to test your code. You may wish to add additional code and tests to more fully test your functions. You do not turn this file in.
MakefileThe instructions for make compile and link the program.
makeYou should see the following output:
gcc -m32 -g -std=c11 -Wall -c -DDEBUG -DHALF trace.c gcc -m32 -g -std=c11 -Wall -c -DDEBUG -DHALF testTrace.c gcc -m32 -o testTrace -g -std=c11 -Wall trace.o testTrace.o
Before attempting to write any code, study the documentation and plan what you need to do. The best way to complete the code is to follow a edit/compile/test sequence. Do not attempt to write everything at once. Rather choose one function, then write, compile, and test a few lines at a time. This will minimize the amount of code you must consider when debugging. When that code is thoroughly tested, proceed with the next few lines.
Note that the number offset from the top of the stack to the first frame pointer may change.
This occurs if your
traceStack() function has a different number of local variables
One way to resolve this is to change your
to have the same parameters defined in exactly
the same order to determine the appropriate offset.
You should only print the frames for the recursive function.
You should not print the frame for the
traceStack() function or the frame
main() function that calls the recursive function.
Your output should match the following format exactly when 1 parameter and 1 local variable are specified. Note the leading zeros in the hexadecimal numbers along with the leading 0x.
FrameAddr FramePtr ReturnAddr Parm1 Local1 0xffceeb08 0xffceeb58 0x0804861e 0x00000000 0xffffffff 0xffceeb58 0xffceeba8 0x0804861e 0x00000001 0x00000000 ...
You should work on the functions in the following order since the second depends on the first. A sample solution contained these approximate line counts, not including empty lines or debugging statements.
traceStack()- 15 lines of code
traceNext()- 11 lines of code
This assignment is automatically graded:
You will submit the single file
You can either submit through the website or use the
~cs270/bin/checkin P3 trace.cYou are done with the assignment!