This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 11/15] btrace: work around _dl_runtime_resolve returning to resolved function
- From: Markus Metzger <markus dot t dot metzger at intel dot com>
- To: palves at redhat dot com
- Cc: gdb-patches at sourceware dot org, Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Thu, 29 Jan 2015 17:28:15 +0100
- Subject: [PATCH v3 11/15] btrace: work around _dl_runtime_resolve returning to resolved function
- Authentication-results: sourceware.org; auth=none
- References: <1422548899-9789-1-git-send-email-markus dot t dot metzger at intel dot 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