Deleted Added
full compact
pmcstat.h (185322) pmcstat.h (203790)
1/*-
2 * Copyright (c) 2005-2007, Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
1/*-
2 * Copyright (c) 2005-2007, Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/usr.sbin/pmcstat/pmcstat.h 185322 2008-11-25 23:24:29Z attilio $
30 * $FreeBSD: head/usr.sbin/pmcstat/pmcstat.h 203790 2010-02-11 22:51:44Z fabient $
31 */
32
33#ifndef _PMCSTAT_H_
34#define _PMCSTAT_H_
35
36#define FLAG_HAS_TARGET 0x00000001 /* process target */
37#define FLAG_HAS_WAIT_INTERVAL 0x00000002 /* -w secs */
38#define FLAG_HAS_OUTPUT_LOGFILE 0x00000004 /* -O file or pipe */
39#define FLAG_HAS_COMMANDLINE 0x00000008 /* command */
40#define FLAG_HAS_SAMPLING_PMCS 0x00000010 /* -S or -P */
41#define FLAG_HAS_COUNTING_PMCS 0x00000020 /* -s or -p */
42#define FLAG_HAS_PROCESS_PMCS 0x00000040 /* -P or -p */
43#define FLAG_HAS_SYSTEM_PMCS 0x00000080 /* -S or -s */
44#define FLAG_HAS_PIPE 0x00000100 /* implicit log */
45#define FLAG_READ_LOGFILE 0x00000200 /* -R file */
46#define FLAG_DO_GPROF 0x00000400 /* -g */
47#define FLAG_HAS_SAMPLESDIR 0x00000800 /* -D dir */
48#define FLAG_HAS_KERNELPATH 0x00001000 /* -k kernel */
49#define FLAG_DO_PRINT 0x00002000 /* -o */
31 */
32
33#ifndef _PMCSTAT_H_
34#define _PMCSTAT_H_
35
36#define FLAG_HAS_TARGET 0x00000001 /* process target */
37#define FLAG_HAS_WAIT_INTERVAL 0x00000002 /* -w secs */
38#define FLAG_HAS_OUTPUT_LOGFILE 0x00000004 /* -O file or pipe */
39#define FLAG_HAS_COMMANDLINE 0x00000008 /* command */
40#define FLAG_HAS_SAMPLING_PMCS 0x00000010 /* -S or -P */
41#define FLAG_HAS_COUNTING_PMCS 0x00000020 /* -s or -p */
42#define FLAG_HAS_PROCESS_PMCS 0x00000040 /* -P or -p */
43#define FLAG_HAS_SYSTEM_PMCS 0x00000080 /* -S or -s */
44#define FLAG_HAS_PIPE 0x00000100 /* implicit log */
45#define FLAG_READ_LOGFILE 0x00000200 /* -R file */
46#define FLAG_DO_GPROF 0x00000400 /* -g */
47#define FLAG_HAS_SAMPLESDIR 0x00000800 /* -D dir */
48#define FLAG_HAS_KERNELPATH 0x00001000 /* -k kernel */
49#define FLAG_DO_PRINT 0x00002000 /* -o */
50#define FLAG_DO_CALLGRAPHS 0x00004000 /* -G */
51#define FLAG_DO_ANALYSIS 0x00008000 /* -g or -G */
52#define FLAG_WANTS_MAPPINGS 0x00010000 /* -m */
50#define FLAG_DO_CALLGRAPHS 0x00004000 /* -G or -F */
51#define FLAG_DO_ANNOTATE 0x00008000 /* -m */
52#define FLAG_DO_TOP 0x00010000 /* -T */
53#define FLAG_DO_ANALYSIS 0x00020000 /* -g or -G or -m or -T */
53
54#define DEFAULT_SAMPLE_COUNT 65536
55#define DEFAULT_WAIT_INTERVAL 5.0
54
55#define DEFAULT_SAMPLE_COUNT 65536
56#define DEFAULT_WAIT_INTERVAL 5.0
56#define DEFAULT_DISPLAY_HEIGHT 23
57#define DEFAULT_DISPLAY_HEIGHT 256 /* file virtual height */
58#define DEFAULT_DISPLAY_WIDTH 1024 /* file virtual width */
57#define DEFAULT_BUFFER_SIZE 4096
58#define DEFAULT_CALLGRAPH_DEPTH 4
59
60#define PRINT_HEADER_PREFIX "# "
61#define READPIPEFD 0
62#define WRITEPIPEFD 1
63#define NPIPEFD 2
64

