This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] LINUX_REBOOT_MAGIC1 printed as UNKNOWN VALUE in argstr


Why does aux_syscalls.stp use hard coded values instead of embedded C and the actual defines? They're all over the place. Something like below seems more proper to me.

%{
#include <linux/reboot.h>
%}

function _reboot_magic_str:string(magic:long) %{
	int magic = (int)THIS->magic;
	switch (magic) {
	case LINUX_REBOOT_MAGIC1:
		strlcpy(THIS->__retvalue, "LINUX_REBOOT_MAGIC1", MAXSTRINGLEN);
		break;
	case LINUX_REBOOT_MAGIC2:
		strlcpy(THIS->__retvalue, "LINUX_REBOOT_MAGIC2", MAXSTRINGLEN);
		break;
	case LINUX_REBOOT_MAGIC2A:
		strlcpy(THIS->__retvalue, "LINUX_REBOOT_MAGIC2A", MAXSTRINGLEN);
		break;
	case LINUX_REBOOT_MAGIC2B:
		strlcpy(THIS->__retvalue, "LINUX_REBOOT_MAGIC2B", MAXSTRINGLEN);
		break;
	case LINUX_REBOOT_MAGIC2C:
		strlcpy(THIS->__retvalue, "LINUX_REBOOT_MAGIC2C", MAXSTRINGLEN);
		break;
	default:
               snprintf(THIS->__retvalue, MAXSTRINGLEN, "UNKNOWN VALUE: %d", magic);
	}
%}


Frank Ch. Eigler wrote:
"Zhaolei" <zhaolei@cn.fujitsu.com> writes:

Argument of magic in argstr is displayed as "UNKNOWN VALUE" because:
Stap get value of magic from kernel, and it is negative value.

This makes sense, as reboot(2) is defined to take signed int parameters.


For this problem, I will commit following patch:

Could this be better (to accept more sign/size mismatches)?


 function _reboot_magic_str(magic) {
-   if(magic==0xFEE1DEAD) return "LINUX_REBOOT_MAGIC1"
+   if(magic==        0xFEE1DEAD) return "LINUX_REBOOT_MAGIC1"
+   if(magic==0xFFFFFFFFFEE1DEAD) return "LINUX_REBOOT_MAGIC1"
[...]

- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]