marcsosduma / cobgdb

Command-Line Debugger for GnuCOBOL on Linux and Windows
GNU General Public License v3.0
5 stars 1 forks source link

FR: display Variable definition from Working-Storage #26

Open eugeniodilo opened 8 months ago

eugeniodilo commented 8 months ago

during a session of debugging and animating the procedure division code, it would be useful to be able to click on a variable to jump to the working-storage where the variable is defined to see its definition clearly and then be able to return with another click to the instruction in execution to continue with debugging.

for example:

GitMensch commented 8 months ago

I agree and by coincidence I've created a FR to provide that in cobcd 21 hours ago :-) https://gitlab.cobolworx.com/COBOLworx/cbl-gdb/-/issues/102

(you possibly find more relevant issues there, including closed ones, that you may want to test here)

The issue: there's likely no code that cobgdb can analyze for that - in this case it would have to use the symbol listing -t- -Xref -fno-tsource (which commonly won't work as it doesn't provide the source names - and I have no clue why this never occurred to me).

Keep in mind that variables may be defined through TYPEDEFs and with REPLACE and most important: would commonly be in a copybook.

eugeniodilo commented 8 months ago

It might be simpler and better to add a new command (D) = show Definition, without touching the functioning of the right click on a variable which now executes the H command.

This new command D = show Definition, can be also activated with a click on the wheel (middle button) of the mouse. If the user click on the middle button (the wheel) , the program open a new window showing the working-storage definition of the field ... = the program will show the variable in the listing of the program . After that the user can close the window and proceed with the debugging session.

GitMensch commented 8 months ago

An extra window like a separate process (in this case the user may configure an editor for that which would be called by a system call [if it is an X-Editor like gvim, then it would be in a separate window, otherwise in the same])?

And the harder part: What is your suggestion how to get to that definition in the first place?

eugeniodilo commented 8 months ago

For me it would work similarly to the H command. Now H opens a window showing the contents of the variable.

The new command D would open a window in which it would show the listing which is an output of the compilation, positioning itself on the required field. To position yourself on the required field perhaps you could use one of the GDB commands (does GDB have a "Find" command?)

GitMensch commented 8 months ago

To position yourself on the required field perhaps you could use one of the GDB commands (does GDB have a "Find" command?)

GDB knows the definition and likely also the place of C variables, but doesn't know anything about COBOL. As most variables will be found in a copybook it doesn't help to search from top of the current file either.

The new command D would open a window in which it would show the listing which is an output of the compilation, positioning itself on the required field.

The point is that this listing doesn't need to exist at all (currently only the debug binary (compiled with -g) and the C source code which automatically is created by -g are needed by GDB, and additional this program needs the COBOL source; we should not make the listing mandatory). ... and even with a listing - then the variable could be part of COPY SUPPRESS...

eugeniodilo commented 8 months ago

Ok I understand your comments well but searching from the beginning of the current file would still be a good solution even if not perfect and complete. We have this program available which now has almost everything needed for debugging, we need to improve it as much as possible. Consequently, if it is something too complex then we can also not do it, it is not a serious problem. During a debug session I can already scroll through the source on the screen and manually search for the field definition and then return to debugging. However, since I can do this operation manually, I think it should be possible to find a way to automate it (without requiring absolute completeness or perfection, if there are limits and constraints just be aware of them).

GitMensch commented 8 months ago

Something that only works in < 50% (copybooks!) should not be implemented; I vote to leave this issue open but wait until cobc may leave the necessary information in the C sources to do the lookup.

In the meantime having a list file around (many people do NOT use list files by default) and checking there is something the user can do.