tools/gdb: add get_task_tls and get_thread_tls

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-09-18 14:26:15 +08:00 committed by Xiang Xiao
parent 5d86bee5c7
commit 8b4a4f8539

View file

@ -603,6 +603,38 @@ def check_version():
suppress_cli_notifications(state)
def get_task_tls(tid, key):
"""get task tls from tid and key"""
tcb = get_tcb(tid)
if not tcb:
return None
try:
stack_alloc_ptr = tcb["stack_alloc_ptr"].cast(
lookup_type("struct tls_info_s").pointer()
)
tls_value = stack_alloc_ptr["tl_task"]["ta_telem"][int(key)]
return tls_value.cast(lookup_type("uintptr_t").pointer())
except gdb.error:
return None
def get_thread_tls(pid, key):
"""get thread tls from pid and key"""
tcb = get_tcb(pid)
if not tcb:
return None
try:
stack_alloc_ptr = tcb["stack_alloc_ptr"].cast(
lookup_type("struct tls_info_s").pointer()
)
tls_value = stack_alloc_ptr["tl_elem"][int(key)]
return tls_value.cast(lookup_type("uintptr_t").pointer())
except gdb.error:
return None
def gather_modules(dir=None) -> List[str]:
dir = os.path.normpath(dir) if dir else os.path.dirname(__file__)
return [