Print debugging statement: Difference between revisions
Content added Content deleted
(Add COBOL) |
|||
Line 48: | Line 48: | ||
result: 10 |
result: 10 |
||
</pre> |
</pre> |
||
=={{header|COBOL}}== |
|||
Works with GnuCOBOL. |
|||
Explicit debug usually just uses DISPLAY, and usually directed at SYSERR. Compiler Directing Facility debug is supported with <code>>>D</code> directive statements. GnuCOBOL also supports full on line step tracing, controlled by both compile time switch, <code>-ftraceall</code>, and a truthy setting in a `COB_SET_TRACE` environment variable (so program step logging can be switched on and off without a recompile (for tracking down pesky production run mysteries)). |
|||
<lang cobol>gcobol*> |
|||
*> steptrace.cob |
|||
*> Tectonics: cobc -xj -fdebugging-line -ftraceall steptrace.cob |
|||
*> export COB_SET_TRACE=Y |
|||
*> |
|||
identification division. |
|||
program-id. steptrace. |
|||
data division. |
|||
working-storage section. |
|||
procedure division. |
|||
steptrace-main. |
|||
display "explicit line" upon syserr |
|||
>>Ddisplay "debug line" upon syserr |
|||
goback. |
|||
end program steptrace.</lang> |
|||
That is fixed form COBOL, columns 1 through 6 ignored by the preprocessor (historical format, from the days of punch card input) with column 7 being a special indicator column, star for comments, dash for continuations, and D is supported by GnuCOBOL for Debug lines. The <code>>>D</code> form is a newer addition to the Compiler Directing Facility, and can float anywhere on a free format compile line. |
|||
{{out}} |
|||
<pre>prompt$ cobc -xj -fdebugging-line -ftraceall steptrace.cob |
|||
explicit line |
|||
debug line |
|||
prompt$ cobc -xj -ftraceall steptrace.cob |
|||
explicit line |
|||
prompt$ export COB_SET_TRACE=Y |
|||
prompt$ ./steptrace |
|||
Source: 'steptrace.cob' |
|||
Program-Id: steptrace Entry: steptrace Line: 22 |
|||
Program-Id: steptrace Section: (None) Line: 22 |
|||
Program-Id: steptrace Paragraph: steptrace-main Line: 22 |
|||
Program-Id: steptrace Statement: DISPLAY Line: 24 |
|||
explicit line |
|||
Program-Id: steptrace Statement: GOBACK Line: 28 |
|||
Program-Id: steptrace Exit: steptrace</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |