Commits

Brian Kearns committed 59650f3

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

  • Participants
  • Parent commits 18dc835

Comments (0)

Files changed (1)

File pypy/tool/gdb_pypy.py

         """
         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):