2 * thread-stack.h: Synthesize a thread's stack using call / return events
3 * Copyright (c) 2014, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 #ifndef __PERF_THREAD_STACK_H
17 #define __PERF_THREAD_STACK_H
19 #include <sys/types.h>
21 #include <linux/types.h>
36 * CALL_RETURN_NO_CALL: 'return' but no matching 'call'
37 * CALL_RETURN_NO_RETURN: 'call' but no matching 'return'
40 CALL_RETURN_NO_CALL
= 1 << 0,
41 CALL_RETURN_NO_RETURN
= 1 << 1,
45 * struct call_return - paired call/return information.
46 * @thread: thread in which call/return occurred
47 * @comm: comm in which call/return occurred
49 * @call_time: timestamp of call (if known)
50 * @return_time: timestamp of return (if known)
51 * @branch_count: number of branches seen between call and return
52 * @call_ref: external reference to 'call' sample (e.g. db_id)
53 * @return_ref: external reference to 'return' sample (e.g. db_id)
54 * @db_id: id used for db-export
55 * @flags: Call/Return flags
58 struct thread
*thread
;
71 * struct call_return_processor - provides a call-back to consume call-return
73 * @cpr: call path root
74 * @process: call-back that accepts call/return information
75 * @data: anonymous data for call-back
77 struct call_return_processor
{
78 struct call_path_root
*cpr
;
79 int (*process
)(struct call_return
*cr
, void *data
);
83 int thread_stack__event(struct thread
*thread
, u32 flags
, u64 from_ip
,
84 u64 to_ip
, u16 insn_len
, u64 trace_nr
);
85 void thread_stack__set_trace_nr(struct thread
*thread
, u64 trace_nr
);
86 void thread_stack__sample(struct thread
*thread
, struct ip_callchain
*chain
,
88 int thread_stack__flush(struct thread
*thread
);
89 void thread_stack__free(struct thread
*thread
);
90 size_t thread_stack__depth(struct thread
*thread
);
92 struct call_return_processor
*
93 call_return_processor__new(int (*process
)(struct call_return
*cr
, void *data
),
95 void call_return_processor__free(struct call_return_processor
*crp
);
96 int thread_stack__process(struct thread
*thread
, struct comm
*comm
,
97 struct perf_sample
*sample
,
98 struct addr_location
*from_al
,
99 struct addr_location
*to_al
, u64 ref
,
100 struct call_return_processor
*crp
);