]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/Check.py
Sync BaseTool trunk (version r2460) into EDKII BaseTools. The change mainly includes:
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / Check.py
index 6f5f9fd0b5570e4318db377c5f78f023a900319c..73d7318de0dace245f214e5b8f0b0f6077c5970b 100644 (file)
@@ -15,6 +15,7 @@ import re
 from CommonDataClass.DataClass import *\r
 from Common.DataType import SUP_MODULE_LIST_STRING, TAB_VALUE_SPLIT\r
 from EccToolError import *\r
+from MetaDataParser import ParseHeaderCommentSection\r
 import EccGlobalData\r
 import c\r
 \r
@@ -48,7 +49,7 @@ class Check(object):
         if EccGlobalData.gConfig.GeneralCheckNonAcsii == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Non-ACSII char in file ...")\r
             SqlCommand = """select ID, FullPath, ExtName from File"""\r
-            RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
+            RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:\r
                     op = open(Record[1]).readlines()\r
@@ -415,13 +416,81 @@ class Check(object):
                     elif Ext in ('.inf', '.dec', '.dsc', '.fdf'):\r
                         FullName = os.path.join(Dirpath, F)\r
                         op = open(FullName).readlines()\r
-                        if not op[0].startswith('## @file') and op[6].startswith('## @file') and op[7].startswith('## @file'):\r
+                        FileLinesList = op\r
+                        LineNo             = 0\r
+                        CurrentSection     = MODEL_UNKNOWN \r
+                        HeaderSectionLines       = []\r
+                        HeaderCommentStart = False \r
+                        HeaderCommentEnd   = False\r
+                        \r
+                        for Line in FileLinesList:\r
+                            LineNo   = LineNo + 1\r
+                            Line     = Line.strip()\r
+                            if (LineNo < len(FileLinesList) - 1):\r
+                                NextLine = FileLinesList[LineNo].strip()\r
+            \r
+                            #\r
+                            # blank line\r
+                            #\r
+                            if (Line == '' or not Line) and LineNo == len(FileLinesList):\r
+                                LastSectionFalg = True\r
+\r
+                            #\r
+                            # check whether file header comment section started\r
+                            #\r
+                            if Line.startswith('#') and \\r
+                                (Line.find('@file') > -1) and \\r
+                                not HeaderCommentStart:\r
+                                if CurrentSection != MODEL_UNKNOWN:\r
+                                    SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
+                                    ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
+                                    for Result in ResultSet:\r
+                                        Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file"" or ""# @file""at the very top file'\r
+                                        EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
+\r
+                                else:\r
+                                    CurrentSection = MODEL_IDENTIFIER_FILE_HEADER\r
+                                    #\r
+                                    # Append the first line to section lines.\r
+                                    #\r
+                                    HeaderSectionLines.append((Line, LineNo))\r
+                                    HeaderCommentStart = True\r
+                                    continue        \r
+            \r
+                            #\r
+                            # Collect Header content.\r
+                            #\r
+                            if (Line.startswith('#') and CurrentSection == MODEL_IDENTIFIER_FILE_HEADER) and\\r
+                                HeaderCommentStart and not Line.startswith('##') and not\\r
+                                HeaderCommentEnd and NextLine != '':\r
+                                HeaderSectionLines.append((Line, LineNo))\r
+                                continue\r
+                            #\r
+                            # Header content end\r
+                            #\r
+                            if (Line.startswith('##') or not Line.strip().startswith("#")) and HeaderCommentStart \\r
+                                and not HeaderCommentEnd:\r
+                                if Line.startswith('##'):\r
+                                    HeaderCommentEnd = True\r
+                                HeaderSectionLines.append((Line, LineNo))\r
+                                ParseHeaderCommentSection(HeaderSectionLines, FullName)\r
+                                break\r
+                        if HeaderCommentStart == False:\r
                             SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
                             ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
                             for Result in ResultSet:\r
-                                Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file""'\r
+                                Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file"" or ""# @file"" at the very top file'\r
                                 EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
+                        if HeaderCommentEnd == False:\r
+                            SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
+                            ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
+                            for Result in ResultSet:\r
+                                Msg = 'INF/DEC/DSC/FDF file header comment should end with ""##"" at the end of file header comment block'\r
+                                # Check whether File header Comment End with '##'\r
+                                if EccGlobalData.gConfig.HeaderCheckFileCommentEnd == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+                                    EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
 \r
