From c88409ef3c14c4fc666de7d57a806a142df1d3a8 Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Fri, 9 Oct 2015 13:09:58 +0200 Subject: [PATCH] Align nd_syscall.mmap* and syscall.mmap* convenience vars lists. * NEWS: Mention deprecations. * tapset/linux/aux_syscalls.stp: Deprecate: get_mmap_args(). * tapset/linux/s390/aux_syscalls.stp: Deprecate get_32mmap_args(). * tapset/linux/s390/nd_syscalls.stp: Provide missing convenience vars. * tapset/linux/x86_64/nd_syscalls.stp: Provide missing convenience vars. * tapset/linux/x86_64/syscalls.stp: Use convenience vars in argstr. --- NEWS | 2 ++ tapset/linux/aux_syscalls.stp | 2 ++ tapset/linux/s390/aux_syscalls.stp | 2 ++ tapset/linux/s390/nd_syscalls.stp | 42 +++++++++++++++++++++++------ tapset/linux/x86_64/nd_syscalls.stp | 29 ++++++++++++++------ tapset/linux/x86_64/syscalls.stp | 18 +++++++------ 6 files changed, 71 insertions(+), 24 deletions(-) diff --git a/NEWS b/NEWS index e955b6047..8fb33a9e7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ * What's new in version 3.0, 2015-10-08 +- Functions get_mmap_args() and get_32mmap_args() got deprecated. + * What's new in version 2.9, 2015-10-08 - SystemTap now uses symbols from /proc/kallsyms when kernel debuginfo is not diff --git a/tapset/linux/aux_syscalls.stp b/tapset/linux/aux_syscalls.stp index 53050d3a7..fc2b13452 100644 --- a/tapset/linux/aux_syscalls.stp +++ b/tapset/linux/aux_syscalls.stp @@ -3278,6 +3278,7 @@ function _mmap_flags:string(flags:long) _stp_lookup_or_str(_stp_mmap_list, STAP_ARG_flags, STAP_RETVALUE, MAXSTRINGLEN); %} +%( systemtap_v <= "3.0" %? # old mmap functions passed in a struct like this. # function get_mmap_args:string (args:long) @@ -3316,6 +3317,7 @@ function get_mmap_args:string (args:long) snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx", (unsigned long)STAP_ARG_args); %} +%) function _sighandler_str:string(uaddr:long) diff --git a/tapset/linux/s390/aux_syscalls.stp b/tapset/linux/s390/aux_syscalls.stp index ef612451e..84cd85ef8 100644 --- a/tapset/linux/s390/aux_syscalls.stp +++ b/tapset/linux/s390/aux_syscalls.stp @@ -142,6 +142,7 @@ function _ptrace_return_arch_prctl_addr:long(request:long, addr:long, data:long) return 0 } +%( systemtap_v <= "3.0" %? function get_32mmap_args:string(args:long) %{ /* pure */ struct mmap_arg_struct_emu31 { @@ -171,3 +172,4 @@ function get_32mmap_args:string(args:long) strlcpy (STAP_RETVALUE, "UNKNOWN", MAXSTRINGLEN); } %} +%) diff --git a/tapset/linux/s390/nd_syscalls.stp b/tapset/linux/s390/nd_syscalls.stp index 3bee562c8..625ed13ff 100644 --- a/tapset/linux/s390/nd_syscalls.stp +++ b/tapset/linux/s390/nd_syscalls.stp @@ -72,19 +72,32 @@ probe nd_syscall.ipc.return = kprobe.function("sys32_ipc").return ? probe nd_syscall.mmap = __nd_syscall.mmap ?, __nd_syscall.mmap32 ? { name = "mmap" + argstr = sprintf("%p, %u, %s, %s, %d, %d", start, len, + _mprotect_prot_str(prot), _mmap_flags(flags), + fd, offset) } probe __nd_syscall.mmap = kprobe.function("old_mmap") ?, kprobe.function("SyS_s390_old_mmap") ? { - // argstr = get_mmap_args($arg) asmlinkage() - argstr = get_mmap_args(pointer_arg(1)) + __args = &@cast(pointer_arg(1), "ulong", "kernel") + start = user_ulong(&(__args)[0]) + len = user_ulong(&(__args)[1]) + prot = user_ulong(&(__args)[2]) + flags = user_ulong(&(__args)[3]) + fd = user_long(&(__args)[4]) + offset = user_ulong(&(__args)[5]) } probe __nd_syscall.mmap32 = kprobe.function("old32_mmap") { - // argstr = get_32mmap_args($arg) asmlinkage() - argstr = get_32mmap_args(pointer_arg(1)) + __args = &@cast(pointer_arg(1), "unsigned int", "kernel") + start = user_uint32(&(__args)[0]) + len = user_uint32(&(__args)[1]) + prot = user_uint32(&(__args)[2]) + flags = user_uint32(&(__args)[3]) + fd = user_int(&(__args)[4]) + offset = user_uint32(&(__args)[5]) } probe nd_syscall.mmap.return = kprobe.function("old_mmap").return ?, kprobe.function("old32_mmap").return ?, @@ -102,18 +115,31 @@ probe nd_syscall.mmap.return = kprobe.function("old_mmap").return ?, probe nd_syscall.mmap2 = __nd_syscall.mmap2 ?, __nd_syscall.mmap2_32 ? { name = "mmap2" + argstr = sprintf("%p, %u, %s, %s, %d, %d", start, length, + _mprotect_prot_str(prot), _mmap_flags(flags), + fd, pgoffset) } probe __nd_syscall.mmap2 = kprobe.function("sys_mmap2") { - // argstr = get_mmap_args($arg) asmlinkage() - argstr = get_mmap_args(pointer_arg(1)) + __args = &@cast(pointer_arg(1), "ulong", "kernel") + start = user_ulong(&(__args)[0]) + length = user_ulong(&(__args)[1]) + prot = user_ulong(&(__args)[2]) + flags = user_ulong(&(__args)[3]) + fd = user_long(&(__args)[4]) + pgoffset = user_ulong(&(__args)[5]) } probe __nd_syscall.mmap2_32 = kprobe.function("sys32_mmap2") { - // argstr = get_32mmap_args($arg) asmlinkage() - argstr = get_32mmap_args(pointer_arg(1)) + __args = &@cast(pointer_arg(1), "unsigned int", "kernel") + start = user_uint32(&(__args)[0]) + length = user_uint32(&(__args)[1]) + prot = user_uint32(&(__args)[2]) + flags = user_uint32(&(__args)[3]) + fd = user_int(&(__args)[4]) + pgoffset = user_uint32(&(__args)[5]) } probe nd_syscall.mmap2.return = kprobe.function("sys_mmap2").return ?, diff --git a/tapset/linux/x86_64/nd_syscalls.stp b/tapset/linux/x86_64/nd_syscalls.stp index 2ec6647dc..38ebceeaa 100644 --- a/tapset/linux/x86_64/nd_syscalls.stp +++ b/tapset/linux/x86_64/nd_syscalls.stp @@ -168,9 +168,17 @@ probe nd_syscall.mmap.return = kprobe.function("sys_mmap").return ? probe nd_syscall.mmap32 = kprobe.function("sys32_mmap") { name = "mmap" - // argstr = get_mmap_args($arg) asmlinkage() - argstr = get_mmap_args(pointer_arg(1)) + __args = &@cast(pointer_arg(1), "unsigned int", "kernel") + start = user_uint32(&(__args)[0]) + len = user_uint32(&(__args)[1]) + prot = user_uint32(&(__args)[2]) + flags = user_uint32(&(__args)[3]) + fd = user_int(&(__args)[4]) + offset = user_uint32(&(__args)[5]) + argstr = sprintf("%p, %u, %s, %s, %d, %d", start, len, + _mprotect_prot_str(prot), _mmap_flags(flags), + fd, offset) } probe nd_syscall.mmap32.return = kprobe.function("sys32_mmap").return { @@ -186,22 +194,27 @@ probe nd_syscall.mmap2 = __nd_syscall.mmap2 ?, __nd_syscall.mmap_pgoff ? { @__syscall_compat_gate(%{ __NR_mmap2 %}, %{ __NR_ia32_mmap2 %}) name = "mmap2" + start = ulong_arg(1) + length = ulong_arg(2) + prot = ulong_arg(3) + prot_str = _mprotect_prot_str(prot) + flags = ulong_arg(4) + flags_str = _mmap_flags(flags) + fd = int_arg(5) + argstr = sprintf("%p, %u, %s, %s, %d, %d", start, length, + prot_str, flags_str, fd, pgoffset) } probe __nd_syscall.mmap2 = kprobe.function("sys32_mmap2") { asmlinkage() - argstr = sprintf("%p, %u, %s, %s, %d, %d", ulong_arg(1), ulong_arg(2), - _mprotect_prot_str(ulong_arg(3)), _mmap_flags(ulong_arg(4)), - int_arg(5), ulong_arg(6)) + pgoffset = ulong_arg(6) } probe __nd_syscall.mmap_pgoff = kprobe.function("sys_mmap_pgoff") { asmlinkage() # $pgoff is the number of pages. Convert this back into a # number of bytes. - argstr = sprintf("%p, %u, %s, %s, %d, %d", ulong_arg(1), ulong_arg(2), - _mprotect_prot_str(ulong_arg(3)), _mmap_flags(ulong_arg(4)), - int_arg(5), ulong_arg(6) * %{ /* pure */ PAGE_SIZE %}) + pgoffset = ulong_arg(6) * %{ /* pure */ PAGE_SIZE %} } probe nd_syscall.mmap2.return = kprobe.function("sys32_mmap2").return ?, kprobe.function("sys_mmap_pgoff").return ? diff --git a/tapset/linux/x86_64/syscalls.stp b/tapset/linux/x86_64/syscalls.stp index 045d48646..e36778a1a 100644 --- a/tapset/linux/x86_64/syscalls.stp +++ b/tapset/linux/x86_64/syscalls.stp @@ -201,16 +201,18 @@ probe syscall.mmap2 = __syscall.mmap2 ?, __syscall.mmap_pgoff ? { @__syscall_compat_gate(%{ __NR_mmap2 %}, %{ __NR_ia32_mmap2 %}) name = "mmap2" - start = $addr - length = $len - prot = $prot - flags = $flags + start = $addr + length = $len + prot = $prot + prot_str = _mprotect_prot_str(prot) + flags = $flags + flags_str = _mmap_flags(flags) + fd = __int32($fd) # Although the kernel gets an unsigned long fd, on the # user-side it is a signed int. Fix this. - fd = __int32($fd) - argstr = sprintf("%p, %u, %s, %s, %d, %d", $addr, $len, - _mprotect_prot_str($prot), _mmap_flags($flags), - __int32($fd), pgoffset) + fd = __int32($fd) + argstr = sprintf("%p, %u, %s, %s, %d, %d", start, length, + prot_str, flags_str, fd, pgoffset) } probe __syscall.mmap2 = kernel.function("sys32_mmap2") { -- 2.43.5