From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12945 invoked by alias); 9 Oct 2013 22:31:20 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 12932 invoked by uid 89); 9 Oct 2013 22:31:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=BAYES_05,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mout.web.de Received: from mout.web.de (HELO mout.web.de) (212.227.17.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 09 Oct 2013 22:31:17 +0000 Received: from [192.168.100.21] ([95.91.99.91]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MfYj1-1VAQ262nAx-00P3js for ; Thu, 10 Oct 2013 00:31:13 +0200 Message-ID: <5255D935.30609@web.de> Date: Wed, 09 Oct 2013 22:31:00 -0000 From: Simon Sobisch User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: gdb@sourceware.org Subject: Question about getting GNU Cobol work with GDB References: <525328B4.3020405@web.de> In-Reply-To: <525328B4.3020405@web.de> X-Forwarded-Message-Id: <525328B4.3020405@web.de> Content-Type: multipart/mixed; boundary="------------090206020805020100070309" X-SW-Source: 2013-10/txt/msg00038.txt.bz2 This is a multi-part message in MIME format. --------------090206020805020100070309 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2483 [posted before to gdb@gnu.org] 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 --------------090206020805020100070309 Content-Type: text/plain; charset=windows-1252; name="HELLO.c.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="HELLO.c.h" Content-length: 1374 /* Generated by cobc 1.1.0 */ /* Generated from HELLO.cob */ /* Generated at Okt 07 2013 23:18:42 CEST */ /* OpenCOBOL build date Apr 20 2013 02:29:02 */ /* OpenCOBOL package date Feb 06 2009 10:30:55 CET */ /* Compile command cobc -g -debug -x --save-temps HELLO.cob */ /* Frame stack declaration */ struct cob_frame { int perform_through; void *return_address; }; /* Union for CALL statement */ union cob_call_union { void *(*funcptr)(); int (*funcint)(); void *func_void; }; union cob_call_union cob_unifunc; /* Data storage */ /* PROGRAM-ID : HELLO */ static unsigned char b_1[4] __attribute__((aligned)); /* RETURN-CODE */ static unsigned char b_6[80] __attribute__((aligned)); /* output-msg */ /* End of data storage */ /* Attributes */ static const cob_field_attr a_1 = {33, 0, 0, 0, NULL}; /* Fields */ /* PROGRAM-ID : HELLO */ static cob_field f_6 = {80, b_6, &a_1}; /* output-msg */ static cob_field f_7 = {50, NULL, &a_1}; /* user-input */ static cob_field f_8 = {1, NULL, &a_1}; /* dummy-var */ /* End of fields */ /* Constants */ static cob_field c_1 = {21, (unsigned char *)"Input name to greet: ", &a_1}; static cob_field c_2 = {12, (unsigned char *)"Hello World!", &a_1}; static cob_field c_3 = {7, (unsigned char *)"Hello \"", &a_1}; static cob_field c_4 = {2, (unsigned char *)"\"!", &a_1}; --------------090206020805020100070309 Content-Type: text/plain; charset=windows-1252; name="HELLO.c.l.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="HELLO.c.l.h" Content-length: 537 /* Generated by cobc 1.1.0 */ /* Generated from HELLO.cob */ /* Generated at Okt 07 2013 23:18:42 CEST */ /* OpenCOBOL build date Apr 20 2013 02:29:02 */ /* OpenCOBOL package date Feb 06 2009 10:30:55 CET */ /* Compile command cobc -g -debug -x --save-temps HELLO.cob */ /* Define perform frame stack */ struct cob_frame *frame_overflow; struct cob_frame *frame_ptr; struct cob_frame frame_stack[255]; unsigned char *b_7 = NULL; /* user-input */ unsigned char *b_8 = NULL; /* dummy-var */ --------------090206020805020100070309 Content-Type: text/plain; charset=windows-1252; name="HELLO.cob" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="HELLO.cob" Content-length: 1091 * Sample COBOL program IDENTIFICATION DIVISION. PROGRAM-ID. 'HELLO'. DATA DIVISION. * WORKING-STORAGE SECTION. 78 input-msg value 'Input name to greet: '. 77 output-msg pic x(80). * LOCAL-STORAGE SECTION. 77 user-input pic x(50). 77 dummy-var pic x(01). * PROCEDURE DIVISION. DISPLAY input-msg END-DISPLAY ACCEPT user-input END-ACCEPT IF user-input = SPACES DISPLAY "Hello World!" END-DISPLAY ELSE 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 DISPLAY FUNCTION TRIM (output-msg) END-DISPLAY END-IF * ACCEPT dummy-var END-ACCEPT * STOP RUN. --------------090206020805020100070309 Content-Type: text/plain; charset=windows-1252; name="HELLO.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="HELLO.c" Content-length: 4796 /* Generated by cobc 1.1.0 */ /* Generated from HELLO.cob */ /* Generated at Okt 07 2013 23:18:42 CEST */ /* OpenCOBOL build date Apr 20 2013 02:29:02 */ /* OpenCOBOL package date Feb 06 2009 10:30:55 CET */ /* Compile command cobc -g -debug -x --save-temps HELLO.cob */ #define __USE_STRING_INLINES 1 #include #include #include #include #include #define COB_SOURCE_FILE "HELLO.cob" #define COB_PACKAGE_VERSION "1.1" #define COB_PATCH_LEVEL 0 /* Global variables */ #include "HELLO.c.h" /* Function prototypes */ int HELLO (); static int HELLO_ (const int); /* Main function */ int main (int argc, char **argv) { cob_init (argc, argv); cob_stop_run (HELLO ()); } /* Functions */ int HELLO () { return HELLO_ (0); } static int HELLO_ (const int entry) { /* Local variables */ #include "HELLO.c.l.h" static int initialized = 0; static cob_field *cob_user_parameters[COB_MAX_FIELD_PARAMS]; static struct cob_module module = { NULL, NULL, NULL, NULL, cob_user_parameters, 0, '.', '$', ',', 1, 1, 1, 0 }; /* Start of function code */ /* CANCEL callback handling */ if (unlikely(entry < 0)) { if (!initialized) { return 0; } initialized = 0; return 0; } /* Initialize frame stack */ frame_ptr = &frame_stack[0]; frame_ptr->perform_through = 0; frame_overflow = &frame_stack[COB_STACK_SIZE - 1]; /* Push module stack */ module.next = cob_current_module; cob_current_module = &module; /* Initialize program */ if (unlikely(initialized == 0)) { if (!cob_initialized) { cob_fatal_error (COB_FERROR_INITIALIZED); } cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL); (*(int *) (b_1)) = 0; memset (b_6, 32, 80); initialized = 1; } /* Allocate LOCAL storage */ b_7 = cob_malloc (50); b_8 = cob_malloc (1); /* Initialialize LOCAL storage */ memset (b_7, 32, 50); *(unsigned char *)(b_8) = 32; cob_save_call_params = cob_call_params; /* Entry dispatch */ goto l_2; /* PROCEDURE DIVISION */ /* Entry HELLO */ l_2:; /* MAIN SECTION */ /* MAIN PARAGRAPH */ /* HELLO.cob:15: DISPLAY */ cob_set_location ("HELLO", "HELLO.cob", 15, "MAIN SECTION", "MAIN PARAGRAPH", "DISPLAY"); { cob_display (0, 1, 1, &c_1); } /* HELLO.cob:17: ACCEPT */ cob_set_location ("HELLO", "HELLO.cob", 17, "MAIN SECTION", "MAIN PARAGRAPH", "ACCEPT"); { cob_accept ((f_7.data = b_7, &f_7)); } /* HELLO.cob:19: IF */ cob_set_location ("HELLO", "HELLO.cob", 19, "MAIN SECTION", "MAIN PARAGRAPH", "IF"); { if (((int)cob_cmp ((f_7.data = b_7, &f_7), &cob_space) == 0)) { /* HELLO.cob:20: DISPLAY */ cob_set_location ("HELLO", "HELLO.cob", 20, "MAIN SECTION", "MAIN PARAGRAPH", "DISPLAY"); { cob_display (0, 1, 1, &c_2); } } else { /* 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 (); } /* HELLO.cob:30: DISPLAY */ cob_set_location ("HELLO", "HELLO.cob", 30, "MAIN SECTION", "MAIN PARAGRAPH", "DISPLAY"); { cob_display (0, 1, 1, cob_intr_trim (0, 0, &f_6, 0)); } } } /* HELLO.cob:34: ACCEPT */ cob_set_location ("HELLO", "HELLO.cob", 34, "MAIN SECTION", "MAIN PARAGRAPH", "ACCEPT"); { cob_accept ((f_8.data = b_8, &f_8)); } /* HELLO.cob:36: STOP */ cob_set_location ("HELLO", "HELLO.cob", 36, "MAIN SECTION", "MAIN PARAGRAPH", "STOP"); { cob_stop_run ((*(int *) (b_1))); } /* Program exit */ /* Deallocate LOCAL storage */ if (b_8) { free (b_8); b_8 = NULL; } if (b_7) { free (b_7); b_7 = NULL; } /* Pop module stack */ cob_current_module = cob_current_module->next; /* Program return */ return (*(int *) (b_1)); } /* End functions */ --------------090206020805020100070309--