Revision: 3464
Author: [email protected]
Date: Mon Dec 14 09:05:38 2009
Log: stats-viewer.py: support passing test_shell pid.

Review URL: http://codereview.chromium.org/496010
http://code.google.com/p/v8/source/detail?r=3464

Modified:
  /branches/bleeding_edge/tools/stats-viewer.py

=======================================
--- /branches/bleeding_edge/tools/stats-viewer.py       Mon Dec 14 08:13:52 2009
+++ /branches/bleeding_edge/tools/stats-viewer.py       Mon Dec 14 09:05:38 2009
@@ -37,6 +37,7 @@

  import mmap
  import os
+import re
  import struct
  import sys
  import time
@@ -95,8 +96,20 @@
      something goes wrong print an informative message and exit the
      program."""
      if not os.path.exists(self.data_name):
-      print "File %s doesn't exist." % self.data_name
-      sys.exit(1)
+      maps_name = "/proc/%s/maps" % self.data_name
+      if not os.path.exists(maps_name):
+        print "\"%s\" is neither a counter file nor a PID." %  
self.data_name
+        sys.exit(1)
+      maps_file = open(maps_name, "r")
+      try:
+        m = re.search(r"/dev/shm/\S*", maps_file.read())
+        if m is not None and os.path.exists(m.group(0)):
+          self.data_name = m.group(0)
+        else:
+          print "Can't find counter file in maps for PID %s." %  
self.data_name
+          sys.exit(1)
+      finally:
+        maps_file.close()
      data_file = open(self.data_name, "r")
      size = os.fstat(data_file.fileno()).st_size
      fileno = data_file.fileno()
@@ -438,6 +451,6 @@

  if __name__ == "__main__":
    if len(sys.argv) != 2:
-    print "Usage: stats-viewer.py <stats data>"
+    print "Usage: stats-viewer.py <stats data>|<test_shell pid>"
      sys.exit(1)
    Main(sys.argv[1])

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to