+                                     \r
 \r
     # Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5\r
     def DoxygenCheckFunctionHeader(self):\r
@@ -504,9 +573,9 @@ class Check(object):
     def MetaDataFileCheckLibraryInstance(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckLibraryInstance == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for library instance type issue ...")\r
-            SqlCommand = """select A.ID, A.Value2, B.Value2 from Inf as A left join Inf as B\r
-                            where A.Value1 = 'LIBRARY_CLASS' and A.Model = %s\r
-                            and B.Value1 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile\r
+            SqlCommand = """select A.ID, A.Value3, B.Value3 from Inf as A left join Inf as B\r
+                            where A.Value2 = 'LIBRARY_CLASS' and A.Model = %s\r
+                            and B.Value2 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile\r
                             group by A.BelongsToFile""" % (MODEL_META_DATA_HEADER, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             LibraryClasses = {}\r
@@ -528,8 +597,8 @@ class Check(object):
                 if Record[2] != 'BASE' and Record[2] not in SupModType:\r
                     EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg="The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
 \r
-            SqlCommand = """select A.ID, A.Value1, B.Value2 from Inf as A left join Inf as B\r
-                            where A.Model = %s and B.Value1 = '%s' and B.Model = %s\r
+            SqlCommand = """select A.ID, A.Value1, B.Value3 from Inf as A left join Inf as B\r
+                            where A.Model = %s and B.Value2 = '%s' and B.Model = %s\r
                             and B.BelongsToFile = A.BelongsToFile""" \\r
                             % (MODEL_EFI_LIBRARY_CLASS, 'MODULE_TYPE', MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
@@ -558,11 +627,13 @@ class Check(object):
             SqlCommand = """select ID, Value1, Value2 from Dsc where Model = %s""" % MODEL_EFI_LIBRARY_CLASS\r
             LibraryClasses = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for LibraryClass in LibraryClasses:\r
-                if LibraryClass[1].upper() != 'NULL':\r
+                if LibraryClass[1].upper() == 'NULL' or LibraryClass[1].startswith('!ifdef') or LibraryClass[1].startswith('!ifndef') or LibraryClass[1].endswith('!endif'):\r
+                    continue\r
+                else:\r
                     LibraryIns = os.path.normpath(os.path.join(EccGlobalData.gWorkspace, LibraryClass[2]))\r
-                    SqlCommand = """select Value2 from Inf where BelongsToFile =\r
+                    SqlCommand = """select Value3 from Inf where BelongsToFile =\r
                                     (select ID from File where lower(FullPath) = lower('%s'))\r
-                                    and Value1 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')\r
+                                    and Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')\r
                     RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
                     IsFound = False\r
                     for Record in RecordSet:\r
@@ -591,8 +662,8 @@ class Check(object):
                     EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg="The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
             SqlCommand = """\r
                          select A.ID, A.Value1, A.BelongsToFile, A.StartLine, B.StartLine from Dsc as A left join Dsc as B\r
-                         where A.Model = %s and B.Model = %s and A.Value3 = B.Value3 and A.Arch = B.Arch and A.ID <> B.ID\r
-                         and A.Value1 = B.Value1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \\r
+                         where A.Model = %s and B.Model = %s and A.Scope1 = B.Scope1 and A.Scope2 = B.Scope2 and A.ID <> B.ID\r
+                         and A.Value1 = B.Value1 and A.Value2 <> B.Value2 and A.BelongsToItem = -1 and B.BelongsToItem = -1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \\r
                             % (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS)\r
             RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -631,9 +702,10 @@ class Check(object):
         if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for duplicate PCDs defined in both DSC and FDF files ...")\r
             SqlCommand = """\r
-                         select A.ID, A.Value2, A.BelongsToFile, B.ID, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B\r
+                         select A.ID, A.Value1, A.Value2, A.BelongsToFile, B.ID, B.Value1, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B\r
                          where A.Model >= %s and A.Model < %s\r
                          and B.Model >= %s and B.Model < %s\r
+                         and A.Value1 = B.Value1\r
                          and A.Value2 = B.Value2\r
                          and A.Enabled > -1\r
                          and B.Enabled > -1\r
@@ -641,71 +713,74 @@ class Check(object):
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                SqlCommand1 = """select Name from File where ID = %s""" % Record[2]\r
-                SqlCommand2 = """select Name from File where ID = %s""" % Record[5]\r
+                SqlCommand1 = """select Name from File where ID = %s""" % Record[3]\r
+                SqlCommand2 = """select Name from File where ID = %s""" % Record[7]\r
                 DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]\r
                 FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]\r
                 if DscFileName != FdfFileName:\r
                     continue\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[1]), BelongsToTable='Dsc', BelongsToItem=Record[0])\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[3]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[4]), BelongsToTable='Fdf', BelongsToItem=Record[3])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[1] + '.' + Record[2]), BelongsToTable='Dsc', BelongsToItem=Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[5] + '.' + Record[6]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[5] + '.' + Record[6]), BelongsToTable='Fdf', BelongsToItem=Record[4])\r
 \r
             EdkLogger.quiet("Checking for duplicate PCDs defined in DEC files ...")\r
             SqlCommand = """\r
-                         select A.ID, A.Value2 from Dec as A, Dec as B\r
+                         select A.ID, A.Value1, A.Value2, A.Model, B.Model from Dec as A left join Dec as B\r
                          where A.Model >= %s and A.Model < %s\r
                          and B.Model >= %s and B.Model < %s\r
+                         and A.Value1 = B.Value1\r
                          and A.Value2 = B.Value2\r
-                         and ((A.Arch = B.Arch) and (A.Arch != 'COMMON' or B.Arch != 'COMMON'))\r
-                         and A.ID != B.ID\r
+                         and A.Scope1 = B.Scope1\r
+                         and A.ID <> B.ID\r
+                         and A.Model = B.Model\r
                          and A.Enabled > -1\r
                          and B.Enabled > -1\r
                          and A.BelongsToFile = B.BelongsToFile\r
                          group by A.ID\r
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
-            RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
+            RecordSet = EccGlobalData.gDb.TblDec.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined duplicated in DEC file" % (Record[1]), BelongsToTable='Dec', BelongsToItem=Record[0])\r
+                RecordCat = Record[1] + '.' + Record[2]\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, RecordCat):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined duplicated in DEC file" % RecordCat, BelongsToTable='Dec', BelongsToItem=Record[0])\r
 \r
     # Check whether PCD settings in the FDF file can only be related to flash.\r
     def MetaDataFileCheckPcdFlash(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdFlash == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking only Flash related PCDs are used in FDF ...")\r
             SqlCommand = """\r
