* Map syscall nr to syscall name
@ 2015-05-07 5:42 sahil aggarwal
2015-05-07 21:35 ` David Matlack
0 siblings, 1 reply; 4+ messages in thread
From: sahil aggarwal @ 2015-05-07 5:42 UTC (permalink / raw)
To: kernelnewbies
Hi all
I am looking for an efficient way to convert syscall number to syscall
name. I can get syscall number by enabling profiling using
perf_event_open(), but cant find way to convert it to actual syscall
name.
Thanks
--sahil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Map syscall nr to syscall name
2015-05-07 5:42 Map syscall nr to syscall name sahil aggarwal
@ 2015-05-07 21:35 ` David Matlack
2015-05-08 5:58 ` sahil aggarwal
0 siblings, 1 reply; 4+ messages in thread
From: David Matlack @ 2015-05-07 21:35 UTC (permalink / raw)
To: kernelnewbies
On Wed, May 6, 2015 at 10:42 PM, sahil aggarwal <sahilagg0693@gmail.com> wrote:
> Hi all
>
> I am looking for an efficient way to convert syscall number to syscall
> name. I can get syscall number by enabling profiling using
> perf_event_open(), but cant find way to convert it to actual syscall
> name.
What arch? Try
http://lxr.free-electrons.com/source/arch/x86/syscalls/syscall_64.tbl
>
> Thanks
>
>
> --sahil
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 4+ messages in thread
* Map syscall nr to syscall name
2015-05-07 21:35 ` David Matlack
@ 2015-05-08 5:58 ` sahil aggarwal
2015-05-08 10:23 ` sahil aggarwal
0 siblings, 1 reply; 4+ messages in thread
From: sahil aggarwal @ 2015-05-08 5:58 UTC (permalink / raw)
To: kernelnewbies
> What arch? Try
x86 , but looking for portable solution.
> http://lxr.free-electrons.com/source/arch/x86/syscalls/syscall_64.tbl
For my arch this is helpful.
Thank you
^ permalink raw reply [flat|nested] 4+ messages in thread
* Map syscall nr to syscall name
2015-05-08 5:58 ` sahil aggarwal
@ 2015-05-08 10:23 ` sahil aggarwal
0 siblings, 0 replies; 4+ messages in thread
From: sahil aggarwal @ 2015-05-08 10:23 UTC (permalink / raw)
To: kernelnewbies
Found something easier:
syscallent.sh ( similar to used by strace )
---------------------------------------------------------
cat ${1+"$@"} |
sed -n 's/^#[ ]*define[ ][ ]*SYS_\([^ ]*\)[
]*[^0-9]*\([0-9]*\).*$/\1 \2/p
s/^#[ ]*define[ ][ ]*__NR_\([^ ]*\)[
]*[^0-9]*\([0-9]*\).*$/\1 \2/p
s/^#[ ]*define[ ][ ]*__NR_\([^ ]*\)[ ]*[^0-9()]*(__NR_Linux +
\([0-9]*\))$/\1 \2/p' |
sort -k2n | uniq |
awk '
BEGIN {
h = "#ifndef _H_SYSCALLENT\n#define
_H_SYSCALLENT\nchar *syscalls[] = { "
print h
}
{
s = "\"" $1 "\","
print s
}
END {
f = " };\n#endif"
print f
}
'
---------------------------------------------------------
This creates header file:
#ifndef _H_SYSCALLENT
#define _H_SYSCALLENT
char *syscalls[] = {
"read",
"write",
"open",
"close",
"stat",
"fstat",
"lstat",
"poll",
"lseek",
"mmap",
......
.....
...
}
#endif
---------------------------------------------------------
included in makefile:
ARCH := $(shell getconf LONG_BIT)
ifeq ($(ARCH),64)
./syscallent.sh /usr/include/asm/unistd_64.h > $(INCDIR)/syscallent.h
else
./syscallent.sh /usr/include/asm/unistd_32.h > $(INCDIR)/syscallent.h
endif
---------------------------------------------------------
Works fine for me. Just want to know if this will be portable method
and won't produce wrong result in any case.?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-05-08 10:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 5:42 Map syscall nr to syscall name sahil aggarwal
2015-05-07 21:35 ` David Matlack
2015-05-08 5:58 ` sahil aggarwal
2015-05-08 10:23 ` sahil aggarwal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.