Suppress repetitive errors for libs not available in stack tool

tools/python/llvm_symbolizer.py generates error logs, which when
called from the stack symbolization scripts can produce a lot of
unhelpful logs, notably the error logged when the |lib| parameter
of |GetSymbolInformation| is not valid:
"Can't run llvm-symbolizer! Given binary is not a valid target. path=%s"
See for instance these logs:
https://chromium-swarm.appspot.com/task?id=61a979f2cac67b10&w=true

This intents to silence most of those errors, especially for the test
bots, by updating the stack tool:
third_party/android_platform/development/scripts/stack et al.
This prevent calls to |GetSymbolInformation| if:
  - the library is not a .so file
  - the library is not a valid file
Logs are produced only if the script is run in verbose mode.

Bug: 1340999
Change-Id: I36e21e6f0567809297e83002722743dda30288f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4444157
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1139389}
NOKEYCHECK=True
GitOrigin-RevId: 51b9b254a06cacbc8378455a2d50868cccd7f480
diff --git a/llvm_symbolizer.py b/llvm_symbolizer.py
index abd8fa7..a36aef1 100644
--- a/llvm_symbolizer.py
+++ b/llvm_symbolizer.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import functools
 import logging
 import os
 import subprocess
@@ -16,7 +17,7 @@
 
 _ELF_MAGIC_HEADER_BYTES = b'\x7f\x45\x4c\x46'
 
-
+@functools.lru_cache
 def IsValidLLVMSymbolizerTarget(file_path):
   """ Verify the passed file is a valid target for llvm-symbolization
 
@@ -127,3 +128,7 @@
           result.append((line[:-1], line_numbers[:-1]))
         else:
           return result
+
+  @staticmethod
+  def IsValidTarget(path):
+    return IsValidLLVMSymbolizerTarget(path)