From 9af44f959b1591daf2f7d2953dbdd3e868044d27 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:45:19 +0200 Subject: Bug fix in debugger - switch/case line numbers. --- debug.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 29ce8b1a..0a66b462 100644 --- a/debug.c +++ b/debug.c @@ -2231,6 +2231,23 @@ set_breakpoint_at(INSTRUCTION *rp, int lineno, int silent) INSTRUCTION *ip, *prevp; for (prevp = rp, ip = rp->nexti; ip; prevp = ip, ip = ip->nexti) { + if (ip->opcode == Op_K_case) { + INSTRUCTION *i1, *i2; + + /* Special case: the code line numbers for a switch do not form + * a monotonically increasing sequence. Check if the line # is between + * the first and last statements of the case block before continuing + * the search. + */ + for (i2 = ip->stmt_start, i1 = i2->nexti; i2 != ip->stmt_end; + i2 = i1, i1 = i1->nexti) { + if (i1->source_line >= lineno) + return add_breakpoint(i2, i1, rp->source_file, silent); + if (i1 == ip->stmt_end) + break; + } + } + if (ip->source_line >= lineno) return add_breakpoint(prevp, ip, rp->source_file, silent); if (ip == (rp + 1)->lasti) -- cgit v1.2.3 From 3ba2f61ff006c308a904c8b1a4bc433082ce87c8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 22:00:44 +0200 Subject: Misc fixes from John. --- debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 0a66b462..ea652478 100644 --- a/debug.c +++ b/debug.c @@ -498,8 +498,8 @@ source_find(char *src) efree(path); return s; } - efree(path); } + efree(path); } d_error(_("cannot find source file named `%s' (%s)"), src, strerror(errno_val)); -- cgit v1.2.3 From 73d24cae0db6cc817db209e5e1ea93b0733d1cca Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 26 Dec 2011 23:39:48 +0200 Subject: The grand merge: dgawk and pgawk folded into gawk. --- debug.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 37418115..76c2dcb9 100644 --- a/debug.c +++ b/debug.c @@ -40,7 +40,6 @@ extern FILE *output_fp; extern IOBUF *curfile; extern const char *command_file; extern const char *get_spec_varname(Func_ptr fptr); -extern int r_interpret(INSTRUCTION *); extern int zzparse(void); #define read_command() (void) zzparse() @@ -214,9 +213,9 @@ struct dbg_option { const char *help_txt; }; -#define DEFAULT_HISTFILE "./.dgawk_history" -#define DEFAULT_OPTFILE "./.dgawkrc" -#define DEFAULT_PROMPT "dgawk> " +#define DEFAULT_HISTFILE "./.gawk_history" +#define DEFAULT_OPTFILE "./.gawkrc" +#define DEFAULT_PROMPT "gawk> " #define DEFAULT_LISTSIZE 15 #define DEFAULT_HISTSIZE 100 @@ -235,7 +234,7 @@ static const char *history_file = DEFAULT_HISTFILE; /* keep all option variables in one place */ static char *output_file = "/dev/stdout"; /* gawk output redirection */ -char *dgawk_Prompt = NULL; /* initialized in interpret */ +char *dgawk_Prompt = NULL; /* initialized in do_debug */ static int list_size = DEFAULT_LISTSIZE; /* # of lines that 'list' prints */ static int do_trace = FALSE; static int do_save_history = TRUE; @@ -485,11 +484,11 @@ source_find(char *src) return s; } - path = find_source(src, &sbuf, &errno_val); + path = find_source(src, & sbuf, & errno_val, FALSE); if (path != NULL) { for (s = srcfiles->next; s != srcfiles; s = s->next) { if ((s->stype == SRC_FILE || s->stype == SRC_INC) - && files_are_same(path, s)) { + && files_are_same(path, s)) { efree(path); return s; } @@ -2722,10 +2721,10 @@ initialize_readline() #endif -/* interpret --- debugger entry point */ +/* debug_prog --- debugger entry point */ int -interpret(INSTRUCTION *pc) +debug_prog(INSTRUCTION *pc) { char *run; @@ -2775,7 +2774,7 @@ interpret(INSTRUCTION *pc) (void) do_run(NULL, 0); } else if (command_file != NULL) { - /* run commands from a file (--command=file or -R file) */ + /* run commands from a file (--debug=file or -D file) */ int fd; fd = open_readfd(command_file); if (fd == INVALID_HANDLE) { @@ -2922,7 +2921,7 @@ do_run(CMDARG *arg ATTRIBUTE_UNUSED, int cmd ATTRIBUTE_UNUSED) prog_running = TRUE; fatal_tag_valid = TRUE; if (setjmp(fatal_tag) == 0) - (void) r_interpret(code_block); + (void) interpret(code_block); fatal_tag_valid = FALSE; prog_running = FALSE; @@ -5377,7 +5376,7 @@ execute_code(volatile INSTRUCTION *code) PUSH_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); if (setjmp(fatal_tag) == 0) { - (void) r_interpret((INSTRUCTION *) code); + (void) interpret((INSTRUCTION *) code); r = POP_SCALAR(); } else /* fatal error */ (void) unwind_stack(save_stack_size); @@ -5517,7 +5516,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) } /* always destroy symbol "@eval", however destroy all newly installed - * globals only if fatal error in r_interpret (r == NULL). + * globals only if fatal error (execute_code() returing NULL). */ pop_context(); /* switch to prev context */ -- cgit v1.2.3 From a89bd16ff78c74513461af3f676d87d4eb9cfd3c Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 31 Dec 2011 20:51:11 +0200 Subject: Remove ancient STREQ, STREQN macros. --- debug.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index ea652478..1cfbac4c 100644 --- a/debug.c +++ b/debug.c @@ -994,7 +994,7 @@ find_param(const char *name, long num, char **pname) pcount = get_param_count(func); for (i = 0; i < pcount; i++) { - if (STREQ(name, pnames[i])) { + if (strcmp(name, pnames[i]) == 0) { r = f->stack[i]; if (r->type == Node_array_ref) r = r->orig_array; @@ -4068,7 +4068,7 @@ do_save(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) */ if (strlen(line) > 1 - && STREQN(line, "sa", 2)) + && strncmp(line, "sa", 2) == 0) continue; fprintf(fp, "%s\n", line); @@ -4102,7 +4102,7 @@ do_option(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) value = arg ? arg->a_string : NULL; for (opt = option_list; opt->name; opt++) { /* linear search */ - if (STREQ(name, opt->name)) + if (strcmp(name, opt->name) == 0) break; } if (! opt->name) @@ -4651,8 +4651,9 @@ unserialize_option(char **pstr, int *pstr_len, int field_cnt ATTRIBUTE_UNUSED) const struct dbg_option *opt; for (opt = option_list; opt->name; opt++) { - if (STREQN(pstr[0], opt->name, pstr_len[0])) { + if (strncmp(pstr[0], opt->name, pstr_len[0]) == 0) { char *value; + value = estrdup(pstr[1], pstr_len[1]); (*(opt->assign))(value); efree(value); @@ -5063,7 +5064,7 @@ find_option(char *name) int idx; for (idx = 0; (p = option_list[idx].name); idx++) { - if (STREQ(p, name)) + if (strcmp(p, name) == 0) return idx; } return -1; @@ -5132,19 +5133,19 @@ set_gawk_output(const char *file) if (fp == NULL) close(fd); - } else if (STREQN(file, "/dev/", 5)) { + } else if (strncmp(file, "/dev/", 5) == 0) { char *cp = (char *) file + 5; - if (STREQ(cp, "stdout")) + if (strcmp(cp, "stdout") == 0) return; - if (STREQ(cp, "stderr")) { + if (strcmp(cp, "stderr") == 0) { output_fp = stderr; output_file = "/dev/stderr"; output_is_tty = os_isatty(fileno(stderr)); return; } - if (STREQN(cp, "fd/", 3)) { + if (strncmp(cp, "fd/", 3) == 0) { cp += 3; fd = (int) strtoul(cp, NULL, 10); if (errno == 0 && fd > INVALID_HANDLE) { @@ -5198,9 +5199,9 @@ static int set_option_flag(const char *value) { long n; - if (STREQ(value, "on")) + if (strcmp(value, "on") == 0) return TRUE; - if (STREQ(value, "off")) + if (strcmp(value, "off") == 0) return FALSE; errno = 0; n = strtol(value, NULL, 0); @@ -5703,7 +5704,7 @@ in_cmd_src(const char *filename) { struct command_source *cs; for (cs = cmd_src; cs != NULL; cs = cs->next) { - if (cs->str != NULL && STREQ(cs->str, filename)) + if (cs->str != NULL && strcmp(cs->str, filename) == 0) return TRUE; } return FALSE; -- cgit v1.2.3