This file is indexed.

/usr/share/systemtap/tapset/stopwatch.stp is in systemtap-common 2.9-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// stopwatch tapset
// Copyright (C) 2012 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.

global _stopwatch_starttime, _stopwatch_acc

/*
 * Description of the stopwatch states:
 * if (! name in _stopwatch_acc) {stopwatch doesn't exist}
 * if (_stopwatch_starttime[name] == 0 ) {stopwatch not running}
 * if (_stopwatch_starttime[name] != 0 ) {stopwatch running}
 */


/**
 * sfunction delete_stopwatch - Remove an existing stopwatch
 * @name: the stopwatch name
 *
 * Remove stopwatch @name.
 */
function delete_stopwatch (name:string)
{
	delete _stopwatch_starttime[name];
	delete _stopwatch_acc[name];
}


/**
 * sfunction start_stopwatch - Start a stopwatch 
 * @name: the stopwatch name
 *
 * Start stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function start_stopwatch (name:string)
{
	stime = _stopwatch_starttime[name]
	if (stime == 0)
		_stopwatch_starttime[name] = gettimeofday_ns()
	/* make sure there is an entry in _stopwatch_acc */
	_stopwatch_acc[name] = _stopwatch_acc[name]
}


/**
 * sfunction stop_stopwatch - Stop a stopwatch 
 * @name: the stopwatch name
 *
 * Stop stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function stop_stopwatch (name:string)
{
	stime = _stopwatch_starttime[name]

	if (stime != 0)
		delta =  gettimeofday_ns() - stime
	else
		delta = 0

	_stopwatch_starttime[name] = 0
	_stopwatch_acc[name] = _stopwatch_acc[name] + delta
}


/**
 * sfunction read_stopwatch_ns - Reads the time in nanoseconds for a stopwatch
 * @name: stopwatch name
 *
 * Returns time in nanoseconds for stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function read_stopwatch_ns:long (name:string)
{
	stime = _stopwatch_starttime[name]
	if (stime != 0)
		delta = gettimeofday_ns() - stime
	else
		delta = 0

	_stopwatch_acc[name] = _stopwatch_acc[name]
	return (_stopwatch_acc[name] + delta)
}


/**
 * sfunction read_stopwatch_us - Reads the time in microseconds for a stopwatch
 * @name: stopwatch name
 *
 * Returns time in microseconds for stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function read_stopwatch_us:long (name:string)
{
	return read_stopwatch_ns(name)/1000;
}


/**
 * sfunction read_stopwatch_ms - Reads the time in milliseconds for a stopwatch
 * @name: stopwatch name
 *
 * Returns time in milliseconds for stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function read_stopwatch_ms:long (name:string)
{
	return read_stopwatch_ns(name)/1000000;
}


/**
 * sfunction read_stopwatch_ms - Reads the time in seconds for a stopwatch
 * @name: stopwatch name
 *
 * Returns time in seconds for stopwatch @name.
 * Creates stopwatch @name if it does not currently exist.
 */
function read_stopwatch_s:long (name:string)
{
	return read_stopwatch_ns(name)/1000000000;
}