[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/25] scripts/qemu-gdb: Simplify fs_base fetching for coroutines
From: |
Kevin Wolf |
Subject: |
[PULL 06/25] scripts/qemu-gdb: Simplify fs_base fetching for coroutines |
Date: |
Mon, 10 Feb 2025 17:10:15 +0100 |
From: Peter Xu <peterx@redhat.com>
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>
---
scripts/qemugdb/coroutine.py | 23 ++---------------------
1 file 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 @@
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'''
--
2.48.1
- [PULL 00/25] Block layer patches, Kevin Wolf, 2025/02/10
- [PULL 03/25] block: Improve blk_get_attached_dev_id() docstring, Kevin Wolf, 2025/02/10
- [PULL 06/25] scripts/qemu-gdb: Simplify fs_base fetching for coroutines,
Kevin Wolf <=
- [PULL 01/25] vpc: Split off vpc_ignore_current_size() helper, Kevin Wolf, 2025/02/10
- [PULL 02/25] vpc: Read images exported from Azure correctly, Kevin Wolf, 2025/02/10
- [PULL 05/25] scripts/qemu-gdb: Always do full stack dump for python errors, Kevin Wolf, 2025/02/10
- [PULL 04/25] block: Fix leak in send_qmp_error_event, Kevin Wolf, 2025/02/10
- [PULL 11/25] block: Inactivate external snapshot overlays when necessary, Kevin Wolf, 2025/02/10
- [PULL 10/25] block: Allow inactivating already inactive nodes, Kevin Wolf, 2025/02/10
- [PULL 08/25] block-backend: Fix argument order when calling 'qapi_event_send_block_io_error()', Kevin Wolf, 2025/02/10
- [PULL 09/25] block: Add 'active' field to BlockDeviceInfo, Kevin Wolf, 2025/02/10
- [PULL 07/25] scripts/qemu-gdb: Support coroutine dumps in coredumps, Kevin Wolf, 2025/02/10
- [PULL 12/25] migration/block-active: Remove global active flag, Kevin Wolf, 2025/02/10