/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1994, by Sun Microsytems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h> /* for strerror() */
#include <fcntl.h>
#include <errno.h>
#include <locale.h>
#include "prbk.h"
extern tnfctl_handle_t *g_hndl;
typedef struct _pidlist {
} pidlist_t;
static boolean_t
{
extern int g_kernelmode;
if (!g_kernelmode) {
"This command is only available "
"in kernel mode (prex invoked with the -k flag)\n"));
return (B_TRUE);
}
if (attrs_p) {
if (err) {
"error on checking trace attributes : %s\n"),
return (B_TRUE);
}
}
return (B_FALSE);
}
/*
* Print trace buffer status (is one allocated, and if so, how big is it.
*/
void
{
if (check_kernelmode(&attrs))
return;
} else {
"tracing suspended\n"));
}
}
}
/*
* Allocate a trace buffer. Check for reasonable size; reject if there's
* already a buffer.
*/
void
{
if (check_kernelmode(&attrs))
return;
gettext("There is already a buffer allocated\n"));
return;
}
"Size %d is less than the minimum buffer size of %d -- "
"buffer size set to %d bytes\n"),
}
if (err) {
gettext("error in allocating buffer: %s\n"),
return;
}
/* get the trace attributes again */
if (check_kernelmode(&attrs))
return;
}
/*
* Deallocate the kernel's trace buffer.
*/
void
{
if (check_kernelmode(NULL))
return;
switch (err) {
case (TNFCTL_ERR_NONE):
break;
case (TNFCTL_ERR_NOBUF):
gettext("There is no buffer to deallocate\n"));
break;
case (TNFCTL_ERR_BADDEALLOC):
gettext("Can't deallocate the buffer when "
"tracing is active\n"));
break;
default:
gettext("error in deleting buffer: %s\n"),
break;
}
}
/*
* Process filter routines.
*
* Process id sets are encoded as "pidlists": a linked list of pids.
* In a feeble attempt at encapsulation, the pidlist_t type is private
* to this file; prexgram.y manipulates pidlists only as opaque handles.
*/
/*
* Add the given pid (new) to the pidlist (pl).
*/
void *
{
gettext("Out of memory -- can't process pid %d\n"),
new);
return (pl);
}
return (npl);
}
/*
* Add the pids in the given pidlist to the process filter list.
* For each pid, check whether it's already in the filter list,
* and whether the process exists.
*/
void
{
if (check_kernelmode(NULL))
return;
if (err) {
}
}
}
/*
* Drop the pids in the given pidlist from the process filter list.
* For each pid, complain if it's not in the process filter list;
* and if the process no longer exists (and hence has already implicitly
* been dropped from the process filter list), say so.
*/
void
{
if (check_kernelmode(NULL))
return;
switch (err) {
case (TNFCTL_ERR_NONE):
break;
case (TNFCTL_ERR_BADARG):
gettext("Process %ld is not being traced\n"),
break;
case (TNFCTL_ERR_NOPROCESS):
break;
default:
break;
}
}
}
/*
* Turn process filter mode on or off. The process filter is maintained
* even when process filtering is off, but has no effect: all processes
* are traced.
*/
void
{
if (check_kernelmode(NULL))
return;
if (err) {
}
}
/*
* Report whether process filter mode is currently on or off, and
* dump the current process filter set.
*/
void
{
int i, pid_count;
if (check_kernelmode(&attrs))
return;
if (err) {
gettext("error in getting process filter list: %s\n"),
return;
}
if (pid_count == 0)
(void) printf("empty.\n");
else {
(void) printf("{");
}
}
}
/*
* Check for process filtering on with empty pid filter.
*/
void
prbk_warn_pfilter_empty(void)
{
int pid_count;
if (check_kernelmode(&attrs))
return;
if (attrs.filter_state) {
if (err) {
gettext("error in getting process filter list: %s\n"),
return;
}
if (!pid_count)
gettext("Warning: Process filtering on, \
but pid filter list is empty\n"));
}
}
/*
* Turn kernel tracing on or off.
*/
void
{
if (check_kernelmode(NULL))
return;
if (err) {
gettext("error in setting tracing state: %s\n"),
}
}
/*
* Show whether kernel tracing is currently on or off.
*/
void
{
if (check_kernelmode(&attrs))
return;
}