Debian Codegraph @

HOWTOs/GNU-APL-Troubleshooting.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.1.2" />
8 <title>Trouble-Shooting GNU APL</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
11
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
15 }
16
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
25 }
26
27 body {
28 margin: 1em 5% 1em 5%;
29 }
30
31 a {
32 color: blue;
33 text-decoration: underline;
34 }
35 a:visited {
36 color: fuchsia;
37 }
38
39 em {
40 font-style: italic;
41 color: navy;
42 }
43
44 strong {
45 font-weight: bold;
46 color: #083194;
47 }
48
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
54 }
55
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
58 }
59 h2 {
60 padding-top: 0.5em;
61 }
62 h3 {
63 float: left;
64 }
65 h3 + * {
66 clear: left;
67 }
68 h5 {
69 font-size: 1.0em;
70 }
71
72 div.sectionbody {
73 margin-left: 0;
74 }
75
76 hr {
77 border: 1px solid silver;
78 }
79
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
83 }
84
85 ul, ol, li > p {
86 margin-top: 0;
87 }
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
90
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
97 }
98 pre {
99 white-space: pre-wrap;
100 }
101
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
106 }
107 #email {
108 }
109 #revnumber, #revdate, #revremark {
110 }
111
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
117 }
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
121 }
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
125 }
126
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
130 }
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
136 }
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
142 }
143
144 div.content { /* Block element content. */
145 padding: 0;
146 }
147
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
155 }
156 div.title + * {
157 margin-top: 0;
158 }
159
160 td div.title:first-child {
161 margin-top: 0.0em;
162 }
163 div.content div.title:first-child {
164 margin-top: 0.0em;
165 }
166 div.content + div.title {
167 margin-top: 0.0em;
168 }
169
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
175 }
176
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
182 }
183
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
190 }
191
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
195 }
196
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
200 }
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
204 }
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
208 }
209
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
217 }
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
221 }
222
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
226 }
227
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
231
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
235 }
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
241 }
242 dd > *:first-child {
243 margin-top: 0.1em;
244 }
245
246 ul, ol {
247 list-style-position: outside;
248 }
249 ol.arabic {
250 list-style-type: decimal;
251 }
252 ol.loweralpha {
253 list-style-type: lower-alpha;
254 }
255 ol.upperalpha {
256 list-style-type: upper-alpha;
257 }
258 ol.lowerroman {
259 list-style-type: lower-roman;
260 }
261 ol.upperroman {
262 list-style-type: upper-roman;
263 }
264
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
270 }
271
272 tfoot {
273 font-weight: bold;
274 }
275 td > div.verse {
276 white-space: pre;
277 }
278
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
282 }
283 div.hdlist tr {
284 padding-bottom: 15px;
285 }
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
288 }
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
294 }
295 td.hdlist2 {
296 vertical-align: top;
297 }
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
301 }
302
303 .comment {
304 background: yellow;
305 }
306
307 .footnote, .footnoteref {
308 font-size: 0.8em;
309 }
310
311 span.footnote, span.footnoteref {
312 vertical-align: super;
313 }
314
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
318 }
319
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
322 }
323
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
332 }
333
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
338 }
339 div.colist td img {
340 margin-top: 0.3em;
341 }
342
343 @media print {
344 #footer-badges { display: none; }
345 }
346
347 #toc {
348 margin-bottom: 2.5em;
349 }
350
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
357 }
358
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
362 }
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
366 }
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
370 }
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
374 }
375
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
392
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
409
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
412
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
416
417 div.unbreakable { page-break-inside: avoid; }
418
419
420 /*
421 * xhtml11 specific
422 *
423 * */
424
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
428 }
429 div.tableblock > table {
430 border: 3px solid #527bbd;
431 }
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
435 }
436 p.table {
437 margin-top: 0;
438 }
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
442 }
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
446 }
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
450 }
451
452
453 /*
454 * html5 specific
455 *
456 * */
457
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
461 }
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
465 }
466 p.tableblock {
467 margin-top: 0;
468 }
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
475 }
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
481 }
482
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
486 }
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
490 }
491 table.tableblock.frame-none {
492 border-style: hidden;
493 }
494
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
497 }
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
500 }
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
503 }
504
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
507 }
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
510 }
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
513 }
514
515
516 /*
517 * manpage specific
518 *
519 * */
520
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
526 }
527 body.manpage h2 {
528 border-style: none;
529 }
530 body.manpage div.sectionbody {
531 margin-left: 3em;
532 }
533
534 @media print {
535 body.manpage div#toc { display: none; }
536 }
537
538
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
543
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
547
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
550 *
551 * Table Of Content generator
552 * Version: 0.4
553 *
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
556 */
557
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
560
561 // toclevels = 1..4.
562 toc: function (toclevels) {
563
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
571 }
572 return text;
573 }
574
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
579 }
580
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
593 }
594 iterate(i);
595 }
596 }
597 }
598 iterate(el);
599 return result;
600 }
601
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
605 }
606
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
616 }
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
619 }
620
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
634 }
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
637 },
638
639
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
643
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
646 */
647
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
654 }
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
660 }
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
663 }
664
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
682 }
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
689 }
690 }
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
703 }
704 }
705 }
706 },
707
708 install: function(toclevels) {
709 var timerId;
710
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
715 }
716 }
717
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
721 }
722
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
728 }
729
730 }
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="article">
736 <div id="header">
737 <h1>Trouble-Shooting GNU APL</h1>
738 </div>
739 <div id="content">
740 <div class="sect1">
741 <h2 id="_abstract">Abstract</h2>
742 <div class="sectionbody">
743 <div class="paragraph"><p>This document contains hints for <strong>GNU APL</strong> users who would like to report
744 <strong>GNU APL</strong> problems and who want to make the life of the <strong>GNU APL</strong> maintainer(s)
745 a little easier by localizing the root cause of a problem.</p></div>
746 </div>
747 </div>
748 <div class="sect1">
749 <h2 id="_introduction">Introduction</h2>
750 <div class="sectionbody">
751 <div class="paragraph"><p><strong>GNU APL</strong> is, in terms of source code size, a fairly large program. As of
752 this writing the source code for the interpreter, not counting code in
753 sub-directories, has more than 110,000 lines of code. Finding faults in
754 code of that quantity is not as trivial as finding faults in a short program
755 of only a few thousand lines. Past experience shows, that after a new fault
756 was observed, the time for reproducing and localizing the fault typically
757 takes more than 90% of the total time to fix it.</p></div>
758 <div class="paragraph"><p>For this reason, <strong>GNU APL</strong> comes with a handful of built-in trouble-shooting
759 capabilities that makes locating a fault easier. Some of these capabilities
760 require that <strong>GNU APL</strong> is built and run in a specific way as described in
761 this document.</p></div>
762 <div class="paragraph"><p>Almost every error that might occur in <strong>GNU APL</strong> falls into one of the
763 following 4 categories of increasing severities:</p></div>
764 <div class="ulist"><ul>
765 <li>
766 <p>
767 Errors in User Programs (aka. APL errors),
768 </p>
769 </li>
770 <li>
771 <p>
772 Incorrect APL results,
773 </p>
774 </li>
775 <li>
776 <p>
777 Failed Assertions, and
778 </p>
779 </li>
780 <li>
781 <p>
782 Crashes of the <strong>GNU APL</strong> interpreter.
783 </p>
784 </li>
785 </ul></div>
786 <div class="paragraph"><p>Each category requires different means and preparations for locating the
787 root cause of the error.</p></div>
788 </div>
789 </div>
790 <div class="sect1">
791 <h2 id="_errors_in_user_programs_aka_apl_errors">Errors in User Programs (aka. APL errors),</h2>
792 <div class="sectionbody">
793 <div class="paragraph"><p>Errors in user programs are reported by the APL intepreter when APL code
794 is being executed. Before the interpreter starts its internal computation(s)
795 it checks the arguments. These checks depend on the computation required
796 and usually occur in the following order:</p></div>
797 <div class="olist arabic"><ol class="arabic">
798 <li>
799 <p>
800 Syntax Check (may raise SYNTAX ERROR)
801 </p>
802 </li>
803 <li>
804 <p>
805 Valence Check (may raise VALENCE ERROR or AXIS ERROR)
806 </p>
807 </li>
808 <li>
809 <p>
810 Value Check (may raise VALUE ERROR)
811 </p>
812 </li>
813 <li>
814 <p>
815 Rank Check (may raise RANK ERROR)
816 </p>
817 </li>
818 <li>
819 <p>
820 Shape Check (may raise LENGTH ERROR)
821 </p>
822 </li>
823 <li>
824 <p>
825 Domain Checks (may raise DOMAIN ERROR)
826 </p>
827 </li>
828 </ol></div>
829 <div class="paragraph"><p>That is, a VALUE error can normally only occur in the absence of SYNTAX
830 and VALENCE ERRORs, a LENGTH ERROR can only occur in the absence of SYNTAX,
831 VALENCE, AXIS, VALUE, and RANK ERRORs, and so on.</p></div>
832 <div class="paragraph"><p>An APL error is displayed immediately and (provided that output coloring
833 is enabled) in a different color than the APL output. The first line of the
834 error display is the type of error, possibly followed by +. The +, if
835 present, indicates that there is more information available about the error
836 (and that the additional information can be obtained with command )MORE.
837 Example:</p></div>
838 <div class="literalblock">
839 <div class="content">
840 <pre>
841
842 <code> +/[1;2] 3 ⍝ ; is not allowed in function axes.
843 AXIS ERROR+
844 +/[1;2]3
845 ^ ^
846 )MORE
847 illegal ; in axis</code>
848
849 </pre>
850 </div></div>
851 <div class="paragraph"><p>APL errors shall, of course, not be reported to the <strong>GNU APL</strong> maintainers,
852 with the following exceptions:</p></div>
853 <div class="ulist"><ul>
854 <li>
855 <p>
856 An error was raised incorrectly, i.e. for valid APL input, or
857 </p>
858 </li>
859 <li>
860 <p>
861 the display of )MORE is misleading or could be improved. Many errors
862 create no )MORE information and that is on purpose. If you believe, however,
863 that a particular error case is difficult to grasp and would benefit from
864 a )MORE information, then feel free to propose that in an email to
865 <a href="mailto:[email protected]">[email protected]</a>
866 </p>
867 </li>
868 </ul></div>
869 </div>
870 </div>
871 <div class="sect1">
872 <h2 id="_incorrect_apl_results">Incorrect APL results</h2>
873 <div class="sectionbody">
874 <div class="paragraph"><p>If <strong>GNU APL</strong> produces an incorrect result, then you should report it in an
875 email to <a href="mailto:[email protected]">[email protected]</a>. People on that mailing list are gentle and helpful,
876 so don&#8217;t be afraid to report an error.</p></div>
877 <div class="paragraph"><p>However, please note the following: Even though APL as a language is
878 standardized, (ISO Standard 13751 "Programming Language APL, Extended")
879 there exist considerable differences (and also errors) between:</p></div>
880 <div class="ulist"><ul>
881 <li>
882 <p>
883 the APL standard, and
884 </p>
885 </li>
886 <li>
887 <p>
888 the APL documentation of different vendors,
889 </p>
890 </li>
891 <li>
892 <p>
893 and the interpreter implementations of different vendors (including <strong>GNU
894 APL</strong>).
895 </p>
896 </li>
897 </ul></div>
898 <div class="paragraph"><p>In the case of such differences, <strong>GNU APL</strong> usually resolves the issue in the
899 following order:</p></div>
900 <div class="ulist"><ul>
901 <li>
902 <p>
903 IBM APL2 PC implementation (highest priority)
904 </p>
905 </li>
906 <li>
907 <p>
908 IBM APL2 language reference manual
909 </p>
910 </li>
911 <li>
912 <p>
913 ISO Standard 13751
914 </p>
915 </li>
916 <li>
917 <p>
918 Other vendors (lowest priority).
919 </p>
920 </li>
921 </ul></div>
922 <div class="paragraph"><p>Before sending an email to <a href="mailto:[email protected]">[email protected]</a> it may make sense to check if the
923 issue was reported already (and often caused by such differences). However,
924 don&#8217;t be afraid to report the same error twice if you are not sure.</p></div>
925 </div>
926 </div>
927 <div class="sect1">
928 <h2 id="_failed_assertions">Failed Assertions</h2>
929 <div class="sectionbody">
930 <div class="paragraph"><p>An assertion is an expression in the source code that the programmer assumes
931 to be <strong>true</strong> (aka. ≠ 0 in C/C++). It can be very hard to find the origin
932 (root cause) of an error, in particular when many CPU instructions were
933 performed between the root cause and error being detected.</p></div>
934 <div class="paragraph"><p>By making assertions all over place in the source code, the programmer
935 introduces checks along the execution path in order to reduce the number of
936 CPU instructions between a root cause and the point in time where it is
937 being detected. In the C/C++ code, assertions are typically made in the
938 following places:</p></div>
939 <div class="ulist"><ul>
940 <li>
941 <p>
942 near the beginning of a function (also known as pre-condition) to check
943 the arguments passed to the function,
944 </p>
945 </li>
946 <li>
947 <p>
948 after calling a reasonably complex sub-function, and
949 </p>
950 </li>
951 <li>
952 <p>
953 near the end of a function (post-condition) to check the result returned by
954 the function.
955 </p>
956 </li>
957 </ul></div>
958 <div class="paragraph"><p>Assertions are implemented as one or the other of two C/C++ macros called
959 Assert() and Assert1(). As of this writing there are more than 530 Assert()
960 and more than 110 Assert1() macros spread across the <strong>GNU APL</strong> source code.
961 The reason for having different Assert macros is their impact on performance.</p></div>
962 <div class="paragraph"><p>Assert1() macros are intended to test more trivial conditions while Assert()
963 macros test more complex conditions. Every test performed by a single Assert()
964 or Assert1() macro has a (relatively mild) performance impact. However, the
965 large number of Assert() macros increases the total performance impact which
966 may be undesirable. To deal with this, the user may <strong>./configure</strong> one of 3
967 different assertion levels as follows (see also <strong>README-2-configure</strong>):</p></div>
968 <div class="ulist"><ul>
969 <li>
970 <p>
971 <strong>ASSERT_LEVEL_WANTED = 0</strong>: this disables both the Assert1() and the Assert()
972 macro so that the interpreter will have the maximal performance.
973 </p>
974 </li>
975 <li>
976 <p>
977 <strong>ASSERT_LEVEL_WANTED = 1</strong> (the default): this disables the Assert1() macro
978 and enables and the Assert() macro.
979 </p>
980 </li>
981 <li>
982 <p>
983 <strong>ASSERT_LEVEL_WANTED = 2</strong>: this enables both the Assert1() and the Assert()
984 macro.
985 </p>
986 </li>
987 </ul></div>
988 <div class="paragraph"><p>We kindly ask the user to:</p></div>
989 <div class="paragraph"><p>make develop</p></div>
990 <div class="paragraph"><p>which, besides other settings, does <strong>./configure</strong> with ASSERT_LEVEL_WANTED=2,
991 thus enabling both Assert macros and possibly making it easier to find the
992 root cause of a fault.</p></div>
993 <div class="paragraph"><p>As confidence with the source code increases over time, Assert() macros will
994 eventually be converted to Assert1() macros while new code will initially
995 be protected with Assert() macros.</p></div>
996 <div class="sect2">
997 <h3 id="_emulating_failed_assertions">Emulating Failed Assertions</h3>
998 <div class="paragraph"><p>Fortunately we can emulate a failed Assert() or Assert1() macro with ⎕FIO:</p></div>
999 <div class="listingblock">
1000 <div class="content">
1001 <pre>
1002
1003 <code> ⎕FIO ¯16 ⍝ emulate Assert()
1004
1005 ⎕FIO ¯17 ⍝ emulate Assert1()</code>
1006
1007 </pre>
1008 </div></div>
1009 <div class="paragraph"><p>If the respective macro is enabled with ASSERT_LEVEL_WANTED as explained
1010 above, then it produces a stack trace like this:</p></div>
1011 <div class="listingblock">
1012 <div class="content">
1013 <pre>
1014
1015 <code> ⎕FIO ¯16
1016
1017
1018 ==============================================================================
1019 Assertion failed: 0 &amp;&amp; "Simulated Assert() (aka. ⎕FIO ¯16)"
1020 in Function: eval_B
1021 in file: Quad_FIO.cc:1085
1022
1023 C/C++ call stack:
1024
1025 ----------------------------------------
1026 -- Stack trace at Assert.cc:72
1027 ----------------------------------------
1028 0x7FBFD71CBBF7 __libc_start_main
1029 0x563D2320B04A main
1030 0x563D233E822F Workspace::immediate_execution(bool)
1031 0x563D2327411A Command::process_line()
1032 0x563D232742DC Command::process_line(UCS_string&amp;)
1033 0x563D232768A2 Command::do_APL_expression(UCS_string&amp;)
1034 0x563D23276C73 Command::finish_context()
1035 0x563D2329B5D2 Executable::execute_body() const
1036 0x563D2338199C StateIndicator::run()
1037 0x563D232DAF86 Prefix::reduce_statements()
1038 0x563D232DBE92 Prefix::reduce_MISC_F_B_()
1039 0x563D2332D0CF Quad_FIO::eval_B(Value_P) const
1040 0x563D2322C2A0 do_Assert(char const*, char const*, char const*, int)
1041 ========================================
1042
1043 SI stack:
1044
1045 Depth: 0
1046 Exec: 0x563d23f9fde0
1047 Safe exec: 0
1048 Pmode: ◊ ⎕FIO ¯16
1049 PC: 3 (4) RETURN_STATS
1050 Stat: ⎕FIO ¯16
1051 err_code: 0x0
1052
1053 ==============================================================================</code>
1054
1055 </pre>
1056 </div></div>
1057 <div class="paragraph"><p>The C/C++ stack above tells us which assertion has failed and where the
1058 assertion is located in the C/C++ source code (i.e. file Quad_FIO.cc line 1085),
1059 while the )SI stack tells us where that location is in the APL code.</p></div>
1060 <div class="paragraph"><p>This brings us closer to the root cause of a problem. Unfortunately the hex
1061 addresses numbers on the left side of the C/C++ stack dump are process
1062 specific, i.e. the same <strong>⎕FIO ¯16</strong> will produce different numbers in a
1063 different process of the operating system.</p></div>
1064 </div>
1065 <div class="sect2">
1066 <h3 id="_line_numbers_in_stack_traces">Line numbers in Stack Traces</h3>
1067 <div class="paragraph"><p>If the functions on the right side of the C/C++ stack are relatively small (as
1068 most functions in the source code of <strong>GNU APL</strong> are) then we can usually find the
1069 exact source line for each stack entry rather easily using the function name
1070 displayed. For larger functions, the same function may be called from different
1071 source code lines in the same function. This can be improved by converting the
1072 hex addresses on the left into source line numbers as exlained in the
1073 following.</p></div>
1074 <div class="paragraph"><p>First of all the C++ compiler must be instructed to not discard line numbers.
1075 Older g++ versions would always keep line numbers in the object files, but
1076 newer versions do not. The trick is this:</p></div>
1077 <div class="listingblock">
1078 <div class="content">
1079 <pre>
1080
1081 <code>CXXFLAGS="-rdynamic -gdwarf-2" ./configure ...</code>
1082
1083 </pre>
1084 </div></div>
1085 <div class="paragraph"><p><strong>make develop</strong> also does that for you. The CXXFLAGS above tell the <strong>g++</strong>
1086 compiler to use an older object format in which line numbers are not discarded.
1087 If your compiler does not accept <strong>-gdwarf-2</strong> then it probably uses it anyway.</p></div>
1088 <div class="paragraph"><p>The second step is to create a file named <strong>apl.lines</strong>. If <strong>GNU APL</strong> finds this
1089 file then it uses it to map hex addresses to line numbers. In the src
1090 directory, the make target <strong>apl.lines</strong> creates this file (which takes quite a
1091 while and is therefore not created in a standard build). <strong>make apl.lines</strong>
1092 essentially does:</p></div>
1093 <div class="listingblock">
1094 <div class="content">
1095 <pre>
1096
1097 <code>objdump --section=.text --line-numbers --disassemble apl &gt; apl.lines</code>
1098
1099 </pre>
1100 </div></div>
1101 <div class="paragraph"><p>which extracts the line numbers from the apl binary (provided that the
1102 compiler has inserted them - see above). If <strong>GNU APL</strong> finds apl.lines, then
1103 the stack dump looks a little different:</p></div>
1104 <div class="listingblock">
1105 <div class="content">
1106 <pre>
1107
1108 <code> ⎕FIO ¯16
1109
1110 ==============================================================================
1111 Assertion failed: 0 &amp;&amp; "Simulated Assert() (aka. ⎕FIO ¯16)"
1112 in Function: eval_B
1113 in file: Quad_FIO.cc:1085
1114
1115 C/C++ call stack:
1116 total_lines in apl.lines: 618610
1117 assembler lines in apl.lines: 86495
1118 source line numbers found: 86495
1119
1120 ----------------------------------------
1121 -- Stack trace at Assert.cc:72
1122 ----------------------------------------
1123 0x29465EE76BF7 __libc_start_main
1124 0x14CCD2 main at main.cc:635
1125 0x3166E1 Workspace::immediate_execution(bool) at Workspace.cc:273
1126 0x1B1004 Command::process_line() at Command.cc:103
1127 0x1B11C6 Command::process_line(UCS_string&amp;) at Command.cc:139
1128 0x1B378C Command::do_APL_expression(UCS_string&amp;) at Command.cc:329
1129 0x1B3B5D Command::finish_context() at Command.cc:347
1130 0x1D6806 Executable::execute_body() const at Executable.cc:261
1131 0x2B564F StateIndicator::run() at StateIndicator.cc:362
1132 0x211DA4 Prefix::reduce_statements() at Prefix.cc:723 (discriminator 4)
1133 0x212A79 Prefix::reduce_MISC_F_B_() at Prefix.cc:990
1134 0x261E7F Quad_FIO::eval_B(Value_P) const at Quad_FIO.cc:1090
1135 0x16CC03 do_Assert(char const*, char const*, char const*, int) at Assert.cc:74
1136 ========================================
1137
1138 SI stack:
1139
1140 Depth: 0
1141 Exec: 0x561c865a4da0
1142 Safe exec: 0
1143 Pmode: ◊ ⎕FIO ¯16
1144 PC: 3 (4) RETURN_STATS
1145 Stat: ⎕FIO ¯16
1146 err_code: 0x0
1147
1148
1149 ==============================================================================</code>
1150
1151 </pre>
1152 </div></div>
1153 <div class="paragraph"><p>The difference is twofold:</p></div>
1154 <div class="olist arabic"><ol class="arabic">
1155 <li>
1156 <p>
1157 the hex numbers are now relative to the location of the <strong>main()</strong> function of
1158 <strong>GNU APL</strong>, which makes them not only smaller but also identical even in
1159 different processes.
1160 </p>
1161 </li>
1162 <li>
1163 <p>
1164 The source line numbers are now displayed for most hex numbers. Some
1165 addresses can not be resolved, this could be caused by C/C++ function
1166 inlining or calls through function pointers etc.
1167 </p>
1168 </li>
1169 </ol></div>
1170 <div class="paragraph"><p>Needless to say that <strong>GNU APL</strong> trouble-shooters prefer stack traces with hex
1171 numbers resolved to line numbers.</p></div>
1172 <div class="paragraph"><p>Occasionally you may get this message:</p></div>
1173 <div class="listingblock">
1174 <div class="content">
1175 <pre>
1176
1177 <code>...
1178 C/C++ call stack:
1179
1180 Cannot show line numbers, since apl.lines is older than apl.
1181 Consider running 'make apl.lines' in directory
1182 /home/eedjsa/apl-1.8 to fix this
1183 ...</code>
1184
1185 </pre>
1186 </div></div>
1187 <div class="paragraph"><p>This happens if you do <strong>make apl</strong> without a subsequent <strong>make apl.lines</strong>.</p></div>
1188 </div>
1189 <div class="sect2">
1190 <h3 id="_summary_concerning_assertions">Summary concerning Assertions</h3>
1191 <div class="paragraph"><p>The <strong>GNU APL</strong> configuration for troubleshooting purposes is obtained like this:</p></div>
1192 <div class="listingblock">
1193 <div class="content">
1194 <pre>
1195
1196 <code>cd &lt;top-level-directory&gt;
1197 make develop
1198 cd src
1199 make clean
1200 make apl.lines</code>
1201
1202 </pre>
1203 </div></div>
1204 <div class="paragraph"><p>where <strong>top-level-directory</strong> is the directory that contains the <strong>README</strong> files.
1205 Additional troubleshooting options may be used as well. Consider the <strong>make</strong>
1206 target <strong>develop:</strong> in file Makefile.incl (around line 41) only as a template
1207 that can be augmented by other troubleshooting options (see also
1208 <strong>README-2-configure</strong>).</p></div>
1209 </div>
1210 </div>
1211 </div>
1212 <div class="sect1">
1213 <h2 id="_the_check_command">The )CHECK command</h2>
1214 <div class="sectionbody">
1215 <div class="paragraph"><p><strong>GNU APL</strong> provides a command <strong>)CHECK</strong> which is somewhat similar to IBM APL2&#8217;s
1216 command <strong>)CHECK WS</strong>. This command performs an internal check of the internal
1217 data structures of the interpreter.</p></div>
1218 <div class="paragraph"><p>Under normal circumstances, the output of the <strong>)CHECK</strong> command should be:</p></div>
1219 <div class="listingblock">
1220 <div class="content">
1221 <pre>
1222
1223 <code>OK - no stale functions
1224 OK - no stale values
1225 OK - no stale indices
1226 OK - no duplicate parents</code>
1227
1228 </pre>
1229 </div></div>
1230 <div class="paragraph"><p>If not, then there were inconsistencies (primarily memory leaks) that need to
1231 be fixed and should therefore be reported to <a href="mailto:[email protected]">[email protected]</a>. For example,
1232 a <strong>stale value</strong> is an APL value that has memory allocated but is not reachable
1233 any longer via either the symbol table or the interpreter (like an APL
1234 variable) or the body of a defined function (like an APL literal).</p></div>
1235 <div class="paragraph"><p>If a )CHECK command fails, then it is important to remember, or better write
1236 down, which sequence of APL operations has led to the state of the workspace.
1237 <strong>GNU APL</strong> has a command <strong>)HISTORY</strong> which displays the last lines entered.</p></div>
1238 <div class="paragraph"><p>An assertion checks the immediate state of the interpreter and can therefore
1239 not check the entire lifetime of an APL value or function. For this purpose,
1240 <strong>GNU APL</strong> povides a different debugging tool called <strong>Value history</strong>.</p></div>
1241 <div class="paragraph"><p>The Value history tracks the locations in the <strong>GNU APL</strong> source code that have
1242 manipulated a value from its creation (memory allocation) to its destruction
1243 (memory deallocation). This tracking, when enabled, has performance impacts
1244 and is therefore disabled by default.</p></div>
1245 <div class="paragraph"><p>If the )CHECK command indicates stale values, but also under some other error
1246 conditions, the history of a value at fault is being displayed and helps the
1247 <strong>GNU APL</strong> maintainers to locate the problem. The value history is enabled in
1248 <strong>./configure</strong>:</p></div>
1249 <div class="listingblock">
1250 <div class="content">
1251 <pre>
1252
1253 <code> ./configure VALUE_HISTORY_WANTED=yes ...</code>
1254
1255 </pre>
1256 </div></div>
1257 <div class="paragraph"><p>and therefore requires recompilation of the interpreter.</p></div>
1258 </div>
1259 </div>
1260 <div class="sect1">
1261 <h2 id="_logging_facilities">Logging facilities</h2>
1262 <div class="sectionbody">
1263 </div>
1264 </div>
1265 <div class="sect1">
1266 <h2 id="_crashes_of_the_gnu_apl_interpreter">Crashes of the GNU APL interpreter</h2>
1267 <div class="sectionbody">
1268 <div class="paragraph"><p>Some programming errors bypass all built-in debugging tools of GNU and
1269 crash the interpreter rather than returning to the interactive immediate
1270 execution mode of APL.</p></div>
1271 <div class="paragraph"><p>The crash may be silent or accompanied by an error message and it may or may
1272 not create a core file. A core file is an important file if no other
1273 information is printed as to what kind of fault has occurred.</p></div>
1274 <div class="paragraph"><p>In the good old times core files were always produced when a binary executable
1275 crashed. These days the creation of core files may need to be enabled before
1276 the crashing binary is started. In GNU/Linux with its <strong>bash</strong> shell that means:</p></div>
1277 <div class="listingblock">
1278 <div class="content">
1279 <pre>
1280
1281 <code>ulimit -c unlimited # enable core files</code>
1282
1283 </pre>
1284 </div></div>
1285 <div class="paragraph"><p>Instead of <strong>unlimited</strong> you may also use a different file size limit.</p></div>
1286 <div class="paragraph"><p>After a core file was produced (we always assume the interpreter was started
1287 in directory src below the top&#8212;level-directory) you can start the debugger
1288 <strong>gdb</strong> in the src directory with the core file as its second argument:</p></div>
1289 <div class="listingblock">
1290 <div class="content">
1291 <pre>
1292
1293 <code>gdb ./apl core</code>
1294
1295 </pre>
1296 </div></div>
1297 <div class="paragraph"><p>After that, you can use the gdb command <strong>bt</strong> (for <em>backtrace</em>) to show a
1298 stack dump similar to the one discussed earlier. The <strong>GNU APL</strong> maintainer(s)
1299 will appreciate a copy of that stack dump for problems that are difficult to
1300 reproduce.</p></div>
1301 <div class="paragraph"><p>Normally the file is named <em><strong>core</strong></em> and found in the same directory as the
1302 binary, but some GNU/Linux distributions use a different directory for storing
1303 core files. See also <strong>man 5 core</strong>.</p></div>
1304 <div class="paragraph"><p>Finally, try to nail down the root cause with logging facilities (see below).</p></div>
1305 </div>
1306 </div>
1307 <div class="sect1">
1308 <h2 id="_non_reproducible_errors">Non-reproducible Errors</h2>
1309 <div class="sectionbody">
1310 <div class="paragraph"><p>The most difficult to fix errors are those that occur on one machine (usually
1311 your&#8217;s) and not on others.</p></div>
1312 <div class="paragraph"><p>The first thing to locate their root cause it to <strong>./configure</strong> with either no
1313 options or via <strong>make develop</strong> to see if the error is related to specific
1314 <strong>./configure</strong> options.</p></div>
1315 <div class="paragraph"><p>Also, look for compiler warnings when <strong>GNU APL</strong> is built. In the default build,
1316 compiler warnings can be overlooked easiy. <strong>make develop</strong> turns most warnings
1317 into errors so you will see at the end if the build was successful.</p></div>
1318 <div class="sect2">
1319 <h3 id="_optimization">Optimization</h3>
1320 <div class="paragraph"><p>Recently we have seen faults that may have been caused by an overly aggressive
1321 optimization of the <strong>GNU APL</strong> C++ source code. These faults were observed for
1322 the same source code but only when compiled with newer versions of the
1323 same g++ compiler.</p></div>
1324 <div class="paragraph"><p>By default <strong>GNU APL</strong> compiles with optimization level -O2. If a fault is
1325 suspected to be caused by optimization, then it could make sense to also
1326 test the same source code of <strong>GNU APL</strong> without any optimization.</p></div>
1327 <div class="paragraph"><p>To do that:</p></div>
1328 <div class="listingblock">
1329 <div class="content">
1330 <pre>
1331
1332 <code>cd src
1333 find and remove or replace the string -O2 in the relevant Makefile(s)
1334 make clean all</code>
1335
1336 </pre>
1337 </div></div>
1338 </div>
1339 </div>
1340 </div>
1341 <div class="sect1">
1342 <h2 id="_logging_facilities_2">Logging facilities</h2>
1343 <div class="sectionbody">
1344 <div class="paragraph"><p>The source code of <strong>GNU APL</strong> is populated with more than 380 Log() macros.
1345 A Log() macro may or may not print some additional information when the
1346 execution of the APL interpreter reaches them.</p></div>
1347 <div class="paragraph"><p>If all these Log() macros would output something, then even a trivial
1348 APL statement would cause a lot of output in which the relevant information
1349 gets easily lost. For that reason, each Log () macro belongs to one of
1350 currently over 45 Groups called <strong>logging facilities</strong>. Each logging facility
1351 can be turned ON or OFF which causes Log() macros belonging the facility
1352 to print or not to print its information.</p></div>
1353 <div class="paragraph"><p>The large (and increasing) number of logging facilities cause the tests,
1354 whether Log() macro or its respective logging facility is ON or OFF, to have
1355 significant performance impacts. For this reason, <strong>GNU APL</strong> provides two
1356 different methods to control how logging facilities are turned ON or OFF:</p></div>
1357 <div class="olist arabic"><ol class="arabic">
1358 <li>
1359 <p>
1360 static logging
1361 </p>
1362 </li>
1363 <li>
1364 <p>
1365 dynamic logging
1366 </p>
1367 </li>
1368 </ol></div>
1369 <div class="paragraph"><p>The method is selected via <strong>./configure</strong> at compile time (more precisely: at
1370 <strong>./configure</strong> time), see also <strong>README-2-configure</strong>.</p></div>
1371 <div class="sect2">
1372 <h3 id="_static_logging">Static Logging</h3>
1373 <div class="paragraph"><p>Static logging is used with:</p></div>
1374 <div class="listingblock">
1375 <div class="content">
1376 <pre>
1377
1378 <code> ./configure DYNAMIC_LOG_WANTED=no</code>
1379
1380 </pre>
1381 </div></div>
1382 <div class="paragraph"><p>Static logging is also the default, therefore <strong>DYNAMIC_LOG_WANTED=no</strong> is the
1383 same as not using DYNAMIC_LOG_WANTED= in <strong>./configure</strong>.</p></div>
1384 <div class="paragraph"><p>With Static logging, the selection of which logging facility shall be ON is
1385 made by the first argument of the <strong>log_def()</strong> macros in file *src/Logging.def.
1386 A value of 0 means OFF while 1 means ON for the respective logging facility.</p></div>
1387 <div class="paragraph"><p>With static logging, the log_def() macro defines an <strong>enum</strong> value for each
1388 log_def() macro which is a compile-time constant. The compiler will therefore
1389 remove all code (including the ON/OFF for all log_def(0, &#8230;) macros and
1390 also all tests for log_def(1, &#8230;) in all Log() macros. That is:</p></div>
1391 <div class="ulist"><ul>
1392 <li>
1393 <p>
1394 Advantage: Static Logging has little if any performance impacts (none
1395 if all log_def macros are off, and
1396 </p>
1397 </li>
1398 <li>
1399 <p>
1400 Disadvantage: changes of log_def() macros require re-compilation of GNU
1401 APL.
1402 </p>
1403 </li>
1404 </ul></div>
1405 </div>
1406 <div class="sect2">
1407 <h3 id="_dynamic_logging">Dynamic Logging</h3>
1408 <div class="paragraph"><p>Dynamic logging is used with:</p></div>
1409 <div class="listingblock">
1410 <div class="content">
1411 <pre>
1412
1413 <code> ./configure DYNAMIC_LOG_WANTED=yes</code>
1414
1415 </pre>
1416 </div></div>
1417 <div class="paragraph"><p>With dynamic logging, the log_def() macro defines the initial value of a
1418 variable (rather than an enum value) for each logging facility. After the
1419 interpreter was started, the value of each variable can be changed from
1420 OFF to ON (and vice versa) with the <strong>GNU APL</strong> debug command <strong>]LOG</strong> (which
1421 toggles the state of the respective variable).</p></div>
1422 <div class="ulist"><ul>
1423 <li>
1424 <p>
1425 Disadvantage: Dynamic Logging has a small performance impact (even
1426 if all variables are set to OFF) which will accumulate for all Log() macros,
1427 </p>
1428 </li>
1429 <li>
1430 <p>
1431 Advantage: no re-compilation of <strong>GNU APL</strong> is required.
1432 </p>
1433 </li>
1434 </ul></div>
1435 <div class="sect3">
1436 <h4 id="_the_log_command">The ]LOG command</h4>
1437 <div class="paragraph"><p>GNU APL has a few debug commands, which are like standard APL commands but
1438 start with ] instead of ). One of these debug commands is <strong>]LOG</strong> which
1439 controls the logging facilities.</p></div>
1440 <div class="paragraph"><p>If static logging was <strong>./configure</strong>'d then <strong>]LOG</strong> displays an error message
1441 because changing the logging facilities at run-time requires dynamic logging.</p></div>
1442 <div class="listingblock">
1443 <div class="content">
1444 <pre>
1445
1446 <code> ]LOG
1447
1448 Command ]LOG is not available, since dynamic logging was not configured
1449 for this APL interpreter. To enable dynamic logging (which will slightly
1450 decrease performance), recompile the interpreter as follows:
1451
1452 ./configure DYNAMIC_LOG_WANTED=yes (... other configure options)
1453 make
1454 make install (or try: src/apl)
1455
1456 above the src directory.</code>
1457
1458 </pre>
1459 </div></div>
1460 <div class="paragraph"><p>If dynamic logging was ./configure&#8217;d then <strong>]LOG</strong> without an argument displays
1461 the current state (i.e. ON or OFF) of all logging facilities:</p></div>
1462 <div class="listingblock">
1463 <div class="content">
1464 <pre>
1465
1466 <code> ]LOG
1467 1: (OFF) AV details
1468 2: (OFF) new and delete calls
1469 3: (OFF) input from user or testcase file
1470 4: (OFF) parser: parsing
1471 5: (OFF) ... function find_closing()
1472 6: (OFF) ... tokenization
1473 7: (OFF) ... function collect_constants()
1474 8: (OFF) ... create value()
1475 9: (OFF) defined function: fix()
1476 10: (OFF) ... set_line()
1477 11: (OFF) ... load()
1478 12: (OFF) ... execute()
1479 13: (OFF) ... enter/leave
1480 14: (OFF) State indicator: enter/leave
1481 15: (OFF) ... push/pop
1482 16: (OFF) Symbol: lookup
1483 17: (OFF) ... push/pop and )ERASE
1484 18: (OFF) ... resolve
1485 19: (OFF) Value: glue()
1486 20: (OFF) ... erase_stale()
1487 21: (OFF) APL primitive function format
1488 22: (OFF) character conversions
1489 23: (OFF) APL system function Quad-FX
1490 24: (OFF) commands )LOAD, )SAVE, )IN, and )OUT
1491 25: (OFF) more verbose errors
1492 26: (OFF) details of error throwing
1493 27: (OFF) nabla editor
1494 28: (OFF) execute(): state changes
1495 29: (OFF) PrintBuffer: align() function
1496 30: (OFF) Output: cork() functions
1497 31: (OFF) Details of test execution
1498 32: (OFF) Prefix parser
1499 33: (OFF) ... location information
1500 34: (OFF) FunOper1 and FunOper2 functions
1501 35: (OFF) Shared Variable operations
1502 36: (OFF) command line arguments (argc/argv)
1503 37: (OFF) interpreter start-up messages
1504 38: (OFF) optimization messages
1505 39: (OFF) )LOAD and )SAVE details
1506 40: (OFF) Svar_DB signals
1507 41: (OFF) Parallel (multi-core) execution
1508 42: (OFF) EOC handler functionality
1509 43: (OFF) ⎕DLX details
1510 44: (OFF) command ]DOXY
1511 45: (OFF) details of Value allocation
1512 46: (OFF) ⎕TF details
1513 47: (OFF) ⎕PLOT details</code>
1514
1515 </pre>
1516 </div></div>
1517 <div class="paragraph"><p>Otherwise <strong>]LOG N</strong> toggles the state of logging facility N, e.g.:</p></div>
1518 <div class="listingblock">
1519 <div class="content">
1520 <pre>
1521
1522 <code> ]log 25
1523 Logging facility 'more verbose errors' is now ON
1524
1525 ]log 26
1526 Logging facility 'details of error throwing' is now ON</code>
1527
1528 </pre>
1529 </div></div>
1530 </div>
1531 </div>
1532 <div class="sect2">
1533 <h3 id="_logging_facilities_of_interest">Logging Facilities of Interest</h3>
1534 <div class="paragraph"><p>Many of the currently over 40 logging facilities serve a particular purpose
1535 for the maintainers or have become obsolete and are therefore not too useful
1536 for the trouble-shooting performed by the user. The others mentioned below.</p></div>
1537 <div class="sect3">
1538 <h4 id="_log_2_new_and_delete_calls">]Log 2 : new and delete calls</h4>
1539 <div class="paragraph"><p>For tracking the allocation and de-allocation of memory.
1540 To find memo leaks.</p></div>
1541 </div>
1542 <div class="sect3">
1543 <h4 id="_log_25_and_26_apl_errors">]Log 25 and 26 : APL Errors</h4>
1544 <div class="paragraph"><p>An APL ERROR provides enough information as to where an error has occurred
1545 in the APL code, but none as to where that error was detected on the C/C++
1546 code. These logging facilities add this information.</p></div>
1547 </div>
1548 <div class="sect3">
1549 <h4 id="_log_32_prefix_parser">]Log 32 Prefix Parser</h4>
1550 <div class="paragraph"><p>Parsing of APL commands and Expressions. To analyze SYNTAX ERRORs.</p></div>
1551 </div>
1552 <div class="sect3">
1553 <h4 id="_log_37_interpreter_startup">]Log 37 : Interpreter Startup</h4>
1554 <div class="paragraph"><p>Information when the <strong>GNU APL</strong> interpreter starts. This facility can also be
1555 enabled from the command line because the output of interest occurs before
1556 the interpreter accepts commands like <strong>]LOG</strong>.</p></div>
1557 </div>
1558 </div>
1559 </div>
1560 </div>
1561 <div class="sect1">
1562 <h2 id="_intrusive_troubleshooting">Intrusive Troubleshooting</h2>
1563 <div class="sectionbody">
1564 <div class="paragraph"><p>If all the above fails, then it is time for intrusive troubleshooting.
1565 By intrusive troubleshooting we mean that the source code is modified
1566 in such a way that it prints troubleshooting information at source code
1567 locations where no Log() macros have been inserted. The top-level algorithm
1568 for intrusive troubleshooting is this:</p></div>
1569 <div class="listingblock">
1570 <div class="content">
1571 <pre>
1572
1573 <code>loop:
1574 1. modify the source code by adding printouts
1575 2. recompile GNU APL
1576 3. run apl and reproduce the problem
1577 4. repeat until the error (or a least a source code file or function
1578 responsible for the error) was found.</code>
1579
1580 </pre>
1581 </div></div>
1582 <div class="paragraph"><p>All this is usually done in the <strong>src</strong> directory where most of the source
1583 files are located and where the compile result will be stored.</p></div>
1584 <div class="paragraph"><p>Alternatively one could use a debugger like gdb for the same purpose,
1585 setting breakpoints and printing data. However, the author prefers to modify
1586 the source code, in particular if more than one printout is needed to
1587 find a fault.</p></div>
1588 <div class="paragraph"><p>To simplify the source code for printouts, <strong>GNU APL</strong> has defined two powerful
1589 macros <strong>LOC</strong> and <strong>Q()</strong>. The <strong>Q()</strong> macro is used exclusively for intrusive
1590 troubleshooting while the LOC macro is also used for other purposes in the
1591 source code (with more than 1700 invocations as of this writing).
1592 Understanding the LOC macro is therefore a prerequisite for understanding the
1593 <strong>GNU APL</strong> code.</p></div>
1594 <div class="sect2">
1595 <h3 id="_the_loc_macro">The LOC Macro</h3>
1596 <div class="paragraph"><p>The LOC macro is a short but somewhat tricky construction based on two
1597 other macros <strong>Loc</strong> and <strong>STR</strong>. The LOC macro takes no arguments and is
1598 therefore used without (), <strong>STR()</strong> takes one argument and <strong>Loc(x) takes
1599 two arguments. All three macros *LOC</strong>, <strong>Loc()</strong>, and <strong>STR()</strong> are <strong>#defined</strong>
1600 in file <strong>Common.hh</strong> which makes them available in practically every source
1601 file. The definitions are:</p></div>
1602 <div class="listingblock">
1603 <div class="content">
1604 <pre>
1605
1606 <code>#define STR(x) #x
1607
1608 #define LOC Loc(__FILE__, __LINE__)
1609
1610 #define Loc(f, l) f ":" STR(l)</code>
1611
1612 </pre>
1613 </div></div>
1614 <div class="paragraph"><p>How does this work? Suppose we have a 13-line C++ file <strong>test.cc</strong> like this:</p></div>
1615 <div class="listingblock">
1616 <div class="content">
1617 <pre>
1618
1619 <code>#include &lt;iostream&gt; // for cout
1620
1621 #define LOC Loc(__FILE__, __LINE__)
1622 #define Loc(f, l) f ":" STR(l)
1623 #define STR(x) #x
1624
1625 int
1626 main()
1627 {
1628 std::cout &lt;&lt; LOC &lt;&lt; std::endl; // line 10 of test.cc
1629 std::cout &lt;&lt; LOC &lt;&lt; std::endl; // line 11 of test.cc
1630 std::cout &lt;&lt; LOC &lt;&lt; std::endl; // line 12 of test.cc
1631 }</code>
1632
1633 </pre>
1634 </div></div>
1635 <div class="paragraph"><p>If we compile and run this file then it produces the following output:</p></div>
1636 <div class="listingblock">
1637 <div class="content">
1638 <pre>
1639
1640 <code>test.cc:10
1641 test.cc:11
1642 test.cc:12</code>
1643
1644 </pre>
1645 </div></div>
1646 <div class="paragraph"><p>That is, LOC expands to a string literal that consists of the filename in
1647 which LOC was used, followed by a colon, followed by the line number in which
1648 LOC was used. String literals have the advantage that they are produced
1649 at compile time and can be passed as function arguments at almost no
1650 performance cost.</p></div>
1651 <div class="paragraph"><p>Now lets see how <strong>LOC</strong> works. Consider the first <strong>LOC</strong> on line <strong>10</strong> of
1652 file <strong>test.cc</strong>. Then:</p></div>
1653 <div class="olist arabic"><ol class="arabic">
1654 <li>
1655 <p>
1656 macro <strong>LOC</strong> expands to <strong>Loc(__FILE__, __LINE__)</strong>
1657 </p>
1658 </li>
1659 <li>
1660 <p>
1661 <strong>__FILE__</strong> expands to literal <strong>"test.cc"</strong>
1662 </p>
1663 </li>
1664 <li>
1665 <p>
1666 <strong>__LINE__</strong> expands to the line number <strong>10</strong>, so that (so far)
1667 </p>
1668 </li>
1669 <li>
1670 <p>
1671 <strong>LOC</strong> expands to <strong>Loc("test.cc", 10)</strong>
1672 </p>
1673 </li>
1674 <li>
1675 <p>
1676 <strong>Loc("test.cc", 10)</strong> expands to <strong>"test.cc" ":" STR(10)</strong>
1677 </p>
1678 </li>
1679 <li>
1680 <p>
1681 <strong>STR(10)</strong> expands to <strong>"10"</strong> so that (so far) LOC expands to
1682 <strong>"test.cc" ":" "10"</strong>
1683 </p>
1684 </li>
1685 <li>
1686 <p>
1687 the compiler combines the 3 adjacent string literals <strong>"test.cc"</strong>, <strong>":"</strong>, and
1688 <strong>"10"</strong> into the single string literal <strong>"test.cc:10"</strong> which is then printed.
1689 </p>
1690 </li>
1691 </ol></div>
1692 <div class="paragraph"><p>This is quite some work for the compiler, but the result is such that the
1693 run-time cost for <strong>GNU APL</strong> is only the loading of the string literal when
1694 <strong>GNU APL</strong> starts.</p></div>
1695 </div>
1696 <div class="sect2">
1697 <h3 id="_the_q_macro">The Q Macro</h3>
1698 <div class="paragraph"><p>The second trick is the Q() macro which is defined as</p></div>
1699 <div class="listingblock">
1700 <div class="content">
1701 <pre>
1702
1703 <code>#define Q(x) get_CERR() &lt;&lt; std::left &lt;&lt; setw(20) &lt;&lt; #x ":" &lt;&lt; " '" &lt;&lt; x &lt;&lt; "' at " LOC &lt;&lt; endl;</code>
1704
1705 </pre>
1706 </div></div>
1707 <div class="paragraph"><p>In this definition <strong>get_CERR()</strong> is a function which returns an output channel
1708 such as <strong>std::cerr</strong> (or <strong>stderr</strong> in C). The operator &lt;&lt; is overloaded a lot
1709 and in such a way that commonly used data types in <strong>GNU APL</strong> are being printed
1710 nicely. A consequence of the overloading is that <strong>Q()</strong> macro can be used
1711 with many different data types without the burdon to properly format them
1712 for the debug output.</p></div>
1713 <div class="paragraph"><p><strong>Q(x)</strong> uses the <strong>LOC</strong> macro to get the source file name and line number of its
1714 invocation and essentially prints <strong>x</strong> in a suitable format and followed by
1715 its source code location. For example:</p></div>
1716 <div class="listingblock">
1717 <div class="content">
1718 <pre>
1719
1720 <code>#include &lt;iostream&gt; // for cout
1721 #include &lt;iomanip&gt; // for setw
1722
1723 using namespace std;
1724
1725 #define STR(x) #x
1726 #define LOC Loc(__FILE__, __LINE__)
1727 #define Loc(f, l) f ":" STR(l)
1728
1729 #define Q(x) cerr &lt;&lt; std::left &lt;&lt; std::setw(20) &lt;&lt; #x ":" &lt;&lt; " '" &lt;&lt; x &lt;&lt; "' at " LOC &lt;&lt; std::endl;
1730
1731 int
1732 main()
1733 {
1734 Q("Hello") // line 15
1735 Q(10)
1736 Q(LOC)
1737 }</code>
1738
1739 </pre>
1740 </div></div>
1741 <div class="paragraph"><p>which, when compiled, produces:</p></div>
1742 <div class="listingblock">
1743 <div class="content">
1744 <pre>
1745
1746 <code>"Hello": 'Hello' at test.cc:15
1747 10: '10' at test.cc:16
1748 LOC: 'test.cc:17' at test.cc:17</code>
1749
1750 </pre>
1751 </div></div>
1752 <div class="paragraph"><p>With these prerequisites intrusive troubleshooting boils down to spreading
1753 <strong>Q()</strong> macros in different source files until the fault is found.</p></div>
1754 <div class="paragraph"><p>A frequent question is not the value of a C++ variable, but rather if (and
1755 when) a particular source code line of code is reached. To answer this
1756 question just insert <strong>Q(LOC)</strong> or <strong>Q(0)</strong> on the line of interest.</p></div>
1757 <div class="paragraph"><p>Another useful helper is <strong>subversion</strong> (svn). After having made multiple
1758 insertions of <strong>Q()</strong> macros in various source files (and hopefully having
1759 located the fault this way), simply do</p></div>
1760 <div class="listingblock">
1761 <div class="content">
1762 <pre>
1763
1764 <code>svn revert *</code>
1765
1766 </pre>
1767 </div></div>
1768 <div class="paragraph"><p>in the <strong>src</strong> directory which undoes all changes you made.</p></div>
1769 </div>
1770 </div>
1771 </div>
1772 <div class="sect1">
1773 <h2 id="_keep_it_short_and_simple">Keep It Short and Simple</h2>
1774 <div class="sectionbody">
1775 <div class="paragraph"><p>The first thing to check before reporting an error is to make sure that you
1776 have compiled and installed the latest GNU APL version from subversion (SVN)
1777 or git.</p></div>
1778 <div class="paragraph"><p>From a maintainer&#8217;s perspective, the trouble reports that are appreciated the
1779 most are the short ones. Locating a fault usually requires multiple
1780 repetitions of the sequence that causes the fault. Consider two extremes:</p></div>
1781 <div class="olist upperalpha"><ol class="upperalpha">
1782 <li>
1783 <p>
1784 The fault can be reproduced by executing a handful of APL lines in
1785 immediate execution mode, possibly accompanied by one or two ∇-defined
1786 functions or lambdas.
1787 </p>
1788 </li>
1789 <li>
1790 <p>
1791 A tar file contains a workspace, possibly )COPYing other workspaces.
1792 In order to reproduce the fault, the workspace has to be )LOADed and
1793 started in a specific way in order to reproduce the error.
1794 </p>
1795 </li>
1796 </ol></div>
1797 <div class="paragraph"><p>In case A. the maintainer can simply copy the lines into a small apl script
1798 created for fixing the fault. That script can then be repeated again and again
1799 by starting the script from the command line of a shell.</p></div>
1800 <div class="paragraph"><p>In case B. the maintainer must first install the workspaces that come with the
1801 fault. Then start apl, )LOAD the workspace and figure out:</p></div>
1802 <div class="ulist"><ul>
1803 <li>
1804 <p>
1805 how the workspace shall be started,
1806 </p>
1807 </li>
1808 <li>
1809 <p>
1810 how the defined functions in the workspace appear, how they interact,
1811 and which ones are related to the fault,
1812 </p>
1813 </li>
1814 <li>
1815 <p>
1816 and so on.
1817 </p>
1818 </li>
1819 </ul></div>
1820 <div class="paragraph"><p>Case B. creates a lot of overhead for the maintainer that does very little to
1821 find the fault. Although sometimes a complex workspace is needed to reproduce
1822 a fault, this is rather rare and almost all errors reported so far could be
1823 reduced to a small number of APL lines.</p></div>
1824 <div class="paragraph"><p>Last but not least, please have a look here:</p></div>
1825 <div class="paragraph"><p><a href="https://www.gnu.org/software/libc/manual/html_node/Reporting-Bugs.html">https://www.gnu.org/software/libc/manual/html_node/Reporting-Bugs.html</a></p></div>
1826 </div>
1827 </div>
1828 </div>
1829 <div id="footnotes"><hr /></div>
1830 <div id="footer">
1831 <div id="footer-text">
1832 Last updated
1833 2024-03-14 14:48:59 CET
1834 </div>
1835 </div>
1836 </body>
1837 </html>