Ouput the full path of the generated EFI image in the map file.
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Thu, 18 Mar 2010 10:29:38 +0000 (10:29 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Thu, 18 Mar 2010 10:29:38 +0000 (10:29 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1936 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/Python/build/build.py

index d6fdd8a..f608dee 100644 (file)
@@ -656,14 +656,16 @@ class PeImageInfo():
     #   @param  BaseName          The full file path of image. \r
     #   @param  Guid              The GUID for image.\r
     #   @param  Arch              Arch of this image.\r
-    #   @param  OutpuDir          The output directory for image.\r
+    #   @param  OutputDir         The output directory for image.\r
+    #   @param  DebugDir          The debug directory for image.\r
     #   @param  ImageClass        PeImage Information\r
     #\r
-    def __init__(self, BaseName, Guid, Arch, OutpuDir, ImageClass):\r
+    def __init__(self, BaseName, Guid, Arch, OutputDir, DebugDir, ImageClass):\r
         self.BaseName         = BaseName\r
         self.Guid             = Guid\r
         self.Arch             = Arch\r
-        self.OutpuDir         = OutpuDir\r
+        self.OutputDir        = OutputDir\r
+        self.DebugDir         = DebugDir\r
         self.Image            = ImageClass\r
         self.Image.Size       = (self.Image.Size / 0x1000 + 1) * 0x1000\r
 \r
@@ -1008,22 +1010,26 @@ class Build():
             sys.stdout.flush()
             ModuleInfo = ModuleList[InfFile]\r
             ModuleName = ModuleInfo.BaseName\r
+            ModuleOutputImage = ModuleInfo.Image.FileName\r
+            ModuleDebugImage  = os.path.join(ModuleInfo.DebugDir, ModuleInfo.BaseName + '.efi')\r
             ## for SMM module in SMRAM, the SMRAM will be allocated from base to top.\r
             if not ModeIsSmm:\r
                 BaseAddress = BaseAddress - ModuleInfo.Image.Size\r
                 #\r
                 # Update Image to new BaseAddress by GenFw tool\r
                 #\r
-                LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleInfo.Image.FileName], ModuleInfo.OutpuDir)\r
+                LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)\r
+                LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage],  ModuleInfo.DebugDir)\r
             else:\r
                 #\r
                 # Set new address to the section header only for SMM driver.\r
                 #\r
-                LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleInfo.Image.FileName], ModuleInfo.OutpuDir)\r
+                LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)\r
+                LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage],  ModuleInfo.DebugDir)\r
             #\r
             # Collect funtion address from Map file\r
             #\r
-            ImageMapTable = ModuleInfo.Image.FileName.replace('.efi', '.map')\r
+            ImageMapTable = ModuleOutputImage.replace('.efi', '.map')\r
             FunctionList = []\r
             if os.path.exists(ImageMapTable):\r
                 OrigImageBaseAddress = 0\r
@@ -1070,9 +1076,13 @@ class Build():
                 elif SectionHeader[0] in ['.data', '.sdata']:\r
                     DataSectionAddress = SectionHeader[1]\r
             if AddrIsOffset:\r
-                MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress))) \r
+                MapBuffer.write('(GUID=%s, .textbaseaddress=-0x%010X, .databaseaddress=-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress), 0 - (BaseAddress + DataSectionAddress))) \r
             else:\r
-                MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress)) \r
+                MapBuffer.write('(GUID=%s, .textbaseaddress=0x%010X, .databaseaddress=0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectionAddress, BaseAddress + DataSectionAddress)) \r
+            #\r
+            # Add debug image full path.\r
+            #\r
+            MapBuffer.write('(IMAGE=%s)\n\n' % (ModuleDebugImage))\r
             #\r
             # Add funtion address\r
             #\r
@@ -1095,6 +1105,7 @@ class Build():
         if self.Fdf != '':\r
             # First get the XIP base address for FV map file.\r
             GuidPattern = re.compile("[-a-fA-F0-9]+")\r
+            GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")\r
             for FvName in Wa.FdfProfile.FvDict.keys():\r
                 FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')\r
                 if not os.path.exists(FvMapBuffer):\r
@@ -1115,6 +1126,15 @@ class Build():
                         if GuidString.upper() in ModuleList:\r
                             Line = Line.replace(GuidString, ModuleList[GuidString.upper()].Name)\r
                     MapBuffer.write('%s' % (Line))\r
+                    #\r
+                    # Add the debug image full path.\r
+                    #\r
+                    MatchGuid = GuidName.match(Line)\r
+                    if MatchGuid != None:\r
+                        GuidString = MatchGuid.group().split("=")[1]\r
+                        if GuidString.upper() in ModuleList:\r
+                            MapBuffer.write('(IMAGE=%s)\n' % (os.path.join(ModuleList[GuidString.upper()].DebugDir, ModuleList[GuidString.upper()].Name + '.efi')))\r
+\r
                 FvMap.close()\r
 \r
     ## Collect MAP information of all modules\r
@@ -1149,7 +1169,7 @@ class Build():
                     ImageClass = PeImageClass (OutputImageFile)\r
                     if not ImageClass.IsValid:\r
                         EdkLogger.error("build", FILE_PARSE_FAILURE, ExtraData=ImageClass.ErrorInfo)\r
-                    ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, ImageClass)\r
+                    ImageInfo = PeImageInfo(Module.Name, Module.Guid, Module.Arch, Module.OutputDir, Module.DebugDir, ImageClass)\r
                     if Module.ModuleType in ['PEI_CORE', 'PEIM', 'COMBINED_PEIM_DRIVER','PIC_PEIM', 'RELOCATABLE_PEIM', 'DXE_CORE']:\r
                         PeiModuleList[Module.MetaFile] = ImageInfo\r
                         PeiSize += ImageInfo.Image.Size\r