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 uint32_t pl_cpuflags2;
55 uintfptr_t pl_pc[PMC_CALLCHAIN_DEPTH_MAX];
58 struct pmclog_ev_dropnotify {
61 struct pmclog_ev_closelog {
64 struct pmclog_ev_initialize {
69 struct pmclog_ev_map_in {
72 char pl_pathname[PATH_MAX];
75 struct pmclog_ev_map_out {
81 struct pmclog_ev_pcsample {
90 struct pmclog_ev_pmcallocate {
92 const char * pl_evname;
97 struct pmclog_ev_pmcallocatedyn {
99 char pl_evname[PMC_NAME_MAX];
104 struct pmclog_ev_pmcattach {
107 char pl_pathname[PATH_MAX];
110 struct pmclog_ev_pmcdetach {
115 struct pmclog_ev_proccsw {
119 pmc_value_t pl_value;
122 struct pmclog_ev_procexec {
125 uintfptr_t pl_entryaddr;
126 char pl_pathname[PATH_MAX];
129 struct pmclog_ev_procexit {
132 pmc_value_t pl_value;
135 struct pmclog_ev_procfork {
140 struct pmclog_ev_sysexit {
144 struct pmclog_ev_userdata {
145 uint32_t pl_userdata;
149 enum pmclog_state pl_state; /* state after 'get_event()' */
150 off_t pl_offset; /* byte offset in stream */
151 size_t pl_count; /* count of records so far */
152 struct timespec pl_ts; /* log entry timestamp */
153 enum pmclog_type pl_type; /* type of log entry */
154 union { /* log entry data */
155 struct pmclog_ev_callchain pl_cc;
156 struct pmclog_ev_closelog pl_cl;
157 struct pmclog_ev_dropnotify pl_dn;
158 struct pmclog_ev_initialize pl_i;
159 struct pmclog_ev_map_in pl_mi;
160 struct pmclog_ev_map_out pl_mo;
161 struct pmclog_ev_pcsample pl_s;
162 struct pmclog_ev_pmcallocate pl_a;
163 struct pmclog_ev_pmcallocatedyn pl_ad;
164 struct pmclog_ev_pmcattach pl_t;
165 struct pmclog_ev_pmcdetach pl_d;
166 struct pmclog_ev_proccsw pl_c;
167 struct pmclog_ev_procexec pl_x;
168 struct pmclog_ev_procexit pl_e;
169 struct pmclog_ev_procfork pl_f;
170 struct pmclog_ev_sysexit pl_se;
171 struct pmclog_ev_userdata pl_u;
175 #define PMCLOG_FD_NONE (-1)
178 void *pmclog_open(int _fd);
179 int pmclog_feed(void *_cookie, char *_data, int _len);
180 int pmclog_read(void *_cookie, struct pmclog_ev *_ev);
181 void pmclog_close(void *_cookie);