Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r69693:59650f378e7c
Date: 2014-03-04 18:04 -0500
http://bitbucket.org/pypy/pypy/changeset/59650f378e7c/

Log:    have gdb_pypy.load_typeids used a named temporary file rather than
        /tmp/typeids.txt.z

diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -118,15 +118,16 @@
         """
         Returns a mapping offset --> description
         """
+        import tempfile
+        import zlib
         vname = 'pypy_g_rpython_memory_gctypelayout_GCData.gcd_inst_typeids_z'
         length = int(self.gdb.parse_and_eval('*(long*)%s' % vname))
         vstart = '(char*)(((long*)%s)+1)' % vname
-        self.gdb.execute('dump binary memory /tmp/typeids.txt.z %s %s+%d'
-                         % (vstart, vstart, length))
-        s = open('/tmp/typeids.txt.z', 'rb').read()
-        import zlib; typeids_txt = zlib.decompress(s)
-        typeids = TypeIdsMap(typeids_txt.splitlines(True), self.gdb)
-        return typeids
+        with tempfile.NamedTemporaryFile('rb') as fobj:
+            self.gdb.execute('dump binary memory %s %s %s+%d' %
+                             (fobj.name, vstart, vstart, length))
+            data = fobj.read()
+        return TypeIdsMap(zlib.decompress(data).splitlines(True), self.gdb)
 
 
 class TypeIdsMap(object):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to