From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Cc: Markus Metzger <markus.t.metzger@intel.com>
Subject: [PATCH] btrace: check for indirect jump return in _Unwind_RaiseException
Date: Thu, 27 Sep 2018 07:42:00 -0000 [thread overview]
Message-ID: <1538034149-12136-1-git-send-email-markus.t.metzger@intel.com> (raw)
Some versions of _Unwind_RaiseException, e.g. on Fedora 28, use an
indirect jump to return to the exception handler.
This messes up the output of "record function-call-history /c" since the
return is interpreted as cross-function goto. It had been detected by
gdb.btrace/exception.exp.
Add a heuristic for "_Unwind_*" functions to interpret an indirect jump
that ends in one of our caller functions as return to the first instance
of that function in our call stack.
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
gdb/
* btrace.c (ftrace_update_function): Add indirect jump heuristic.
---
gdb/btrace.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index e25f047ce24..d3ad0ab7de8 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -620,6 +620,20 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
if (start == pc)
return ftrace_new_tailcall (btinfo, mfun, fun);
+ /* Some versions of _Unwind_RaiseException use an indirect
+ jump to 'return' to the exception handler of the caller
+ handling the exception instead of a return. Let's restrict
+ this heuristic to that and related functions. */
+ const char *fname = ftrace_print_function_name (bfun);
+ if (strncmp (fname, "_Unwind_", strlen ("_Unwind_")) == 0)
+ {
+ struct btrace_function *caller
+ = ftrace_find_call_by_number (btinfo, bfun->up);
+ caller = ftrace_find_caller (btinfo, caller, mfun, fun);
+ if (caller != NULL)
+ return ftrace_new_return (btinfo, mfun, fun);
+ }
+
/* If we can't determine the function for PC, we treat a jump at
the end of the block as tail call if we're switching functions
and as an intra-function branch if we don't. */
--
2.17.1
next reply other threads:[~2018-09-27 7:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-27 7:42 Markus Metzger [this message]
2018-09-27 7:44 ` [PATCH] testsuite: fix is_amd64_regs_target Markus Metzger
2018-09-27 21:10 ` Tom Tromey
2018-09-28 7:07 ` Metzger, Markus T
2018-09-28 17:34 ` Tom Tromey
[not found] ` <8a5ded70-add4-df1d-5f7f-6f7682d58059@ericsson.com>
2018-09-29 18:09 ` Pedro Alves
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=1538034149-12136-1-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.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