From 456b8f722f263e275a380eebfc111d2d318d17e3 Mon Sep 17 00:00:00 2001 From: mysterywave Date: Thu, 14 Oct 2021 18:23:51 -0500 Subject: [PATCH] Fixed labels and made switch statment fancy --- src/options.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/options.c b/src/options.c index a7b7d95..2ef0e90 100644 --- a/src/options.c +++ b/src/options.c @@ -69,17 +69,23 @@ int parse_args(int argc, char *argv[]) { extern char **environ; while ((opt = getopt_long(argc, argv, "vFDe:s:b:B:o:", long_options, NULL)) != -1) { switch (opt) { - case 'v': + case 'v': { OPT_VERBOSE = 1; break; - case 'D': + } + + case 'D': { OPT_DEBUG = 1; OPT_VERBOSE = 1; break; - case 's': + } + + case 's': { symbol_defs_str = (char *)optarg; break; - case 'e': + } + + case 'e': { char *_eq = strstr(optarg, "="); if (!_eq) { setenv(optarg, "", 1); @@ -89,16 +95,24 @@ int parse_args(int argc, char *argv[]) { setenv(optarg, val, 1); } break; - case 'b': + } + + case 'b': { BREAK_AT = parse_bp(optarg); break; - case 'B': + } + + case 'B': { BREAK_AFTER = parse_bp(optarg); break; - case 'F': + } + + case 'F': { OPT_FOLLOW_FORK = 1; break; - case 'o': + } + + case 'o': { FILE *_output_file = fopen(optarg, "a+"); if (!_output_file) { fatal("failed to open logging file \"%s\".\n", optarg); @@ -107,8 +121,11 @@ int parse_args(int argc, char *argv[]) { output_fd = _output_file; } break; - default: + } + + default: { exit_failure(argv); + } } } @@ -171,7 +188,7 @@ void evaluate_symbol_defs(Breakpoint **bps, int bpsc, ProcMapsEntry *pme_head) { _sym_sign = '+'; continue; } else if (c == '-' || c == '+' || c == ',' || c == ';') { -parsevalue: +parsevalue:; uint64_t val = 0; if (strcmp(buf, "libc") == 0) val = libc_base; else if (strcmp(buf, "bin") == 0) val = bin_base;