This is the mail archive of the gdb-cvs@sourceware.org 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]

[binutils-gdb] btrace: work around _dl_runtime_resolve returning to resolved function


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=986b66010c684a871f5606cb4f074d4e3d829e2f

commit 986b66010c684a871f5606cb4f074d4e3d829e2f
Author: Markus Metzger <markus.t.metzger@intel.com>
Date:   Fri Jan 23 13:32:12 2015 +0100

    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 with 32-bit inferior reported by Jan Kratochvil.
    
    gdb/
    	* btrace.c (ftrace_update_function): Treat return as tailcall for
    	"_dl_runtime_resolve".

Diff:
---
 gdb/ChangeLog |  5 +++++
 gdb/btrace.c  | 19 ++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 09a675f..3e9fa55 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-03-03  Markus Metzger  <markus.t.metzger@intel.com>
 
+	* btrace.c (ftrace_update_function): Treat return as tailcall for
+	"_dl_runtime_resolve".
+
+2015-03-03  Markus Metzger  <markus.t.metzger@intel.com>
+
 	* btrace.h (btrace_function) <lbegin, lend>: Remove.
 	* btrace.c (ftrace_debug): Do not print the line range.
 	(ftrace_skip_file, ftrace_update_lines): Remove.
diff --git a/gdb/btrace.c b/gdb/btrace.c
index c5d3ee1..5436ee9 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -478,7 +478,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.  */


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