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
This commit is contained in:
Christopher Ferris
2022-01-25 13:05:53 -08:00
parent 632da0a501
commit 27bee5adfa

View File

@@ -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))