YuuichiNakamura commented on a change in pull request #1271:
URL: https://github.com/apache/incubator-nuttx/pull/1271#discussion_r442688004



##########
File path: syscall/Makefile
##########
@@ -76,27 +88,43 @@ $(BIN1): $(PROXY_OBJS)
 $(BIN2): $(STUB_OBJS)
        $(call ARCHIVE, $@, $(STUB_OBJS))
 
+$(BIN3): $(WRAP_OBJS)
+       $(call ARCHIVE, $@, $(WRAP_OBJS))
+
+$(SYSCALLIST): .context
+
 .depend: Makefile $(SRCS)
-       $(Q) $(MKDEP) $(PROXYDEPPATH) $(STUBDEPPATH) \
+       $(Q) $(MKDEP) $(PROXYDEPPATH) $(STUBDEPPATH) $(WRAPDEPPATH) \
          "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
        $(Q) touch $@
 
 depend: .depend
 
 .context: syscall.csv
        $(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools -f Makefile.host mksyscall
+ifeq ($(CONFIG_LIB_SYSCALL),y)
        $(Q) (cd proxies; $(MKSYSCALL) -p $(CSVFILE);)
        $(Q) (cd stubs; $(MKSYSCALL) -s $(CSVFILE);)
+else
+ifeq ($(CONFIG_SCHED_INSTRUMENTATION_SYSCALL),y)
+       $(Q) (cd wraps; $(MKSYSCALL) -w $(CSVFILE);)
+       $(Q) $(MKSYSCALL) -l $(CSVFILE) > $(SYSCALLLIST:.txt=.h)
+       $(Q) $(call PREPROCESS, $(SYSCALLLIST:.txt=.h), $(SYSCALLLIST))
+       $(Q) sed -i -n -e '/^[^#]/p' $(SYSCALLLIST)

Review comment:
       I tried to take your way and found that cpp generates the error because 
`--wrap=xxx` is invalid as C tokens.
   It seems should be avoided to handle non-C-source text directly by C 
preprocessor.
   So I suggests the alternative idea to prepare the host command to generate 
the command line for linker such as:
   ```
   #include <stdio.h>
   #include <nuttx/config.h>
   #include <arch/arch.h>
   
   #ifndef UP_WRAPOPT
   #define UP_WRAPOPT(f) "--wrap=" #f " "
   #endif
   
   int main()
   {
       printf("%s",
   #define SYSCALL_LOOKUP1(f,n) UP_WRAPOPT(f)
   #define SYSCALL_LOOKUP(f,n)  UP_WRAPOPT(f)
   #include <sys/syscall_lookup.h>
   #undef SYSCALL_LOOKUP1
   #undef SYSCALL_LOOKUP
       );
   }
   ```
   It is built and executed by the host environment.
   In my brief trial it seems work as my expectation, but my concern is whether 
the host tool is permitted to include "nuttx/config.h" and "arch/arch.h" 
directly.
   Are there available for such purpose? Or do you know better way for it?
   
   BTW, I found that similar consideration should be needed for wrapper file 
because `__wrap_` and `__real_` also depend on GNU linker.
   I'll take similar way with mksyscall to generate the wrapper code such as:
   ```
   #include <nuttx/arch.h>
   #ifndef UP_WRAPSYM
   #define UP_WRAPSYM(s) __wrap_##s
   #endif
   #ifndef UP_REALSYM
   #define UP_REALSYM(s) __real_##s
   #endif
   
   int UP_WRAPSYM(open)(FAR const char * parm1, int parm2, ...)
     :
   ```
   Thanks for good suggestion.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to