def __init__(oErrorReport, oCdbWrapper, uExitCode):
   oErrorReport.sErrorTypeId = "CdbTerminated:%d" % uExitCode;
   oErrorReport.sErrorDescription = "Cdb terminated unexpectedly";
   oErrorReport.sSecurityImpact = None;
   oErrorReport.oException = None;
   oErrorReport.oStack = None;
   oErrorReport.sStackId = None;
   oErrorReport.sCodeId = None;
   oErrorReport.sCodeDescription = None;
   oErrorReport.atsAdditionalInformation = [];
   oErrorReport.sProcessBinaryName = "cdb.exe";
   oErrorReport.sId = oErrorReport.sErrorTypeId;
   oErrorReport.sHTMLStack = None;
   oErrorReport.sHTMLBinaryInformation = None;
   # Turn cdb output into formatted HTML. It is separated into blocks, one for the initial cdb output and one for each
   # command executed.
   sHTMLCdbStdIO = '<hr class="StdIOSeparator"/>'.join(oCdbWrapper.asHTMLCdbStdIOBlocks);
   del oCdbWrapper.asHTMLCdbStdIOBlocks;
   # Create HTML details
   oErrorReport.sHTMLDetails = sHTMLDetailsTemplate % {
     "sId": fsHTMLEncode(oErrorReport.sId),
     "sExceptionDescription": fsHTMLEncode(oErrorReport.sErrorDescription),
     "sProcessBinaryName": fsHTMLEncode(oErrorReport.sProcessBinaryName),
     "sCodeDescription": fsHTMLEncode(oErrorReport.sCodeDescription or "Unknown"),
     "sSecurityImpact": oErrorReport.sSecurityImpact and \
           '<span class="SecurityImpact">%s</span>' % fsHTMLEncode(oErrorReport.sSecurityImpact) or "None",
     "sStack": oErrorReport.sHTMLStack or "Unknown",
     "sBinaryInformation": oErrorReport.sHTMLBinaryInformation or "Unknown",
     "sCdbStdIO": sHTMLCdbStdIO,
   };
 def __init__(oErrorReport, oCdbWrapper, uExitCode):
     oErrorReport.sErrorTypeId = "CdbTerminated:%d" % uExitCode
     oErrorReport.sErrorDescription = "Cdb terminated unexpectedly"
     oErrorReport.sSecurityImpact = None
     oErrorReport.oException = None
     oErrorReport.oStack = None
     oErrorReport.sStackId = None
     oErrorReport.sCodeId = None
     oErrorReport.sCodeDescription = None
     oErrorReport.atsAdditionalInformation = []
     oErrorReport.sProcessBinaryName = "cdb.exe"
     oErrorReport.sId = oErrorReport.sErrorTypeId
     oErrorReport.sHTMLStack = None
     oErrorReport.sHTMLBinaryInformation = None
     # Turn cdb output into formatted HTML. It is separated into blocks, one for the initial cdb output and one for each
     # command executed.
     sHTMLCdbStdIO = '<hr class="StdIOSeparator"/>'.join(
         oCdbWrapper.asHTMLCdbStdIOBlocks)
     del oCdbWrapper.asHTMLCdbStdIOBlocks
     # Create HTML details
     oErrorReport.sHTMLDetails = sHTMLDetailsTemplate % {
       "sId": fsHTMLEncode(oErrorReport.sId),
       "sExceptionDescription": fsHTMLEncode(oErrorReport.sErrorDescription),
       "sProcessBinaryName": fsHTMLEncode(oErrorReport.sProcessBinaryName),
       "sCodeDescription": fsHTMLEncode(oErrorReport.sCodeDescription or "Unknown"),
       "sSecurityImpact": oErrorReport.sSecurityImpact and \
             '<span class="SecurityImpact">%s</span>' % fsHTMLEncode(oErrorReport.sSecurityImpact) or "None",
       "sStack": oErrorReport.sHTMLStack or "Unknown",
       "sBinaryInformation": oErrorReport.sHTMLBinaryInformation or "Unknown",
       "sCdbStdIO": sHTMLCdbStdIO,
     }