-                         select ID, Value2, BelongsToFile from Fdf as A\r
+                         select ID, Value1, Value2, BelongsToFile from Fdf as A\r
                          where A.Model >= %s and Model < %s\r
                          and A.Enabled > -1\r
                          and A.Value2 not like '%%Flash%%'\r
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblFdf.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg="The PCD [%s] defined in FDF file is not related to Flash" % (Record[1]), BelongsToTable='Fdf', BelongsToItem=Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg="The PCD [%s] defined in FDF file is not related to Flash" % (Record[1] + '.' + Record[2]), BelongsToTable='Fdf', BelongsToItem=Record[0])\r
 \r
     # Check whether PCDs used in Inf files but not specified in Dsc or FDF files\r
     def MetaDataFileCheckPcdNoUse(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for non-specified PCDs ...")\r
             SqlCommand = """\r
-                         select ID, Value2, BelongsToFile from Inf as A\r
+                         select ID, Value1, Value2, BelongsToFile from Inf as A\r
                          where A.Model >= %s and Model < %s\r
                          and A.Enabled > -1\r
-                         and A.Value2 not in\r
-                             (select Value2 from Dsc as B\r
+                         and (A.Value1, A.Value2) not in\r
+                             (select Value1, Value2 from Dsc as B\r
                               where B.Model >= %s and B.Model < %s\r
                               and B.Enabled > -1)\r
-                         and A.Value2 not in\r
-                             (select Value2 from Fdf as C\r
+                         and (A.Value1, A.Value2) not in\r
+                             (select Value1, Value2 from Fdf as C\r
                               where C.Model >= %s and C.Model < %s\r
                               and C.Enabled > -1)\r
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg="The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg="The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1] + '.' + Record[2]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
 \r
     # Check whether having duplicate guids defined for Guid/Protocol/Ppi\r
     def MetaDataFileCheckGuidDuplicate(self):\r
@@ -729,7 +804,7 @@ class Check(object):
         if EccGlobalData.gConfig.MetaDataFileCheckModuleFileNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for no used module files ...")\r
             SqlCommand = """\r
-                         select upper(Path) from File where ID in (select BelongsToFile from INF where BelongsToFile != -1)\r
+                         select upper(Path) from File where ID in (select BelongsToFile from Inf where BelongsToFile != -1)\r
                          """\r
             InfPathSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             InfPathList = []\r
@@ -756,15 +831,15 @@ class Check(object):
         if EccGlobalData.gConfig.MetaDataFileCheckPcdType == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for pcd type in c code function usage ...")\r
             SqlCommand = """\r
-                         select ID, Model, Value1, BelongsToFile from INF where Model > %s and Model < %s\r
+                         select ID, Model, Value1, Value2, BelongsToFile from INF where Model > %s and Model < %s\r
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER)\r
             PcdSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             for Pcd in PcdSet:\r
                 Model = Pcd[1]\r
                 PcdName = Pcd[2]\r
