From 539dcf5440f63d5b0e2781294ec3ecc0ed9fda86 Mon Sep 17 00:00:00 2001 From: Yufeng Jin Date: Mon, 30 Oct 2023 19:24:08 +0800 Subject: [PATCH] mcount: Restore/reset rstack only when the return address is hijacked When specifying estimate_return, the return address is not hijacked. This patch ensures that mcount_rstack_reset_exception() is not called in this case, to avoid recording incorrect end times. Signed-off-by: Yufeng Jin --- libmcount/mcount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmcount/mcount.c b/libmcount/mcount.c index 5f31a9950..b101def23 100644 --- a/libmcount/mcount.c +++ b/libmcount/mcount.c @@ -1356,7 +1356,7 @@ static int __mcount_entry(unsigned long *parent_loc, unsigned long child, struct return -1; } - if (unlikely(mtdp->in_exception)) { + if (!mcount_estimate_return && unlikely(mtdp->in_exception)) { unsigned long frame_addr; /* same as __builtin_frame_addr(2) but avoid warning */ @@ -1493,7 +1493,7 @@ static int __cygprof_entry(unsigned long parent, unsigned long child) filtered = mcount_entry_filter_check(mtdp, child, &tr); - if (unlikely(mtdp->in_exception)) { + if (!mcount_estimate_return && unlikely(mtdp->in_exception)) { unsigned long *frame_ptr; unsigned long frame_addr; @@ -1640,7 +1640,7 @@ static void _xray_entry(unsigned long parent, unsigned long child, struct mcount filtered = mcount_entry_filter_check(mtdp, child, &tr); - if (unlikely(mtdp->in_exception)) { + if (!mcount_estimate_return && unlikely(mtdp->in_exception)) { unsigned long *frame_ptr; unsigned long frame_addr;