]> granicus.if.org Git - strace/commitdiff
2002-12-30 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Mon, 30 Dec 2002 10:23:00 +0000 (10:23 +0000)
committerRoland McGrath <roland@redhat.com>
Mon, 30 Dec 2002 10:23:00 +0000 (10:23 +0000)
* syscall.c (qualify_one): New function.
(qual_options): Replace lookup field with qualify, update initializer.
(qualify): Update caller.
(qual_signal, qual_fault, qual_desc): Rewritten from lookup_*.
(qual_syscall): Rewritten lookup_syscall, match name more than once.
Fixes RH#70579, bites IA64 -efoo when foo exists on IA32.

syscall.c

index b5c6aa0dfae8e5bdf1a29e8d228f3aacdc9e1267..204b8ace7037030b5f5ac23935c37638a1e35bb9 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -217,91 +217,118 @@ static int sorted_count[MAX_QUALS];
 
 static struct timeval shortest = { 1000000, 0 };
 
-static int lookup_syscall(), lookup_signal(), lookup_fault(), lookup_desc();
+static int qual_syscall(), qual_signal(), qual_fault(), qual_desc();
 
 static struct qual_options {
        int bitflag;
        char *option_name;
-       int (*lookup)();
+       int (*qualify)();
        char *argument_name;
 } qual_options[] = {
-       { QUAL_TRACE,   "trace",        lookup_syscall, "system call"   },
-       { QUAL_TRACE,   "t",            lookup_syscall, "system call"   },
-       { QUAL_ABBREV,  "abbrev",       lookup_syscall, "system call"   },
-       { QUAL_ABBREV,  "a",            lookup_syscall, "system call"   },
-       { QUAL_VERBOSE, "verbose",      lookup_syscall, "system call"   },
-       { QUAL_VERBOSE, "v",            lookup_syscall, "system call"   },
-       { QUAL_RAW,     "raw",          lookup_syscall, "system call"   },
-       { QUAL_RAW,     "x",            lookup_syscall, "system call"   },
-       { QUAL_SIGNAL,  "signal",       lookup_signal,  "signal"        },
-       { QUAL_SIGNAL,  "signals",      lookup_signal,  "signal"        },
-       { QUAL_SIGNAL,  "s",            lookup_signal,  "signal"        },
-       { QUAL_FAULT,   "fault",        lookup_fault,   "fault"         },
-       { QUAL_FAULT,   "faults",       lookup_fault,   "fault"         },
-       { QUAL_FAULT,   "m",            lookup_fault,   "fault"         },
-       { QUAL_READ,    "read",         lookup_desc,    "descriptor"    },
-       { QUAL_READ,    "reads",        lookup_desc,    "descriptor"    },
-       { QUAL_READ,    "r",            lookup_desc,    "descriptor"    },
-       { QUAL_WRITE,   "write",        lookup_desc,    "descriptor"    },
-       { QUAL_WRITE,   "writes",       lookup_desc,    "descriptor"    },
-       { QUAL_WRITE,   "w",            lookup_desc,    "descriptor"    },
+       { QUAL_TRACE,   "trace",        qual_syscall,   "system call"   },
+       { QUAL_TRACE,   "t",            qual_syscall,   "system call"   },
+       { QUAL_ABBREV,  "abbrev",       qual_syscall,   "system call"   },
+       { QUAL_ABBREV,  "a",            qual_syscall,   "system call"   },
+       { QUAL_VERBOSE, "verbose",      qual_syscall,   "system call"   },
+       { QUAL_VERBOSE, "v",            qual_syscall,   "system call"   },
+       { QUAL_RAW,     "raw",          qual_syscall,   "system call"   },
+       { QUAL_RAW,     "x",            qual_syscall,   "system call"   },
+       { QUAL_SIGNAL,  "signal",       qual_signal,    "signal"        },
+       { QUAL_SIGNAL,  "signals",      qual_signal,    "signal"        },
+       { QUAL_SIGNAL,  "s",            qual_signal,    "signal"        },
+       { QUAL_FAULT,   "fault",        qual_fault,     "fault"         },
+       { QUAL_FAULT,   "faults",       qual_fault,     "fault"         },
+       { QUAL_FAULT,   "m",            qual_fault,     "fault"         },
+       { QUAL_READ,    "read",         qual_desc,      "descriptor"    },
+       { QUAL_READ,    "reads",        qual_desc,      "descriptor"    },
+       { QUAL_READ,    "r",            qual_desc,      "descriptor"    },
+       { QUAL_WRITE,   "write",        qual_desc,      "descriptor"    },
+       { QUAL_WRITE,   "writes",       qual_desc,      "descriptor"    },
+       { QUAL_WRITE,   "w",            qual_desc,      "descriptor"    },
        { 0,            NULL,           NULL,           NULL            },
 };
 
