def run(self, cmd=None, arg_filename=None, arg_lineno=None, arg_toggle=True):
    debug("CoronaDebuggerCommand: " + cmd)
    global coronaDbg
    global corona_sdk_version
    global corona_sdk_debug
    self.view = self.window.active_view()

    if self.view is None:
      sublime.error_message("Cannot find an active view.  You may need to restart Sublime Text.")
      return

    # if we aren't started yet and a step is asked for, do a start
    if (coronaDbg is None or not coronaDbg.isRunning()) and cmd in ['run', 'step', 'over']:
      cmd = "start"

    if cmd == "start":
      if corona_sdk_debug:
        # Show Sublime Console
        self.window.run_command("show_panel", {"panel": "console"})
        # sublime.log_commands(True)

      # Hide the build panel (since the "Console" pane duplicates it)
      self.window.run_command("hide_panel", {"panel": "output.exec"})

      if coronaDbg is not None:
        debug("Cleaning up debugger thread")
        coronaDbg.join()
        coronaDbg = None

      self.saved_layout = self.window.get_layout()

      # Figure out where the PUT and the Simulator are
      filename = self.window.active_view().file_name()
      if filename is None or not filename.endswith(".lua"):
        filename = None
        # No current .lua file, see if we have one open
        for view in self.window.views():
          if view.file_name() and view.file_name().endswith(".lua"):
            if filename is None or not filename.endswith("main.lua"):  # prefer a 'main.lua' if there is one
              filename = view.file_name()

      if filename is None:
        sublime.error_message("Can't find an open '.lua' file to determine the location of 'main.lua'")
        return
      mainlua = _corona_utils.ResolveMainLua(filename)
      if mainlua is None:
        sublime.error_message("Can't locate 'main.lua' for this project (try opening it in an editor tab)")
        return
      self.window.open_file(mainlua)  # make sure main.lua is open as that's the first place we'll stop
      projectDir = os.path.dirname(mainlua)
      if not projectDir:
        sublime.error_message("Cannot find 'main.lua' for '"+self.view.file_name()+"'.  This does not look like a Corona SDK app")
        return

      dbg_path, dbg_flags, dbg_version = _corona_utils.GetSimulatorCmd(mainlua, True)
      dbg_cmd = [dbg_path]
      dbg_cmd += dbg_flags
      dbg_cmd.append(mainlua)
      debug("debugger cmd: " + str(dbg_cmd))

      debug("dbg_version: " + str(dbg_version))
      if dbg_version:
        corona_sdk_version = dbg_version.rpartition(".")[2]
        debug("corona_sdk_version: " + str(corona_sdk_version))

      global consoleOutputQ, variablesOutputQ, luaStackOutputQ, debuggerCmdQ
      consoleOutputQ = coronaQueue.Queue()
      variablesOutputQ = coronaQueue.Queue()
      luaStackOutputQ = coronaQueue.Queue()
      debuggerCmdQ = coronaQueue.Queue()

      coronaDbg = CoronaDebuggerThread(projectDir, self.debuggerFinished)
      if coronaDbg.setup():
        if self.window.num_groups() == 1:
          self.initializeWindowPanes()
        else:
          # Clear the existing windows
          variables_output(' ')
          stack_output(' ')
        self.window.focus_group(0)
        RunSubprocess(dbg_cmd, self.window)
        coronaDbg.start()

    elif cmd == "restart":
      if coronaDbg is not None:
        self.window.run_command("corona_debugger", {"cmd": "exit"})
      sublime.set_timeout(lambda: self.window.run_command("corona_debugger", {"cmd": "start"}), 0)

    elif cmd == "exit":
      debugger_status("exiting debugger...")
      StopSubprocess()
      if coronaDbg is None:
        self.closeWindowPanes()
      else:
        coronaDbg.doCommand(cmd)
        coronaDbg.stop()
        coronaDbg.join()
        coronaDbg = None
    elif ["run", "step", "over"] in cmd:
      coronaDbg.doCommand(cmd)
      coronaDbg.doCommand('backtrace')
      if not corona_sdk_version or ( int(corona_sdk_version) < 2489 or int(corona_sdk_version) > 2515 ):
        coronaDbg.doCommand('locals')
    elif cmd == "dump":
      self.dumpVariable()
    elif cmd == "setb":
      # toggle a breakpoint at the current cursor position
      if arg_filename is None:
        filename = self.view.file_name()
        (lineno, col) = self.view.rowcol(self.view.sel()[0].begin())
        lineno += 1
      else:
        filename = arg_filename
        lineno = int(arg_lineno)

      if self.toggle_breakpoint(filename, lineno, arg_toggle):
        cmd = "setb"
      else:
        cmd = "delb"

      cmd += " " + '"' + filename + '"'
      cmd += " " + str(lineno)
      debug("setb: " + cmd)

      if coronaDbg is not None:
        coronaDbg.doCommand(cmd)

    else:
      print("CoronaDebuggerCommand: Unrecognized command: " + cmd)
dataset/ETHPy150Open coronalabs/CoronaSDK-SublimeText/debugger.py/CoronaDebuggerCommand.run/swapped operands of `in`