summary refs log tree commit diff stats
path: root/scripts/qemugdb
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2024-12-12 15:48:00 -0500
committerKevin Wolf <kwolf@redhat.com>2025-02-06 13:59:00 +0100
commitf4e343b6559eda19efe972b9dcd52e479320e388 (patch)
tree8eae18158102080fee882c2f3b502450bcc9995c /scripts/qemugdb
parent5bf10468b68816377264e557e91186a2ee129c95 (diff)
downloadfocaccia-qemu-f4e343b6559eda19efe972b9dcd52e479320e388.tar.gz
focaccia-qemu-f4e343b6559eda19efe972b9dcd52e479320e388.zip
scripts/qemu-gdb: Simplify fs_base fetching for coroutines
There're a bunch of code trying to fetch fs_base in different ways.  IIUC
the simplest way instead is "$fs_base".  It also has the benefit that it'll
work for both live gdb session or coredumps.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-ID: <20241212204801.1420528-3-peterx@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'scripts/qemugdb')
-rw-r--r--scripts/qemugdb/coroutine.py23
1 files changed, 2 insertions, 21 deletions
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
index 7db46d4b68..20f76ed37b 100644
--- a/scripts/qemugdb/coroutine.py
+++ b/scripts/qemugdb/coroutine.py
@@ -13,28 +13,9 @@ import gdb
 
 VOID_PTR = gdb.lookup_type('void').pointer()
 
-def get_fs_base():
-    '''Fetch %fs base value using arch_prctl(ARCH_GET_FS).  This is
-       pthread_self().'''
-    # %rsp - 120 is scratch space according to the SystemV ABI
-    old = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
-    gdb.execute('call (int)arch_prctl(0x1003, $rsp - 120)', False, True)
-    fs_base = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
-    gdb.execute('set *(uint64_t*)($rsp - 120) = %s' % old, False, True)
-    return fs_base
-
 def pthread_self():
-    '''Fetch pthread_self() from the glibc start_thread function.'''
-    f = gdb.newest_frame()
-    while f.name() != 'start_thread':
-        f = f.older()
-        if f is None:
-            return get_fs_base()
-
-    try:
-        return f.read_var("arg")
-    except ValueError:
-        return get_fs_base()
+    '''Fetch the base address of TLS.'''
+    return gdb.parse_and_eval("$fs_base")
 
 def get_glibc_pointer_guard():
     '''Fetch glibc pointer guard value'''