utils.py:support import check and requirements.txt

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-08-15 19:55:28 +08:00 • committed by Xiang Xiao
parent bf2d6a3554
commit e71d45ce86
2 changed files with 10 additions and 0 deletions

View file

View file

@ -145,6 +145,16 @@ def get_symbol_value(name, locspec="nx_start", cacheable=True):
return value
def import_check(module, name="", errmsg=""):
try:
module = __import__(module, fromlist=[name])
except ImportError:
gdb.write(errmsg if errmsg else f"Error to import {module}\n")
return None
return getattr(module, name) if name else module
def hexdump(address, size):
inf = gdb.inferiors()[0]
mem = inf.read_memory(address, size)