Commit 17884141 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger/gdb: Fix Python temporary file creation Windows.

Reviewed-by: hjk
parent 81c8540b
...@@ -7,7 +7,7 @@ import sys ...@@ -7,7 +7,7 @@ import sys
import gdb import gdb
import base64 import base64
import __builtin__ import __builtin__
import os
# Fails on Windows. # Fails on Windows.
try: try:
...@@ -21,22 +21,28 @@ except: ...@@ -21,22 +21,28 @@ except:
return '?' return '?'
# Fails on SimulatorQt. # Fails on SimulatorQt.
tempFileCounter = 0
try: try:
import tempfile import tempfile
# Test if 2.6 is used (Windows), trigger exception and default
# to 2nd version.
tempfile.NamedTemporaryFile(prefix="gdbpy_",delete=True)
def createTempFile(): def createTempFile():
file = tempfile.NamedTemporaryFile(prefix="gdbpy_") file = tempfile.NamedTemporaryFile(prefix="gdbpy_",delete=False)
return file.name, file
def removeTempFile(name, file):
file.close() file.close()
return file.name, file
except: except:
fileCounter = 0
def createTempFile(): def createTempFile():
fileCounter += 1 global tempFileCounter
return "gdbpy_tmp%d" % fileCounter, None tempFileCounter += 1
fileName = "%s/gdbpy_tmp_%d_%d" % (tempfile.gettempdir(), os.getpid(), tempFileCounter)
return fileName, None
def removeTempFile(name, file): def removeTempFile(name, file):
try:
os.remove(name)
except:
pass pass
verbosity = 0 verbosity = 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment