Algorithm Debugger: gcc and gdb
Ensure code is compiled with
-g
or-ggdb
flag so that debugging information is produced that gdb can use
Useful Commands
r
: Run the programb {function_name | line_number}
: Puts breakpoint at beginning of function or at a line numberinfo args
: Prints function argument values of the current frameinfo locals
: Prints local variable values of the current framep *{array}@{n}
: Prints n values of the array (ideally n is the array length)ptype {struct}
: Prints details about type (useful for printing fields in a struct)Epic gdb function I found for printing a linked list: Print the whole linked list in gdb?
n
: Step into the next line of the current function, doesn’t step into functionss
: Step into the next line of the program: Should probably avoid and use breakpoints for important functions insteadframe
: Prints the current stack frame + the line of code run (maybe useful for code line highlighting?)where
: Prints information about all stack frames
Local vs Remote
Our code runner should by be default cloud based so the structs client can simply connect to it via HTTPS or WebSockets (probably via a server), and the user doesn’t have to worry about running it locally.
However having a code runner that runs locally (on the user’s laptop) allows working with files on the user’s local file system more easily rather than needing the user to upload them each time they make a change to their multi-file project in vs code.
Things to work out
How to compile user C code? Using an external system like piston or judge0? Or subprocess (sounds kinda doomed for security)
How to run gdb through node? help i’m absolutely clueless (I can only think of using a subprocess)
Would the user keep connection with gdb the entire time (this doesn’t seem feasible for performance + creating a timeline the user has control over doesn’t seem so easy but i could be very wrong), or is the operation performed in one big swoop?
What would the backend return? Perhaps a series of instructions that are given to svg.js? (eg. create circle in svg.js with property address=0x000555…)
How does the user input an operation? (If there is no main function, is there another way besides the drawing tool?)
People’s assignment code (especially COMP2521) may have data too large to visualize (eg. 500000 size array), how do we make sure this won’t break our website.