Exemple #3
0
def cCdbWrapper_fasReadOutput(oCdbWrapper):
    sLine = ""
    asLines = []
    while 1:
        sChar = oCdbWrapper.oCdbProcess.stdout.read(1)
        if sChar == "\r":
            pass
            # ignored.
        elif sChar in ("\n", ""):
            if sChar == "\n" or sLine:
                if dxBugIdConfig["bOutputStdOut"]:
                    print "cdb>%s" % repr(sLine)[1:-1]
                # Add the line to the current block of I/O
                oCdbWrapper.asHTMLCdbStdIOBlocks[
                    -1] += "<span class=\"CDBOutput\">%s</span><br/>" % fsHTMLEncode(
                        sLine)
                asLines.append(sLine)
            if sChar == "":
                break
            sLine = ""
        else:
            sLine += sChar
            # Detect the prompt.
            oPromptMatch = re.match("^\d+:\d+(:x86)?> $", sLine)
            if oPromptMatch:
                oCdbWrapper.sCurrentISA = oPromptMatch.group(
                    1) and "x86" or oCdbWrapper.sCdbISA
                if dxBugIdConfig["bOutputStdOut"]:
                    print "cdb>%s" % repr(sLine)[1:-1]
                # The prompt is stored in a new block of I/O
                oCdbWrapper.asHTMLCdbStdIOBlocks.append(
                    "<span class=\"CDBPrompt\">%s</span>" %
                    fsHTMLEncode(sLine))
                return asLines
    oCdbWrapper.bCdbRunning = False
    return None
def cCdbWrapper_fCdbStdErrThread(oCdbWrapper):
    sLine = ""
    while 1:
        sChar = oCdbWrapper.oCdbProcess.stderr.read(1)
        if sChar == "\r":
            pass
            # ignored.
        elif sChar in ("\n", ""):
            if sChar == "\n" or sLine:
                oCdbWrapper.asHTMLCdbStdIOBlocks[
                    -1] += "<span class=\"CDBStdErr\">%s</span><br/>" % fsHTMLEncode(
                        sLine)
                if dxBugIdConfig["bOutputStdErr"]:
                    print "cdb:stderr>%s" % repr(sLine)[1:-1]
            if sChar == "":
                break
            sLine = ""
        else:
            sLine += sChar
    oCdbWrapper.bCdbRunning = False
import re;
from dxBugIdConfig import dxBugIdConfig;
from mHTML import fsHTMLEncode;

def cCdbWrapper_fasSendCommandAndReadOutput(oCdbWrapper, sCommand, bIsRelevantIO = True):
  if dxBugIdConfig["bOutputStdIn"]:
    print "cdb<%s" % repr(sCommand)[1:-1];
  try:
    oCdbWrapper.oCdbProcess.stdin.write("%s\r\n" % sCommand);
  except Exception, oException:
    oCdbWrapper.bCdbRunning = False;
    return None;
  if bIsRelevantIO:
    # Add the command to the current output block; this block should contain only one line that has the cdb prompt.
    oCdbWrapper.asHTMLCdbStdIOBlocks[-1] += "<span class=\"CDBCommand\">%s</span><br/>" % fsHTMLEncode(sCommand);
  else:
    # Remove the second to last output block: it contains the cdb prompt that is linked to this command and thus it
    # has become irrelevant.
    oCdbWrapper.asHTMLCdbStdIOBlocks.pop(-1);
  # The following command will always add a new output block with the new cdb prompt, regardless of bDoNotSaveIO.
  asOutput = oCdbWrapper.fasReadOutput(bIsRelevantIO = bIsRelevantIO);
  # Detect obvious errors executing the command. (this will not catch everything, but does help development)
  assert asOutput is None or len(asOutput) != 1 or not re.match(r"^(\s*\^ .*|Couldn't resolve error at .+)$", asOutput[0]), \
      "There was a problem executing the command %s:\r\n%s" % \
      (repr(sCommand), "\r\n".join([repr(sLine) for sLine in asOutput]));
  return asOutput;