-                if len(Pcd[2].split(".")) > 1:\r
-                    PcdName = Pcd[2].split(".")[1]\r
-                BelongsToFile = Pcd[3]\r
+                if Pcd[3]:\r
+                    PcdName = Pcd[3]\r
+                BelongsToFile = Pcd[4]\r
                 SqlCommand = """\r
                              select ID from File where FullPath in\r
                             (select B.Path || '\\' || A.Value1 from INF as A, File as B where A.Model = %s and A.BelongsToFile = %s\r
@@ -809,9 +884,9 @@ class Check(object):
             EdkLogger.quiet("Checking for pcd type in c code function usage ...")\r
             Table = EccGlobalData.gDb.TblInf\r
             SqlCommand = """\r
-                         select A.ID, A.Value2, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B\r
-                         where A.Value1 = 'FILE_GUID' and B.Value1 = 'FILE_GUID' and\r
-                         A.Value2 = B.Value2 and A.ID <> B.ID group by A.ID\r
+                         select A.ID, A.Value3, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B\r
+                         where A.Value2 = 'FILE_GUID' and B.Value2 = 'FILE_GUID' and\r
+                         A.Value3 = B.Value3 and A.ID <> B.ID group by A.ID\r
                          """ % (Table.Table, Table.Table)\r
             RecordSet = Table.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -836,7 +911,7 @@ class Check(object):
                      select A.ID, A.Value1 from %s as A, %s as B\r
                      where A.Model = %s and B.Model = %s\r
                      and A.Value1 = B.Value1 and A.ID <> B.ID\r
-                     and A.Arch = B.Arch\r
+                     and A.Scope1 = B.Scope1\r
                      and A.Enabled > -1\r
                      and B.Enabled > -1\r
                      group by A.ID\r
@@ -857,16 +932,16 @@ class Check(object):
         if Model == MODEL_EFI_PPI:\r
             Name = 'ppi'\r
         SqlCommand = """\r
-                     select A.ID, A.Value2 from %s as A, %s as B\r
+                     select A.ID, A.Value1, A.Value2 from %s as A, %s as B\r
                      where A.Model = %s and B.Model = %s\r
                      and A.Value2 = B.Value2 and A.ID <> B.ID\r
-                     and A.Arch = B.Arch\r
+                     and A.Scope1 = B.Scope1 and A.Value1 <> B.Value1\r
                      group by A.ID\r
                      """ % (Table.Table, Table.Table, Model, Model)\r
         RecordSet = Table.Exec(SqlCommand)\r
-        for Record in RecordSet:\r
-            if not EccGlobalData.gException.IsException(ErrorID, Record[1]):\r
-                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s value [%s] is used more than one time" % (Name.upper(), Record[1]), BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+        for Record in RecordSet:     \r
+            if not EccGlobalData.gException.IsException(ErrorID, Record[1] + ':' + Record[2]):\r
+                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s value [%s] is used more than one time" % (Name.upper(), Record[2]), BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
 \r
     # Naming Convention Check\r
     def NamingConventionCheck(self):\r