summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-09-02 06:06:59 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-09-02 06:06:59 +0300
commita205df7903bce201577df4f7049c190e283f1ea4 (patch)
treee3946b219a17db13e8bbfe778faaf79e23ca689f
parentfb838ec318104f66a36e59f71ffb4f9eaa9b2eaa (diff)
parentf84a4ffb830e5f9ce138cb74fae99ad930805723 (diff)
downloadgawk-a205df7903bce201577df4f7049c190e283f1ea4.tar.gz
Merge branch 'gawk-4.1-stable'
-rw-r--r--doc/ChangeLog8
-rw-r--r--doc/gawk.info69
-rw-r--r--doc/gawk.texi62
-rw-r--r--doc/gawktexi.in62
4 files changed, 106 insertions, 95 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 69069fd2..47d74797 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,6 +1,12 @@
+2014-09-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Corrections to walkthrough in debugger chapter.
+ Thanks to David "bamber" Ward <dlward134@gmail.com> for
+ the problem report.
+
2014-09-01 Arnold D. Robbins <arnold@skeeve.com>
- * gaktexi.in: Add index entry for @ - @load, @include,
+ * gawktexi.in: Add index entry for @ - @load, @include,
and indirect function calls. Thanks to "Kenny McKormack" in
comp.lang.awk.
diff --git a/doc/gawk.info b/doc/gawk.info
index f4b2b913..bff22dc9 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -20542,7 +20542,7 @@ options. (`gawk' is not designed to debug command-line programs, only
programs contained in files.) In our case, we invoke the debugger like
this:
- $ gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile
+ $ gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile
where both `getopt.awk' and `uniq.awk' are in `$AWKPATH'. (Experienced
users of GDB or similar debuggers should note that this syntax is
@@ -20594,7 +20594,7 @@ for a breakpoint in `uniq.awk' is at the beginning of the function
To set the breakpoint, use the `b' (breakpoint) command:
gawk> b are_equal
- -| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
+ -| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 63
The debugger tells us the file and line number where the breakpoint
is. Now type `r' or `run' and the program runs until it hits the
@@ -20604,8 +20604,8 @@ breakpoint for the first time:
-| Starting program:
-| Stopping in Rule ...
-| Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':64
- -| 64 if (fcount == 0 && charcount == 0)
+ at `awklib/eg/prog/uniq.awk':63
+ -| 63 if (fcount == 0 && charcount == 0)
gawk>
Now we can look at what's going on inside our program. First of all,
@@ -20615,11 +20615,11 @@ the current stack frames:
gawk> bt
-| #0 are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':69
- -| #1 in main() at `awklib/eg/prog/uniq.awk':89
+ at `awklib/eg/prog/uniq.awk':68
+ -| #1 in main() at `awklib/eg/prog/uniq.awk':88
This tells us that `are_equal()' was called by the main program at
-line 89 of `uniq.awk'. (This is not a big surprise, since this is the
+line 88 of `uniq.awk'. (This is not a big surprise, since this is the
only call to `are_equal()' in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -20638,13 +20638,13 @@ function was called without arguments (*note Function Calls::).
A more useful variable to display might be the current record:
gawk> p $0
- -| $0 = string ("gawk is a wonderful program!")
+ -| $0 = "gawk is a wonderful program!"
This might be a bit puzzling at first since this is the second line of
our test input above. Let's look at `NR':
gawk> p NR
- -| NR = number (2)
+ -| NR = 2
So we can see that `are_equal()' was only called for the second record
of the file. Of course, this is because our program contains a rule for
@@ -20658,7 +20658,7 @@ of the file. Of course, this is because our program contains a rule for
OK, let's just check that that rule worked correctly:
gawk> p last
- -| last = string ("awk is a wonderful program!")
+ -| last = "awk is a wonderful program!"
Everything we have done so far has verified that the program has
worked as planned, up to and including the call to `are_equal()', so
@@ -20667,38 +20667,39 @@ must begin "stepping through" the lines of `are_equal()'. We start by
typing `n' (for "next"):
gawk> n
- -| 67 if (fcount > 0) {
+ -| 66 if (fcount > 0) {
- This tells us that `gawk' is now ready to execute line 67, which
+ This tells us that `gawk' is now ready to execute line 66, which
decides whether to give the lines the special "field skipping" treatment
-indicated by the `-f' command-line option. (Notice that we skipped
-from where we were before at line 64 to here, since the condition in
-line 64 `if (fcount == 0 && charcount == 0)' was false.)
+indicated by the `-1' command-line option. (Notice that we skipped
+from where we were before at line 63 to here, since the condition in
+line 63 `if (fcount == 0 && charcount == 0)' was false.)
Continuing to step, we now get to the splitting of the current and
last records:
gawk> n
- -| 68 n = split(last, alast)
+ -| 67 n = split(last, alast)
gawk> n
- -| 69 m = split($0, aline)
+ -| 68 m = split($0, aline)
At this point, we should be curious to see what our records were
split into, so we try to look:
gawk> p n m alast aline
- -| n = number (5)
- -| m = number (5)
+ -| n = 5
+ -| m = untyped variable
-| alast = array, 5 elements
- -| aline = array, 5 elements
+ -| aline = untyped variable
(The `p' command can take more than one argument, similar to `awk''s
`print' statement.)
This is kind of disappointing, though. All we found out is that
-there are five elements in each of our arrays. Useful enough (we now
-know that none of the words were accidentally left out), but what if we
-want to see inside the array?
+there are five elements in `alast'; `m' and `aline' don't have values
+yet since we are at line 68 but haven't executed it yet. This
+information is useful enough (we now know that none of the words were
+accidentally left out), but what if we want to see inside the array?
The first choice would be to use subscripts:
@@ -20708,25 +20709,25 @@ want to see inside the array?
Oops!
gawk> p alast[1]
- -| alast["1"] = string ("awk")
+ -| alast["1"] = "awk"
This would be kind of slow for a 100-member array, though, so `gawk'
provides a shortcut (reminiscent of another language not to be
mentioned):
gawk> p @alast
- -| alast["1"] = string ("awk")
- -| alast["2"] = string ("is")
- -| alast["3"] = string ("a")
- -| alast["4"] = string ("wonderful")
- -| alast["5"] = string ("program!")
+ -| alast["1"] = "awk"
+ -| alast["2"] = "is"
+ -| alast["3"] = "a"
+ -| alast["4"] = "wonderful"
+ -| alast["5"] = "program!"
It looks like we got this far OK. Let's take another step or two:
gawk> n
- -| 70 clast = join(alast, fcount, n)
+ -| 69 clast = join(alast, fcount, n)
gawk> n
- -| 71 cline = join(aline, fcount, m)
+ -| 70 cline = join(aline, fcount, m)
Well, here we are at our error (sorry to spoil the suspense). What
we had in mind was to join the fields starting from the second one to
@@ -20734,8 +20735,8 @@ make the virtual record to compare, and if the first field was numbered
zero, this would work. Let's look at what we've got:
gawk> p cline clast
- -| cline = string ("gawk is a wonderful program!")
- -| clast = string ("awk is a wonderful program!")
+ -| cline = "gawk is a wonderful program!"
+ -| clast = "awk is a wonderful program!"
Hey, those look pretty familiar! They're just our original,
unaltered, input records. A little thinking (the human brain is still
@@ -34431,7 +34432,7 @@ Node: Debugging Terms826097
Node: Awk Debugging828694
Node: Sample Debugging Session829586
Node: Debugger Invocation830106
-Node: Finding The Bug831439
+Node: Finding The Bug831442
Node: List of Debugger Commands837921
Node: Breakpoint Control839253
Node: Debugger Execution Control842917
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 6d37c556..81b36ae5 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -28701,7 +28701,7 @@ to debug command-line programs, only programs contained in files.)
In our case, we invoke the debugger like this:
@example
-$ @kbd{gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile}
+$ @kbd{gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile}
@end example
@noindent
@@ -28763,7 +28763,7 @@ the breakpoint, use the @code{b} (breakpoint) command:
@example
gawk> @kbd{b are_equal}
-@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
+@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 63
@end example
The debugger tells us the file and line number where the breakpoint is.
@@ -28775,8 +28775,8 @@ gawk> @kbd{r}
@print{} Starting program:
@print{} Stopping in Rule ...
@print{} Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':64
-@print{} 64 if (fcount == 0 && charcount == 0)
+ at `awklib/eg/prog/uniq.awk':63
+@print{} 63 if (fcount == 0 && charcount == 0)
gawk>
@end example
@@ -28788,12 +28788,12 @@ listing of the current stack frames:
@example
gawk> @kbd{bt}
@print{} #0 are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':69
-@print{} #1 in main() at `awklib/eg/prog/uniq.awk':89
+ at `awklib/eg/prog/uniq.awk':68
+@print{} #1 in main() at `awklib/eg/prog/uniq.awk':88
@end example
This tells us that @code{are_equal()} was called by the main program at
-line 89 of @file{uniq.awk}. (This is not a big surprise, since this
+line 88 of @file{uniq.awk}. (This is not a big surprise, since this
is the only call to @code{are_equal()} in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -28817,7 +28817,7 @@ A more useful variable to display might be the current record:
@example
gawk> @kbd{p $0}
-@print{} $0 = string ("gawk is a wonderful program!")
+@print{} $0 = "gawk is a wonderful program!"
@end example
@noindent
@@ -28826,7 +28826,7 @@ our test input above. Let's look at @code{NR}:
@example
gawk> @kbd{p NR}
-@print{} NR = number (2)
+@print{} NR = 2
@end example
@noindent
@@ -28845,7 +28845,7 @@ OK, let's just check that that rule worked correctly:
@example
gawk> @kbd{p last}
-@print{} last = string ("awk is a wonderful program!")
+@print{} last = "awk is a wonderful program!"
@end example
Everything we have done so far has verified that the program has worked as
@@ -28856,13 +28856,13 @@ be inside this function. To investigate further, we must begin
@example
gawk> @kbd{n}
-@print{} 67 if (fcount > 0) @{
+@print{} 66 if (fcount > 0) @{
@end example
-This tells us that @command{gawk} is now ready to execute line 67, which
+This tells us that @command{gawk} is now ready to execute line 66, which
decides whether to give the lines the special ``field skipping'' treatment
-indicated by the @option{-f} command-line option. (Notice that we skipped
-from where we were before at line 64 to here, since the condition in line 64
+indicated by the @option{-1} command-line option. (Notice that we skipped
+from where we were before at line 63 to here, since the condition in line 63
@samp{if (fcount == 0 && charcount == 0)} was false.)
Continuing to step, we now get to the splitting of the current and
@@ -28870,9 +28870,9 @@ last records:
@example
gawk> @kbd{n}
-@print{} 68 n = split(last, alast)
+@print{} 67 n = split(last, alast)
gawk> @kbd{n}
-@print{} 69 m = split($0, aline)
+@print{} 68 m = split($0, aline)
@end example
At this point, we should be curious to see what our records were split
@@ -28880,10 +28880,10 @@ into, so we try to look:
@example
gawk> @kbd{p n m alast aline}
-@print{} n = number (5)
-@print{} m = number (5)
+@print{} n = 5
+@print{} m = untyped variable
@print{} alast = array, 5 elements
-@print{} aline = array, 5 elements
+@print{} aline = untyped variable
@end example
@noindent
@@ -28891,7 +28891,9 @@ gawk> @kbd{p n m alast aline}
@command{awk}'s @code{print} statement.)
This is kind of disappointing, though. All we found out is that there
-are five elements in each of our arrays. Useful enough (we now know that
+are five elements in @code{alast}; @code{m} and @code{aline} don't have
+values yet since we are at line 68 but haven't executed it yet.
+This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -28907,7 +28909,7 @@ Oops!
@example
gawk> @kbd{p alast[1]}
-@print{} alast["1"] = string ("awk")
+@print{} alast["1"] = "awk"
@end example
This would be kind of slow for a 100-member array, though, so
@@ -28916,11 +28918,11 @@ not to be mentioned):
@example
gawk> @kbd{p @@alast}
-@print{} alast["1"] = string ("awk")
-@print{} alast["2"] = string ("is")
-@print{} alast["3"] = string ("a")
-@print{} alast["4"] = string ("wonderful")
-@print{} alast["5"] = string ("program!")
+@print{} alast["1"] = "awk"
+@print{} alast["2"] = "is"
+@print{} alast["3"] = "a"
+@print{} alast["4"] = "wonderful"
+@print{} alast["5"] = "program!"
@end example
It looks like we got this far OK. Let's take another step
@@ -28928,9 +28930,9 @@ or two:
@example
gawk> @kbd{n}
-@print{} 70 clast = join(alast, fcount, n)
+@print{} 69 clast = join(alast, fcount, n)
gawk> @kbd{n}
-@print{} 71 cline = join(aline, fcount, m)
+@print{} 70 cline = join(aline, fcount, m)
@end example
Well, here we are at our error (sorry to spoil the suspense). What we
@@ -28940,8 +28942,8 @@ this would work. Let's look at what we've got:
@example
gawk> @kbd{p cline clast}
-@print{} cline = string ("gawk is a wonderful program!")
-@print{} clast = string ("awk is a wonderful program!")
+@print{} cline = "gawk is a wonderful program!"
+@print{} clast = "awk is a wonderful program!"
@end example
Hey, those look pretty familiar! They're just our original, unaltered,
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 589c50b2..3a443b55 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -27799,7 +27799,7 @@ to debug command-line programs, only programs contained in files.)
In our case, we invoke the debugger like this:
@example
-$ @kbd{gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile}
+$ @kbd{gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile}
@end example
@noindent
@@ -27861,7 +27861,7 @@ the breakpoint, use the @code{b} (breakpoint) command:
@example
gawk> @kbd{b are_equal}
-@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
+@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 63
@end example
The debugger tells us the file and line number where the breakpoint is.
@@ -27873,8 +27873,8 @@ gawk> @kbd{r}
@print{} Starting program:
@print{} Stopping in Rule ...
@print{} Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':64
-@print{} 64 if (fcount == 0 && charcount == 0)
+ at `awklib/eg/prog/uniq.awk':63
+@print{} 63 if (fcount == 0 && charcount == 0)
gawk>
@end example
@@ -27886,12 +27886,12 @@ listing of the current stack frames:
@example
gawk> @kbd{bt}
@print{} #0 are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':69
-@print{} #1 in main() at `awklib/eg/prog/uniq.awk':89
+ at `awklib/eg/prog/uniq.awk':68
+@print{} #1 in main() at `awklib/eg/prog/uniq.awk':88
@end example
This tells us that @code{are_equal()} was called by the main program at
-line 89 of @file{uniq.awk}. (This is not a big surprise, since this
+line 88 of @file{uniq.awk}. (This is not a big surprise, since this
is the only call to @code{are_equal()} in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -27915,7 +27915,7 @@ A more useful variable to display might be the current record:
@example
gawk> @kbd{p $0}
-@print{} $0 = string ("gawk is a wonderful program!")
+@print{} $0 = "gawk is a wonderful program!"
@end example
@noindent
@@ -27924,7 +27924,7 @@ our test input above. Let's look at @code{NR}:
@example
gawk> @kbd{p NR}
-@print{} NR = number (2)
+@print{} NR = 2
@end example
@noindent
@@ -27943,7 +27943,7 @@ OK, let's just check that that rule worked correctly:
@example
gawk> @kbd{p last}
-@print{} last = string ("awk is a wonderful program!")
+@print{} last = "awk is a wonderful program!"
@end example
Everything we have done so far has verified that the program has worked as
@@ -27954,13 +27954,13 @@ be inside this function. To investigate further, we must begin
@example
gawk> @kbd{n}
-@print{} 67 if (fcount > 0) @{
+@print{} 66 if (fcount > 0) @{
@end example
-This tells us that @command{gawk} is now ready to execute line 67, which
+This tells us that @command{gawk} is now ready to execute line 66, which
decides whether to give the lines the special ``field skipping'' treatment
-indicated by the @option{-f} command-line option. (Notice that we skipped
-from where we were before at line 64 to here, since the condition in line 64
+indicated by the @option{-1} command-line option. (Notice that we skipped
+from where we were before at line 63 to here, since the condition in line 63
@samp{if (fcount == 0 && charcount == 0)} was false.)
Continuing to step, we now get to the splitting of the current and
@@ -27968,9 +27968,9 @@ last records:
@example
gawk> @kbd{n}
-@print{} 68 n = split(last, alast)
+@print{} 67 n = split(last, alast)
gawk> @kbd{n}
-@print{} 69 m = split($0, aline)
+@print{} 68 m = split($0, aline)
@end example
At this point, we should be curious to see what our records were split
@@ -27978,10 +27978,10 @@ into, so we try to look:
@example
gawk> @kbd{p n m alast aline}
-@print{} n = number (5)
-@print{} m = number (5)
+@print{} n = 5
+@print{} m = untyped variable
@print{} alast = array, 5 elements
-@print{} aline = array, 5 elements
+@print{} aline = untyped variable
@end example
@noindent
@@ -27989,7 +27989,9 @@ gawk> @kbd{p n m alast aline}
@command{awk}'s @code{print} statement.)
This is kind of disappointing, though. All we found out is that there
-are five elements in each of our arrays. Useful enough (we now know that
+are five elements in @code{alast}; @code{m} and @code{aline} don't have
+values yet since we are at line 68 but haven't executed it yet.
+This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -28005,7 +28007,7 @@ Oops!
@example
gawk> @kbd{p alast[1]}
-@print{} alast["1"] = string ("awk")
+@print{} alast["1"] = "awk"
@end example
This would be kind of slow for a 100-member array, though, so
@@ -28014,11 +28016,11 @@ not to be mentioned):
@example
gawk> @kbd{p @@alast}
-@print{} alast["1"] = string ("awk")
-@print{} alast["2"] = string ("is")
-@print{} alast["3"] = string ("a")
-@print{} alast["4"] = string ("wonderful")
-@print{} alast["5"] = string ("program!")
+@print{} alast["1"] = "awk"
+@print{} alast["2"] = "is"
+@print{} alast["3"] = "a"
+@print{} alast["4"] = "wonderful"
+@print{} alast["5"] = "program!"
@end example
It looks like we got this far OK. Let's take another step
@@ -28026,9 +28028,9 @@ or two:
@example
gawk> @kbd{n}
-@print{} 70 clast = join(alast, fcount, n)
+@print{} 69 clast = join(alast, fcount, n)
gawk> @kbd{n}
-@print{} 71 cline = join(aline, fcount, m)
+@print{} 70 cline = join(aline, fcount, m)
@end example
Well, here we are at our error (sorry to spoil the suspense). What we
@@ -28038,8 +28040,8 @@ this would work. Let's look at what we've got:
@example
gawk> @kbd{p cline clast}
-@print{} cline = string ("gawk is a wonderful program!")
-@print{} clast = string ("awk is a wonderful program!")
+@print{} cline = "gawk is a wonderful program!"
+@print{} clast = "awk is a wonderful program!"
@end example
Hey, those look pretty familiar! They're just our original, unaltered,