linux: support for monitoring syscall
Any chance this kind of information is available on other platforms too?
Any chance this kind of information is available on other platforms too?
Theoretically possible, but currently only intended to support Linux.
One more thing. We should allow the user to disable this "syscall" monitoring at compile time time. Since the /proc/<pid>/syscall file is only present when the kernel is compiled with CONFIG_HAVE_ARCH_TRACEHOOK, it may be useless for users without such kernel. Another reason for having this compile option is we can save code size by not compiling the syscall number-to-name mapping table into htop binary, in case we implement one in the future.
@Explorer09 Or disable the column, when the feature is not available at runtime.
@ Explorer09 Or disable the column, when the feature is not available at runtime.
I wish a compile time option to disable it as well.
@ Explorer09 Or disable the column, when the feature is not available at runtime.
I wish a compile time option to disable it as well.
Like so?
# Check for syscall feature option
AC_ARG_ENABLE(
[syscall],
[
AS_HELP_STRING(
[--enable-syscall],
[Enable 'syscall' feature. Possible values: off, buildtime-check, runtime-check, always-on. Default is 'off'.]
)
],
[case "${enableval}" in
off) syscall_feature=0 ;;
buildtime-check) syscall_feature=1 ;;
runtime-check) syscall_feature=2 ;;
always-on) syscall_feature=3 ;;
*) AC_MSG_ERROR([Invalid value for --enable-syscall]) ;;
esac],
[syscall_feature=0]
)
# If buildtime-check is enabled, check if /proc/self/syscall exists and is non-empty
AS_IF(
[test "x$syscall_feature" = "x1"],
[
AC_CHECK_FILE(
[/proc/self/syscall],
[syscall_exists=yes],
[syscall_exists=no]
)
AS_IF(
[test "x$syscall_exists" = "xyes" && test -s /proc/self/syscall],
[],
[syscall_feature=0]
)
]
)
# Set the result of the check to a preprocessor directive
AC_DEFINE_UNQUOTED([SYSCALL_FEATURE], [$syscall_feature], [Define to the selected syscall feature state.])
@BenBE
- I merged your "runtime-check" and "always-on" into one option, because checking the thing at runtime is trivial.
- When cross-compiling, checking
/proc/self/syscallwon't help. It's better just enable it in that case.
AC_ARG_ENABLE([syscall],
[AS_HELP_STRING([--enable-syscall],
[enable 'syscall' monitoring. @<:@default=check@:>@])],
[],
[enable_syscall=check]
)
if test "x$enable_syscall" = xcheck; then
if "$cross_compiling" != no; then
enable_syscall=yes
elif test -f /proc/self/syscall && test -s /proc/self/syscall; then
enable_syscall=yes
else
enable_syscall=no
fi
fi
if test "x$enable_syscall" = xyes; then
AC_DEFINE([HAVE_SYSCALL], [1], [Define to 1 is syscall monitoring is enabled.])
fi
@BenBE
* I merged your "runtime-check" and "always-on" into one option, because checking the thing at runtime is trivial. * When cross-compiling, checking `/proc/self/syscall` won't help. It's better just enable it in that case.AC_ARG_ENABLE([syscall], [AS_HELP_STRING([--enable-syscall], [enable 'syscall' monitoring. @<:@default=check@:>@])], [], [enable_syscall=check] ) if test "x$enable_syscall" = xcheck; then if "$cross_compiling" != no; then enable_syscall=yes elif test -f /proc/self/syscall && test -s /proc/self/syscall; then enable_syscall=yes else enable_syscall=no fi fi if test "x$enable_syscall" = xyes; then AC_DEFINE([HAVE_SYSCALL], [1], [Define to 1 is syscall monitoring is enabled.]) fi
Very good job, I will merge it
@Explorer09
@JohnSanpe You should handle the
runningstring as special and assign a placeholder number for it. The reason is it allows us to displayrunningstring with colors. This status should be special in sorting/collating anyway.
Using special placeholder number may conflict with future syscalls, so storing possible states separately may be a better choice? This is also more convenient for us to use lookup tables in the future.
You should handle the
runningstring as special and assign a placeholder number for it. The reason is it allows us to displayrunningstring with colors. This status should be special in sorting/collating anyway.Using special placeholder number may conflict with future syscalls, so storing possible states separately may be a better choice? This is also more convenient for us to use lookup tables in the future.
Use a negative number. E.g. -2, or maybe -1000 which has an even less chance to cause conflict.
You should handle the
runningstring as special and assign a placeholder number for it. The reason is it allows us to displayrunningstring with colors. This status should be special in sorting/collating anyway.Using special placeholder number may conflict with future syscalls, so storing possible states separately may be a better choice? This is also more convenient for us to use lookup tables in the future.
Use a negative number. E.g.
-2, or maybe-1000which has an even less chance to cause conflict.
I have already fixed it 😄
Does CI seem to have some issues?
Does CI seem to have some issues?
No. CI is waiting for approval by one of the maintainers as this is your first pull request for this project.