DebugPal AI: An Offline-First Visual Socratic Pointer & Memory Tutor Built for my Classmate
I built DebugPal AI because my friend Rohan kept getting Segmentation fault (core dumped) in our Data Structures lab-and every time an AI fixed his code, he understood the bug a little less. So I built him something different. DebugPal AI is a visual, Socratic C/C++ debugging tutor that helps students understand why pointer and memory bugs happen instead of simply handing them corrected code.
๐ Live Demo: https://debug-pal.vercel.app/
๐ GitHub: https://github.com/ahanghosh77/debug-pal
The Friend I Built It For
Rohan is my classmate and lab partner. We're working through university Data Structures labs where we use C and C++, including pointers, linked lists, dynamic memory allocation, and manual memory management. For someone coming from a higher-level language such as Python, the hardest part isn't always writing the algorithm. It's understanding what is actually happening in memory.
Rohan's recurring enemy was: Segmentation fault (core dumped)
The compiler would tell him that the program crashed. But it didn't give him the mental model he needed to understand why. And when he asked cloud AI tools for help, the usual experience was: "Here's the corrected code." The code worked. The understanding didn't. That was especially frustrating because our university exams aren't just about getting a program to run. We also have to explain the concepts on paper. So I wanted to build something that would make him think through the bug instead of simply copying the fix.
Meet DebugPal AI
DebugPal AI takes a C/C++ memory bug and turns it into a visual debugging lesson. Instead of:
Your program crashed. Here is the corrected code.
the experience is closer to:
What does this pointer currently contain?
↓ Where is that address pointing?
↓ Is that memory actually valid?
↓ What invariant did your program violate?
↓ Now... how would you fix it?
The goal is to create the "Ohhh, that's why!" moment.
1. Visual Memory Map
Pointers are difficult to understand when they're represented only as text. DebugPal visualizes the simulated memory state with:
- Call Stack frames
- Stack variables
- Heap allocations
- Hex-style memory addresses
- Pointer targets
- Invalid memory destinations
- Dangerous memory blocks
For example, instead of simply seeing head -> next -> next, the student can see the pointer chain and where the final arrow ends up. When the destination is invalid, DebugPal makes the crash point visually obvious. This is particularly useful for beginners who have learned the syntax of pointers but haven't yet developed a mental model of memory.
2. It Teaches the Invariant Behind the Crash
A segmentation fault is only the symptom. The more important question is: What rule did my program violate? DebugPal tries to make that rule explicit. For example:
head
↓
node
↓
NULL
and then: head -> next -> next
Instead of immediately revealing the corrected code, DebugPal asks the student to reason about the next pointer and whether the next dereference is valid. This turns debugging into a small reasoning exercise.
3. Three Levels of Socratic Guidance
DebugPal deliberately doesn't reveal everything immediately. The guidance is split into three levels:
Comments
No comments yet. Start the discussion.