]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/MemoryProfileSymbolGen.py
BaseTools: Fix old python2 idioms
[mirror_edk2.git] / BaseTools / Scripts / MemoryProfileSymbolGen.py
index a9790d8883c8ef004ac2169cae3d110f9c1a5f36..eaae0283c51d07e67075e897dbce626186b4f9ff 100644 (file)
 #\r
 ##\r
 \r
+from __future__ import print_function\r
 import os\r
 import re\r
 import sys\r
 from optparse import OptionParser\r
 \r
-versionNumber = "1.0"\r
+versionNumber = "1.1"\r
 __copyright__ = "Copyright (c) 2016, Intel Corporation. All rights reserved."\r
 \r
 class Symbols:\r
@@ -58,10 +59,10 @@ class Symbols:
         try:\r
             nmCommand = "nm"\r
             nmLineOption = "-l"\r
-            print "parsing (debug) - " + pdbName\r
+            print("parsing (debug) - " + pdbName)\r
             os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))\r
         except :\r
-            print 'ERROR: nm command not available.  Please verify PATH'\r
+            print('ERROR: nm command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -72,7 +73,7 @@ class Symbols:
         linefile.close()\r
 \r
         # 000113ca T AllocatePool      c:\home\edk-ii\MdePkg\Library\UefiMemoryAllocationLib\MemoryAllocationLib.c:399\r
-        patchLineFileMatchString = "([0-9a-fA-F]{8})\s+[T|D|t|d]\s+(\w+)\s*((?:[a-zA-Z]:)?[\w+\-./_a-zA-Z0-9\\\\]*):?([0-9]*)"\r
+        patchLineFileMatchString = "([0-9a-fA-F]*)\s+[T|D|t|d]\s+(\w+)\s*((?:[a-zA-Z]:)?[\w+\-./_a-zA-Z0-9\\\\]*):?([0-9]*)"\r
 \r
         for reportLine in reportLines:\r
             #print "check - " + reportLine\r
@@ -111,11 +112,11 @@ class Symbols:
             DIA2DumpCommand = "Dia2Dump.exe"\r
             #DIA2SymbolOption = "-p"\r
             DIA2LinesOption = "-l"\r
-            print "parsing (pdb) - " + pdbName\r
+            print("parsing (pdb) - " + pdbName)\r
             #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))\r
             os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))\r
         except :\r
-            print 'ERROR: DIA2Dump command not available.  Please verify PATH'\r
+            print('ERROR: DIA2Dump command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -190,7 +191,7 @@ def processLine(newline):
 \r
     driverPrefixLen = len("Driver - ")\r
     # get driver name\r
-    if cmp(newline[0:driverPrefixLen],"Driver - ") == 0 :\r
+    if cmp(newline[0:driverPrefixLen], "Driver - ") == 0 :\r
         driverlineList = newline.split(" ")\r
         driverName = driverlineList[2]\r
         #print "Checking : ", driverName\r
@@ -213,7 +214,7 @@ def processLine(newline):
         else :\r
             symbolsFile.symbolsTable[driverName].parse_debug_file (driverName, pdbName)\r
 \r
-    elif cmp(newline,"") == 0 :\r
+    elif cmp(newline, "") == 0 :\r
         driverName = ""\r
 \r
     # check entry line\r
@@ -226,7 +227,7 @@ def processLine(newline):
         rvaName = ""\r
         symbolName = ""\r
 \r
-    if cmp(rvaName,"") == 0 :\r
+    if cmp(rvaName, "") == 0 :\r
         return newline\r
     else :\r
         return newline + symbolName\r
@@ -254,16 +255,16 @@ def main():
     try :\r
         file = open(Options.inputfilename)\r
     except Exception:\r
-        print "fail to open " + Options.inputfilename\r
+        print("fail to open " + Options.inputfilename)\r
         return 1\r
     try :\r
         newfile = open(Options.outputfilename, "w")\r
     except Exception:\r
-        print "fail to open " + Options.outputfilename\r
+        print("fail to open " + Options.outputfilename)\r
         return 1\r
 \r
     try:\r
-        while 1:\r
+        while True:\r
             line = file.readline()\r
             if not line:\r
                 break\r