Hide struct number_set implementation details from users
* number_set.h (number_slot_t, struct number_set): Move to number_set.c. (struct number_set): Add forward declaration. (read_set, write_set, signal_set): Change prototypes from objects to pointers. * filter_qualify.c (read_set, write_set, signal_set): Change definitions from objects to pointers. (abbrev_set, inject_set, raw_set, trace_set, verbose_set): Change definitions from arrays to pointers. (qualify_read): Initialize read_set before first use. (qualify_write): Initialize write_set before first use. (qualify_signals): Initialize signal_set before first use. (qualify_trace): Initialize trace_set before first use. (qualify_abbrev): Initialize abbrev_set before first use. (qualify_verbose): Initialize verbose_set before first use. (qualify_raw): Initialize raw_set before first use. (qualify_inject_common): Initialize inject_set before first use. * strace.c (print_signalled, print_stopped): Update signal_set usage. * syscall.c (dumpio): Update usage of read_set and write_set.
This commit is contained in:
parent
ef7b7a70c1
commit
5d7623a502
@ -31,15 +31,15 @@
|
||||
#include "number_set.h"
|
||||
#include "filter.h"
|
||||
|
||||
struct number_set read_set;
|
||||
struct number_set write_set;
|
||||
struct number_set signal_set;
|
||||
struct number_set *read_set;
|
||||
struct number_set *write_set;
|
||||
struct number_set *signal_set;
|
||||
|
||||
static struct number_set abbrev_set[SUPPORTED_PERSONALITIES];
|
||||
static struct number_set inject_set[SUPPORTED_PERSONALITIES];
|
||||
static struct number_set raw_set[SUPPORTED_PERSONALITIES];
|
||||
static struct number_set trace_set[SUPPORTED_PERSONALITIES];
|
||||
static struct number_set verbose_set[SUPPORTED_PERSONALITIES];
|
||||
static struct number_set *abbrev_set;
|
||||
static struct number_set *inject_set;
|
||||
static struct number_set *raw_set;
|
||||
static struct number_set *trace_set;
|
||||
static struct number_set *verbose_set;
|
||||
|
||||
static int
|
||||
sigstr_to_uint(const char *s)
|
||||
@ -178,42 +178,56 @@ parse_error:
|
||||
static void
|
||||
qualify_read(const char *const str)
|
||||
{
|
||||
qualify_tokens(str, &read_set, string_to_uint, "descriptor");
|
||||
if (!read_set)
|
||||
read_set = alloc_number_set_array(1);
|
||||
qualify_tokens(str, read_set, string_to_uint, "descriptor");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_write(const char *const str)
|
||||
{
|
||||
qualify_tokens(str, &write_set, string_to_uint, "descriptor");
|
||||
if (!write_set)
|
||||
write_set = alloc_number_set_array(1);
|
||||
qualify_tokens(str, write_set, string_to_uint, "descriptor");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_signals(const char *const str)
|
||||
{
|
||||
qualify_tokens(str, &signal_set, sigstr_to_uint, "signal");
|
||||
if (!signal_set)
|
||||
signal_set = alloc_number_set_array(1);
|
||||
qualify_tokens(str, signal_set, sigstr_to_uint, "signal");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_trace(const char *const str)
|
||||
{
|
||||
if (!trace_set)
|
||||
trace_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, trace_set, "system call");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_abbrev(const char *const str)
|
||||
{
|
||||
if (!abbrev_set)
|
||||
abbrev_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, abbrev_set, "system call");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_verbose(const char *const str)
|
||||
{
|
||||
if (!verbose_set)
|
||||
verbose_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, verbose_set, "system call");
|
||||
}
|
||||
|
||||
static void
|
||||
qualify_raw(const char *const str)
|
||||
{
|
||||
if (!raw_set)
|
||||
raw_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, raw_set, "system call");
|
||||
}
|
||||
|
||||
@ -260,6 +274,10 @@ qualify_inject_common(const char *const str,
|
||||
if (number_set_array_is_empty(tmp_set, p))
|
||||
continue;
|
||||
|
||||
if (!inject_set) {
|
||||
inject_set =
|
||||
alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
}
|
||||
if (!inject_vec[p]) {
|
||||
inject_vec[p] = xcalloc(nsyscall_vec[p],
|
||||
sizeof(*inject_vec[p]));
|
||||
|
@ -35,8 +35,15 @@
|
||||
#include "number_set.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
typedef unsigned int number_slot_t;
|
||||
#define BITS_PER_SLOT (sizeof(number_slot_t) * 8)
|
||||
|
||||
struct number_set {
|
||||
number_slot_t *vec;
|
||||
unsigned int nslots;
|
||||
bool not;
|
||||
};
|
||||
|
||||
static void
|
||||
number_setbit(const unsigned int i, number_slot_t *const vec)
|
||||
{
|
||||
|
14
number_set.h
14
number_set.h
@ -28,13 +28,7 @@
|
||||
#ifndef STRACE_NUMBER_SET_H
|
||||
#define STRACE_NUMBER_SET_H
|
||||
|
||||
typedef unsigned int number_slot_t;
|
||||
|
||||
struct number_set {
|
||||
number_slot_t *vec;
|
||||
unsigned int nslots;
|
||||
bool not;
|
||||
};
|
||||
struct number_set;
|
||||
|
||||
extern bool
|
||||
number_set_array_is_empty(const struct number_set *, unsigned int idx);
|
||||
@ -63,8 +57,8 @@ alloc_number_set_array(unsigned int nmemb);
|
||||
extern void
|
||||
free_number_set_array(struct number_set *, unsigned int nmemb);
|
||||
|
||||
extern struct number_set read_set;
|
||||
extern struct number_set write_set;
|
||||
extern struct number_set signal_set;
|
||||
extern struct number_set *read_set;
|
||||
extern struct number_set *write_set;
|
||||
extern struct number_set *signal_set;
|
||||
|
||||
#endif /* !STRACE_NUMBER_SET_H */
|
||||
|
4
strace.c
4
strace.c
@ -2086,7 +2086,7 @@ print_signalled(struct tcb *tcp, const int pid, int status)
|
||||
}
|
||||
|
||||
if (cflag != CFLAG_ONLY_STATS
|
||||
&& is_number_in_set(WTERMSIG(status), &signal_set)) {
|
||||
&& is_number_in_set(WTERMSIG(status), signal_set)) {
|
||||
printleader(tcp);
|
||||
#ifdef WCOREDUMP
|
||||
tprintf("+++ killed by %s %s+++\n",
|
||||
@ -2121,7 +2121,7 @@ print_stopped(struct tcb *tcp, const siginfo_t *si, const unsigned int sig)
|
||||
{
|
||||
if (cflag != CFLAG_ONLY_STATS
|
||||
&& !hide_log(tcp)
|
||||
&& is_number_in_set(sig, &signal_set)) {
|
||||
&& is_number_in_set(sig, signal_set)) {
|
||||
printleader(tcp);
|
||||
if (si) {
|
||||
tprintf("--- %s ", signame(sig));
|
||||
|
@ -432,7 +432,7 @@ dumpio(struct tcb *tcp)
|
||||
if (fd < 0)
|
||||
return;
|
||||
|
||||
if (is_number_in_set(fd, &read_set)) {
|
||||
if (is_number_in_set(fd, read_set)) {
|
||||
switch (tcp->s_ent->sen) {
|
||||
case SEN_read:
|
||||
case SEN_pread:
|
||||
@ -455,7 +455,7 @@ dumpio(struct tcb *tcp)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_number_in_set(fd, &write_set)) {
|
||||
if (is_number_in_set(fd, write_set)) {
|
||||
switch (tcp->s_ent->sen) {
|
||||
case SEN_write:
|
||||
case SEN_pwrite:
|
||||
|
Loading…
Reference in New Issue
Block a user