RE: Question about getting GNU Cobol work with GDB

Madan Teodor-TEMADAN1 <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <B6CD0A5F6B061F49B5DA45DABDD419230A147C20@039-SN2MPN1-011.039d.mgd.msft.net>
To see COBOL sources instead of generated C, you could emit #line pragma in the generated source. That should cover setting breakpoints as well.
See http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html 

Teodor Madan

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Simon Sobisch
Sent: Thursday, October 10, 2013 01:31
To: [email protected]
Subject: Question about getting GNU Cobol work with GDB


[posted before to [email protected]]

Hi co-hackers,

GNU Cobol (formerly OpenCOBOL) translates COBOL to C (compiling it with GCC later on).
We try to use GDB as debugging frontend but are unsure how some points can be reached without actually patching the GDB (if it's possible at all).
As one of the maintainers of GNU Cobol I write to you with the hope that we can get as far as possible.

A sample is attached, snippets:

HELLO.cob:

                INSPECT user-input REPLACING TRAILING SPACES BY LOW-VALUE
                MOVE SPACES TO output-msg
                STRING 'Hello "'  DELIMITED BY SIZE
                       user-input DELIMITED BY LOW-VALUE
                       '"!'       DELIMITED BY SIZE
                       INTO output-msg
                END-STRING

HELLO.c[h,l.h]

static cob_field f_6	= {80, b_6, &a_1};	/* output-msg */
static cob_field f_7	= {50, NULL, &a_1};	/* user-input */

static int
HELLO_ (const int entry)


	// [...]

          unsigned char	*b_7 = NULL;	/* user-input */

	// [...]

          /* HELLO.cob:23: INSPECT */

          cob_set_location ("HELLO", "HELLO.cob", 23, "MAIN SECTION", "MAIN PARAGRAPH", "INSPECT");
          {
            cob_inspect_init ((f_7.data = b_7, &f_7), 1);
            cob_inspect_start ();
            cob_inspect_trailing (&cob_low, &cob_space);
            cob_inspect_finish ();
          }
          /* HELLO.cob:24: MOVE */
          cob_set_location ("HELLO", "HELLO.cob", 24, "MAIN SECTION", "MAIN PARAGRAPH", "MOVE");
          {
            memset (b_6, 32, 80);
          }
          /* HELLO.cob:25: STRING */
          cob_set_location ("HELLO", "HELLO.cob", 25, "MAIN SECTION", "MAIN PARAGRAPH", "STRING");
          {
            cob_string_init (&f_6, 0);
            cob_string_delimited (0);
            cob_string_append (&c_3);
            cob_string_delimited (&cob_low);
            cob_string_append ((f_7.data = b_7, &f_7));
            cob_string_delimited (0);
            cob_string_append (&c_4);
            cob_string_finish ();
          }

	// [...]
}

Not clear is how to
- let the programmer see only the COBOL source, not the C source, while stepping
- let the programmer view/change/... COBOL variables (there is a mapping like you can see above)
- set breakpoints within the COBOL source

We're free to add directives and other necessary stuff into the generated C files, even performing "stuff" at runtime, if this helps.

Thank you for your answers,
Simon Sobisch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.