View | Details | Raw Unified | Return to bug 18597 | Differences between
and this patch

Collapse All | Expand All

(-)a/tapset/linux/nd_syscalls.stp (-8 / +2 lines)
Lines 3154-3177 probe __nd_syscall.io_setup.return = kprobe.function("sys_io_setup").return ? Link Here
3154
# long compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
3154
# long compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
3155
#
3155
#
3156
probe nd_syscall.io_submit = __nd_syscall.io_submit,
3156
probe nd_syscall.io_submit = __nd_syscall.io_submit,
3157
	__nd_syscall.compat_io_submit ?
3157
	kprobe.function("compat_sys_io_submit") ?
3158
{
3158
{
3159
	name = "io_submit"
3159
	name = "io_submit"
3160
	asmlinkage()
3160
	asmlinkage()
3161
	ctx_id = ulong_arg(1)
3161
	ctx_id = ulong_arg(1)
3162
	nr = long_arg(2)
3162
	iocbpp_uaddr = pointer_arg(3)
3163
	iocbpp_uaddr = pointer_arg(3)
3163
	argstr = sprintf("%u, %d, %p", ctx_id, nr, iocbpp_uaddr)
3164
	argstr = sprintf("%u, %d, %p", ctx_id, nr, iocbpp_uaddr)
3164
}
3165
}
3165
probe __nd_syscall.io_submit = kprobe.function("sys_io_submit") ?
3166
probe __nd_syscall.io_submit = kprobe.function("sys_io_submit") ?
3166
{
3167
{
3167
	@__syscall_gate(%{ __NR_io_submit %})
3168
	@__syscall_gate(%{ __NR_io_submit %})
3168
	asmlinkage()
3169
	nr = long_arg(2)
3170
}
3171
probe __nd_syscall.compat_io_submit = kprobe.function("compat_sys_io_submit") ?
3172
{
3173
	asmlinkage()
3174
	nr = int_arg(2)
3175
}
3169
}
3176
probe nd_syscall.io_submit.return = __nd_syscall.io_submit.return,
3170
probe nd_syscall.io_submit.return = __nd_syscall.io_submit.return,
3177
	kprobe.function("compat_sys_io_submit").return ?
3171
	kprobe.function("compat_sys_io_submit").return ?
