diff options
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 98 |
1 files changed, 87 insertions, 11 deletions
@@ -310,6 +310,7 @@ static void delete_item(struct list_item *d); static int breakpoint_triggered(BREAKPOINT *b); static int watchpoint_triggered(struct list_item *w); static void print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump); +static void print_ns_list(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump); static int print_code(INSTRUCTION *pc, void *x); static void next_command(); static void debug_post_execute(INSTRUCTION *pc); @@ -1031,7 +1032,7 @@ NODE *find_symbol(const char *name, char **pname) if (prog_running) r = find_param(name, cur_frame, pname); if (r == NULL) - r = lookup(name); + r = lookup(name, false); // for now, require fully qualified name if (r == NULL) fprintf(out_fp, _("no symbol `%s' in current context\n"), name); return r; @@ -3807,7 +3808,12 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) break; case Op_K_do: - print_func(fp, "[doloop_cond = %p] [target_break = %p]\n", (pc+1)->doloop_cond, pc->target_break); + print_func(fp, "[doloop_cond = %p] [target_break = %p]", (pc+1)->doloop_cond, pc->target_break); + if (pc->comment) + print_func(fp, " [comment = %p]", pc->comment); + print_func(fp, "\n"); + if (pc->comment) + print_instruction(pc->comment, print_func, fp, in_dump); break; case Op_K_for: @@ -3815,15 +3821,44 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) /* fall through */ case Op_K_arrayfor: print_func(fp, "[forloop_body = %p] ", (pc+1)->forloop_body); - print_func(fp, "[target_break = %p] [target_continue = %p]\n", pc->target_break, pc->target_continue); + print_func(fp, "[target_break = %p] [target_continue = %p]", pc->target_break, pc->target_continue); + if (pc->comment != NULL) { + print_func(fp, " [comment = %p]\n", (pc)->comment); + print_instruction(pc->comment, print_func, fp, in_dump); + } else + print_func(fp, "\n"); break; case Op_K_switch: + { + bool need_newline = false; print_func(fp, "[switch_start = %p] [switch_end = %p]\n", (pc+1)->switch_start, (pc+1)->switch_end); + if (pc->comment || (pc+1)->switch_end->comment) + print_func(fp, "%*s", noffset, ""); + if (pc->comment) { + print_func(fp, "[start_comment = %p]", pc->comment); + need_newline = true; + } + if ((pc+1)->switch_end->comment) { + print_func(fp, "[end_comment = %p]", (pc + 1)->switch_end->comment); + need_newline = true; + } + if (need_newline) + print_func(fp, "\n"); + if (pc->comment) + print_instruction(pc->comment, print_func, fp, in_dump); + if ((pc+1)->switch_end->comment) + print_instruction((pc+1)->switch_end->comment, print_func, fp, in_dump); + } break; case Op_K_default: - print_func(fp, "[stmt_start = %p] [stmt_end = %p]\n", pc->stmt_start, pc->stmt_end); + print_func(fp, "[stmt_start = %p] [stmt_end = %p]", pc->stmt_start, pc->stmt_end); + if (pc->comment) { + print_func(fp, " [comment = %p]\n", pc->comment); + print_instruction(pc->comment, print_func, fp, in_dump); + } else + print_func(fp, "\n"); break; case Op_var_update: @@ -3848,8 +3883,13 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) break; case Op_func: - print_func(fp, "[param_cnt = %d] [source_file = %s]\n", pcount, + print_func(fp, "[param_cnt = %d] [source_file = %s]", pcount, pc->source_file ? pc->source_file : "cmd. line"); + if (pc[3].nexti != NULL) { + print_func(fp, "[ns_list = %p]\n", pc[3].nexti); + print_ns_list(pc[3].nexti, print_func, fp, in_dump); + } else + print_func(fp, "\n"); break; case Op_K_getline_redir: @@ -3915,8 +3955,22 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) break; case Op_K_case: - print_func(fp, "[target_jmp = %p] [match_exp = %s]\n", + print_func(fp, "[target_jmp = %p] [match_exp = %s]", pc->target_jmp, (pc + 1)->match_exp ? "true" : "false"); + if (pc->comment) { + print_func(fp, " [comment = %p]\n", pc->comment); + print_instruction(pc->comment, print_func, fp, in_dump); + } else + print_func(fp, "\n"); + break; + + case Op_K_namespace: + print_func(fp, "[namespace = %s]", pc->ns_name); + if (pc->nexti) + print_func(fp, "[nexti = %p]", pc->nexti); + if (pc->comment) + print_func(fp, "[comment = %p]", pc->comment); + print_func(fp, "\n"); break; case Op_arrayfor_incr: @@ -3957,7 +4011,7 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) break; case Op_builtin: - print_func(fp, "%s [arg_count = %ld]\n", getfname(pc->builtin), + print_func(fp, "%s [arg_count = %ld]\n", getfname(pc->builtin, false), pc->expr_count); break; @@ -3995,9 +4049,14 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) break; case Op_rule: - print_func(fp, "[in_rule = %s] [source_file = %s]\n", + print_func(fp, "[in_rule = %s] [source_file = %s]", ruletab[pc->in_rule], pc->source_file ? pc->source_file : "cmd. line"); + if (pc[3].nexti != NULL) { + print_func(fp, "[ns_list = %p]\n", pc[3].nexti); + print_ns_list(pc[3].nexti, print_func, fp, in_dump); + } else + print_func(fp, "\n"); break; case Op_lint: @@ -4032,9 +4091,14 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) case Op_comment: print_memory(pc->memory, func, print_func, fp); - print_func(fp, " [comment_type = %s]\n", + print_func(fp, " [comment_type = %s]", pc->memory->comment_type == EOL_COMMENT ? - "EOL" : "FULL"); + "EOL" : "BLOCK"); + if (pc->comment) { + print_func(fp, " [comment = %p]\n", pc->comment); + print_instruction(pc->comment, print_func, fp, in_dump); + } else + print_func(fp, "\n"); break; case Op_push_i: @@ -4086,6 +4150,18 @@ print_code(INSTRUCTION *pc, void *x) return 0; } +/* print_ns_list --- print the list of namespaces */ + +static void +print_ns_list(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) +{ + for (; pc != NULL; pc = pc->nexti) { + print_instruction(pc, print_func, fp, in_dump); + if (pc->comment != NULL) + print_instruction(pc->comment, print_func, fp, in_dump); + } +} + /* do_dump_instructions --- dump command */ int @@ -5530,7 +5606,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) return false; } - f = lookup("@eval"); + f = lookup("@eval", false); assert(f != NULL); if (this_func == NULL) { /* in main */ /* do a function call */ |