--- 5 unchanged lines hidden (view full) ---

70#define PMCSTAT_OPEN_FOR_WRITE 1
71#define PMCSTAT_DEFAULT_NW_HOST "localhost"
72#define PMCSTAT_DEFAULT_NW_PORT "9000"
73#define PMCSTAT_NHASH 256
74#define PMCSTAT_HASH_MASK 0xFF
75
76#define PMCSTAT_LDD_COMMAND "/usr/bin/ldd"
77
59#define DEFAULT_BUFFER_SIZE 4096
60#define DEFAULT_CALLGRAPH_DEPTH 4
61
62#define PRINT_HEADER_PREFIX "# "
63#define READPIPEFD 0
64#define WRITEPIPEFD 1
65#define NPIPEFD 2
66

--- 5 unchanged lines hidden (view full) ---

72#define PMCSTAT_OPEN_FOR_WRITE 1
73#define PMCSTAT_DEFAULT_NW_HOST "localhost"
74#define PMCSTAT_DEFAULT_NW_PORT "9000"
75#define PMCSTAT_NHASH 256
76#define PMCSTAT_HASH_MASK 0xFF
77
78#define PMCSTAT_LDD_COMMAND "/usr/bin/ldd"
79
78#define PMCSTAT_PRINT_ENTRY(A,T,...) do { \
79 (void) fprintf((A)->pa_printfile, "%-9s", T); \
80 (void) fprintf((A)->pa_printfile, " " __VA_ARGS__); \
81 (void) fprintf((A)->pa_printfile, "\n"); \
80#define PMCSTAT_PRINT_ENTRY(T,...) do { \
81 (void) fprintf(args.pa_printfile, "%-9s", T); \
82 (void) fprintf(args.pa_printfile, " " __VA_ARGS__); \
83 (void) fprintf(args.pa_printfile, "\n"); \
82 } while (0)
83
84 } while (0)
85
86#define PMCSTAT_PL_NONE 0
87#define PMCSTAT_PL_CALLGRAPH 1
88#define PMCSTAT_PL_GPROF 2
89#define PMCSTAT_PL_ANNOTATE 3
90#define PMCSTAT_PL_CALLTREE 4
91
92#define PMCSTAT_TOP_DELTA 0
93#define PMCSTAT_TOP_ACCUM 1
94
95#define min(A,B) ((A) < (B) ? (A) : (B))
96#define max(A,B) ((A) > (B) ? (A) : (B))
97
84enum pmcstat_state {
85 PMCSTAT_FINISHED = 0,
86 PMCSTAT_EXITING = 1,
87 PMCSTAT_RUNNING = 2
88};
89
90struct pmcstat_ev {
91 STAILQ_ENTRY(pmcstat_ev) ev_next;

--- 13 unchanged lines hidden (view full) ---

105struct pmcstat_target {
106 SLIST_ENTRY(pmcstat_target) pt_next;
107 pid_t pt_pid;
108};
109
110struct pmcstat_args {
111 int pa_flags; /* argument flags */
112 int pa_required; /* required features */
98enum pmcstat_state {
99 PMCSTAT_FINISHED = 0,
100 PMCSTAT_EXITING = 1,
101 PMCSTAT_RUNNING = 2
102};
103
104struct pmcstat_ev {
105 STAILQ_ENTRY(pmcstat_ev) ev_next;

--- 13 unchanged lines hidden (view full) ---

119struct pmcstat_target {
120 SLIST_ENTRY(pmcstat_target) pt_next;
121 pid_t pt_pid;
122};
123
124struct pmcstat_args {
125 int pa_flags; /* argument flags */
126 int pa_required; /* required features */
127 int pa_pplugin; /* pre-processing plugin */
128 int pa_plugin; /* analysis plugin */
113 int pa_verbosity; /* verbosity level */
114 FILE *pa_printfile; /* where to send printed output */
115 int pa_logfd; /* output log file */
116 char *pa_inputpath; /* path to input log */
117 char *pa_outputpath; /* path to output log */
118 void *pa_logparser; /* log file parser */
119 const char *pa_fsroot; /* FS root where executables reside */
120 char *pa_kernel; /* pathname of the kernel */
121 const char *pa_samplesdir; /* directory for profile files */
122 const char *pa_mapfilename;/* mapfile name */
123 FILE *pa_graphfile; /* where to send the callgraph */
124 int pa_graphdepth; /* print depth for callgraphs */
125 double pa_interval; /* printing interval in seconds */
126 uint32_t pa_cpumask; /* filter for CPUs analysed */
129 int pa_verbosity; /* verbosity level */
130 FILE *pa_printfile; /* where to send printed output */
131 int pa_logfd; /* output log file */
132 char *pa_inputpath; /* path to input log */
133 char *pa_outputpath; /* path to output log */
134 void *pa_logparser; /* log file parser */
135 const char *pa_fsroot; /* FS root where executables reside */
136 char *pa_kernel; /* pathname of the kernel */
137 const char *pa_samplesdir; /* directory for profile files */
138 const char *pa_mapfilename;/* mapfile name */
139 FILE *pa_graphfile; /* where to send the callgraph */
140 int pa_graphdepth; /* print depth for callgraphs */
141 double pa_interval; /* printing interval in seconds */
142 uint32_t pa_cpumask; /* filter for CPUs analysed */
143 int pa_ctdumpinstr; /* dump instructions with calltree */
144 int pa_topmode; /* delta or accumulative */
145 int pa_toptty; /* output to tty or file */
146 int pa_topcolor; /* terminal support color */
147 int pa_mergepmc; /* merge PMC with same name */
127 int pa_argc;
128 char **pa_argv;
129 STAILQ_HEAD(, pmcstat_ev) pa_events;
130 SLIST_HEAD(, pmcstat_target) pa_targets;
148 int pa_argc;
149 char **pa_argv;
150 STAILQ_HEAD(, pmcstat_ev) pa_events;
151 SLIST_HEAD(, pmcstat_target) pa_targets;
131} args;
152};
132
153
154extern int pmcstat_displayheight; /* current terminal height */
155extern int pmcstat_displaywidth; /* current terminal width */
156extern struct pmcstat_args args; /* command line args */
157
133/* Function prototypes */
158/* Function prototypes */
134void pmcstat_attach_pmcs(struct pmcstat_args *_a);
135void pmcstat_cleanup(struct pmcstat_args *_a);
136void pmcstat_clone_event_descriptor(struct pmcstat_args *_a,
159void pmcstat_attach_pmcs(void);
160void pmcstat_cleanup(void);
161void pmcstat_clone_event_descriptor(
137 struct pmcstat_ev *_ev, uint32_t _cpumask);
162 struct pmcstat_ev *_ev, uint32_t _cpumask);
138int pmcstat_close_log(struct pmcstat_args *_a);
139void pmcstat_create_process(struct pmcstat_args *_a);
140void pmcstat_find_targets(struct pmcstat_args *_a, const char *_arg);
141void pmcstat_initialize_logging(struct pmcstat_args *_a);
142void pmcstat_kill_process(struct pmcstat_args *_a);
163int pmcstat_close_log(void);
164void pmcstat_create_process(void);
165void pmcstat_find_targets(const char *_arg);
166void pmcstat_initialize_logging(void);
167void pmcstat_kill_process(void);
143int pmcstat_open_log(const char *_p, int _mode);
168int pmcstat_open_log(const char *_p, int _mode);
144void pmcstat_print_counters(struct pmcstat_args *_a);
145void pmcstat_print_headers(struct pmcstat_args *_a);
146void pmcstat_print_pmcs(struct pmcstat_args *_a);
169void pmcstat_print_counters(void);
170void pmcstat_print_headers(void);
171void pmcstat_print_pmcs(void);
147void pmcstat_show_usage(void);
172void pmcstat_show_usage(void);
148void pmcstat_shutdown_logging(struct pmcstat_args *_a);
149void pmcstat_start_pmcs(struct pmcstat_args *_a);
173void pmcstat_shutdown_logging(void);
174void pmcstat_start_pmcs(void);
150void pmcstat_start_process(void);
175void pmcstat_start_process(void);
151int pmcstat_process_log(struct pmcstat_args *_a);
176int pmcstat_process_log(void);
177int pmcstat_keypress_log(void);
178void pmcstat_display_log(void);
179void pmcstat_pluginconfigure_log(char *_opt);
152uint32_t pmcstat_get_cpumask(const char *_a);
180uint32_t pmcstat_get_cpumask(const char *_a);
181void pmcstat_topexit(void);
153
154#endif /* _PMCSTAT_H_ */
182
183#endif /* _PMCSTAT_H_ */