From 27bee5adfadf98e0de5ac6005ccc3dbb98088d2a Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 25 Jan 2022 13:05:53 -0800 Subject: [PATCH] Fix exception when path not found. Add a default return value in a call in the GetLibraryByBuildId() function to avoid an exception if a file cannot be found in the symbol directory. Bug: 216232380 Test: Ran the input from the bug. Verified without the change, the Test: exception occurs and with the fix, no exception. Test: Ran unit tests of stack_core.py. Change-Id: I015982eb835f5a3d7f03dcc3e0b1627b0c1a7cfe --- scripts/stack_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stack_core.py b/scripts/stack_core.py index 50d5c9425..f601d5a40 100755 --- a/scripts/stack_core.py +++ b/scripts/stack_core.py @@ -332,7 +332,7 @@ class TraceConverter: # Search for a library with the given basename and build_id anywhere in the symbols directory. @functools.lru_cache(maxsize=None) def GetLibraryByBuildId(self, symbols_dir, basename, build_id): - for candidate in self.GlobSymbolsDir(symbols_dir).get(basename): + for candidate in self.GlobSymbolsDir(symbols_dir).get(basename, []): info = self.GetLibraryInfo(candidate) if info and info.build_id == build_id: return "/" + str(candidate.relative_to(symbols_dir))