This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 3/3] btrace: update tail call heuristic
- 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
- Date: Tue, 19 Jan 2016 13:41:20 +0100
- Subject: [PATCH 3/3] btrace: update tail call heuristic
- Authentication-results: sourceware.org; auth=none
- References: <1453207280-21138-1-git-send-email-markus dot t dot metzger at intel dot com>
An unconditional jump to the start of a function typically indicates a tail
call.
If we can't determine the start of the function at the destination address, we
used to treat it as a tail call, as well. This results in lots of tail calls
for code for which we don't have symbol information.
Restrict the heuristic to only consider jumps as tail calls that switch
functions in the case where we can't determine the start of a function. This
effecticely disables tail call detection for code without symbol information.
2016-01-19 Markus Metzger <markus.t.metzger@intel.com>
gdb/
* btrace.c (ftrace_update_function): Update tail call heuristic.
---
gdb/btrace.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index a683bfa..b584386 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -528,10 +528,17 @@ ftrace_update_function (struct btrace_function *bfun, CORE_ADDR pc)
start = get_pc_function_start (pc);
+ /* A jump to the start of a function is (typically) a tail call. */
+ if (start == pc)
+ return ftrace_new_tailcall (bfun, 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 (start == 0 || start == pc)
+ the end of the block as tail call if we're switching functions
+ and as an intra-function branch if we don't. */
+ if (start == 0 && ftrace_function_switched (bfun, mfun, fun))
return ftrace_new_tailcall (bfun, mfun, fun);
+
+ break;
}
}
}
--
1.8.3.1