On Wed, 7 Oct 2020, Daniel Wagner wrote: > Signed-off-by: Daniel Wagner <dwagner@xxxxxxx> > --- > src/ssdd/ssdd.8 | 35 +++++++++++++++++----------------- > src/ssdd/ssdd.c | 50 +++++++++++++++++++++++++++---------------------- > 2 files changed, 45 insertions(+), 40 deletions(-) > > diff --git a/src/ssdd/ssdd.8 b/src/ssdd/ssdd.8 > index 99f30145d079..5c29d0abb732 100644 > --- a/src/ssdd/ssdd.8 > +++ b/src/ssdd/ssdd.8 > @@ -1,31 +1,30 @@ > -.TH SSDD 8 "June 13, 2019" > +.TH SSDD 8 "September 19, 2020" > .SH NAME > ssdd \- have a tracer do a bunch of PTRACE_SINGLESTEPs > .SH SYNOPSIS > -.B ssdd > -.RI "<options>" > +.LP > +ssdd [-f|--forks NUM] [-h|--help] [-i|--iters NUM] > .SH DESCRIPTION > -Have a tracer do a bunch of PTRACE_SINGLESTEPs against > -a tracee as fast as possible. Create several of these > -tracer/tracee pairs and see if they can be made to > -interfere with each other. > -The tracer waits on each PTRACE_SINGLESTEP with a waitpid(2) > -and checks that waitpid's return values for correctness. > +Have a tracer do a bunch of PTRACE_SINGLESTEPs against a tracee as > +fast as possible. Create several of these tracer/tracee pairs and > +see if they can be made to interfere with each other. The tracer > +waits on each PTRACE_SINGLESTEP with a waitpid(2) and checks that > +waitpid's return values for correctness. > .SH OPTIONS > -.B \-f, \-\-forks > -number of tracer/tracee pairs to fork off. > -Default is 10. > -.br > .TP > -.B \-i, \-\-iters > -number of PTRACE_SINGLESTEP iterations to > -do before declaring success, for each tracer/ > -tracee pair set up. Default is 10,000. > +.B \-f, \-\-forks=NUM > +number of tracer/tracee pairs to fork off. > .br > +Default is 10. > .TP > .B \-h, \-\-help > Display usage > - > +.TP > +.B \-i, \-\-iters=NUM > +number of PTRACE_SINGLESTEP iterations to do before declaring > +success, for each tracer tracee pair set up. > +.br > +Default is 10,000. > .SH AUTHOR > ssdd was written by Joe Korty <joe.korty@xxxxxxxxxxxxxxxxx> > .PP > diff --git a/src/ssdd/ssdd.c b/src/ssdd/ssdd.c > index f165da96e23a..66d6009dc572 100644 > --- a/src/ssdd/ssdd.c > +++ b/src/ssdd/ssdd.c > @@ -68,13 +68,16 @@ static int got_sigchld; > > enum option_value { OPT_NFORKS=1, OPT_NITERS, OPT_HELP }; > > -static void usage() > +static void usage(int error) > { > - printf("ssdd <options>\n"); > - printf("\t-f --forks=<number of forks>\n"); > - printf("\t-i --iters=<number of iterations>\n"); > - printf("\t-h --help\n"); > - exit(0); > + printf("ssdd V %1.2f\n", VERSION); > + printf("Usage:\n" > + "ssdd <options>\n\n" > + "-f --forks=NUM number of forks\n" > + "-h --help print this message\n" > + "-i --iters=NUM number of iterations\n" > + ); > + exit(error); > } > > static int do_wait(pid_t *wait_pid, int *ret_sig) > @@ -292,27 +295,30 @@ int main(int argc, char **argv) > int option_index = 0; > > static struct option long_options[] = { > - {"forks", required_argument, NULL, OPT_NFORKS}, > - {"iters", required_argument, NULL, OPT_NITERS}, > - {"help", no_argument, NULL, OPT_HELP}, > + {"forks", required_argument, NULL, OPT_NFORKS}, > + {"help", no_argument, NULL, OPT_HELP}, > + {"iters", required_argument, NULL, OPT_NITERS}, > {NULL, 0, NULL, 0}, > }; > - int c = getopt_long(argc, argv, "f:i:h", long_options, &option_index); > + int c = getopt_long(argc, argv, "f:hi:", long_options, &option_index); > if (c == -1) > break; > switch(c) { > - case 'f': > - case OPT_NFORKS: > - nforks = atoi(optarg); > - break; > - case 'i': > - case OPT_NITERS: > - nsteps = atoi(optarg); > - break; > - case 'h': > - case OPT_HELP: > - usage(); > - break; > + case 'f': > + case OPT_NFORKS: > + nforks = atoi(optarg); > + break; > + case 'h': > + case OPT_HELP: > + usage(0); > + break; > + case 'i': > + case OPT_NITERS: > + nsteps = atoi(optarg); > + break; > + default: > + usage(1); > + break; > } > } > > -- > 2.28.0 > > Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>