From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 01/12] qemu-gdb: allow using glibc_pointer_guard() on core dumps
Date: Thu, 29 Oct 2015 18:09:14 +0000 [thread overview]
Message-ID: <1446142165-24416-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1446142165-24416-1-git-send-email-stefanha@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
get_fs_base() cannot be run on a core dump, because it uses the arch_prctl
system call. The fs base is the value that is returned by pthread_self(),
and it would be nice to just glean it from the "info threads" output:
* 1 Thread 0x7f16a3fff700 (LWP 33642) pthread_cond_wait@@GLIBC_2.3.2 ()
^^^^^^^^^^^^^^
but unfortunately the gdb API does not provide that. Instead, we can
look for the "arg" argument of the start_thread function if glibc debug
information are available. If not, fall back to the old mechanism.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1444636974-19950-2-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
scripts/qemugdb/coroutine.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
index 3c54918..b1d4546 100644
--- a/scripts/qemugdb/coroutine.py
+++ b/scripts/qemugdb/coroutine.py
@@ -16,7 +16,8 @@
import gdb
def get_fs_base():
- '''Fetch %fs base value using arch_prctl(ARCH_GET_FS)'''
+ '''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 arch_prctl(0x1003, $rsp - 120)', False, True)
@@ -24,9 +25,22 @@ def get_fs_base():
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()
+
def get_glibc_pointer_guard():
'''Fetch glibc pointer guard value'''
- fs_base = get_fs_base()
+ fs_base = pthread_self()
return gdb.parse_and_eval('*(uint64_t*)((uint64_t)%s + 0x30)' % fs_base)
def glibc_ptr_demangle(val, pointer_guard):
--
2.4.3
next prev parent reply other threads:[~2015-10-29 18:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 18:09 [Qemu-devel] [PULL 00/12] Block patches Stefan Hajnoczi
2015-10-29 18:09 ` Stefan Hajnoczi [this message]
2015-10-29 18:09 ` [Qemu-devel] [PULL 02/12] qemu-gdb: extract parts of "qemu coroutine" implementation Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 03/12] qemu-gdb: add $qemu_coroutine_sp and $qemu_coroutine_pc Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 04/12] s390x: include HW_COMPAT_* props Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 05/12] ppc/spapr: add 2.4 compat props Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 06/12] virtio-blk: switch off scsi-passthrough by default Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 07/12] gdb command: qemu handlers Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 08/12] virtio: sync the dataplane vring state to the virtqueue before virtio_save Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 09/12] sd.h: Move sd.h to include/hw/sd/ Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 10/12] sdhci: Split sdhci.h for public and internal device usage Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 11/12] target-arm: xlnx-zynqmp: Add sdhci support Stefan Hajnoczi
2015-10-29 18:09 ` [Qemu-devel] [PULL 12/12] block: Consider all child nodes in bdrv_requests_pending() Stefan Hajnoczi
2015-10-30 9:40 ` [Qemu-devel] [PULL 00/12] Block patches Peter Maydell
2015-10-30 14:19 ` Markus Armbruster
2015-10-30 17:37 ` Peter Maydell
2015-10-30 21:59 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446142165-24416-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).