Lines Matching +full:- +full:seed

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * x86 decoder sanity test - based on test_get_insn.c
24 * access out-of-instruction-buffer.
32 static int x86_64; /* x86-64 bit mode flag */
33 static unsigned int seed; /* Random seed */ variable
42 fprintf(stderr, "Usage: %s [-y|-n|-v] [-s seed[,no]] [-m max] [-i input]\n", prog); in usage()
43 fprintf(stderr, "\t-y 64bit mode\n"); in usage()
44 fprintf(stderr, "\t-n 32bit mode\n"); in usage()
45 fprintf(stderr, "\t-v Verbosity(-vv dumps any decoded result)\n"); in usage()
46 fprintf(stderr, "\t-s Give a random seed (and iteration number)\n"); in usage()
47 fprintf(stderr, "\t-m Give a maximum iteration number\n"); in usage()
48 fprintf(stderr, "\t-i Give an input file with decoded binary\n"); in usage()
57 indent, field->value, field->bytes[0], field->bytes[1], in dump_field()
58 field->bytes[2], field->bytes[3]); in dump_field()
60 field->got, field->nbytes); in dump_field()
66 dump_field(fp, "prefixes", "\t", &insn->prefixes); in dump_insn()
67 dump_field(fp, "rex_prefix", "\t", &insn->rex_prefix); in dump_insn()
68 dump_field(fp, "vex_prefix", "\t", &insn->vex_prefix); in dump_insn()
69 dump_field(fp, "opcode", "\t", &insn->opcode); in dump_insn()
70 dump_field(fp, "modrm", "\t", &insn->modrm); in dump_insn()
71 dump_field(fp, "sib", "\t", &insn->sib); in dump_insn()
72 dump_field(fp, "displacement", "\t", &insn->displacement); in dump_insn()
73 dump_field(fp, "immediate1", "\t", &insn->immediate1); in dump_insn()
74 dump_field(fp, "immediate2", "\t", &insn->immediate2); in dump_insn()
76 insn->attr, insn->opnd_bytes, insn->addr_bytes); in dump_insn()
78 insn->length, insn->x86_64, insn->kaddr); in dump_insn()
96 fprintf(fp, " | %s -i -\n", prog); in dump_stream()
100 /* Give a seed and iteration number */ in dump_stream()
101 fprintf(fp, " $ %s -s 0x%x,%lu\n", prog, seed, nr_iter); in dump_stream()
113 if (read(fd, &seed, sizeof(seed)) != sizeof(seed)) in init_random_seed()
149 for (i = 0; i < MAX_INSN_SIZE - 1; i += 2) in generate_insn()
165 while ((c = getopt(argc, argv, "ynvs:m:i:")) != -1) { in parse_args()
177 if (strcmp("-", optarg) == 0) in parse_args()
185 seed = (unsigned int)strtoul(optarg, &tmp, 0); in parse_args()
191 usage("Failed to parse seed"); in parse_args()
206 usage("Max iteration number must be bigger than iter-num"); in parse_args()
209 usage("Don't use input file (-i) with random seed (-s)"); in parse_args()
211 /* Initialize random seed */ in parse_args()
213 if (!set_seed) /* No seed is given */ in parse_args()
215 srand(seed); in parse_args()
245 /* Access out-of-range memory */ in main()
256 "%s: %s: decoded and checked %d %s instructions with %d errors (seed:0x%x)\n", in main()
262 seed); in main()