From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Richard Henderson <rth@twiddle.net>,
Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH v2] linux-user: provide frame information in x86-64 safe_syscall
Date: Mon, 6 Jun 2016 19:56:54 +0100 [thread overview]
Message-ID: <1465239414-4932-1-git-send-email-peter.maydell@linaro.org> (raw)
Use cfi directives in the x86-64 safe_syscall to allow gdb to get
backtraces right from within it. (In particular this will be
quite a common situation if the user interrupts QEMU while it's
in a blocked safe-syscall: at the point of the syscall insn RBP
is in use for something else, and so gdb can't find the frame then
without assistance.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
v1->v2 changes: minor tweaks as requested by rth
I was planning to send this in a series with some other safe-syscall code
for the other architectures, but I haven't got round to those yet, so
might as well send out the fixed version of this by itself.
linux-user/host/x86_64/safe-syscall.inc.S | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/linux-user/host/x86_64/safe-syscall.inc.S b/linux-user/host/x86_64/safe-syscall.inc.S
index dde434c..e09368d 100644
--- a/linux-user/host/x86_64/safe-syscall.inc.S
+++ b/linux-user/host/x86_64/safe-syscall.inc.S
@@ -24,6 +24,7 @@
* -1-and-errno-set convention is done by the calling wrapper.
*/
safe_syscall_base:
+ .cfi_startproc
/* This saves a frame pointer and aligns the stack for the syscall.
* (It's unclear if the syscall ABI has the same stack alignment
* requirements as the userspace function call ABI, but better safe than
@@ -31,6 +32,8 @@ safe_syscall_base:
* does not list any ABI differences regarding stack alignment.)
*/
push %rbp
+ .cfi_adjust_cfa_offset 8
+ .cfi_rel_offset rbp, 0
/* The syscall calling convention isn't the same as the
* C one:
@@ -70,12 +73,19 @@ safe_syscall_start:
safe_syscall_end:
/* code path for having successfully executed the syscall */
pop %rbp
+ .cfi_remember_state
+ .cfi_def_cfa_offset 8
+ .cfi_restore rbp
ret
return_ERESTARTSYS:
/* code path when we didn't execute the syscall */
+ .cfi_restore_state
mov $-TARGET_ERESTARTSYS, %rax
pop %rbp
+ .cfi_def_cfa_offset 8
+ .cfi_restore rbp
ret
+ .cfi_endproc
.size safe_syscall_base, .-safe_syscall_base
--
1.9.1
next reply other threads:[~2016-06-06 18:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 18:56 Peter Maydell [this message]
2016-06-06 21:03 ` [Qemu-devel] [PATCH v2] linux-user: provide frame information in x86-64 safe_syscall Richard Henderson
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=1465239414-4932-1-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
/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).