This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[patch] LINUX_REBOOT_MAGIC1 printed as UNKNOWN VALUE in argstr
Hi, everyone
I used the stap to strace the syscall reboot as following. The argument
LINUX_REBOOT_MAGIC1 is printed as "UNKNOWN VALUE":
# cat reboot.c
#include <sys/syscall.h>
#include <unistd.h>
#include <linux/reboot.h>
int main(int argc, char *argv[])
{
syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 0,
LINUX_REBOOT_CMD_RESTART, NULL);
return 0;
}
# cat reboot.stp
probe syscall.reboot {
print(argstr."\n")
}
# stap reboot.stp -c ./a.out
UNKNOWN VALUE: -18751827, UNKNOWN VALUE: 0, LINUX_REBOOT_CMD_RESTART, 0x0000000000000000
Argument of magic in argstr is displayed as "UNKNOWN VALUE" because:
Stap get value of magic from kernel, and it is negative value. When compare
64bit negative value with 32bit HEX value(treated as positive) in function
_reboot_magic_str, result is not "equal".
As a solution, we can compare it with decimal negative value to get correct
result with following patch.
Within _reboot_flag_str function in tapset, it is using same type of
comparison for flag argument, but because flag's type defined in kernel
is unsigned, no problem in this function.
The same problem may exists somewhere else if HEX value is compared with
negative value for argument.
For this problem, I will commit following patch:
Signed-off-by: "Zhaolei" zhaolei@cn.fujitsu.com
--- aux_syscalls.stp.old 2007-08-28 17:23:20.000000000 +0900
+++ aux_syscalls.stp 2007-08-28 17:23:33.000000000 +0900
@@ -1175,7 +1175,7 @@ function _shutdown_how_str(how) {
}
function _reboot_magic_str(magic) {
- if(magic==0xFEE1DEAD) return "LINUX_REBOOT_MAGIC1"
+ if(magic==-18751827) return "LINUX_REBOOT_MAGIC1"
if(magic==672274793) return "LINUX_REBOOT_MAGIC2"
if(magic==85072278) return "LINUX_REBOOT_MAGIC2A"
if(magic==369367448) return "LINUX_REBOOT_MAGIC2B"
Regards
Zhaolei