Skip to content

Commit 9d88589

Browse files
committed
Merge branch 'mcount-update'
A couple of fixes and update during investigation of namhyung#1949. Signed-off-by: Namhyung Kim <[email protected]>
2 parents 7e07a43 + c454d1e commit 9d88589

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

arch/x86_64/mcount.S

+30-7
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ GLOBAL(mcount)
5858
/* save rax (implicit argument for variadic functions) */
5959
push %rax
6060

61+
/* save scratch registers due to -fipa-ra */
62+
push %r10
63+
push %r11
64+
6165
call mcount_entry
6266

67+
pop %r11
68+
pop %r10
69+
6370
pop %rax
6471

6572
/* restore original stack pointer */
@@ -88,10 +95,19 @@ END(mcount)
8895
*/
8996
ENTRY(mcount_return)
9097
.cfi_startproc
91-
sub $48, %rsp
92-
.cfi_def_cfa_offset 48
93-
94-
movq %rdi, 32(%rsp)
98+
sub $96, %rsp
99+
.cfi_def_cfa_offset 96
100+
101+
/* save all caller-saved registers due to -fipa-ra */
102+
movq %r11, 80(%rsp)
103+
movq %r10, 72(%rsp)
104+
movq %r9, 64(%rsp)
105+
movq %r8, 56(%rsp)
106+
movq %rdi, 48(%rsp)
107+
movq %rsi, 40(%rsp)
108+
movq %rcx, 32(%rsp)
109+
110+
/* below are used to carry return value */
95111
movdqu %xmm0, 16(%rsp)
96112
movq %rdx, 8(%rsp)
97113
movq %rax, 0(%rsp)
@@ -113,14 +129,21 @@ ENTRY(mcount_return)
113129
movq 0(%rsp), %rsp
114130

115131
/* restore original return address in parent */
116-
movq %rax, 40(%rsp)
132+
movq %rax, 88(%rsp)
117133

118134
movq 0(%rsp), %rax
119135
movq 8(%rsp), %rdx
120136
movdqu 16(%rsp), %xmm0
121-
movq 32(%rsp), %rdi
122137

123-
add $40, %rsp
138+
movq 32(%rsp), %rcx
139+
movq 40(%rsp), %rsi
140+
movq 48(%rsp), %rdi
141+
movq 56(%rsp), %r8
142+
movq 64(%rsp), %r9
143+
movq 72(%rsp), %r10
144+
movq 80(%rsp), %r11
145+
146+
add $88, %rsp
124147
.cfi_def_cfa_offset 8
125148
retq
126149
.cfi_endproc

libmcount/mcount.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ void mcount_entry_filter_record(struct mcount_thread_data *mtdp, struct mcount_r
12011201
#define FLAGS_TO_CHECK (TRIGGER_FL_RECOVER | TRIGGER_FL_TRACE_ON | TRIGGER_FL_TRACE_OFF)
12021202

12031203
if (tr->flags & FLAGS_TO_CHECK) {
1204-
if (tr->flags & TRIGGER_FL_RECOVER) {
1204+
if ((tr->flags & TRIGGER_FL_RECOVER) && !mcount_estimate_return) {
12051205
mcount_rstack_restore(mtdp);
12061206
*rstack->parent_loc = mcount_return_fn;
12071207
rstack->flags |= MCOUNT_FL_RECOVER;

libmcount/mcount.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ struct mcount_ret_stack {
4949
unsigned long parent_ip;
5050
unsigned long child_ip;
5151
enum mcount_rstack_flag flags;
52+
unsigned dyn_idx;
5253
/* time in nsec (CLOCK_MONOTONIC) */
5354
uint64_t start_time;
5455
uint64_t end_time;
55-
int tid;
56-
unsigned dyn_idx;
5756
uint64_t filter_time;
5857
unsigned filter_size;
5958
unsigned short depth;

libmcount/record.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ static int record_event(struct mcount_thread_data *mtdp, struct mcount_event *ev
905905
rec->data += 4; /* set 'more' bit in uftrace_record */
906906

907907
*(uint16_t *)ptr = data_size;
908-
memcpy(ptr + 2, event->data, data_size);
908+
mcount_memcpy1(ptr + 2, event->data, data_size);
909909
}
910910

911911
curr_buf->size += size;

0 commit comments

Comments
 (0)