cwatch: work on COBOL representation
The cwatch
implementation works very reliable now. The only issue: it often is confusing for a COBOL user.
Example run (from my memory, the details may be a bit different) for MOVE "Test" TO VAR
and a previous cwatch VAR
(gdb) c
Continuing.
Hardware watchpoint 4: (char *)(char[16]0x0da9f25)
Old value = "some old content"
New value = "sest "
memmove_sse3_backwards, no source available
(gdb) c
Continuing.
Hardware watchpoint 4: (char *)(char[16]0x0da9f25)
Old value = "sest "
New value = "Test "
memmove_sse3_backwards, no source available
Reasons for confusion here:
- the change happens "somewhere in C", the programme has to use
backtrace
to see the COBOL line - the change happens in multiple steps
- the programmer has to remember which watchpoint was for which COBOL expression (or guess based on the
backtrace
, which is hard when a redefined field was changed - or the changed happened on a higher/deeper variable level)
I suggest to work on this with one of the following approaches:
- create a subclass of Breakpoint, use that for
cwatch
- on
cwatch
: do what is currently done, but use the subclass and ideally also store the original COBOL expression that was used for creating the watchpoint in the new Breakpoint class and the resulting cob_field, if possible also the "old value" - on a
stop()
: somewhere store the reference "I was stopped" and continue to the end of the COBOL statement (note: possibly thestop()
method is called again before that, as seen above - on the end of the statement show the COBOL view
- on
cwatch
: do what is currently done, but also store the original COBOL expression (or better: payload( that was used for creating the watchpoint along with the watchpoint number and the resulting cob_field, if possible also the "old value" - if the watchpoint-trigger event was raised, check the watchpoint number for the registered ones, if those are "owned" by cwatch then do similar as noted above
The output would then be something like:
(gdb) c
Continuing.
Hardware watchpoint 4: VAR/PROG
Old value = "some old content"
New value = "Test "
PROG prog.cob:718
MOVE "Test" TO VAR`
This would make cwatch much more useful to COBOL programmers and may also solve cbl-gdb-vsextension#17.