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/pmclog.h>
45 struct pmclog_ev_callchain {
50 uintfptr_t pl_pc[PMC_CALLCHAIN_DEPTH_MAX];
53 struct pmclog_ev_dropnotify {
56 struct pmclog_ev_closelog {
59 struct pmclog_ev_initialize {
64 struct pmclog_ev_map_in {
67 char pl_pathname[PATH_MAX];
70 struct pmclog_ev_map_out {
76 struct pmclog_ev_pcsample {
83 struct pmclog_ev_pmcallocate {
85 const char * pl_evname;
90 struct pmclog_ev_pmcattach {
93 char pl_pathname[PATH_MAX];
96 struct pmclog_ev_pmcdetach {
101 struct pmclog_ev_proccsw {
104 pmc_value_t pl_value;
107 struct pmclog_ev_procexec {
110 uintfptr_t pl_entryaddr;
111 char pl_pathname[PATH_MAX];
114 struct pmclog_ev_procexit {
117 pmc_value_t pl_value;
120 struct pmclog_ev_procfork {
125 struct pmclog_ev_sysexit {
129 struct pmclog_ev_userdata {
130 uint32_t pl_userdata;
134 enum pmclog_state pl_state; /* state after 'get_event()' */
135 off_t pl_offset; /* byte offset in stream */
136 size_t pl_count; /* count of records so far */
137 struct timespec pl_ts; /* log entry timestamp */
138 enum pmclog_type pl_type; /* type of log entry */
139 union { /* log entry data */
140 struct pmclog_ev_callchain pl_cc;
141 struct pmclog_ev_closelog pl_cl;
142 struct pmclog_ev_dropnotify pl_dn;
143 struct pmclog_ev_initialize pl_i;
144 struct pmclog_ev_map_in pl_mi;
145 struct pmclog_ev_map_out pl_mo;
146 struct pmclog_ev_pcsample pl_s;
147 struct pmclog_ev_pmcallocate pl_a;
148 struct pmclog_ev_pmcattach pl_t;
149 struct pmclog_ev_pmcdetach pl_d;
150 struct pmclog_ev_proccsw pl_c;
151 struct pmclog_ev_procexec pl_x;
152 struct pmclog_ev_procexit pl_e;
153 struct pmclog_ev_procfork pl_f;
154 struct pmclog_ev_sysexit pl_se;
155 struct pmclog_ev_userdata pl_u;
159 #define PMCLOG_FD_NONE (-1)
161 void *pmclog_open(int _fd);
162 int pmclog_feed(void *_cookie, char *_data, int _len);
163 int pmclog_read(void *_cookie, struct pmclog_ev *_ev);
164 void pmclog_close(void *_cookie);