It was thus said that the Great Jerome H. Fine once stated:
I know of only one example of a debugger which
supports
a Program Counter History Log.
I am in the process of adding a Program Counter History Log
to the System Debugger in RT-11 on a PDP-11. I would
appreciate a few suggestions from anyone who has any
experience with a debugger program which supports
Program Counter History Logging.
I've somewhat played around with this concept with a 6809 emulator I wrote
[1]. One version of the emulator will print out the current instruction
being executed. I've found that it generally took a few hundred
instructions to isolate bugs, but the code in question was never that large
to begin with.
For those who have direct PDP-11 experience, the
following information might also be useful. At present,
there are two buffers which can be displayed:
(a) A buffer with 40 of the last interrupt entries to SD:
which are composed of 5 words each:
- Program Counter Address from the Stack
- Program Status Word from the Stack
- Word (instruction?) at that Address
What is "that Address"? The word pointed to by the PC? Or the stord
pointed to by the SP?
- Word (instruction?) at the Previous Address
- Control Word which is used by SD: (PROSNG)
(b) A buffer with the last 1000 Addresses of the last
1000 instructions that have been executed
The current logic in the code to save each instruction
address in the 1000 word buffer ONCE and ONLY
once uses all five of the above values.
There seems no point in displaying all 1000 addresses
since only about 200 can stay on the screen and it takes
too long in any case. However, just how useful are the
past 1000 addresses as an aid in debugging?
It can be helpful, but only if the addresses are examined immediately
after the bug---even at 1MHz a thousand instructions go by quickly. Again,
with one of my emulators, even though it was only a few hundred instructions
to isolate the bug, I had to skip thousands upon thousands of other
instructions before the bug hit, and even then, if I was too slow, I had to
back up several thousand instructions (if the bug wasn't an infinite-loop
type bug).
NOW finally, here are my questions.
Are there any suggestions as to how many previous
instructions are needed to usually be helpful to have a
log for when a program has a problem? Also, would
it be useful to have the first word (two bytes) of the
instruction as well as the address in order to identify
the actual instruction or is the address almost always
sufficient?
As long as the instruction stream doesn't change [2], just the address
is needed, as you can use that to get the instruction out of memory.
-spc
[1] A library really, in C. Easy to use, and makes absolutely no
assumptions about memory layout (or hardware, for that matter); it
also includes a disassembler (also a library). But it's not the
fastest emulator, but as far as I know, it is accurate, and it's
still faster than the actual devices on modern hardware (on my
2.5GHz machine it can run the 6809 at around 85MHz). If anyone is
interested, I can make the code available.
[2] No self-modifying code