<div dir="ltr"><div>Recently, class %sched and %clock are added. Is it necessary to add<br></div><div>regular expression to filter system call?</div><div><br></div><div>I use '@' as the prefix of regular expression. I think following regular</div><div>expressions may be used. @time, @[pg]id, @^wait @xattr, @^dup, @^send,</div><div>@^recv, @^read, @^write, @^sem, @^shm, @^msg, @^inotify, @^pkey_</div><div><br></div><div>diff --git a/qualify.c b/qualify.c</div><div>index 157d313..5753530 100644</div><div>--- a/qualify.c</div><div>+++ b/qualify.c</div><div>@@ -27,6 +27,7 @@</div><div> </div><div> #include "defs.h"</div><div> #include "nsig.h"</div><div>+#include <regex.h></div><div> </div><div> typedef unsigned int number_slot_t;</div><div> #define BITS_PER_SLOT (sizeof(number_slot_t) * 8)</div><div>@@ -258,6 +259,35 @@ qualify_syscall_class(const char *s, struct number_set *set)</div><div> }</div><div> </div><div> static bool</div><div>+qualify_syscall_regex(const char *s, struct number_set *set)</div><div>+{</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>if(!s || *s != '@')</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">           </span>return false;</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>s++;</div><div>+</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>regex_t preg;</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>if (regcomp(&preg, s, REG_EXTENDED | REG_NOSUB))</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">          </span>error_msg_and_die("invalid regular expression: '%s'", s);</div><div>+</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>unsigned int p;</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>for (p = 0; p < SUPPORTED_PERSONALITIES; ++p) {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">            </span>unsigned int i;</div><div>+</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">               </span>for (i = 0; i < nsyscall_vec[p]; ++i) {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                    </span>if (!sysent_vec[p][i].sys_name</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>    || regexec(&preg, sysent_vec[p][i].sys_name,</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>       0, NULL, 0)) {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                              </span>continue;</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                     </span>}</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">                     </span>add_number_to_set(i, &set[p]);</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">            </span>}</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>}</div><div>+</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>regfree(&preg);</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>return true;</div><div>+}</div><div>+</div><div>+static bool</div><div> qualify_syscall_name(const char *s, struct number_set *set)</div><div> {</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">       </span>unsigned int p;</div><div>@@ -285,6 +315,7 @@ qualify_syscall(const char *token, struct number_set *set)</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre"> </span>if (*token >= '0' && *token <= '9')</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">            </span>return qualify_syscall_number(token, set);</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">   </span>return qualify_syscall_class(token, set)</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>       || qualify_syscall_regex(token, set)</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">       </span>       || qualify_syscall_name(token, set);</div><div> }</div><div> </div><div>diff --git a/tests/Makefile.am b/tests/Makefile.am</div><div>index 8dff1db..c82f28a 100644</div><div>--- a/tests/Makefile.am</div><div>+++ b/tests/Makefile.am</div><div>@@ -536,6 +536,7 @@ DECODER_TESTS = \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">       </span>qual_fault-exit_group.test \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre"> </span>read-write.test \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">    </span>readv.test \</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>regex.test \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre"> </span>sched.test \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre"> </span>scm_rights-fd.test \</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre"> </span>seccomp-strict.test \</div><div>diff --git a/tests/regex.test b/tests/regex.test</div><div>new file mode 100755</div><div>index 0000000..2b835d2</div><div>--- /dev/null</div><div>+++ b/tests/regex.test</div><div>@@ -0,0 +1,74 @@</div><div>+#!/bin/sh</div><div>+#</div><div>+# Check -e trace=@REGEX option.</div><div>+#</div><div>+# Copyright (c) 2017 The strace developers.</div><div>+# All rights reserved.</div><div>+#</div><div>+# Redistribution and use in source and binary forms, with or without</div><div>+# modification, are permitted provided that the following conditions</div><div>+# are met:</div><div>+# 1. Redistributions of source code must retain the above copyright</div><div>+#    notice, this list of conditions and the following disclaimer.</div><div>+# 2. Redistributions in binary form must reproduce the above copyright</div><div>+#    notice, this list of conditions and the following disclaimer in the</div><div>+#    documentation and/or other materials provided with the distribution.</div><div>+# 3. The name of the author may not be used to endorse or promote products</div><div>+#    derived from this software without specific prior written permission.</div><div>+#</div><div>+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</div><div>+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</div><div>+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</div><div>+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,</div><div>+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT</div><div>+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</div><div>+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</div><div>+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</div><div>+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</div><div>+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</div><div>+</div><div>+. "${srcdir=.}/init.sh"</div><div>+</div><div>+while read w s; do {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>try_run_prog "../$s" || continue</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>run_strace -a$w -e@^clock ../$s > "$EXP"</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>match_diff "$LOG" "$EXP"</div><div>+} < /dev/null; done << EOF</div><div>+37 clock_adjtime</div><div>+40 clock_nanosleep</div><div>+36 clock_xettime</div><div>+EOF</div><div>+</div><div>+# Surprised that fcntl*, futimesat, utime, utimensat, and utimes tests</div><div>+# linked with musl use clock_gettime?  Me too!</div><div>+grep -E -v '^(#|clock_|times$|fcntl|futimesat$|utime)' \</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>< "$srcdir/pure_executables.list" > negative.list</div><div>+</div><div>+while read s; do {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>try_run_prog "../$s" || continue</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>run_strace -qq -esignal=none -e@^clock ../$s > /dev/null</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>match_diff "$LOG" /dev/null</div><div>+} < /dev/null; done < negative.list</div><div>+</div><div>+while read w s; do {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>try_run_prog "../$s" || continue</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>run_strace -a$w -e@^sched_ ../$s > "$EXP"</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>match_diff "$LOG" "$EXP"</div><div>+} < /dev/null; done << EOF</div><div>+28 sched_xetaffinity</div><div>+23 sched_xetparam</div><div>+31 sched_rr_get_interval</div><div>+33 sched_get_priority_mxx</div><div>+29 sched_xetattr</div><div>+22 sched_xetscheduler</div><div>+14 sched_yield</div><div>+EOF</div><div>+</div><div>+grep -E -v '^(#|sched_|times$)' \</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>< "$srcdir/pure_executables.list" > negative.list</div><div>+</div><div>+while read s; do {</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>try_run_prog "../$s" || continue</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>run_strace -qq -esignal=none -e@^sched_ ../$s > /dev/null</div><div>+<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>match_diff "$LOG" /dev/null</div><div>+} < /dev/null; done < negative.list</div><div>-- </div><div>2.7.4</div></div>