#include #include #include #include #include #include "parse.h" #include "analyze.h" void read_args(int argc, char *argv[], struct parse_opts *opts) { int optind = 0, c; static struct option long_options[] = { { .val = 'p', .name = "pid", .has_arg = 1, }, { .val = 'm', .name = "map", .has_arg = 1, }, }; char short_options[] = "p:m:"; opts->parse_mask = 0; while (1) { c = getopt_long(argc, argv, short_options, long_options, &optind); if (c == -1) break; printf("%c: %s\n", c, optarg); switch (c) { case 'p': opts->pid = atoi(optarg); opts->parse_mask |= PARSE_PID; break; case 'm': opts->parse_mask |= PARSE_MAP_NAME; opts->map_name = optarg; break; } } } int main(int argc, char *argv[]) { struct pageframe pf; struct process *process_list = NULL; struct parse_opts opts; if (argc < 3) { printf("A pid needs to be given as an argument\n"); return 1; } read_args(argc, argv, &opts); memset(&pf, 0, sizeof(pf)); scan_all_pids(&pf, &process_list, &opts); print_pid_stats(&pf, process_list); print_page_stats(&pf); return 0; }