This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v3 11/15] btrace: work around _dl_runtime_resolve returning to resolved function

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 <>

2015-01-29  Markus Metzger <>

	* btrace.c (ftrace_update_function): Treat return as tailcall for
 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)
-	  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);
+	  }
 	  /* Ignore calls to the next instruction.  They are used for PIC.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]