FR: new command that shows the location of a variable
.. or at least the place where it is defined, in which case the user can do a follow-up list some.cpy:53
.
This mimics the command "show definition" in MF animator and other debuggers (the use is to see both the variable definition and its context).
I guess this information would needed to be included in the internal symbol table - or could that be somehow found at runtime?
For adding it into the symbol table this would need additional lookup, most reasonably likely adjustment to cob_dump_field_ext
, maybe similar to:
P_dump:
{
cob_field f0;
memset(&f0,0,sizeof(f0));
/* Dump WORKING-STORAGE */
cob_dump_output("WORKING-STORAGE");
cob_dump_field_ext ( 1, "ME-EXCH-BASIS", COB_SET_FLD(f0, 3, b_8, &a_3), 0, 0); /* prog.cob:55 */
cob_dump_field_ext ( 5, "ME-X-FX", COB_SET_FLD(f0, 1, b_8, &a_1), 0, 0); /* :56 */
cob_dump_field_ext ( 5, "ME-X-P", COB_SET_FLD(f0, 1, b_8 + 1, &a_1), 0, 0); /* :57 */
cob_dump_field_ext ( 5, "ME-X-C", COB_SET_FLD(f0, 1, b_8 + 2, &a_1), 0, 0); /* :58 */
/* cob_dump_field_ext ( 1, "FILLER", COB_SET_FLD(f0, 3, b_8, &a_1), 0, 0); REDEFINES */ /* :59 */
/* cob_dump_field_ext (88, "SW-EXCH-BASIS-KOMPLETT", COB_SET_FLD(f0, 3, b_8, &a_1), 0, 0); VALUE (cob_field *)&c_3 */ /* :60 */
/* cob_dump_field_ext ( 1, "ME-EXCH-RMS", COB_SET_FLD(f0, 1, b_14, &a_3), 0, 0); */
/* cob_dump_field_ext ( 5, "ME-X-RMS", &f_15, 0, 0); */
/* cob_dump_field_ext ( 1, "FILLER", &f_16, 0, 0); REDEFINES */
/* cob_dump_field_ext (88, "SW-EXCH-RMS-KOMPLETT", &f_16, 0, 0); VALUE (cob_field *)&c_1 OR (cob_field *)&c_4 */
cob_dump_field_ext ( 1, "SOME-VAR", COB_SET_FLD(f19, 3, b_55, &a_3), 0, 0); /* sub1/some.cpy:12 */
}
Note: GC3.2 creates #line
directives to the place where the variables are initialized, but I don't see a direct option how to use that in the python extension.