riscv-openocd/src
Mike Dunn ee13916411 xscale: fix analyze_trace for trace data collected in wrap mode
This patch fixes the xscale_analyze_trace() function.  This function was
defective for a trace collected in 'fill' mode (hiccups with repeated
instructions) and completely broken when buffer overflowed in 'wrap' mode.  The
reason for the latter case is that the checkpoint registers were interpreted
incorrectly when two checkpoints are present in the trace (which will be true in
'wrap' mode once the buffer fills).  In this case, checkpoint1 register will
contain the older entry, and checkpoint0 the newer.  The original code assumed
the opposite.  I eventually gave up trying to understand all the logic of the
function, and rewrote it.  I think it's much cleaner and understandable now.  I
have been using and testing this for a few weeks now.  I'm confident it hasn't
regressed in any way.

Also added capability to handle (as best as possible) the case where an
instruction can not be read from the loaded trace image; e.g., partial image.
This was a 'TODO' comment in the original xscale_analyze_trace().

Outside of xcsale_analyze_trace(), these (related) changes were made:

- Remove pc_ok and current_pc elements from struct xscale_trace.  These elements
  and associated logic are useless clutter because the very first entry placed
  in the trace buffer is always an indirect jump to the address at which
  execution resumed.  This type of trace entry includes the literal address in
  the trace buffer, so the initial address of the trace is immediately
  determined from the trace buffer contents and does not need to be recorded
  when trace is enabled.

- Added num_checkpoints to struct xscale_trace_data, which is necessary in order
  to correctly interpret the checkpoint register contents.

- In xscale_read_trace()
  - Fix potential array out-of-bounds condition.
  - Eliminate partial address entries when parsing trace (can occur in wrap mode).
  - Count and record number of checkpoints in trace.

- Added small, inlined utility function xscale_display_instruction() to help
  make the code more concise and clear.

TODO:
 - Save processor state (arm or thumb) in struct xscale_trace when trace is
   enabled so that trace can be analyzed correctly (currently assumes arm mode).
 - Add element to struct xscale_trace that records (when trace is enabled)
   whether vector table is relocated high (to 0xffff0000) or not, so that a
   branch to an exception vector is traced correctly (curently assumes vectors
   at 0x0).
2010-04-15 19:17:31 +02:00
..
flash NOR/TMS470: review scope of symbols 2010-04-11 01:19:41 +08:00
helper HELPER/LOG: review unused symbols 2010-04-10 22:25:22 +08:00
jtag JTAG/COMMANDS: review scope of functions 2010-04-10 22:01:16 +08:00
pld PLD: review scope of functions 2010-04-10 17:06:16 +08:00
server telnet_server: review unused symbols 2010-03-25 07:44:59 +01:00
svf rename jtag_khz as adapter_khz 2010-03-15 08:37:43 -07:00
target xscale: fix analyze_trace for trace data collected in wrap mode 2010-04-15 19:17:31 +02:00
xsvf jtag: cut down on usage of unintended modification of global end state 2010-03-18 08:43:19 +01:00
Makefile.am Driver for USB-JTAG, Altera USB-Blaster and compatibles 2009-12-26 15:05:06 -08:00
ecosboard.c NOR/DRIVERS: review scope of functions 2010-04-10 19:38:15 +08:00
hello.c HELLO: review unused symbols 2010-04-10 17:23:06 +08:00
hello.h HELLO: review unused symbols 2010-04-10 17:23:06 +08:00
main.c add openocd.h for top-level declarations 2009-11-14 07:29:16 -08:00
openocd.c OPENOCD: review scope of functions 2010-04-10 22:04:03 +08:00
openocd.h remove #if logic for openocd_sleep_*lude 2009-12-02 13:26:26 -08:00