This file is indexed.

/usr/share/systemtap/tapset/s390/registers.stp is in systemtap-common 2.3-1ubuntu1.

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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/* Dwarfless register access for s390x */

global _reg_offsets, _stp_regs_registered

function _stp_register_regs() {
	/* Same order as pt_regs */
	_reg_offsets["args"] = 0
	_reg_offsets["psw.mask"] = 8
	_reg_offsets["psw.addr"] = 16
	_reg_offsets["r0"] = 24
	_reg_offsets["r1"] = 32
	_reg_offsets["r2"] = 40
	_reg_offsets["r3"] = 48
	_reg_offsets["r4"] = 56
	_reg_offsets["r5"] = 64
	_reg_offsets["r6"] = 72
	_reg_offsets["r7"] = 80
	_reg_offsets["r8"] = 88
	_reg_offsets["r9"] = 96
	_reg_offsets["r10"] = 104
	_reg_offsets["r11"] = 112
	_reg_offsets["r12"] = 120
	_reg_offsets["r13"] = 128
	_reg_offsets["r14"] = 136
	_reg_offsets["r15"] = 144

	_reg_offsets["orig_gpr2"] = 152
	_reg_offsets["ilc"] = 160
	_reg_offsets["trap"] = 162

	/*
	 * If we ever need to support s390 (31-bit arch), we can
	 * get to the register offsets by using just a
	 * reg32_offset = _reg_offsets["reg"]/2
	 * or somesuch
	 */
	_stp_regs_registered = 1
}


/*
 * Though the flag says 31bit, asm-s390/thread_info.h comment
 * says "32bit process"
 */
function probing_32bit_app() %{ /* pure */
	if (CONTEXT->user_mode_p && _stp_is_compat_task())
		STAP_RETVALUE = 1;
	else
		STAP_RETVALUE = 0;
%}

function _stp_probing_kernel: long () {
	return !user_mode();
}

function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
	long value;
	struct pt_regs *regs;
	regs = (CONTEXT->user_mode_p ? CONTEXT->uregs : CONTEXT->kregs);
	if (!regs) {
		CONTEXT->last_error = "No registers available in this context";
		return;
	}
	if (STAP_ARG_offset < 0 || STAP_ARG_offset > sizeof(struct pt_regs) - sizeof(unsigned short)) {
		snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
				"Bad register offset: %lld",
				(long long)STAP_ARG_offset);
		CONTEXT->last_error = CONTEXT->error_buffer;
		return;
	}

	if (STAP_ARG_offset < sizeof(struct pt_regs) - 2 * sizeof(unsigned short))
		memcpy(&value, ((char *)regs) + STAP_ARG_offset,
				sizeof(value));
	else {
		/* ilc or trap */
		unsigned short us_value;
		memcpy(&us_value, ((char *)regs) + STAP_ARG_offset,
				sizeof(us_value));
		value = us_value;	// not sign-extended
	}
	STAP_RETVALUE = value;
%}

function _stp_sign_extend32:long (value:long) {
	if (value & 0x80000000)
		value |= (0xffffffff << 32)
	return value
}

function _stp_register:long (name:string, sign_extend:long) {
	if (!registers_valid()) {
		error("cannot access CPU registers in this context")
		return 0
	}
	if (!_stp_regs_registered)
		_stp_register_regs()
	offset = _reg_offsets[name]
	if (offset == 0 && !(name in _reg_offsets)) {
		error("Unknown register: " . name)
		return 0
	}
	value = _stp_get_register_by_offset(offset)
	if (probing_32bit_app()) {
		if (sign_extend)
			value = _stp_sign_extend32(value)
		else
			value &= 0xffffffff
	}
	return value
}

/* Return the named register value as a signed value. */
function register:long (name:string) {
	return _stp_register(name, 1)
}

/*
 * Return the named register value as an unsigned value.  Specifically,
 * don't sign-extend the register value when promoting it to 64 bits.
 */
function u_register:long (name:string) {
	return _stp_register(name, 0)
}

/*
 * Return the value of function arg #argnum (1=first arg).
 * If truncate=1, mask off the top 32 bits.
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
 * 32-bit app), sign-extend the 32-bit value.
 */
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
%{ /* pure */
	unsigned long val = 0;
	struct pt_regs *regs;

	STAP_RETVALUE = 0;
	if (STAP_ARG_argnum < 1 || STAP_ARG_argnum > 6) {
		snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
			 "Cannot access arg %d", (int)STAP_ARG_argnum);
		CONTEXT->last_error = CONTEXT->error_buffer;
		return;
	}
	if (CONTEXT->user_mode_p) {
		CONTEXT->last_error = ("Cannot access function args in"
				       " user context");
		return;
	}
	regs = CONTEXT->kregs;
	if (!regs) {
		CONTEXT->last_error = ("Cannot access function args"
				       " (no registers available)");
		return;
	}

	syscall_get_arguments(current, regs, (((int)STAP_ARG_argnum) - 1), 1,
			      &val);

	if (STAP_ARG_truncate || _stp_is_compat_task()) {
		if (STAP_ARG_sign_extend)
			STAP_RETVALUE = (int64_t) (int32_t) val;
		else
			/* High bits may be garbage. */
			STAP_RETVALUE = (int64_t) (val & 0xffffffff);
	}
	else
		STAP_RETVALUE = (int64_t) val;
	return;
%}

/* Return the value of function arg #argnum (1=first arg) as a signed int. */
function int_arg:long (argnum:long) {
	return _stp_arg(argnum, 1, 1)
}

/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
function uint_arg:long (argnum:long) {
	return _stp_arg(argnum, 0, 1)
}

function long_arg:long (argnum:long) {
	return _stp_arg(argnum, 1, 0)
}

function ulong_arg:long (argnum:long) {
	return _stp_arg(argnum, 0, 0)
}

function longlong_arg:long (argnum:long) {
	if (probing_32bit_app()) {
		/* TODO verify if this is correct for 31bit apps */
		highbits = _stp_arg(argnum, 0, 1)
		lowbits = _stp_arg(argnum+1, 0, 1)
		return ((highbits << 32) | lowbits)
	} else
		return _stp_arg(argnum, 0, 0)
}

function ulonglong_arg:long (argnum:long) {
	return longlong_arg(argnum)
}

function pointer_arg:long (argnum:long) {
	return _stp_arg(argnum, 0, 0)
}

function s32_arg:long (argnum:long) {
	return int_arg(argnum)
}

function u32_arg:long (argnum:long) {
	return uint_arg(argnum)
}

function s64_arg:long (argnum:long) {
	return longlong_arg(argnum)
}

function u64_arg:long (argnum:long) {
	return ulonglong_arg(argnum)
}

function asmlinkage() %{ /* pure */ %}

function fastcall() %{ /* pure */ %}

function regparm(n:long) %{
	snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
		"regparm is invalid on s390.");
	CONTEXT->last_error = CONTEXT->error_buffer;
%}