summaryrefslogtreecommitdiff
path: root/lib/regex/interp.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-16 21:32:49 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-16 21:32:49 -0700
commit447bbbd25bbb42f2c3da11ac298f52a31bfb573d (patch)
treec1d4a9329552b78a2fe029a1ba977d086159310b /lib/regex/interp.myr
parenta32ef8d8bb4254a5e376fcfb14cf5355f778a29a (diff)
downloadmc-447bbbd25bbb42f2c3da11ac298f52a31bfb573d.tar.gz
Add better regex debugging.
Diffstat (limited to 'lib/regex/interp.myr')
-rw-r--r--lib/regex/interp.myr16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr
index 15c71f8..c1226ee 100644
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -104,7 +104,8 @@ const run = {re, wholestr
thr = re.runq
re.runq = thr.next
- trace(re, thr, "\nrunning tid={}, ip={}, s[{}]={}\n", thr.tid, thr.ip, re.strp, std.decode(re.str[re.strp:]))
+ trace(re, thr, "\nrunning tid={}, ip={}, s[{}]={}\n", \
+ thr.tid, thr.ip, re.strp, std.decode(re.str[re.strp:]))
ip = thr.ip
consumed = step(re, thr, -1)
while !consumed
@@ -143,7 +144,7 @@ const run = {re, wholestr
;;
;;
std.bsclear(states)
- trace(re, thr, "switch\n")
+ trace(re, Zthr, "switch\n")
re.runq = re.expired
re.expired = Zthr
re.expiredtail = Zthr
@@ -277,7 +278,8 @@ const die = {re, thr, msg
trace(re, thr, "\t\tdie {}: {}\n", thr.tid, msg)
if !thr.dead
re.nthr--
- ;;
+ ;;
+ re.lastip = thr.ip
thr.dead = true
}
@@ -322,9 +324,15 @@ const within = {re, str
const trace : (re : regex#, thr : rethread#, msg : byte[:], args : ... -> void) = {re, thr, msg, args
var ap
- if re.debug
+ if re.trace && thr != Zthr
ap = std.vastart(&args)
std.putv(msg, &ap)
+ std.put("\t{}\n", re.pat)
+ std.put("\t")
+ for var i = 0; i < re.pcidx[thr.ip] - 1; i++
+ std.put(" ")
+ ;;
+ std.put("^\n")
;;
}