2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2005-2007 Joseph Koshy
5 * Copyright (c) 2007 The FreeBSD Foundation
8 * Portions of this software were developed by A. Joseph Koshy under
9 * sponsorship from the FreeBSD Foundation and Google, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include <sys/cdefs.h>
39 #include <sys/pmclog.h>
48 struct pmclog_ev_callchain {
53 uintfptr_t pl_pc[PMC_CALLCHAIN_DEPTH_MAX];
56 struct pmclog_ev_dropnotify {
59 struct pmclog_ev_closelog {
62 struct pmclog_ev_initialize {
67 struct pmclog_ev_map_in {
70 char pl_pathname[PATH_MAX];
73 struct pmclog_ev_map_out {
79 struct pmclog_ev_pcsample {
86 struct pmclog_ev_pmcallocate {
88 const char * pl_evname;
93 struct pmclog_ev_pmcallocatedyn {
95 char pl_evname[PMC_NAME_MAX];
100 struct pmclog_ev_pmcattach {
103 char pl_pathname[PATH_MAX];
106 struct pmclog_ev_pmcdetach {
111 struct pmclog_ev_proccsw {
114 pmc_value_t pl_value;
117 struct pmclog_ev_procexec {
120 uintfptr_t pl_entryaddr;
121 char pl_pathname[PATH_MAX];
124 struct pmclog_ev_procexit {
127 pmc_value_t pl_value;
130 struct pmclog_ev_procfork {
135 struct pmclog_ev_sysexit {
139 struct pmclog_ev_userdata {
140 uint32_t pl_userdata;
144 enum pmclog_state pl_state; /* state after 'get_event()' */
145 off_t pl_offset; /* byte offset in stream */
146 size_t pl_count; /* count of records so far */
147 struct timespec pl_ts; /* log entry timestamp */
148 enum pmclog_type pl_type; /* type of log entry */
149 union { /* log entry data */
150 struct pmclog_ev_callchain pl_cc;
151 struct pmclog_ev_closelog pl_cl;
152 struct pmclog_ev_dropnotify pl_dn;
153 struct pmclog_ev_initialize pl_i;
154 struct pmclog_ev_map_in pl_mi;
155 struct pmclog_ev_map_out pl_mo;
156 struct pmclog_ev_pcsample pl_s;
157 struct pmclog_ev_pmcallocate pl_a;
158 struct pmclog_ev_pmcallocatedyn pl_ad;
159 struct pmclog_ev_pmcattach pl_t;
160 struct pmclog_ev_pmcdetach pl_d;
161 struct pmclog_ev_proccsw pl_c;
162 struct pmclog_ev_procexec pl_x;
163 struct pmclog_ev_procexit pl_e;
164 struct pmclog_ev_procfork pl_f;
165 struct pmclog_ev_sysexit pl_se;
166 struct pmclog_ev_userdata pl_u;
170 #define PMCLOG_FD_NONE (-1)
173 void *pmclog_open(int _fd);
174 int pmclog_feed(void *_cookie, char *_data, int _len);
175 int pmclog_read(void *_cookie, struct pmclog_ev *_ev);
176 void pmclog_close(void *_cookie);