0

Does MicroFocus Cobol or any other, have a feature equivalent to Python's sys.settrace()? The function passed as a parameter to such a tracing function, would be called after the execution of each line of the source code.

Benny
  • 607
  • 7
  • 20
  • What are you trying to achieve? The short answer is no, but if we know what you want, there may be some resolution - hard to say, for now :-) – Bill Woodger Jun 04 '13 at 20:49
  • Well, if you're happy, we're happy.:-) If that was all the answer you wanted, why make the question so complex? "How can I trace the flow of a Cobol program using the source line-numbers of paragraphs/SECTIONS, and nothing more complicated that that please?" – Bill Woodger Jun 05 '13 at 18:40

2 Answers2

1

It's not an exact equivalent, but you can use READY TRACE for debugging. Enable it with the TRACE compiler directive.

David Gorsline
  • 4,933
  • 12
  • 31
  • 36
1

OpenCOBOL supports

-ftrace               Generate trace code
                    - Executed SECTION/PARAGRAPH
-ftraceall            Generate trace code
                    - Executed SECTION/PARAGRAPH/STATEMENTS
                    - Turned on by -debug

cobc command line options. This isn't quite the same as the Python point of view, but outputs a tracer round on entry to sections, paragraphs and sentences when enabled. No doubt other compilers will have something equivalent. Along with the READY TRACE, debugging and >>D other debugging features like those allowed with DECLARATIVES. http://opencobol.add1tocobol.com/#declaratives

procedure division.
declaratives.
handle-errors section.
    use after standard error procedure on filename-1.
handle-error.
    display "Something bad happened with " filename-1 end-display.
.
helpful-debug section.
    use for debugging on main-file.
help-me.
    display "Just touched " main-file end-display.
.
end declaratives.
Brian Tiffin
  • 3,978
  • 1
  • 24
  • 34