2 * Copyright (c) 2005-2007 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
36 #include <sys/cdefs.h>
37 #include <sys/pmclog.h>
46 struct pmclog_ev_callchain {
51 uintfptr_t pl_pc[PMC_CALLCHAIN_DEPTH_MAX];
54 struct pmclog_ev_dropnotify {
57 struct pmclog_ev_closelog {
60 struct pmclog_ev_initialize {
65 struct pmclog_ev_map_in {
68 char pl_pathname[PATH_MAX];
71 struct pmclog_ev_map_out {
77 struct pmclog_ev_pcsample {
84 struct pmclog_ev_pmcallocate {
86 const char * pl_evname;
91 struct pmclog_ev_pmcattach {
94 char pl_pathname[PATH_MAX];
97 struct pmclog_ev_pmcdetach {
102 struct pmclog_ev_proccsw {
105 pmc_value_t pl_value;
108 struct pmclog_ev_procexec {
111 uintfptr_t pl_entryaddr;
112 char pl_pathname[PATH_MAX];
115 struct pmclog_ev_procexit {
118 pmc_value_t pl_value;
121 struct pmclog_ev_procfork {
126 struct pmclog_ev_sysexit {
130 struct pmclog_ev_userdata {
131 uint32_t pl_userdata;
135 enum pmclog_state pl_state; /* state after 'get_event()' */
136 off_t pl_offset; /* byte offset in stream */
137 size_t pl_count; /* count of records so far */
138 struct timespec pl_ts; /* log entry timestamp */
139 enum pmclog_type pl_type; /* type of log entry */
140 union { /* log entry data */
141 struct pmclog_ev_callchain pl_cc;
142 struct pmclog_ev_closelog pl_cl;
143 struct pmclog_ev_dropnotify pl_dn;
144 struct pmclog_ev_initialize pl_i;
145 struct pmclog_ev_map_in pl_mi;
146 struct pmclog_ev_map_out pl_mo;
147 struct pmclog_ev_pcsample pl_s;
148 struct pmclog_ev_pmcallocate pl_a;
149 struct pmclog_ev_pmcattach pl_t;
150 struct pmclog_ev_pmcdetach pl_d;
151 struct pmclog_ev_proccsw pl_c;
152 struct pmclog_ev_procexec pl_x;
153 struct pmclog_ev_procexit pl_e;
154 struct pmclog_ev_procfork pl_f;
155 struct pmclog_ev_sysexit pl_se;
156 struct pmclog_ev_userdata pl_u;
160 #define PMCLOG_FD_NONE (-1)
163 void *pmclog_open(int _fd);
164 int pmclog_feed(void *_cookie, char *_data, int _len);
165 int pmclog_read(void *_cookie, struct pmclog_ev *_ev);
166 void pmclog_close(void *_cookie);