[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] 'watch' in gawk debugger gives wrong NR
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] 'watch' in gawk debugger gives wrong NR |
Date: |
Mon, 23 Nov 2015 21:05:07 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi.
Thanks for your note. Here is what I got when I tried your example
using the gawk-4.1-stable branch in git. I don't think there's
a bug.
Run gawk:
| Script started on Mon Nov 23 20:56:29 2015
| [aahz:pts/6 gawk.git]$ ./gawk -D -f testprog.awk data.in
List:
| gawk> list
| 1 #! /usr/bin/gawk -f
| 2 BEGIN {
| 3 c = 0
| 4 }
| 5
| 6 /apple/ {
| 7 nr = NR
| 8 c++
| 9 # printf "[c, NR] = [%s, %s]\n", c, NR
| 10 }
| 11
| 12 END {
| 13 print c
| 14 }
Setup watchpoints, display variables, and breakpoint:
| gawk> watch c
| Watchpoint 1: c
| gawk> display nr
| 1: nr = untyped variable
| gawk> display NR
| 2: NR = 0
| gawk> display c
| 3: c = untyped variable
| gawk> break 6
| Breakpoint 2 set at file `testprog.awk', line 6
Run!
| gawk> run
| Starting program:
| Stopping in Rule ...
| Breakpoint 2, main() at `testprog.awk':6
| 6 /apple/ {
| 1: nr = untyped variable
| 2: NR = 1
| 3: c = 0
| gawk> print $0
| $0 = "1 1 pear"
So far, so good. First record doesn't match, nr has not been assigned
to, and NR is correct.
| gawk> continue
| Watchpoint 1: c
| Old value: untyped variable
| New value: 0
Hmm. This is a little strange. Maybe I need to look at why the
watchpoint was triggered.
| main() at `testprog.awk':6
| 6 /apple/ {
| 1: nr = untyped variable
| 2: NR = 1
| 3: c = 0
| gawk> print $0
| $0 = "1 1 pear"
So, we're still in the first record. NR is ok.
| gawk> continue
| Breakpoint 2, main() at `testprog.awk':6
| 6 /apple/ {
| 1: nr = untyped variable
| 2: NR = 2
| 3: c = 0
| gawk> print $0
| $0 = "2 1 apple 4"
Continue on:
| gawk> continue
| Breakpoint 2, main() at `testprog.awk':6
| 6 /apple/ {
| 1: nr = 2
| 2: NR = 3
| 3: c = 1
| gawk> print $0
| $0 = "3 2 pear"
We're at record 3. It won't match, but NR is displayed correctly.
| gawk> exit
| error: unknown command - "exit", try help
| gawk> ^D
I think display of NR is OK. I probably need to figure out
why the watchpoint triggered.
Thanks,
Arnold