/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/* Monitor contention tracking and monitor wait handling. */
/*
* Monitor's under contention are unique per trace and signature.
* Two monitors with the same trace and signature will be treated
* the same as far as accumulated contention time.
*
* The tls table (or thread table) will be used to store the monitor in
* contention or being waited on.
*
* Monitor wait activity is emitted as it happens.
*
* Monitor contention is tabulated and summarized at dump time.
*
*/
#include "hprof.h"
typedef struct MonitorKey {
} MonitorKey;
typedef struct MonitorInfo {
} MonitorInfo;
typedef struct IterateInfo {
int count;
} IterateInfo;
/* Private internal functions. */
static MonitorKey*
{
void * key_ptr;
int key_len;
return (MonitorKey*)key_ptr;
}
static MonitorInfo *
{
HPROF_ASSERT(index!=0);
return info;
}
static MonitorIndex
{
char *sig;
return index;
}
static void
{
}
static void
{
"Monitor 0x%08x: trace=0x%08x, sig=0x%08x, "
"num_hits=%d, contended_time=(%d,%d)\n",
}
static void
{
}
static int
{
return -1;
return 1;
}
}
static void
{
info->contended_time = 0;
}
static TraceIndex
{
return trace_index;
}
/* External functions (called from hprof_init.c) */
void
monitor_init(void)
{
}
void
monitor_list(void)
{
"------------------- Monitor Table ------------------------\n");
"----------------------------------------------------------\n");
}
void
monitor_cleanup(void)
{
}
void
monitor_clear(void)
{
}
/* Contended monitor output */
void
{
int n_entries;
if ( n_entries == 0 ) {
return;
}
int i;
int n_items;
/* First write all trace we might refer to. */
/* Looking for an array of monitor index values of interest */
/* Get a combined total and an array of monitor index numbers */
/* Sort that list */
if ( n_entries > 0 ) {
}
/* Apply the cutoff */
n_items = 0;
for (i = 0; i < n_entries; i++) {
double percent;
(double)iterate.total_contended_time;
break;
}
}
/* Output the items that make sense */
if ( n_items > 0 && total_contended_time > 0 ) {
double accum;
/* Output the info on this monitor enter site */
accum = 0.0;
for (i = 0; i < n_items; i++) {
double percent;
char *sig;
sig);
}
}
}
void
{
}
void
{
HPROF_ASSERT(tls_index!=0);
HPROF_ASSERT(index!=0);
tls_set_monitor(tls_index, 0);
}
void
{
HPROF_ASSERT(tls_index!=0);
}
void
{
HPROF_ASSERT(tls_index!=0);
if ( index ==0 ) {
/* As best as I can tell, on Solaris X86 (not SPARC) I sometimes
* get a "waited" event on a thread that I have never seen before
* at all, so how did I get a WAITED event? Perhaps when I
* did the VM_INIT handling, a thread I've never seen had already
* done the WAIT (which I never saw?), and now I see this thread
* for the first time, and also as it finishes it's WAIT?
* Only happening on faster processors?
*/
tls_set_monitor(tls_index, 0);
return;
}
HPROF_ASSERT(index!=0);
tls_set_monitor(tls_index, 0);
} else {
}
}