def cCdbWrapper_fCdbStdErrThread(oCdbWrapper):
  sLine = "";
  while 1:
    sChar = oCdbWrapper.oCdbProcess.stderr.read(1);
    if sChar == "\r":
      pass; # ignored.
    elif sChar in ("\n", ""):
      if sChar == "\n" or sLine:
        oCdbWrapper.asHTMLCdbStdIOBlocks[-1] += "<span class=\"CDBStdErr\">%s</span><br/>" % fsHTMLEncode(sLine);
        if dxBugIdConfig["bOutputStdErr"]:
          print "cdb:stderr>%s" % repr(sLine)[1:-1];
      if sChar == "":
        break;
      sLine = "";
    else:
      sLine += sChar;
  oCdbWrapper.bCdbRunning = False;
def cCdbWrapper_fasReadOutput(oCdbWrapper):
  sLine = "";
  asLines = [];
  while 1:
    sChar = oCdbWrapper.oCdbProcess.stdout.read(1);
    if sChar == "\r":
      pass; # ignored.
    elif sChar in ("\n", ""):
      if sChar == "\n" or sLine:
        if dxBugIdConfig["bOutputStdOut"]:
          print "cdb>%s" % repr(sLine)[1:-1];
        # Add the line to the current block of I/O
        oCdbWrapper.asHTMLCdbStdIOBlocks[-1] += "<span class=\"CDBOutput\">%s</span><br/>" % fsHTMLEncode(sLine)
        asLines.append(sLine);
      if sChar == "":
        break;
      sLine = "";
    else:
      sLine += sChar;
      # Detect the prompt.
      oPromptMatch = re.match("^\d+:\d+(:x86)?> $", sLine);
      if oPromptMatch:
        oCdbWrapper.sCurrentISA = oPromptMatch.group(1) and "x86" or oCdbWrapper.sCdbISA;
        if dxBugIdConfig["bOutputStdOut"]:
          print "cdb>%s" % repr(sLine)[1:-1];
        # The prompt is stored in a new block of I/O
        oCdbWrapper.asHTMLCdbStdIOBlocks.append("<span class=\"CDBPrompt\">%s</span>" % fsHTMLEncode(sLine));
        return asLines;
  oCdbWrapper.bCdbRunning = False;
  return None;
import re
from dxBugIdConfig import dxBugIdConfig
from mHTML import fsHTMLEncode


def cCdbWrapper_fasSendCommandAndReadOutput(oCdbWrapper, sCommand):
    if dxBugIdConfig["bOutputStdIn"]:
        print "cdb<%s" % repr(sCommand)[1:-1]
    try:
        oCdbWrapper.oCdbProcess.stdin.write("%s\r\n" % sCommand)
    except Exception, oException:
        oCdbWrapper.bCdbRunning = False
        return None
    # Add the command to the current output block; this block should contain only one line that has the cdb prompt.
    oCdbWrapper.asHTMLCdbStdIOBlocks[
        -1] += "<span class=\"CDBCommand\">%s</span><br/>" % fsHTMLEncode(
            sCommand)
    asOutput = oCdbWrapper.fasReadOutput()
    # Detect obvious errors executing the command. (this will not catch everything, but does help development)
    assert asOutput is None or len(asOutput) != 1 or not re.match(r"^(\s*\^ .*|Couldn't resolve error at .+)$", asOutput[0]), \
        "There was a problem executing the command %s:\r\n%s" % \
        (repr(sCommand), "\r\n".join([repr(sLine) for sLine in asOutput]))
    return asOutput