Dumper: Fix failing GDB startup when using MinGW

Task-number: QTCREATORBUG-13892
Change-Id: Ia843cf4d88c574013e67cacaa8484b52fdbd4b8a
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Christian Stenger
2015-01-27 09:35:53 +01:00
committed by hjk
parent f2cfd3c01a
commit ed437bb656

View File

@@ -33,8 +33,13 @@ import struct
import sys import sys
import base64 import base64
import re import re
import subprocess
import time import time
try:
import subprocess
hasSubprocess = True
except:
hasSubprocess = False
hasPlot = False
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
xrange = range xrange = range
@@ -78,29 +83,29 @@ SeparateUtf8StringFormat \
# matplot based display for array-like structures. # matplot based display for array-like structures.
# #
try: try:
# FIXME: That might not be the one we want. import matplotlib
pythonExecutable = sys.executable
subprocess.check_call([pythonExecutable, '-c', 'import matplotlib'])
hasPlot = True hasPlot = True
except: except:
hasPlot = False hasPlot = False
if hasSubprocess and hasPlot:
matplotFigure = {}
matplotCount = 0
matplotFigure = {} devNull = open(os.devnull)
matplotCount = 0 # FIXME: That might not be the one we want.
pythonExecutable = sys.executable
devNull = open(os.devnull) matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull) bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull)
matplotProc.stdin.write(b"import sys\n") matplotProc.stdin.write(b"import sys\n")
matplotProc.stdin.write(b"sys.ps1=''\n") matplotProc.stdin.write(b"sys.ps1=''\n")
matplotProc.stdin.write(b"from matplotlib import pyplot\n") matplotProc.stdin.write(b"from matplotlib import pyplot\n")
matplotProc.stdin.write(b"import time\n") matplotProc.stdin.write(b"import time\n")
matplotProc.stdin.write(b"pyplot.ion()\n") matplotProc.stdin.write(b"pyplot.ion()\n")
matplotProc.stdin.flush() matplotProc.stdin.flush()
def matplotSend(iname, show, data): def matplotSend(iname, show, data):
global matplotFigure global matplotFigure
global matplotCount global matplotCount
@@ -130,7 +135,7 @@ def matplotSend(iname, show, data):
matplotProc.stdin.flush() matplotProc.stdin.flush()
def matplotQuit(): def matplotQuit():
matplotProc.stdin.write(b"exit") matplotProc.stdin.write(b"exit")
matplotProc.kill() matplotProc.kill()
devNull.close() devNull.close()