diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-11-14 21:45:19 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-11-14 21:45:19 +0200 |
commit | 9af44f959b1591daf2f7d2953dbdd3e868044d27 (patch) | |
tree | a804e0c656d408d8d64904318c59075d0e84dfa3 | |
parent | 169aedcf3822c4b37b58d01ce97210839496e484 (diff) | |
download | egawk-9af44f959b1591daf2f7d2953dbdd3e868044d27.tar.gz egawk-9af44f959b1591daf2f7d2953dbdd3e868044d27.tar.bz2 egawk-9af44f959b1591daf2f7d2953dbdd3e868044d27.zip |
Bug fix in debugger - switch/case line numbers.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | debug.c | 17 |
2 files changed, 23 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2011-11-14 John Haque <j.eh@mchsi.com> + + * debug.c (set_breakpoint_at): Fix problem with setting + breakpoints in a switch statement. Thanks to Giorgio Palandri + <giorgio.palandri@gmail.com> for the bug report. + 2011-11-14 Arnold D. Robbins <arnold@skeeve.com> * mbsupport.h: Add check for HAVE_BTOWC, per Pat Rankin. @@ -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) |