Add unique syscall entry numbers (SENs)

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sen.h.
(syscallent_names, syscallent_patterns, syscallent_files): New variables.
(sen.h): New rule.
* defs.h (struct sysent): Add sen field.
* generate_sen.sh: New file.
* linux/syscall.h: Include "sen.h".
* syscall.c (SEN_NAME): New temporary macro.
(SEN): Use it to prepend syscall entry number.
This commit is contained in:
Elvira Khabirova 2015-07-10 22:24:54 +03:00 committed by Dmitry V. Levin
parent 140ecf8766
commit 28e32df56f
5 changed files with 25 additions and 3 deletions

View File

@ -163,6 +163,7 @@ EXTRA_DIST = \
debian/strace64.manpages \
debian/watch \
errnoent.sh \
generate_sen.sh \
ioctlsort.c \
linux/32/ioctls_inc.h \
linux/32/ioctls_inc_align32.h \
@ -567,7 +568,7 @@ EXTRA_DIST = \
srpm: dist-xz
rpmbuild --define '%_srcrpmdir .' -ts $(distdir).tar.xz
BUILT_SOURCES = .version sys_func.h
BUILT_SOURCES = .version sys_func.h sen.h
$(srcdir)/.version:
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
@ -579,6 +580,15 @@ sys_func.h: $(patsubst %,$(srcdir)/%,$(strace_SOURCES_c))
sed -n 's/^SYS_FUNC(.*/extern &;/p' $$f; \
done | sort -u > $@
syscallent_names = subcall.h syscallent.h syscallent1.h \
syscallent-n32.h syscallent-n64.h syscallent-o32.h
syscallent_patterns = $(patsubst %,\%/%,$(syscallent_names))
syscallent_files = $(filter $(syscallent_patterns),$(EXTRA_DIST))
sen.h: $(patsubst %,$(srcdir)/%,$(syscallent_files))
for f in $^; do cat -- $$f; done | \
$(srcdir)/generate_sen.sh > $@
dist-hook:
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
@ -605,7 +615,7 @@ ioctlsort_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD)
ioctls_inc_h = $(wildcard $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h)
ioctlent_h = $(patsubst $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%,ioctlent%,$(ioctls_inc_h))
BUILT_SOURCES += $(ioctlent_h)
CLEANFILES = sys_func.h $(ioctlent_h)
CLEANFILES = sys_func.h sen.h $(ioctlent_h)
ioctlent%.h: ioctlsort%
./$< > $@

1
defs.h
View File

@ -249,6 +249,7 @@ extern char *stpcpy(char *dst, const char *src);
typedef struct sysent {
unsigned nargs;
int sys_flags;
int sen;
int (*sys_func)();
const char *sys_name;
} struct_sysent;

8
generate_sen.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh -e
echo 'enum {'
echo 'SEN_printargs = 0,'
sed -n '/printargs/! s/.*SEN(\([^)]*\)).*/\1/p' |
sort -u |
sed 's/.*/SEN_&,/'
echo '};'

View File

@ -28,6 +28,7 @@
#include "dummy.h"
#include "sys_func.h"
#include "sen.h"
#if NEED_UID16_PARSERS
extern SYS_FUNC(chown16);

View File

@ -81,7 +81,8 @@
#define SI STACKTRACE_INVALIDATE_CACHE
#define SE STACKTRACE_CAPTURE_ON_ENTER
#define SEN(syscall_name) SYS_FUNC_NAME(syscall_name)
#define SEN_NAME(syscall_name) SEN_ ## syscall_name
#define SEN(syscall_name) SEN_NAME(syscall_name), SYS_FUNC_NAME(syscall_name)
const struct_sysent sysent0[] = {
#include "syscallent.h"
@ -101,6 +102,7 @@ static const struct_sysent sysent2[] = {
/* Now undef them since short defines cause wicked namespace pollution. */
#undef SEN
#undef SEN_NAME
#undef TD
#undef TF
#undef TI