From e8c440a6136db3a1b7503e5224474b3b7f03363e Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 7 Mar 2016 23:07:51 +0200 Subject: Improve instruction dump. --- ChangeLog | 5 +++++ debug.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ChangeLog b/ChangeLog index 86cb8e7e..76ff7556 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-03-07 Arnold D. Robbins + + * profile.c (print_instruction): Further improvements in + instruction dump, especially for when pretty-printing. + 2016-03-03 Arnold D. Robbins * profile.c (pp_list): Unconditionally compute delimlen. Avoids diff --git a/debug.c b/debug.c index a32b0156..50bcd890 100644 --- a/debug.c +++ b/debug.c @@ -3797,6 +3797,31 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) print_func(fp, "[branch_end = %p]\n", pc->branch_end); break; + case Op_K_while: + print_func(fp, "[while_body = %p] [target_break = %p]\n", (pc+1)->while_body, pc->target_break); + break; + + case Op_K_do: + print_func(fp, "[doloop_cond = %p] [target_break = %p]\n", (pc+1)->doloop_cond, pc->target_break); + break; + + case Op_K_for: + print_func(fp, "[forloop_cond = %p] ", (pc+1)->forloop_cond); + /* 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); + break; + + case Op_K_switch: + print_func(fp, "[switch_start = %p] [switch_end = %p]\n", (pc+1)->switch_start, (pc+1)->switch_end); + break; + + case Op_K_case: + case Op_K_default: + print_func(fp, "[stmt_start = %p] [stmt_end = %p]\n", pc->stmt_start, pc->stmt_end); + break; + case Op_var_update: print_func(fp, "[update_%s()]\n", get_spec_varname(pc->update_var)); break; -- cgit v1.2.3 From 5f4505729ff5677d62495dcc78acf7eedfc1c90d Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 7 Mar 2016 23:08:09 +0200 Subject: helpers/fixdump.awk: Remove extraneous spaces in converted output. --- helpers/ChangeLog | 5 +++++ helpers/fixdump.awk | 2 ++ 2 files changed, 7 insertions(+) diff --git a/helpers/ChangeLog b/helpers/ChangeLog index 3215d159..ed6b7adc 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,8 @@ +2016-03-07 Arnold D. Robbins + + * fixdump.awk (translate): Remove extraneous spaces in + prints of code targets. + 2015-08-28 Daniel Richard G. * testdfa.c: Define and use the USE_EBCDIC cpp symbol diff --git a/helpers/fixdump.awk b/helpers/fixdump.awk index b03f03f7..d0190969 100644 --- a/helpers/fixdump.awk +++ b/helpers/fixdump.awk @@ -65,5 +65,7 @@ function translate(line, n, data, seps, i, newline) gsub(seps[i], Newaddr[seps[i]], newline) } + gsub(/ = +/, " = ", newline) + print newline } -- cgit v1.2.3 From 13927d9dec274f6c188005a9d87e097e225a1799 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 7 Mar 2016 23:09:21 +0200 Subject: helpers/fixdump.awk: Convert to Unix line endings. --- helpers/ChangeLog | 1 + helpers/fixdump.awk | 142 ++++++++++++++++++++++++++-------------------------- 2 files changed, 72 insertions(+), 71 deletions(-) diff --git a/helpers/ChangeLog b/helpers/ChangeLog index ed6b7adc..7ffbe62e 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -2,6 +2,7 @@ * fixdump.awk (translate): Remove extraneous spaces in prints of code targets. + * fixdump.awk: Convert to normal Unix line endings. 2015-08-28 Daniel Richard G. diff --git a/helpers/fixdump.awk b/helpers/fixdump.awk index d0190969..3ec502d2 100644 --- a/helpers/fixdump.awk +++ b/helpers/fixdump.awk @@ -1,71 +1,71 @@ -#! /usr/bin/gawk -f - -BEGIN { - address_re = "0x[[:xdigit:]]+" - bracketed_address = "\\[(([[:space:]]*[[:digit:]]*:)?|[[:alpha:]_]+ = )0x[[:xdigit:]]+\\]" -} - -{ - line[NR] = $0 - extract_addresses($0, NR) -} - -END { - for (i = 1; i <= NR; i++) { - if (line[i] !~ address_re) { - print line[i] - continue - } - - translate(line[i]) - } -} - -# Global arrays -# -# Address[line] --- Address of instruction - first hex number -# Target[address] = 1 --- Address is target of a jump -# Newaddr[address] --- Replacement address, counting from 1 - -function extract_addresses(line, num, data, i, n, seps, addr) -{ - if (line !~ address_re) - return - - split(line, data, bracketed_address, seps) - n = length(seps) - - for (i = 1; i <= n; i++) { - addr = gensub(".*(" address_re ").*", "\\1", 1, seps[i]) - if (i == 1) - Address[num] = addr - else { - Target[addr]++ - if (! (addr in Newaddr)) - Newaddr[addr] = new_address() - } - } -} - -function new_address() -{ - return sprintf("%8d", ++Address_seed) -} - -function translate(line, n, data, seps, i, newline) -{ - split(line, data, address_re, seps) - n = length(seps) - newline = line - for (i = 1; i <= n; i++) { - if (! (seps[i] in Target)) { - gsub(seps[i], " ", newline) - continue - } - gsub(seps[i], Newaddr[seps[i]], newline) - } - - gsub(/ = +/, " = ", newline) - - print newline -} +#! /usr/bin/gawk -f + +BEGIN { + address_re = "0x[[:xdigit:]]+" + bracketed_address = "\\[(([[:space:]]*[[:digit:]]*:)?|[[:alpha:]_]+ = )0x[[:xdigit:]]+\\]" +} + +{ + line[NR] = $0 + extract_addresses($0, NR) +} + +END { + for (i = 1; i <= NR; i++) { + if (line[i] !~ address_re) { + print line[i] + continue + } + + translate(line[i]) + } +} + +# Global arrays +# +# Address[line] --- Address of instruction - first hex number +# Target[address] = 1 --- Address is target of a jump +# Newaddr[address] --- Replacement address, counting from 1 + +function extract_addresses(line, num, data, i, n, seps, addr) +{ + if (line !~ address_re) + return + + split(line, data, bracketed_address, seps) + n = length(seps) + + for (i = 1; i <= n; i++) { + addr = gensub(".*(" address_re ").*", "\\1", 1, seps[i]) + if (i == 1) + Address[num] = addr + else { + Target[addr]++ + if (! (addr in Newaddr)) + Newaddr[addr] = new_address() + } + } +} + +function new_address() +{ + return sprintf("%8d", ++Address_seed) +} + +function translate(line, n, data, seps, i, newline) +{ + split(line, data, address_re, seps) + n = length(seps) + newline = line + for (i = 1; i <= n; i++) { + if (! (seps[i] in Target)) { + gsub(seps[i], " ", newline) + continue + } + gsub(seps[i], Newaddr[seps[i]], newline) + } + + gsub(/ = +/, " = ", newline) + + print newline +} -- cgit v1.2.3