+static void
+qualify_one(n, opt, not)
+       int n;
+       struct qual_options *opt;
+       int not;
+{
+       if (not)
+               qual_flags[n] &= ~opt->bitflag;
+       else
+               qual_flags[n] |= opt->bitflag;
+}
+
 static int
-lookup_syscall(s)
-char *s;
+qual_syscall(s, opt, not)
+       char *s;
+       struct qual_options *opt;
+       int not;
 {
        int i;
+       int any = 0;
 
        for (i = 0; i < nsyscalls; i++) {
-               if (strcmp(s, sysent[i].sys_name) == 0)
-                       return i;
+               if (strcmp(s, sysent[i].sys_name) == 0) {
+                       qualify_one(i, opt, not);
+                       any = 1;
+               }
        }
-       return -1;
+       return !any;
 }
 
 static int
-lookup_signal(s)
-char *s;
+qual_signal(s, opt, not)
+       char *s;
+       struct qual_options *opt;
+       int not;
 {
        int i;
        char buf[32];
 
-       if (s && *s && isdigit((unsigned char)*s))
-               return atoi(s);
+       if (s && *s && isdigit((unsigned char)*s)) {
+               qualify_one(atoi(s), opt, not);
+               return 1;
+       }
        strcpy(buf, s);
        s = buf;
        for (i = 0; s[i]; i++)
                s[i] = toupper((unsigned char)(s[i]));
        if (strncmp(s, "SIG", 3) == 0)
                s += 3;
-       for (i = 0; i <= NSIG; i++) {
-               if (strcmp(s, signame(i) + 3) == 0)
-                       return i;
-       }
-       return -1;
+       for (i = 0; i <= NSIG; i++)
+               if (strcmp(s, signame(i) + 3) == 0) {
+                       qualify_one(atoi(s), opt, not);
+                       return 1;
+               }
+       return 0;
 }
 
 static int
-lookup_fault(s)
-char *s;
+qual_fault(s, opt, not)
+       char *s;
+       struct qual_options *opt;
+       int not;
 {
        return -1;
 }
 
 static int
-lookup_desc(s)
-char *s;
+qual_desc(s, opt, not)
+       char *s;
+       struct qual_options *opt;
+       int not;
 {
-       if (s && *s && isdigit((unsigned char)*s))
-               return atoi(s);
+       if (s && *s && isdigit((unsigned char)*s)) {
+               qualify_one(atoi(s), opt, not);
+       }
        return -1;
 }
 
 static int
 lookup_class(s)
-char *s;
+       char *s;
 {
        if (strcmp(s, "file") == 0)
                return TRACE_FILE;
@@ -370,15 +397,11 @@ char *s;
                        }
                        continue;
                }
-               if ((n = (*opt->lookup)(p)) < 0) {
+               if (opt->qualify(p, opt, not)) {
                        fprintf(stderr, "strace: invalid %s `%s'\n",
                                opt->argument_name, p);
                        exit(1);
                }
-               if (not)
-                       qual_flags[n] &= ~opt->bitflag;
-               else
-                       qual_flags[n] |= opt->bitflag;
        }
        return;
 }