public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com
Cc: gdb-patches@sourceware.org, Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH v3 11/15] btrace: work around _dl_runtime_resolve returning to resolved function
Date: Thu, 29 Jan 2015 16:33:00 -0000	[thread overview]
Message-ID: <1422548899-9789-12-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1422548899-9789-1-git-send-email-markus.t.metzger@intel.com>

On some systems, _dl_runtime_resolve returns to the resolved function
instead of jumping to it.  Since btrace will not find the function in
the current stack back trace, it will start a new back trace on the
same level.  It will look the same to the user via the backtrace
command but the frames will have different id's which confuses stepping.

This fixes a test fail on 32-bit systems reported by Jan Kratochvil.

CC: Jan Kratochvil <jan.kratochvil@redhat.com>

2015-01-29  Markus Metzger <markus.t.metzger@intel.com>

gdb/
	* btrace.c (ftrace_update_function): Treat return as tailcall for
	"_dl_runtime_resolve".
---
 gdb/btrace.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/btrace.c b/gdb/btrace.c
index b29e0b2..45e9035 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -506,7 +506,24 @@ ftrace_update_function (struct btrace_function *bfun, CORE_ADDR pc)
       switch (last->iclass)
 	{
 	case BTRACE_INSN_RETURN:
-	  return ftrace_new_return (bfun, mfun, fun);
+	  {
+	    const char *fname;
+
+	    /* On some systems, _dl_runtime_resolve returns to the resolved
+	       function instead of jumping to it.  From our perspective,
+	       however, this is a tailcall.
+	       If we treated it as return, we wouldn't be able to find the
+	       resolved function in our stack back trace.  Hence, we would
+	       lose the current stack back trace and start anew with an empty
+	       back trace.  When the resolved function returns, we would then
+	       create a stack back trace with the same function names but
+	       different frame id's.  This will confuse stepping.  */
+	    fname = ftrace_print_function_name (bfun);
+	    if (strcmp (fname, "_dl_runtime_resolve") == 0)
+	      return ftrace_new_tailcall (bfun, mfun, fun);
+
+	    return ftrace_new_return (bfun, mfun, fun);
+	  }
 
 	case BTRACE_INSN_CALL:
 	  /* Ignore calls to the next instruction.  They are used for PIC.  */
-- 
1.8.3.1

  parent reply	other threads:[~2015-01-29 16:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 16:28 [PATCH v3 00/15] record btrace: prepare for a new trace format Markus Metzger
2015-01-29 16:29 ` [PATCH v3 02/15] btrace: add format argument to supports_btrace Markus Metzger
2015-01-29 16:29 ` [PATCH v3 13/15] btrace: increase buffer size for exception test Markus Metzger
2015-01-29 16:29 ` [PATCH v3 05/15] record-btrace: add bts buffer size configuration option Markus Metzger
2015-01-29 16:29 ` [PATCH v3 07/15] btrace: extend struct btrace_insn Markus Metzger
2015-01-29 16:29 ` [PATCH v3 12/15] btrace: support 32-bit inferior on 64-bit host Markus Metzger
2015-01-29 16:29 ` [PATCH v3 08/15] btrace: identify cpu Markus Metzger
2015-01-29 16:30 ` [PATCH v3 09/15] record-btrace: indicate gaps Markus Metzger
2015-01-29 16:30 ` [PATCH v3 14/15] configure: check for libipt Markus Metzger
2015-01-29 16:30 ` [PATCH v3 06/15] btrace: update btrace_compute_ftrace parameters Markus Metzger
2015-01-29 16:30 ` [PATCH v3 01/15] btrace: add struct btrace_data Markus Metzger
2015-01-29 16:33 ` Markus Metzger [this message]
2015-01-29 17:11 ` [PATCH v3 03/15] btrace, linux: add perf event buffer abstraction Markus Metzger
2015-01-29 17:11 ` [PATCH v3 10/15] btrace: less debug output Markus Metzger
2015-01-29 18:35 ` [PATCH v3 04/15] record btrace: add configuration struct Markus Metzger
2015-01-29 19:29   ` Eli Zaretskii
2015-01-29 19:28 ` [PATCH v3 15/15] [wip] btrace: support Intel(R) Processor Trace Markus Metzger
2015-01-29 19:28   ` Eli Zaretskii
2015-01-30 18:57     ` Metzger, Markus T
2015-02-04  8:25 ` [PATCH v3 00/15] record btrace: prepare for a new trace format Metzger, Markus T

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=1422548899-9789-12-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=palves@redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).