+ #######################################################################
+ ## Breakpoint placing functions ##
+ #######################################################################
+
+ # Places a breakpoint on line 'line_to_break' for file 'file_to_break'
+ fun place_breakpoint(breakpoint: Breakpoint)
+ do
+ if not self.breakpoints.keys.has(breakpoint.file) then
+ self.breakpoints[breakpoint.file] = new HashSet[Breakpoint]
+ end
+ if find_breakpoint(breakpoint.file, breakpoint.line) == null then
+ self.breakpoints[breakpoint.file].add(breakpoint)
+ print "Breakpoint added on line {breakpoint.line} for file {breakpoint.file}"
+ else
+ print "Breakpoint already present on line {breakpoint.line} for file {breakpoint.file}"
+ end
+ end
+
+ #######################################################################
+ ## Breakpoint removing functions ##
+ #######################################################################
+
+ # Removes a breakpoint on line 'line_to_break' for file 'file_to_break'
+ fun remove_breakpoint(file_to_break: String, line_to_break: Int)
+ do
+ if self.breakpoints.keys.has(file_to_break) then
+ var bp = find_breakpoint(file_to_break, line_to_break)
+
+ if bp != null then
+ self.breakpoints[file_to_break].remove(bp)
+ print "Breakpoint removed on line {line_to_break} for file {file_to_break}"
+ return
+ end
+ end
+
+ print "No breakpoint existing on line {line_to_break} for file {file_to_break}"
+ end
+
+ #######################################################################
+ ## Breakpoint searching functions ##
+ #######################################################################
+
+ # Finds a breakpoint for 'file' and 'line' in the class HashMap
+ fun find_breakpoint(file: String, line: Int): nullable Breakpoint
+ do
+ if self.breakpoints.keys.has(file)
+ then
+ for i in self.breakpoints[file]
+ do
+ if i.line == line
+ then
+ return i
+ end
+ end
+ end
+
+ return null
+ end
+
+ #######################################################################
+ ## Command listing function ##
+ #######################################################################
+
+ # Lists the commands available when using the debugger
+ fun list_commands
+ do
+ print "\nCommand not recognized\n"
+ print "Commands accepted : \n"
+ print "[break/b] line : Adds a breakpoint on line *line_nb* of the current file\n"
+ print "[break/b] file_name line_nb : Adds a breakpoint on line *line_nb* of file *file_name* \n"
+ print "[p/print] variable : [p/print] * shows the status of all the variables\n"
+ print "s : steps in on the current function\n"
+ print "n : steps-over the current instruction\n"
+ print "finish : steps out of the current function\n"
+ print "[d/delete] line_nb : Removes a breakpoint on line *line_nb* of the current file \n"
+ print "[d/delete] file_name line_nb : Removes a breakpoint on line *line_nb* of file *file_name* \n"
+ print "kill : kills the current program (Exits with an error and stack trace)\n"
+ end
+