Skip to content

Commit

Permalink
mcount: Restore/reset rstack only when the return address is hijacked
Browse files Browse the repository at this point in the history
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 <jinyufeng2000@gmail.com>
  • Loading branch information
jyf111 committed Oct 30, 2023
1 parent d36ff37 commit 539dcf5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libmcount/mcount.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 539dcf5

Please sign in to comment.