Example #1
0
    def makeThreadSuspendMessage(self, thread_id, frame, stop_reason, message):

        """ <xml>
            <thread id="id" stop_reason="reason">
                    <frame id="id" name="functionName " file="file" line="line">
                    <var variable stuffff....
                </frame>
            </thread>
           """
        try:
            cmdTextList = ["<xml>"]

            if message:
                message = pydevd_vars.makeValidXmlValue(str(message))

            cmdTextList.append('<thread id="%s" stop_reason="%s" message="%s">' % (thread_id, stop_reason, message))

            curFrame = frame
            try:
                while curFrame:
                    #print cmdText
                    myId = str(id(curFrame))
                    #print "id is ", myId

                    if curFrame.f_code is None:
                        break #Iron Python sometimes does not have it!

                    myName = curFrame.f_code.co_name #method name (if in method) or ? if global
                    if myName is None:
                        break #Iron Python sometimes does not have it!

                    #print "name is ", myName

                    filename, base = pydevd_file_utils.GetFilenameAndBase(curFrame)

                    myFile = pydevd_file_utils.NormFileToClient(filename)

                    #print "file is ", myFile
                    #myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame)

                    myLine = str(curFrame.f_lineno)
                    #print "line is ", myLine

                    #the variables are all gotten 'on-demand'
                    #variables = pydevd_vars.frameVarsToXML(curFrame.f_locals)

                    variables = ''
                    cmdTextList.append('<frame id="%s" name="%s" ' % (myId , pydevd_vars.makeValidXmlValue(myName)))
                    cmdTextList.append('file="%s" line="%s">"' % (quote(myFile, '/>_= \t'), myLine))
                    cmdTextList.append(variables)
                    cmdTextList.append("</frame>")
                    curFrame = curFrame.f_back
            except :
                traceback.print_exc()

            cmdTextList.append("</thread></xml>")
            cmdText = ''.join(cmdTextList)
            return NetCommand(CMD_THREAD_SUSPEND, 0, cmdText)
        except:
            return self.makeErrorMessage(0, GetExceptionTracebackStr())
Example #2
0
def get_text_list_for_frame(frame):
    # partial copy-paste from makeThreadSuspendStr
    curFrame = frame
    cmdTextList = []
    try:
        while curFrame:
            #print cmdText
            myId = str(id(curFrame))
            #print "id is ", myId

            if curFrame.f_code is None:
                break  #Iron Python sometimes does not have it!

            myName = curFrame.f_code.co_name  #method name (if in method) or ? if global
            if myName is None:
                break  #Iron Python sometimes does not have it!

            #print "name is ", myName

            filename, base = pydevd_file_utils.GetFilenameAndBase(curFrame)

            myFile = pydevd_file_utils.NormFileToClient(filename)
            if file_system_encoding.lower() != "utf-8" and hasattr(
                    myFile, "decode"):
                # myFile is a byte string encoded using the file system encoding
                # convert it to utf8
                myFile = myFile.decode(file_system_encoding).encode("utf-8")

            #print "file is ", myFile
            #myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame)

            myLine = str(curFrame.f_lineno)
            #print "line is ", myLine

            #the variables are all gotten 'on-demand'
            #variables = pydevd_vars.frameVarsToXML(curFrame.f_locals)

            variables = ''
            cmdTextList.append('<frame id="%s" name="%s" ' %
                               (myId, pydevd_vars.makeValidXmlValue(myName)))
            cmdTextList.append('file="%s" line="%s">"' %
                               (quote(myFile, '/>_= \t'), myLine))
            cmdTextList.append(variables)
            cmdTextList.append("</frame>")
            curFrame = curFrame.f_back
    except:
        traceback.print_exc()

    return cmdTextList
Example #3
0
    def makeThreadSuspendMessage(self, thread_id, frame, stop_reason):
        """ <xml>
            <thread id="id" stop_reason="reason">
                    <frame id="id" name="functionName " file="file" line="line">
                    <var variable stuffff....
                </frame>
            </thread>
           """
        try:
            cmdTextList = ["<xml>"]
            cmdTextList.append('<thread id="%s" stop_reason="%s">' %
                               (thread_id, stop_reason))

            curFrame = frame
            while curFrame:
                #print cmdText
                myId = str(id(curFrame))
                #print "id is ", myId

                if curFrame.f_code is None:
                    break  #Iron Python sometimes does not have it!

                myName = curFrame.f_code.co_name  #method name (if in method) or ? if global
                if myName is None:
                    break  #Iron Python sometimes does not have it!

                #print "name is ", myName

                myFile = pydevd_file_utils.NormFileToClient(
                    curFrame.f_code.co_filename)
                if file_system_encoding.lower() != "utf-8" and hasattr(
                        myFile, "decode"):
                    # myFile is a byte string encoded using the file system encoding
                    # convert it to utf8
                    myFile = myFile.decode(file_system_encoding).encode(
                        "utf-8")

                #print "file is ", myFile
                #myFile = inspect.getsourcefile(curFrame) or inspect.getfile(frame)

                myLine = str(curFrame.f_lineno)
                #print "line is ", myLine

                #the variables are all gotten 'on-demand'
                #variables = pydevd_vars.frameVarsToXML(curFrame)

                variables = ''
                cmdTextList.append(
                    '<frame id="%s" name="%s" ' %
                    (myId, pydevd_vars.makeValidXmlValue(myName)))
                cmdTextList.append('file="%s" line="%s">"' %
                                   (quote(myFile, '/>_= \t'), myLine))
                cmdTextList.append(variables)
                cmdTextList.append("</frame>")
                curFrame = curFrame.f_back

            cmdTextList.append("</thread></xml>")
            cmdText = ''.join(cmdTextList)
            return NetCommand(CMD_THREAD_SUSPEND, 0, cmdText)
        except:
            return self.makeErrorMessage(0, GetExceptionTracebackStr())