summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorMax Knutsen <maknutse@microsoft.com>2019-07-16 17:26:55 +0800
committerLiming Gao <liming.gao@intel.com>2019-08-01 15:36:48 +0800
commit307e1650be267b67db7be1089e0979ace460d830 (patch)
tree5c7d2a53371f84c079de722389dccbba90442c8d /BaseTools
parent76912197fabec2603f6c206f087a84265f451b32 (diff)
downloadedk2-307e1650be267b67db7be1089e0979ace460d830.tar.gz
edk2-307e1650be267b67db7be1089e0979ace460d830.tar.bz2
edk2-307e1650be267b67db7be1089e0979ace460d830.zip
BaseTools:Add extra debugging message
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2014 Add extra debugging to improve error identification. Error while processing file if the file is read incorrectly This patch is going to fix that issue. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/Python/AutoGen/StrGather.py16
-rw-r--r--BaseTools/Source/Python/Trim/Trim.py4
2 files changed, 13 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py
index 2e4671a433..eed30388be 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -526,12 +526,16 @@ def SearchString(UniObjectClass, FileList, IsCompatibleMode):
return UniObjectClass
for File in FileList:
- if os.path.isfile(File):
- Lines = open(File, 'r')
- for Line in Lines:
- for StrName in STRING_TOKEN.findall(Line):
- EdkLogger.debug(EdkLogger.DEBUG_5, "Found string identifier: " + StrName)
- UniObjectClass.SetStringReferenced(StrName)
+ try:
+ if os.path.isfile(File):
+ Lines = open(File, 'r')
+ for Line in Lines:
+ for StrName in STRING_TOKEN.findall(Line):
+ EdkLogger.debug(EdkLogger.DEBUG_5, "Found string identifier: " + StrName)
+ UniObjectClass.SetStringReferenced(StrName)
+ except:
+ EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, "SearchString: Error while processing file", File=File, RaiseError=False)
+ raise
UniObjectClass.ReToken()
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 43119bd7ff..8767b67f7e 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -73,8 +73,10 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
try:
with open(Source, "r") as File:
Lines = File.readlines()
- except:
+ except IOError:
EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Source)
+ expect:
+ EdkLogger.error("Trim", AUTOGEN_ERROR, "TrimPreprocessedFile: Error while processing file", File=Source)
PreprocessedFile = ""
InjectedFile = ""