Inspiration

After spending a semester drawing pointers and diagrams on paper for 15-122, Principles of Imperative Computation, we were thinking about how we could make a pedagogical tool that not only serves as a debugger, but a conceptual guide in the understanding of the concept of pointers and memory allocation.

What it does

PointMe takes in C programs and graphically displays the memory allocation of the program line-by-line, showing the pointers and references among objects in both the stack and heap. Allocated memory that cannot be referenced remains in the heap, showing the dangers of failing to free memory through visual clutter.

How we built it

PointMe is a program visualizer that is rooted in both functional and imperative programming principles. At its core, it consists of expressions, which are parsed with the powerful evalExpression function, using Dijkstra's shunting-yard algorithm to efficiently parse operators. It preprocesses the entire C program to make it easier to read in a string-only format in Python, using shortcuts like rewriting types with a special indicator character as well as a shorter length in order to make it easier to differentiate particular kinds of strings. The heap and stack are both separate data structures, with the Variable object presiding over all pointers, variables, and constants. A Variable can point towards an address in the heapDict structure, or it can hold a primitive value itself, holding a type to differentiate itself to the programmer.

Challenges we ran into

One challenge we ran into was the length of the project. As a fairly ambitious project, there were many things that we had to implement, such as parsing and support for control flow, structs, assignment, pointers, and allocation of memory. Additionally, one of our members is a 15-112 TA, and as such had to arrive four hours late. Another challenge was the challenge of debugging, as the data structures we used are quite extensive, and the program is so long that debugging is quite a feat.

Accomplishments that we're proud of

We're proud of this entire project, as a whole. No matter the member, this was a fun project that we all feel we genuinely contributed a lot to, as well as a project that could be used for actual pedagogical purpose. Since three members of our group are teaching assistants in the School of Computer Science, we were very proud to have created a tool to potentially help future students. The concepts were also quite advanced, as none of us have embarked upon serious software engineering feats in the past, so it was an exercise in patience and planning as we tried to determine the structure of our program, such as delegating the top-down preprocessing to some and the lofty task of evaluation expression to others.

What we learned

As a whole, this project was great review for 15-122 for all of us, as we got to refresh on topics like pointers and memory allocation. As three of us are students in 15-213, this was also helpful in familiarizing ourselves before delving into more complicated material. We learned how to apply functional programming techniques, as our paradigm of functions evaluating to values (literally, as we read int main and then went to other functions from there) ended up simplifying the control flow for our program quite a bit, against the alternative. As my first hackathon, I felt it was a great experience, and one that I am eager to repeat soon.

What's next for PointMe

PointMe is by no means a finished product, and that's why GitHub exists. We fully intend to shape it up and try and see what pedagogical usage there is in such a tool, because that's why it was created. It would be a shame to leave something unfinished, and so our next step would probably be to streamline the program, to better deploy it in the future. We also would like to integrate support for different colors based on type.

Built With

Share this project:

Updates