#define QUAL_ABBREV 0x002 /* abbreviate the structures of this syscall */
#define QUAL_VERBOSE 0x004 /* decode the structures of this syscall */
#define QUAL_RAW 0x008 /* print all args in hex for this syscall */
-#define QUAL_SIGNAL 0x010 /* report events with this signal */
+#define QUAL_FAULT 0x010 /* fail this system call on purpose */
+#define QUAL_SIGNAL 0x100 /* report events with this signal */
#define QUAL_READ 0x200 /* dump data read from this file descriptor */
#define QUAL_WRITE 0x400 /* dump data written to this file descriptor */
-#define QUAL_FAULT 0x080 /* fail this system call on purpose */
typedef uint8_t qualbits_t;
#define DEFAULT_QUAL_FLAGS (QUAL_TRACE | QUAL_ABBREV | QUAL_VERBOSE)
struct number_set;
extern struct number_set read_set;
extern struct number_set write_set;
+extern struct number_set signal_set;
extern bool is_number_in_set(unsigned int number, const struct number_set *);
extern void qualify_read(const char *);
extern void qualify_write(const char *);
+extern void qualify_signals(const char *);
extern int dm_ioctl(struct tcb *, const unsigned int, long);
extern int file_ioctl(struct tcb *, const unsigned int, long);
struct number_set read_set;
struct number_set write_set;
+struct number_set signal_set;
static void
number_setbit(const unsigned int i, number_slot_t *const vec)
{
qualify_tokens(str, &write_set, string_to_uint, "descriptor");
}
+
+static int
+sigstr_to_uint(const char *s)
+{
+ int i;
+
+ if (*s >= '0' && *s <= '9')
+ return string_to_uint_upto(s, 255);
+
+ if (strncasecmp(s, "SIG", 3) == 0)
+ s += 3;
+
+ for (i = 0; i <= 255; ++i) {
+ const char *name = signame(i);
+
+ if (strncasecmp(name, "SIG", 3) != 0)
+ continue;
+
+ name += 3;
+
+ if (strcasecmp(name, s) != 0)
+ continue;
+
+ return i;
+ }
+
+ return -1;
+}
+
+void
+qualify_signals(const char *const str)
+{
+ qualify_tokens(str, &signal_set, sigstr_to_uint, "signal");
+}
#endif
static int qual_fault(const char *, unsigned int, int);
-static int qual_signal(const char *, unsigned int, int);
static int qual_syscall(const char *, unsigned int, int);
static const struct qual_options {
{ 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_SIGNAL, "signal", NULL, "signal" },
+ { QUAL_SIGNAL, "signals", NULL, "signal" },
+ { QUAL_SIGNAL, "s", NULL, "signal" },
{ QUAL_READ, "read", NULL, "descriptor" },
{ QUAL_READ, "reads", NULL, "descriptor" },
{ QUAL_READ, "r", NULL, "descriptor" },
return rc;
}
-static int
-qual_signal(const char *s, const unsigned int bitflag, const int not)
-{
- int i;
-
- if (*s >= '0' && *s <= '9') {
- i = string_to_uint_upto(s, 255);
- if (i < 0)
- return -1;
- qualify_one(i, bitflag, not, -1, NULL);
- return 0;
- }
- if (strncasecmp(s, "SIG", 3) == 0)
- s += 3;
- for (i = 0; i <= NSIG; ++i) {
- const char *name = signame(i);
- if (strncasecmp(name, "SIG", 3) != 0)
- continue;
- name += 3;
-
- if (strcasecmp(name, s) != 0)
- continue;
- qualify_one(i, bitflag, not, -1, NULL);
- return 0;
- }
- return -1;
-}
-
void
qualify(const char *s)
{
}
switch (opt->bitflag) {
+ case QUAL_SIGNAL:
+ qualify_signals(s);
+ return;
case QUAL_READ:
qualify_read(s);
return;