/*
* 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"
/*
* Includes
*/
#ifndef DEBUG
#endif
#include <assert.h>
#include <limits.h>
#include <values.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "tnf_trace.h"
/*
* Defines
*/
/*
* CAUTION: halfword_accessible assumes that the pointer is to a reclaimable
* block - i.e. negative offsets have a 0 in high bit
*/
#define HALFWORD_ACCESSIBLE(x) \
((((x) & 0xffff8000) == 0) || (((x) & 0xffff8000) == 0x7fff8000))
/*
* Check that x can be encoded in tagarg slot
* Same as above, but operates on ints (no space bit)
*/
#define TAGARG_CHECK(x) \
(((x) < 32767) && ((x) > -32768))
/*
* Check that hi 32 bits of hrtime are zero
*/
#define TIME_CHECK(x) \
(((x) >> 32) == 0)
/*
* CAUTION: Use the following macro only when doing a self relative pointer
* to a target in the same block
*/
/*
* Typedefs
*/
typedef struct {
/*
* tnf_trace_alloc
* the probe allocation function
*/
void *
{
volatile char *file_start;
#if defined(DEBUG) || defined(VERYVERBOSE)
#endif
/* check if already in a probe */
return (NULL);
#ifdef VERYVERBOSE
#endif
/*
* CAUTION: Ordering of function calls in this file is critical because
* we call TNFW_B_GIVEBACK. Between the time we allocate space for the
* event and call TNFW_B_GIVEBACK there can be no other allocations!!
*/
/*
* Write probe tag if needed
*/
#ifdef VERYVERBOSE
#endif
if (probe_index == 0) {
#ifdef VERYVERBOSE
sleep(2);
#endif
goto null_ret;
}
#ifdef VERYVERBOSE
#endif
}
/*
* Determine how much memory is required
*/
if (PROBE_IS_FILE_PTR(probe_index)) {
/* common case - probe_index is a file ptr */
} else {
/* rare case -- get an extra fwd ptr */
asize += sizeof (tnf_ref32_t);
}
/*
* Allocate memory
*/
#ifdef _TNF_VERBOSE
#endif
#ifdef _TNF_VERBOSE
#endif
goto null_ret;
/* LINTED pointer cast may result in improper alignment */
#ifdef _TNF_VERBOSE
#endif
/* set file_start after calling alloc because it allocs the file */
/* Check if the probe tag needs more work */
if (!PROBE_IS_FILE_PTR(probe_index)) {
/* LINTED use up first fwd ptr */
/* LINTED ptr subtraction */
/* LINTED ptr subtraction */
fwd_p++;
}
/*
* Get timestamp
*/
/*
* initialize and write schedule record if needed
* watch out for sched->record_p - it has to be checked after alloc is
* called for the event, because it could be side effected by alloc
* if a fork happened. Pre-requisite to our algorithm - if a fork
* happens all other threads have to be quiescent i.e. not in a probe.
*/
#ifdef _TNF_VERBOSE
#endif
/* LINTED pointer cast */
/* No record written yet */
goto new_schedule;
}
/*
* Note: Don't bother about space bit here, because we'll
* only use bits 15:2 anyway
*/
/* LINTED - ptr subtraction */
if (!TAGARG_CHECK(sched_offset))
/* Record too far away to reference */
goto new_schedule;
if (!TIME_CHECK(time_diff))
/* Time delta can't fit in 32 bits */
goto new_schedule;
/*
* Can reuse existing schedule record
* Since we did not allocate any more space, can giveback
*/
/* LINTED - GIVEBACK returns a pointer subtraction */
/*
* Store return params and two common event members, return buffer
*/
/* LINTED - TIME_CHECK already passed, see above */
return (buffer);
/*
* Write a new schedule record for this thread
*/
#ifdef VERYVERBOSE
"new schedule record\n");
#endif
time_diff = 0;
/* use one of the extra alloced words for the forwarding ptr */
/* LINTED - ptr subtraction */
/* LINTED - ptr subtraction */
} else {
/* Allocation failed (tracing may have been stopped) */
sched_offset = 0;
}
goto good_ret;
/*
* reset re-entrancy protector, because tnf_trace_end() will
* not be called
*/
#ifdef VERYVERBOSE
#endif
return (NULL);
}
/*
* tnf_trace_end
* the last (usually only) function in the list of probe functions
*/
void
{
#ifdef VERYVERBOSE
#endif
}
/*
* tnf_trace_commit
* a probe commit function that really commits trace data
*/
void
{
#ifdef VERYVERBOSE
#endif
return;
}
/*
* tnf_trace_rollback
* a probe commit function that unrolls trace data
*/
void
{
#ifdef VERYVERBOSE
#endif
return;
}
/*
* tnf_allocate
* exported interface for allocating trace memory
*/
void *
{
void *retval;
#ifdef _TNF_VERBOSE
#endif
#ifdef _TNF_VERBOSE
#endif
return (retval);
}