'Get ready for potential debugging.  Must be called on the thread
that is being debugged.'

def SetupAXDebugging(self, baseFrame=None, userFrame=None):

    if (userFrame is None):
        userFrame = baseFrame
    else:
        userFrame.f_locals['__axstack_address__'] = axdebug.GetStackAddress()
    traceenter('SetupAXDebugging', self)
    self._threadprotectlock.acquire()
    try:
        thisThread = win32api.GetCurrentThreadId()
        if (self.debuggingThread is None):
            self.debuggingThread = thisThread
        else:
            if (self.debuggingThread != thisThread):
                trace('SetupAXDebugging    called    on    other    thread    -    ignored!')
                return
            self.recursiveData.insert(0, (self.logicalbotframe, self.stopframe, self.currentframe, self.debuggingThreadStateHandle))
    finally:
        self._threadprotectlock.release()
    trace('SetupAXDebugging    has    base    frame    as', _dumpf(baseFrame))
    self.botframe = baseFrame
    self.stopframe = userFrame
    self.logicalbotframe = baseFrame
    self.currentframe = None
    self.debuggingThreadStateHandle = axdebug.GetThreadStateHandle()
    self._BreakFlagsChanged()
