core-dump debugging does not work "No stack." -> remove of calls to inferior (especially cob_malloc) necessary
To leverage GDBs features I've tested debugging a core dump today. While it works in general (complete stack and all variables in "C" are visible), it does not work with cobcd.oy
The following is how I've did that:
1 create dump
$ mygdbwrapper MYPROG # stops at breakpoint cob_runtime_error (gdb) gcore /tmp/MYPROG.core.dump Saved corefile /tmp/MYPROG.core.dump (gdb) quit
2 load dump in a different terminal
$ CPRINT=1 gdb cobcrun /tmp/tst.core.dump --eval-command="set solib-search-path $COB_LIBRARY_PATH" Reading symbols from cobcrun... warning: Could not load shared library symbols for 101 libraries, e.g. ./MYPROG.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib64/libthread_db.so.1". Core was generated by '/opt/gnucobol/bin/cobcrun MPROG'. Program terminated with signal SIGTRAP, Trace/breakpoint trap. #0 cob_runtime_error (fmt=0x7ffff7bcbc76 "%s") at common.c:7191 7191 int more_error_procedures = 1; Reading symbols from /tmp/tst/MYPROG.so... registering CPrint (Usage is "cprint" <COBOL identifier>") [Version 4.5] registering CWatch (Usage is "cwatch <COBOL identifier>") Reading symbols from /home/me/tst/PROG77.so... Reading symbols from /tmp/tst/PROG47.so... [99 more] (gdb) bt #0 cob_runtime_error (fmt=0x7ffff7bcbc76 "%s") at common.c:7191 #1 0x00007ffff7ba6f3c in cob_call_error () at call.c:1026 #2 0x00007ffff7ba7356 in cob_call_field (f=0x7fffe84e71f0 <VARIABLE_STRING_OBXXX_COB+176>, cs=0x0, errind=1, fold_case=0) at call.c:1164 #3 0x00007fffe813dfda in MYPROG_ (entry=0) at /tmp/tst/src/MYPROG.cob:188 #4 0x00007fffe81173a1 in MYPROG_ (entry=6596720) at /tmp/tst/src/MYPROG.cob:134 #5 0x0000000000401a00 in main (argc=2, argv=0x7fffffffc3b8) at cobcrun.c:421 (gdb) f 3 #3 0x00007fffe813dfda in MYPROG_ (entry=0) at tmp/tst/src/MYPROG.cob:188 271 MOVE "TST" TO VAR. (gdb) cprint VAR No stack. (gdb) p cob_source_line $1 = 188 (gdb) quit
SomedayTM we should also be able to debug coredumps. Other than the changes that may have been implemented to solve #28 (closed) we have to think about the question how to provide cbl-dbg with the variable data.
What definitely does not work is to query the running program - as there is none available.