(-)a/tapset/linux/nd_syscalls2.stp (-19 / +6 lines)
Lines 584-590 probe nd_syscall.prctl.return = kprobe.function("sys_prctl").return ? Link Here
584
#		 char __user *buf,
584
#		 char __user *buf,
585
#		 size_t count,
585
#		 size_t count,
586
#		 loff_t pos)
586
#		 loff_t pos)
587
# asmlinkage long sys32_pread64(unsigned int fd, char __user *ubuf,
588
#                                size_t count, u32 poshi, u32 poslo)
587
#
589
#
590
# Note we need to probe s390's sys32_pread64 since it isn't a simple
591
# wrapper.
588
probe nd_syscall.pread =
592
probe nd_syscall.pread =
589
%( arch == "s390" %?
593
%( arch == "s390" %?
590
	__nd_syscall.pread, __nd_syscall.compat_pread ?
594
	__nd_syscall.pread, __nd_syscall.compat_pread ?
Lines 4551-4575 probe nd_syscall.sync_file_range = kprobe.function("sys_sync_file_range") ? Link Here
4551
	name = "sync_file_range"
4555
	name = "sync_file_range"
4552
	fd = int_arg(1)
4556
	fd = int_arg(1)
4553
%( CONFIG_64BIT == "y" %?
4557
%( CONFIG_64BIT == "y" %?
4554
%( arch == "s390" %?
4558
	offset = longlong_arg(2)
4555
	# On s390x RHEL7 (3.10.0-229.el7.s390x), when longlong_arg()
4559
	nbytes = longlong_arg(3)
4556
	# gets called On a 32-bit executable it tries to grab the
4557
	# 64-bit value out of 2 different registers. However, at this
4558
	# point the value has been put into a single
4559
	# register. Normally we'd fix this by probing the the compat
4560
	# function. But, on this kernel the compat function is in
4561
	# assembly language, which we can't probe. So, we'll grab the
4562
	# registers directly.
4563
	if (%{ /* pure */ _stp_is_compat_task() %}) {
4564
		offset = u_register("r3")
4565
		nbytes = u_register("r4")
4566
	}
4567
	else
4568
%)
4569
	{
4570
		offset = longlong_arg(2)
4571
		nbytes = longlong_arg(3)
4572
	}
4573
	flags = uint_arg(4)
4560
	flags = uint_arg(4)
4574
%:
4561
%:
4575
%( arch == "arm" %?
4562
%( arch == "arm" %?
(-)a/tapset/powerpc/registers.stp (-10 / +17 lines)
Lines 124-131 function u_register:long (name:string) { Link Here
124
 * If truncate=1, mask off the top 32 bits.
124
 * If truncate=1, mask off the top 32 bits.
125
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
125
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
126
 * 32-bit app), sign-extend the 32-bit value.
126
 * 32-bit app), sign-extend the 32-bit value.
127
 * If force64=1, return a 64-bit value even if we're in a 32-bit app.
127
 */
128
 */
128
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) {
129
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
130
{
131
	return _stp_arg2(argnum, sign_extend, truncate, 0)
132
}
133
function _stp_arg2:long (argnum:long, sign_extend:long, truncate:long,
134
			 force64:long)
135
{
129
	val = 0
136
	val = 0
130
	if (argnum < 1 || argnum > 8) {
137
	if (argnum < 1 || argnum > 8) {
131
		error(sprintf("Cannot access arg(%d)", argnum))
138
		error(sprintf("Cannot access arg(%d)", argnum))
Lines 149-155 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) { Link Here
149
	else if (argnum == 8)
156
	else if (argnum == 8)
150
		val = u_register("r10")
157
		val = u_register("r10")
151
158
152
	if (truncate) {
159
	if ((truncate || @__compat_task) && !force64) {
153
		if (sign_extend)
160
		if (sign_extend)
154
			val = _stp_sign_extend32(val)
161
			val = _stp_sign_extend32(val)
155
		else
162
		else
Lines 161-189 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) { Link Here
161
168
162
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
169
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
163
function int_arg:long (argnum:long) {
170
function int_arg:long (argnum:long) {
164
	return _stp_arg(argnum, 1, 1)
171
	return _stp_arg2(argnum, 1, 1, 0)
165
}
172
}
166
173
167
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
174
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
168
function uint_arg:long (argnum:long) {
175
function uint_arg:long (argnum:long) {
169
	return _stp_arg(argnum, 0, 1)
176
	return _stp_arg2(argnum, 0, 1, 0)
170
}
177
}
171
178
172
function long_arg:long (argnum:long) {
179
function long_arg:long (argnum:long) {
173
	return _stp_arg(argnum, 1, 0)
180
	return _stp_arg2(argnum, 1, 0, 0)
174
}
181
}
175
182
176
function ulong_arg:long (argnum:long) {
183
function ulong_arg:long (argnum:long) {
177
	return _stp_arg(argnum, 0, 0)
184
	return _stp_arg2(argnum, 0, 0, 0)
178
}
185
}
179
186
180
function longlong_arg:long (argnum:long) {
187
function longlong_arg:long (argnum:long) {
181
	if (probing_32bit_app()) {
188
	if (probing_32bit_app()) {
182
		lowbits = _stp_arg(argnum, 0, 1)
189
		lowbits = _stp_arg2(argnum, 0, 1, 0)
183
		highbits = _stp_arg(argnum+1, 0, 1)
190
		highbits = _stp_arg2(argnum+1, 0, 1, 0)
184
		return ((highbits << 32) | lowbits)
191
		return ((highbits << 32) | lowbits)
185
	} else
192
	} else
186
		return _stp_arg(argnum, 0, 0)
193
		return _stp_arg2(argnum, 0, 0, 1)
187
}
194
}
188
195
189
function ulonglong_arg:long (argnum:long) {
196
function ulonglong_arg:long (argnum:long) {
Lines 191-197 function ulonglong_arg:long (argnum:long) { Link Here
191
}
198
}
192
199
193
function pointer_arg:long (argnum:long) {
200
function pointer_arg:long (argnum:long) {
194
	return _stp_arg(argnum, 0, 0)
201
	return _stp_arg2(argnum, 0, 0, 0)
195
}
202
}
196
203
197
function s32_arg:long (argnum:long) {
204
function s32_arg:long (argnum:long) {
(-)a/tapset/s390/registers.stp (-9 / +15 lines)
Lines 198-206 function u_register:long (name:string) { Link Here
198
 * If truncate=1, mask off the top 32 bits.
198
 * If truncate=1, mask off the top 32 bits.
199
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
199
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
200
 * 32-bit app), sign-extend the 32-bit value.
200
 * 32-bit app), sign-extend the 32-bit value.
201
 * If force64=1, return a 64-bit value even if we're in a 32-bit app.
201
 */
202
 */
202
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
203
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
203
{
204
{
205
	return _stp_arg2(argnum, sign_extend, truncate, 0)
206
}
207
function _stp_arg2:long (argnum:long, sign_extend:long, truncate:long,
208
			 force64:long)
209
{
204
	val = 0
210
	val = 0
205
	if (argnum < 1 || argnum > 8) {
211
	if (argnum < 1 || argnum > 8) {
206
		error(sprintf("Cannot acces arg(%d)", argnum))
212
		error(sprintf("Cannot acces arg(%d)", argnum))
Lines 237-243 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) Link Here
237
	else if (argnum >= 6)
243
	else if (argnum >= 6)
238
		val = _stp_get_kernel_stack_param(argnum - 6)
244
		val = _stp_get_kernel_stack_param(argnum - 6)
239
245
240
	if (truncate || %{ /* pure */ _stp_is_compat_task() %}) {
246
	if ((truncate || @__compat_task) && !force64) {
241
		/* High bits may be garbage. */
247
		/* High bits may be garbage. */
242
		val = (val & 0xffffffff)
248
		val = (val & 0xffffffff)
243
		if (sign_extend)
249
		if (sign_extend)
Lines 248-277 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) Link Here
248
254
249
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
255
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
250
function int_arg:long (argnum:long) {
256
function int_arg:long (argnum:long) {
251
	return _stp_arg(argnum, 1, 1)
257
	return _stp_arg2(argnum, 1, 1, 0)
252
}
258
}
253
259
254
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
260
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
255
function uint_arg:long (argnum:long) {
261
function uint_arg:long (argnum:long) {
256
	return _stp_arg(argnum, 0, 1)
262
	return _stp_arg2(argnum, 0, 1, 0)
257
}
263
}
258
264
259
function long_arg:long (argnum:long) {
265
function long_arg:long (argnum:long) {
260
	return _stp_arg(argnum, 1, 0)
266
	return _stp_arg2(argnum, 1, 0, 0)
261
}
267
}
262
268
263
function ulong_arg:long (argnum:long) {
269
function ulong_arg:long (argnum:long) {
264
	return _stp_arg(argnum, 0, 0)
270
	return _stp_arg2(argnum, 0, 0, 0)
265
}
271
}
266
272
267
function longlong_arg:long (argnum:long) {
273
function longlong_arg:long (argnum:long) {
268
	if (probing_32bit_app()) {
274
	if (probing_32bit_app()) {
269
		/* TODO verify if this is correct for 31bit apps */
275
		/* TODO verify if this is correct for 31bit apps */
270
		highbits = _stp_arg(argnum, 0, 1)
276
		highbits = _stp_arg2(argnum, 0, 1, 0)
271
		lowbits = _stp_arg(argnum+1, 0, 1)
277
		lowbits = _stp_arg2(argnum+1, 0, 1, 0)
272
		return ((highbits << 32) | lowbits)
278
		return ((highbits << 32) | lowbits)
273
	} else
279
	} else
274
		return _stp_arg(argnum, 0, 0)
280
		return _stp_arg2(argnum, 0, 0, 1)
275
}
281
}
276
282
277
function ulonglong_arg:long (argnum:long) {
283
function ulonglong_arg:long (argnum:long) {
Lines 279-285 function ulonglong_arg:long (argnum:long) { Link Here
279
}
285
}
280
286
281
function pointer_arg:long (argnum:long) {
287
function pointer_arg:long (argnum:long) {
282
	return _stp_arg(argnum, 0, 0)
288
	return _stp_arg2(argnum, 0, 0, 0)
283
}
289
}
284
290
285
function s32_arg:long (argnum:long) {
291
function s32_arg:long (argnum:long) {
(-)a/tapset/x86_64/registers.stp (-11 / +20 lines)
Lines 112-119 function u_register:long (name:string) { Link Here
112
 * If truncate=1, mask off the top 32 bits.
112
 * If truncate=1, mask off the top 32 bits.
113
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
113
 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
114
 * 32-bit app), sign-extend the 32-bit value.
114
 * 32-bit app), sign-extend the 32-bit value.
115
 * If force64=1, return a 64-bit value even if we're in a 32-bit app.
115
 */
116
 */
116
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) %{ /* pure */
117
function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
118
{
119
	return _stp_arg2(argnum, sign_extend, truncate, 0)
120
}
121
function _stp_arg2:long (argnum:long, sign_extend:long, truncate:long,
122
			 force64:long)
123
%{ /* pure */
124
117
	long val;
125
	long val;
118
	struct pt_regs *regs;
126
	struct pt_regs *regs;
119
	int result, n, nr_regargs;
127
	int result, n, nr_regargs;
Lines 138-144 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) %{ /* pure Link Here
138
			nr_regargs = 6;
146
			nr_regargs = 6;
139
	} else
147
	} else
140
		nr_regargs = (CONTEXT->regparm & _STP_REGPARM_MASK);
148
		nr_regargs = (CONTEXT->regparm & _STP_REGPARM_MASK);
141
	if (CONTEXT->user_mode_p && _stp_is_compat_task()) {
149
	if (!STAP_ARG_force64 && CONTEXT->user_mode_p && _stp_is_compat_task()) {
142
		argsz = sizeof(int);
150
		argsz = sizeof(int);
143
		result = _stp_get_arg32_by_number(n, nr_regargs, regs, &val);
151
		result = _stp_get_arg32_by_number(n, nr_regargs, regs, &val);
144
	} else
152
	} else
Lines 167-173 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) %{ /* pure Link Here
167
	default:
175
	default:
168
		goto bad_argnum;
176
		goto bad_argnum;
169
	}
177
	}
170
	if (STAP_ARG_truncate || argsz == sizeof(int)) {
178
	if ((STAP_ARG_truncate || _stp_is_compat_task())
179
	    && !STAP_ARG_force64) {
171
		if (STAP_ARG_sign_extend)
180
		if (STAP_ARG_sign_extend)
172
			STAP_RETVALUE = (int64_t) __stp_sign_extend32(val);
181
			STAP_RETVALUE = (int64_t) __stp_sign_extend32(val);
173
		else
182
		else
Lines 198-226 function probing_32bit_app:long() %{ /* pure */ Link Here
198
207
199
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
208
/* Return the value of function arg #argnum (1=first arg) as a signed int. */
200
function int_arg:long (argnum:long) {
209
function int_arg:long (argnum:long) {
201
	return _stp_arg(argnum, 1, 1)
210
	return _stp_arg2(argnum, 1, 1, 0)
202
}
211
}
203
212
204
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
213
/* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
205
function uint_arg:long (argnum:long) {
214
function uint_arg:long (argnum:long) {
206
	return _stp_arg(argnum, 0, 1)
215
	return _stp_arg2(argnum, 0, 1, 0)
207
}
216
}
208
217
209
function long_arg:long (argnum:long) {
218
function long_arg:long (argnum:long) {
210
	return _stp_arg(argnum, 1, 0)
219
	return _stp_arg2(argnum, 1, 0, 0)
211
}
220
}
212
221
213
function ulong_arg:long (argnum:long) {
222
function ulong_arg:long (argnum:long) {
214
	return _stp_arg(argnum, 0, 0)
223
	return _stp_arg2(argnum, 0, 0, 0)
215
}
224
}
216
225
217
function longlong_arg:long (argnum:long) {
226
function longlong_arg:long (argnum:long) {
218
	if (probing_32bit_app()) {
227
	if (probing_32bit_app()) {
219
		lowbits = _stp_arg(argnum, 0, 1)
228
		lowbits = _stp_arg2(argnum, 0, 1, 0)
220
		highbits = _stp_arg(argnum+1, 0, 1)
229
		highbits = _stp_arg2(argnum+1, 0, 1, 0)
221
		return ((highbits << 32) | lowbits)
230
		return ((highbits << 32) | lowbits)
222
	} else
231
	} else
223
		return _stp_arg(argnum, 0, 0)
232
		return _stp_arg2(argnum, 0, 0, 1)
224
}
233
}
225
234
226
function ulonglong_arg:long (argnum:long) {
235
function ulonglong_arg:long (argnum:long) {
Lines 228-234 function ulonglong_arg:long (argnum:long) { Link Here
228
}
237
}
229
238
230
function pointer_arg:long (argnum:long) {
239
function pointer_arg:long (argnum:long) {
231
	return _stp_arg(argnum, 0, 0)
240
	return _stp_arg2(argnum, 0, 0, 0)
232
}
241
}
233
242
234
function s32_arg:long (argnum:long) {
243
function s32_arg:long (argnum:long) {
(-)a/testsuite/systemtap.syscall/pread.c (+10 lines)
Lines 1-11 Link Here
1
/* COVERAGE: pread pread64 */
1
/* COVERAGE: pread pread64 */
2
#define _BSD_SOURCE
2
#define _BSD_SOURCE
3
#define _DEFAULT_SOURCE
3
#define _DEFAULT_SOURCE
4
#define _LARGEFILE64_SOURCE
5
#define _ISOC99_SOURCE		   /* Needed for LLONG_MAX on RHEL5 */
6
#define _FILE_OFFSET_BITS 64
4
#include <sys/types.h>
7
#include <sys/types.h>
5
#include <sys/stat.h>
8
#include <sys/stat.h>
6
#include <fcntl.h>
9
#include <fcntl.h>
7
#include <stdlib.h>
10
#include <stdlib.h>
8
#include <unistd.h>
11
#include <unistd.h>
12
#include <limits.h>
9
#include <linux/unistd.h>
13
#include <linux/unistd.h>
10
#include <sys/uio.h>
14
#include <sys/uio.h>
11
#include <sys/syscall.h>
15
#include <sys/syscall.h>
Lines 55-60 int main() Link Here
55
  pread(fd, buf, 11, -1);
59
  pread(fd, buf, 11, -1);
56
  //staptest// pread (NNNN, XXXX, 11, -1) = NNNN
60
  //staptest// pread (NNNN, XXXX, 11, -1) = NNNN
57
61
62
  pread(fd, buf, 11, 0x12345678deadbeefLL);
63
  //staptest// pread (NNNN, XXXX, 11, 1311768468603649775) = NNNN
64
65
  pread(fd, buf, 11, LLONG_MAX);
66
  //staptest// pread (NNNN, XXXX, 11, 9223372036854775807) = NNNN
67
58
  close (fd);
68
  close (fd);
59
  //staptest// close (NNNN) = 0
69
  //staptest// close (NNNN) = 0
60
70
(-)a/testsuite/systemtap.syscall/pwrite.c (+10 lines)
Lines 1-11 Link Here
1
/* COVERAGE: pwrite pwrite64 */
1
/* COVERAGE: pwrite pwrite64 */
2
#define _BSD_SOURCE
2
#define _BSD_SOURCE
3
#define _DEFAULT_SOURCE
3
#define _DEFAULT_SOURCE
4
#define _LARGEFILE64_SOURCE
5
#define _ISOC99_SOURCE		   /* Needed for LLONG_MAX on RHEL5 */
6
#define _FILE_OFFSET_BITS 64
4
#include <sys/types.h>
7
#include <sys/types.h>
5
#include <sys/stat.h>
8
#include <sys/stat.h>
6
#include <fcntl.h>
9
#include <fcntl.h>
7
#include <stdlib.h>
10
#include <stdlib.h>
8
#include <unistd.h>
11
#include <unistd.h>
12
#include <limits.h>
9
#include <linux/unistd.h>
13
#include <linux/unistd.h>
10
#include <sys/uio.h>
14
#include <sys/uio.h>
11
#include <sys/syscall.h>
15
#include <sys/syscall.h>
Lines 46-51 int main() Link Here
46
  pwrite(fd, "Hello Again", 11, -1);
50
  pwrite(fd, "Hello Again", 11, -1);
47
  //staptest// pwrite (NNNN, "Hello Again", 11, -1) = NNNN
51
  //staptest// pwrite (NNNN, "Hello Again", 11, -1) = NNNN
48
52
53
  pwrite(-1, "Hello Again", 11, 0x12345678deadbeefLL);
54
  //staptest// pwrite (-1, "Hello Again", 11, 1311768468603649775) = NNNN
55
56
  pwrite(-1, "Hello Again", 11, LLONG_MAX);
57
  //staptest// pwrite (-1, "Hello Again", 11, 9223372036854775807) = NNNN
58
49
  close (fd);
59
  close (fd);
50
  //staptest// close (NNNN) = 0
60
  //staptest// close (NNNN) = 0
51
61

Return to bug 18597